diff --git a/mk/linux/mojosetup/.hg/00changelog.i b/mk/linux/mojosetup/.hg/00changelog.i new file mode 100644 index 00000000..d3a83110 Binary files /dev/null and b/mk/linux/mojosetup/.hg/00changelog.i differ diff --git a/mk/linux/mojosetup/.hg/branch b/mk/linux/mojosetup/.hg/branch new file mode 100644 index 00000000..4ad96d51 --- /dev/null +++ b/mk/linux/mojosetup/.hg/branch @@ -0,0 +1 @@ +default diff --git a/mk/linux/mojosetup/.hg/branchheads.cache b/mk/linux/mojosetup/.hg/branchheads.cache new file mode 100644 index 00000000..c8db408c --- /dev/null +++ b/mk/linux/mojosetup/.hg/branchheads.cache @@ -0,0 +1,2 @@ +48f7a9461c372d6d6967f033bdb310c49bb4e848 767 +48f7a9461c372d6d6967f033bdb310c49bb4e848 default diff --git a/mk/linux/mojosetup/.hg/dirstate b/mk/linux/mojosetup/.hg/dirstate new file mode 100644 index 00000000..9a4ea9b9 Binary files /dev/null and b/mk/linux/mojosetup/.hg/dirstate differ diff --git a/mk/linux/mojosetup/.hg/hgrc b/mk/linux/mojosetup/.hg/hgrc new file mode 100644 index 00000000..e7539e30 --- /dev/null +++ b/mk/linux/mojosetup/.hg/hgrc @@ -0,0 +1,2 @@ +[paths] +default = http://hg.icculus.org/icculus/mojosetup diff --git a/mk/linux/mojosetup/.hg/requires b/mk/linux/mojosetup/.hg/requires new file mode 100644 index 00000000..5175383b --- /dev/null +++ b/mk/linux/mojosetup/.hg/requires @@ -0,0 +1,3 @@ +revlogv1 +store +fncache diff --git a/mk/linux/mojosetup/.hg/store/00changelog.i b/mk/linux/mojosetup/.hg/store/00changelog.i new file mode 100644 index 00000000..ff32ea3c Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/00changelog.i differ diff --git a/mk/linux/mojosetup/.hg/store/00manifest.i b/mk/linux/mojosetup/.hg/store/00manifest.i new file mode 100644 index 00000000..30c0265c Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/00manifest.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/.hgignore.i b/mk/linux/mojosetup/.hg/store/data/.hgignore.i new file mode 100644 index 00000000..adc1280f Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/.hgignore.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/.hgtags.i b/mk/linux/mojosetup/.hg/store/data/.hgtags.i new file mode 100644 index 00000000..760f85cd Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/.hgtags.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/_b_u_i_l_d___r_e_v_i_s_i_o_n.txt.i b/mk/linux/mojosetup/.hg/store/data/_b_u_i_l_d___r_e_v_i_s_i_o_n.txt.i new file mode 100644 index 00000000..32686891 Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/_b_u_i_l_d___r_e_v_i_s_i_o_n.txt.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/_c_make_lists.txt.i b/mk/linux/mojosetup/.hg/store/data/_c_make_lists.txt.i new file mode 100644 index 00000000..420b23b4 Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/_c_make_lists.txt.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/_l_i_c_e_n_s_e.i b/mk/linux/mojosetup/.hg/store/data/_l_i_c_e_n_s_e.i new file mode 100644 index 00000000..a1ac892c Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/_l_i_c_e_n_s_e.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/_l_i_c_e_n_s_e.txt.i b/mk/linux/mojosetup/.hg/store/data/_l_i_c_e_n_s_e.txt.i new file mode 100644 index 00000000..63c7aab8 Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/_l_i_c_e_n_s_e.txt.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/archive__pck.c.i b/mk/linux/mojosetup/.hg/store/data/archive__pck.c.i new file mode 100644 index 00000000..570a5c77 Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/archive__pck.c.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/archive__tar.c.i b/mk/linux/mojosetup/.hg/store/data/archive__tar.c.i new file mode 100644 index 00000000..1103a7eb Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/archive__tar.c.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/archive__uz2.c.i b/mk/linux/mojosetup/.hg/store/data/archive__uz2.c.i new file mode 100644 index 00000000..eab5ac37 Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/archive__uz2.c.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/archive__zip.c.i b/mk/linux/mojosetup/.hg/store/data/archive__zip.c.i new file mode 100644 index 00000000..be39d2ec Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/archive__zip.c.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/buildver.c.i b/mk/linux/mojosetup/.hg/store/data/buildver.c.i new file mode 100644 index 00000000..8f706cbe Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/buildver.c.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/bzip2-1.0.4/_c_h_a_n_g_e_s.i b/mk/linux/mojosetup/.hg/store/data/bzip2-1.0.4/_c_h_a_n_g_e_s.i new file mode 100644 index 00000000..b082562c Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/bzip2-1.0.4/_c_h_a_n_g_e_s.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/bzip2-1.0.4/_l_i_c_e_n_s_e.i b/mk/linux/mojosetup/.hg/store/data/bzip2-1.0.4/_l_i_c_e_n_s_e.i new file mode 100644 index 00000000..03bd3ec2 Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/bzip2-1.0.4/_l_i_c_e_n_s_e.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/bzip2-1.0.4/_makefile-libbz2__so.i b/mk/linux/mojosetup/.hg/store/data/bzip2-1.0.4/_makefile-libbz2__so.i new file mode 100644 index 00000000..a8dafa3e Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/bzip2-1.0.4/_makefile-libbz2__so.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/bzip2-1.0.4/_makefile.i b/mk/linux/mojosetup/.hg/store/data/bzip2-1.0.4/_makefile.i new file mode 100644 index 00000000..4c7ba8d4 Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/bzip2-1.0.4/_makefile.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/bzip2-1.0.4/_r_e_a_d_m_e._c_o_m_p_i_l_a_t_i_o_n._p_r_o_b_l_e_m_s.i b/mk/linux/mojosetup/.hg/store/data/bzip2-1.0.4/_r_e_a_d_m_e._c_o_m_p_i_l_a_t_i_o_n._p_r_o_b_l_e_m_s.i new file mode 100644 index 00000000..c4da246d Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/bzip2-1.0.4/_r_e_a_d_m_e._c_o_m_p_i_l_a_t_i_o_n._p_r_o_b_l_e_m_s.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/bzip2-1.0.4/_r_e_a_d_m_e._x_m_l._s_t_u_f_f.i b/mk/linux/mojosetup/.hg/store/data/bzip2-1.0.4/_r_e_a_d_m_e._x_m_l._s_t_u_f_f.i new file mode 100644 index 00000000..0d7db801 Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/bzip2-1.0.4/_r_e_a_d_m_e._x_m_l._s_t_u_f_f.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/bzip2-1.0.4/_r_e_a_d_m_e.i b/mk/linux/mojosetup/.hg/store/data/bzip2-1.0.4/_r_e_a_d_m_e.i new file mode 100644 index 00000000..bd19e0f9 Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/bzip2-1.0.4/_r_e_a_d_m_e.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/bzip2-1.0.4/blocksort.c.i b/mk/linux/mojosetup/.hg/store/data/bzip2-1.0.4/blocksort.c.i new file mode 100644 index 00000000..8c23c26b Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/bzip2-1.0.4/blocksort.c.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/bzip2-1.0.4/bz-common.xsl.i b/mk/linux/mojosetup/.hg/store/data/bzip2-1.0.4/bz-common.xsl.i new file mode 100644 index 00000000..b7dac31a Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/bzip2-1.0.4/bz-common.xsl.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/bzip2-1.0.4/bz-fo.xsl.i b/mk/linux/mojosetup/.hg/store/data/bzip2-1.0.4/bz-fo.xsl.i new file mode 100644 index 00000000..7f4ce2e0 Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/bzip2-1.0.4/bz-fo.xsl.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/bzip2-1.0.4/bz-html.xsl.i b/mk/linux/mojosetup/.hg/store/data/bzip2-1.0.4/bz-html.xsl.i new file mode 100644 index 00000000..da6833b6 Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/bzip2-1.0.4/bz-html.xsl.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/bzip2-1.0.4/bzdiff.1.i b/mk/linux/mojosetup/.hg/store/data/bzip2-1.0.4/bzdiff.1.i new file mode 100644 index 00000000..181ba639 Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/bzip2-1.0.4/bzdiff.1.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/bzip2-1.0.4/bzdiff.i b/mk/linux/mojosetup/.hg/store/data/bzip2-1.0.4/bzdiff.i new file mode 100644 index 00000000..3b1b1c88 Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/bzip2-1.0.4/bzdiff.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/bzip2-1.0.4/bzgrep.1.i b/mk/linux/mojosetup/.hg/store/data/bzip2-1.0.4/bzgrep.1.i new file mode 100644 index 00000000..67c9bb2d Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/bzip2-1.0.4/bzgrep.1.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/bzip2-1.0.4/bzgrep.i b/mk/linux/mojosetup/.hg/store/data/bzip2-1.0.4/bzgrep.i new file mode 100644 index 00000000..2b61c808 Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/bzip2-1.0.4/bzgrep.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/bzip2-1.0.4/bzip.css.i b/mk/linux/mojosetup/.hg/store/data/bzip2-1.0.4/bzip.css.i new file mode 100644 index 00000000..dbac9350 Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/bzip2-1.0.4/bzip.css.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/bzip2-1.0.4/bzip2.1.i b/mk/linux/mojosetup/.hg/store/data/bzip2-1.0.4/bzip2.1.i new file mode 100644 index 00000000..579fe873 Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/bzip2-1.0.4/bzip2.1.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/bzip2-1.0.4/bzip2.1.preformatted.i b/mk/linux/mojosetup/.hg/store/data/bzip2-1.0.4/bzip2.1.preformatted.i new file mode 100644 index 00000000..aac74b05 Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/bzip2-1.0.4/bzip2.1.preformatted.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/bzip2-1.0.4/bzip2.c.i b/mk/linux/mojosetup/.hg/store/data/bzip2-1.0.4/bzip2.c.i new file mode 100644 index 00000000..f7cb404b Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/bzip2-1.0.4/bzip2.c.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/bzip2-1.0.4/bzip2.txt.i b/mk/linux/mojosetup/.hg/store/data/bzip2-1.0.4/bzip2.txt.i new file mode 100644 index 00000000..d22fe5a8 Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/bzip2-1.0.4/bzip2.txt.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/bzip2-1.0.4/bzip2recover.c.i b/mk/linux/mojosetup/.hg/store/data/bzip2-1.0.4/bzip2recover.c.i new file mode 100644 index 00000000..1b81e961 Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/bzip2-1.0.4/bzip2recover.c.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/bzip2-1.0.4/bzlib.c.i b/mk/linux/mojosetup/.hg/store/data/bzip2-1.0.4/bzlib.c.i new file mode 100644 index 00000000..79665c06 Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/bzip2-1.0.4/bzlib.c.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/bzip2-1.0.4/bzlib.h.i b/mk/linux/mojosetup/.hg/store/data/bzip2-1.0.4/bzlib.h.i new file mode 100644 index 00000000..fb8b7215 Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/bzip2-1.0.4/bzlib.h.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/bzip2-1.0.4/bzlib__private.h.i b/mk/linux/mojosetup/.hg/store/data/bzip2-1.0.4/bzlib__private.h.i new file mode 100644 index 00000000..81151269 Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/bzip2-1.0.4/bzlib__private.h.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/bzip2-1.0.4/bzmore.1.i b/mk/linux/mojosetup/.hg/store/data/bzip2-1.0.4/bzmore.1.i new file mode 100644 index 00000000..8c66ba06 Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/bzip2-1.0.4/bzmore.1.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/bzip2-1.0.4/bzmore.i b/mk/linux/mojosetup/.hg/store/data/bzip2-1.0.4/bzmore.i new file mode 100644 index 00000000..25c49d74 Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/bzip2-1.0.4/bzmore.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/bzip2-1.0.4/compress.c.i b/mk/linux/mojosetup/.hg/store/data/bzip2-1.0.4/compress.c.i new file mode 100644 index 00000000..db3cf7e5 Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/bzip2-1.0.4/compress.c.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/bzip2-1.0.4/crctable.c.i b/mk/linux/mojosetup/.hg/store/data/bzip2-1.0.4/crctable.c.i new file mode 100644 index 00000000..0f188dfe Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/bzip2-1.0.4/crctable.c.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/bzip2-1.0.4/decompress.c.i b/mk/linux/mojosetup/.hg/store/data/bzip2-1.0.4/decompress.c.i new file mode 100644 index 00000000..9c148241 Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/bzip2-1.0.4/decompress.c.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/bzip2-1.0.4/dlltest.c.i b/mk/linux/mojosetup/.hg/store/data/bzip2-1.0.4/dlltest.c.i new file mode 100644 index 00000000..f5fbf1fc Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/bzip2-1.0.4/dlltest.c.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/bzip2-1.0.4/dlltest.dsp.i b/mk/linux/mojosetup/.hg/store/data/bzip2-1.0.4/dlltest.dsp.i new file mode 100644 index 00000000..ada63302 Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/bzip2-1.0.4/dlltest.dsp.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/bzip2-1.0.4/entities.xml.i b/mk/linux/mojosetup/.hg/store/data/bzip2-1.0.4/entities.xml.i new file mode 100644 index 00000000..6abcf86b Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/bzip2-1.0.4/entities.xml.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/bzip2-1.0.4/format.pl.i b/mk/linux/mojosetup/.hg/store/data/bzip2-1.0.4/format.pl.i new file mode 100644 index 00000000..8220d9e2 Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/bzip2-1.0.4/format.pl.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/bzip2-1.0.4/huffman.c.i b/mk/linux/mojosetup/.hg/store/data/bzip2-1.0.4/huffman.c.i new file mode 100644 index 00000000..0b41cfa5 Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/bzip2-1.0.4/huffman.c.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/bzip2-1.0.4/libbz2.def.i b/mk/linux/mojosetup/.hg/store/data/bzip2-1.0.4/libbz2.def.i new file mode 100644 index 00000000..9d512ac8 Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/bzip2-1.0.4/libbz2.def.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/bzip2-1.0.4/libbz2.dsp.i b/mk/linux/mojosetup/.hg/store/data/bzip2-1.0.4/libbz2.dsp.i new file mode 100644 index 00000000..9314c3a0 Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/bzip2-1.0.4/libbz2.dsp.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/bzip2-1.0.4/makefile.msc.i b/mk/linux/mojosetup/.hg/store/data/bzip2-1.0.4/makefile.msc.i new file mode 100644 index 00000000..2b7fcdfd Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/bzip2-1.0.4/makefile.msc.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/bzip2-1.0.4/manual.html.i b/mk/linux/mojosetup/.hg/store/data/bzip2-1.0.4/manual.html.i new file mode 100644 index 00000000..cc9f454b Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/bzip2-1.0.4/manual.html.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/bzip2-1.0.4/manual.pdf.d b/mk/linux/mojosetup/.hg/store/data/bzip2-1.0.4/manual.pdf.d new file mode 100644 index 00000000..6945179b Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/bzip2-1.0.4/manual.pdf.d differ diff --git a/mk/linux/mojosetup/.hg/store/data/bzip2-1.0.4/manual.pdf.i b/mk/linux/mojosetup/.hg/store/data/bzip2-1.0.4/manual.pdf.i new file mode 100644 index 00000000..539a3935 Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/bzip2-1.0.4/manual.pdf.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/bzip2-1.0.4/manual.ps.d b/mk/linux/mojosetup/.hg/store/data/bzip2-1.0.4/manual.ps.d new file mode 100644 index 00000000..24fc8fb1 Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/bzip2-1.0.4/manual.ps.d differ diff --git a/mk/linux/mojosetup/.hg/store/data/bzip2-1.0.4/manual.ps.i b/mk/linux/mojosetup/.hg/store/data/bzip2-1.0.4/manual.ps.i new file mode 100644 index 00000000..7fe3bf0a Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/bzip2-1.0.4/manual.ps.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/bzip2-1.0.4/manual.xml.i b/mk/linux/mojosetup/.hg/store/data/bzip2-1.0.4/manual.xml.i new file mode 100644 index 00000000..95306b81 Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/bzip2-1.0.4/manual.xml.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/bzip2-1.0.4/mk251.c.i b/mk/linux/mojosetup/.hg/store/data/bzip2-1.0.4/mk251.c.i new file mode 100644 index 00000000..e40e2f6e Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/bzip2-1.0.4/mk251.c.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/bzip2-1.0.4/randtable.c.i b/mk/linux/mojosetup/.hg/store/data/bzip2-1.0.4/randtable.c.i new file mode 100644 index 00000000..1ef6825a Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/bzip2-1.0.4/randtable.c.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/bzip2-1.0.4/sample1.bz2.i b/mk/linux/mojosetup/.hg/store/data/bzip2-1.0.4/sample1.bz2.i new file mode 100644 index 00000000..6e350522 Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/bzip2-1.0.4/sample1.bz2.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/bzip2-1.0.4/sample1.ref.i b/mk/linux/mojosetup/.hg/store/data/bzip2-1.0.4/sample1.ref.i new file mode 100644 index 00000000..2fcfd0cc Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/bzip2-1.0.4/sample1.ref.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/bzip2-1.0.4/sample2.bz2.i b/mk/linux/mojosetup/.hg/store/data/bzip2-1.0.4/sample2.bz2.i new file mode 100644 index 00000000..b5f4a83e Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/bzip2-1.0.4/sample2.bz2.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/bzip2-1.0.4/sample2.ref.i b/mk/linux/mojosetup/.hg/store/data/bzip2-1.0.4/sample2.ref.i new file mode 100644 index 00000000..e92bba39 Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/bzip2-1.0.4/sample2.ref.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/bzip2-1.0.4/sample3.bz2.i b/mk/linux/mojosetup/.hg/store/data/bzip2-1.0.4/sample3.bz2.i new file mode 100644 index 00000000..aacf635d Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/bzip2-1.0.4/sample3.bz2.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/bzip2-1.0.4/sample3.ref.i b/mk/linux/mojosetup/.hg/store/data/bzip2-1.0.4/sample3.ref.i new file mode 100644 index 00000000..58c911fe Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/bzip2-1.0.4/sample3.ref.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/bzip2-1.0.4/spew_g.c.i b/mk/linux/mojosetup/.hg/store/data/bzip2-1.0.4/spew_g.c.i new file mode 100644 index 00000000..9824b0ec Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/bzip2-1.0.4/spew_g.c.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/bzip2-1.0.4/unzcrash.c.i b/mk/linux/mojosetup/.hg/store/data/bzip2-1.0.4/unzcrash.c.i new file mode 100644 index 00000000..e08f68f9 Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/bzip2-1.0.4/unzcrash.c.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/bzip2-1.0.4/words0.i b/mk/linux/mojosetup/.hg/store/data/bzip2-1.0.4/words0.i new file mode 100644 index 00000000..34f492f1 Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/bzip2-1.0.4/words0.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/bzip2-1.0.4/words1.i b/mk/linux/mojosetup/.hg/store/data/bzip2-1.0.4/words1.i new file mode 100644 index 00000000..95e44d18 Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/bzip2-1.0.4/words1.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/bzip2-1.0.4/words2.i b/mk/linux/mojosetup/.hg/store/data/bzip2-1.0.4/words2.i new file mode 100644 index 00000000..0fc58aa9 Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/bzip2-1.0.4/words2.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/bzip2-1.0.4/words3.i b/mk/linux/mojosetup/.hg/store/data/bzip2-1.0.4/words3.i new file mode 100644 index 00000000..75304624 Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/bzip2-1.0.4/words3.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/bzip2-1.0.4/xmlproc.sh.i b/mk/linux/mojosetup/.hg/store/data/bzip2-1.0.4/xmlproc.sh.i new file mode 100644 index 00000000..5cc37244 Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/bzip2-1.0.4/xmlproc.sh.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/bzip2/blocksort.c.i b/mk/linux/mojosetup/.hg/store/data/bzip2/blocksort.c.i new file mode 100644 index 00000000..1c5aa783 Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/bzip2/blocksort.c.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/bzip2/bzlib.c.i b/mk/linux/mojosetup/.hg/store/data/bzip2/bzlib.c.i new file mode 100644 index 00000000..f89cb865 Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/bzip2/bzlib.c.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/bzip2/bzlib.h.i b/mk/linux/mojosetup/.hg/store/data/bzip2/bzlib.h.i new file mode 100644 index 00000000..ff4fd768 Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/bzip2/bzlib.h.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/bzip2/bzlib__private.h.i b/mk/linux/mojosetup/.hg/store/data/bzip2/bzlib__private.h.i new file mode 100644 index 00000000..1d885432 Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/bzip2/bzlib__private.h.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/bzip2/compress.c.i b/mk/linux/mojosetup/.hg/store/data/bzip2/compress.c.i new file mode 100644 index 00000000..4fd7e9a4 Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/bzip2/compress.c.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/bzip2/crctable.c.i b/mk/linux/mojosetup/.hg/store/data/bzip2/crctable.c.i new file mode 100644 index 00000000..7c1ad8cf Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/bzip2/crctable.c.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/bzip2/decompress.c.i b/mk/linux/mojosetup/.hg/store/data/bzip2/decompress.c.i new file mode 100644 index 00000000..e5e0d62e Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/bzip2/decompress.c.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/bzip2/huffman.c.i b/mk/linux/mojosetup/.hg/store/data/bzip2/huffman.c.i new file mode 100644 index 00000000..671cf04a Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/bzip2/huffman.c.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/bzip2/randtable.c.i b/mk/linux/mojosetup/.hg/store/data/bzip2/randtable.c.i new file mode 100644 index 00000000..a41582bf Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/bzip2/randtable.c.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/bzip2/version.txt.i b/mk/linux/mojosetup/.hg/store/data/bzip2/version.txt.i new file mode 100644 index 00000000..877e04f6 Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/bzip2/version.txt.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/checksum__crc32.c.i b/mk/linux/mojosetup/.hg/store/data/checksum__crc32.c.i new file mode 100644 index 00000000..b62be54c Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/checksum__crc32.c.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/checksum__md5.c.i b/mk/linux/mojosetup/.hg/store/data/checksum__md5.c.i new file mode 100644 index 00000000..ef3ad52b Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/checksum__md5.c.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/checksum__sha1.c.i b/mk/linux/mojosetup/.hg/store/data/checksum__sha1.c.i new file mode 100644 index 00000000..89092477 Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/checksum__sha1.c.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/docs.txt.i b/mk/linux/mojosetup/.hg/store/data/docs.txt.i new file mode 100644 index 00000000..557a1cbf Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/docs.txt.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/examples/aquaria/make.sh.i b/mk/linux/mojosetup/.hg/store/data/examples/aquaria/make.sh.i new file mode 100644 index 00000000..ac68826f Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/examples/aquaria/make.sh.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/examples/aquaria/meta/splash.bmp.i b/mk/linux/mojosetup/.hg/store/data/examples/aquaria/meta/splash.bmp.i new file mode 100644 index 00000000..eddefb4d Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/examples/aquaria/meta/splash.bmp.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/examples/aquaria/scripts/app__localization.lua.i b/mk/linux/mojosetup/.hg/store/data/examples/aquaria/scripts/app__localization.lua.i new file mode 100644 index 00000000..023ed4d0 Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/examples/aquaria/scripts/app__localization.lua.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/examples/aquaria/scripts/config.lua.i b/mk/linux/mojosetup/.hg/store/data/examples/aquaria/scripts/config.lua.i new file mode 100644 index 00000000..3b868a29 Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/examples/aquaria/scripts/config.lua.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/examples/duke3d/data/duke3d.png.i b/mk/linux/mojosetup/.hg/store/data/examples/duke3d/data/duke3d.png.i new file mode 100644 index 00000000..2bd6bc57 Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/examples/duke3d/data/duke3d.png.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/examples/duke3d/data/duke3d__readme.txt.i b/mk/linux/mojosetup/.hg/store/data/examples/duke3d/data/duke3d__readme.txt.i new file mode 100644 index 00000000..b2ee4f48 Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/examples/duke3d/data/duke3d__readme.txt.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/examples/duke3d/data/gpl.txt.i b/mk/linux/mojosetup/.hg/store/data/examples/duke3d/data/gpl.txt.i new file mode 100644 index 00000000..eac91e64 Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/examples/duke3d/data/gpl.txt.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/examples/duke3d/data/mojosetup__readme.txt.i b/mk/linux/mojosetup/.hg/store/data/examples/duke3d/data/mojosetup__readme.txt.i new file mode 100644 index 00000000..cb3801b2 Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/examples/duke3d/data/mojosetup__readme.txt.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/examples/duke3d/make.sh.i b/mk/linux/mojosetup/.hg/store/data/examples/duke3d/make.sh.i new file mode 100644 index 00000000..34325459 Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/examples/duke3d/make.sh.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/examples/duke3d/meta/splash.bmp.i b/mk/linux/mojosetup/.hg/store/data/examples/duke3d/meta/splash.bmp.i new file mode 100644 index 00000000..ee37c92c Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/examples/duke3d/meta/splash.bmp.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/examples/duke3d/scripts/app__localization.lua.i b/mk/linux/mojosetup/.hg/store/data/examples/duke3d/scripts/app__localization.lua.i new file mode 100644 index 00000000..455f2a31 Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/examples/duke3d/scripts/app__localization.lua.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/examples/duke3d/scripts/config.lua.i b/mk/linux/mojosetup/.hg/store/data/examples/duke3d/scripts/config.lua.i new file mode 100644 index 00000000..19dd7c66 Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/examples/duke3d/scripts/config.lua.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/examples/lugaru/make.sh.i b/mk/linux/mojosetup/.hg/store/data/examples/lugaru/make.sh.i new file mode 100644 index 00000000..6f8a6334 Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/examples/lugaru/make.sh.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/examples/lugaru/meta/splash.bmp.i b/mk/linux/mojosetup/.hg/store/data/examples/lugaru/meta/splash.bmp.i new file mode 100644 index 00000000..9c7bc5ee Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/examples/lugaru/meta/splash.bmp.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/examples/lugaru/scripts/app__localization.lua.i b/mk/linux/mojosetup/.hg/store/data/examples/lugaru/scripts/app__localization.lua.i new file mode 100644 index 00000000..f9ffaf7e Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/examples/lugaru/scripts/app__localization.lua.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/examples/lugaru/scripts/config.lua.i b/mk/linux/mojosetup/.hg/store/data/examples/lugaru/scripts/config.lua.i new file mode 100644 index 00000000..aace6c6b Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/examples/lugaru/scripts/config.lua.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/examples/postal1/make.sh.i b/mk/linux/mojosetup/.hg/store/data/examples/postal1/make.sh.i new file mode 100644 index 00000000..0b08dd00 Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/examples/postal1/make.sh.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/examples/postal1/meta/splash.bmp.i b/mk/linux/mojosetup/.hg/store/data/examples/postal1/meta/splash.bmp.i new file mode 100644 index 00000000..0ab67c60 Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/examples/postal1/meta/splash.bmp.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/examples/postal1/scripts/app__localization.lua.i b/mk/linux/mojosetup/.hg/store/data/examples/postal1/scripts/app__localization.lua.i new file mode 100644 index 00000000..200ad20a Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/examples/postal1/scripts/app__localization.lua.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/examples/postal1/scripts/config.lua.i b/mk/linux/mojosetup/.hg/store/data/examples/postal1/scripts/config.lua.i new file mode 100644 index 00000000..032257c6 Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/examples/postal1/scripts/config.lua.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/examples/postal2/make.sh.i b/mk/linux/mojosetup/.hg/store/data/examples/postal2/make.sh.i new file mode 100644 index 00000000..775f77ab Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/examples/postal2/make.sh.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/examples/postal2/meta/splash.bmp.i b/mk/linux/mojosetup/.hg/store/data/examples/postal2/meta/splash.bmp.i new file mode 100644 index 00000000..0ab67c60 Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/examples/postal2/meta/splash.bmp.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/examples/postal2/scripts/app__localization.lua.i b/mk/linux/mojosetup/.hg/store/data/examples/postal2/scripts/app__localization.lua.i new file mode 100644 index 00000000..52916b2a Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/examples/postal2/scripts/app__localization.lua.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/examples/postal2/scripts/config.lua.i b/mk/linux/mojosetup/.hg/store/data/examples/postal2/scripts/config.lua.i new file mode 100644 index 00000000..b873459c Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/examples/postal2/scripts/config.lua.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/examples/postal2aw/make.sh.i b/mk/linux/mojosetup/.hg/store/data/examples/postal2aw/make.sh.i new file mode 100644 index 00000000..6cfe9026 Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/examples/postal2aw/make.sh.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/examples/postal2aw/meta/splash.bmp.i b/mk/linux/mojosetup/.hg/store/data/examples/postal2aw/meta/splash.bmp.i new file mode 100644 index 00000000..9c035bf7 Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/examples/postal2aw/meta/splash.bmp.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/examples/postal2aw/scripts/app__localization.lua.i b/mk/linux/mojosetup/.hg/store/data/examples/postal2aw/scripts/app__localization.lua.i new file mode 100644 index 00000000..1bc89442 Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/examples/postal2aw/scripts/app__localization.lua.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/examples/postal2aw/scripts/config.lua.i b/mk/linux/mojosetup/.hg/store/data/examples/postal2aw/scripts/config.lua.i new file mode 100644 index 00000000..2f7756f5 Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/examples/postal2aw/scripts/config.lua.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/examples/prey-demo/make.sh.i b/mk/linux/mojosetup/.hg/store/data/examples/prey-demo/make.sh.i new file mode 100644 index 00000000..434a5dc2 Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/examples/prey-demo/make.sh.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/examples/prey-demo/meta/splash.bmp.i b/mk/linux/mojosetup/.hg/store/data/examples/prey-demo/meta/splash.bmp.i new file mode 100644 index 00000000..a5ba5a50 Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/examples/prey-demo/meta/splash.bmp.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/examples/prey-demo/scripts/app__localization.lua.i b/mk/linux/mojosetup/.hg/store/data/examples/prey-demo/scripts/app__localization.lua.i new file mode 100644 index 00000000..2bc65e2b Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/examples/prey-demo/scripts/app__localization.lua.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/examples/prey-demo/scripts/config.lua.i b/mk/linux/mojosetup/.hg/store/data/examples/prey-demo/scripts/config.lua.i new file mode 100644 index 00000000..b79736c2 Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/examples/prey-demo/scripts/config.lua.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/examples/prey/make.sh.i b/mk/linux/mojosetup/.hg/store/data/examples/prey/make.sh.i new file mode 100644 index 00000000..013c0638 Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/examples/prey/make.sh.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/examples/prey/meta/splash.bmp.i b/mk/linux/mojosetup/.hg/store/data/examples/prey/meta/splash.bmp.i new file mode 100644 index 00000000..bba92424 Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/examples/prey/meta/splash.bmp.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/examples/prey/scripts/app__localization.lua.i b/mk/linux/mojosetup/.hg/store/data/examples/prey/scripts/app__localization.lua.i new file mode 100644 index 00000000..b373ec4a Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/examples/prey/scripts/app__localization.lua.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/examples/prey/scripts/config.lua.i b/mk/linux/mojosetup/.hg/store/data/examples/prey/scripts/config.lua.i new file mode 100644 index 00000000..1a057c08 Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/examples/prey/scripts/config.lua.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/examples/ut3-dedicated-patches/data/_r_e_a_d_m_e-ut3-patch2.txt.i b/mk/linux/mojosetup/.hg/store/data/examples/ut3-dedicated-patches/data/_r_e_a_d_m_e-ut3-patch2.txt.i new file mode 100644 index 00000000..dbeefbf1 Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/examples/ut3-dedicated-patches/data/_r_e_a_d_m_e-ut3-patch2.txt.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/examples/ut3-dedicated-patches/data/_u_t3-linux-server-_e_u_l_a.txt.i b/mk/linux/mojosetup/.hg/store/data/examples/ut3-dedicated-patches/data/_u_t3-linux-server-_e_u_l_a.txt.i new file mode 100644 index 00000000..8d06f4b0 Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/examples/ut3-dedicated-patches/data/_u_t3-linux-server-_e_u_l_a.txt.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/examples/ut3-dedicated-patches/make.sh.i b/mk/linux/mojosetup/.hg/store/data/examples/ut3-dedicated-patches/make.sh.i new file mode 100644 index 00000000..bf64a8c0 Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/examples/ut3-dedicated-patches/make.sh.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/examples/ut3-dedicated-patches/scripts/config.lua.i b/mk/linux/mojosetup/.hg/store/data/examples/ut3-dedicated-patches/scripts/config.lua.i new file mode 100644 index 00000000..5a79043c Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/examples/ut3-dedicated-patches/scripts/config.lua.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/examples/ut3-dedicated/make.sh.i b/mk/linux/mojosetup/.hg/store/data/examples/ut3-dedicated/make.sh.i new file mode 100644 index 00000000..f14c780e Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/examples/ut3-dedicated/make.sh.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/examples/ut3-dedicated/scripts/config.lua.i b/mk/linux/mojosetup/.hg/store/data/examples/ut3-dedicated/scripts/config.lua.i new file mode 100644 index 00000000..9751387a Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/examples/ut3-dedicated/scripts/config.lua.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/fileio.c.i b/mk/linux/mojosetup/.hg/store/data/fileio.c.i new file mode 100644 index 00000000..8f829109 Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/fileio.c.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/fileio.h.i b/mk/linux/mojosetup/.hg/store/data/fileio.h.i new file mode 100644 index 00000000..b06087a0 Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/fileio.h.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/gui.c.i b/mk/linux/mojosetup/.hg/store/data/gui.c.i new file mode 100644 index 00000000..178cafb1 Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/gui.c.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/gui.h.i b/mk/linux/mojosetup/.hg/store/data/gui.h.i new file mode 100644 index 00000000..be558b33 Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/gui.h.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/gui/gui__macosx.c.i b/mk/linux/mojosetup/.hg/store/data/gui/gui__macosx.c.i new file mode 100644 index 00000000..b5ed2f3c Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/gui/gui__macosx.c.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/gui/gui__stdio.c.i b/mk/linux/mojosetup/.hg/store/data/gui/gui__stdio.c.i new file mode 100644 index 00000000..09999cc8 Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/gui/gui__stdio.c.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/gui__cocoa.m.i b/mk/linux/mojosetup/.hg/store/data/gui__cocoa.m.i new file mode 100644 index 00000000..a1d34478 Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/gui__cocoa.m.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/gui__gtkplus2.c.i b/mk/linux/mojosetup/.hg/store/data/gui__gtkplus2.c.i new file mode 100644 index 00000000..8563976d Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/gui__gtkplus2.c.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/gui__macosx.c.i b/mk/linux/mojosetup/.hg/store/data/gui__macosx.c.i new file mode 100644 index 00000000..3b56213e Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/gui__macosx.c.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/gui__ncurses.c.i b/mk/linux/mojosetup/.hg/store/data/gui__ncurses.c.i new file mode 100644 index 00000000..6c6e3a95 Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/gui__ncurses.c.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/gui__stdio.c.i b/mk/linux/mojosetup/.hg/store/data/gui__stdio.c.i new file mode 100644 index 00000000..87cdc19c Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/gui__stdio.c.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/gui__www.c.i b/mk/linux/mojosetup/.hg/store/data/gui__www.c.i new file mode 100644 index 00000000..c590b04e Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/gui__www.c.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/libfetch/_r_e_a_d_m_e.txt.i b/mk/linux/mojosetup/.hg/store/data/libfetch/_r_e_a_d_m_e.txt.i new file mode 100644 index 00000000..fa63a4db Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/libfetch/_r_e_a_d_m_e.txt.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/libfetch/common.c.i b/mk/linux/mojosetup/.hg/store/data/libfetch/common.c.i new file mode 100644 index 00000000..a9924502 Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/libfetch/common.c.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/libfetch/common.h.i b/mk/linux/mojosetup/.hg/store/data/libfetch/common.h.i new file mode 100644 index 00000000..7444adb1 Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/libfetch/common.h.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/libfetch/fetch.c.i b/mk/linux/mojosetup/.hg/store/data/libfetch/fetch.c.i new file mode 100644 index 00000000..754297a0 Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/libfetch/fetch.c.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/libfetch/fetch.h.i b/mk/linux/mojosetup/.hg/store/data/libfetch/fetch.h.i new file mode 100644 index 00000000..cd4b7da1 Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/libfetch/fetch.h.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/libfetch/file.c.i b/mk/linux/mojosetup/.hg/store/data/libfetch/file.c.i new file mode 100644 index 00000000..98c4d1d2 Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/libfetch/file.c.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/libfetch/ftp.c.i b/mk/linux/mojosetup/.hg/store/data/libfetch/ftp.c.i new file mode 100644 index 00000000..54da44c5 Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/libfetch/ftp.c.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/libfetch/ftp.errors.i b/mk/linux/mojosetup/.hg/store/data/libfetch/ftp.errors.i new file mode 100644 index 00000000..0286fac1 Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/libfetch/ftp.errors.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/libfetch/ftperr.h.i b/mk/linux/mojosetup/.hg/store/data/libfetch/ftperr.h.i new file mode 100644 index 00000000..83344d81 Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/libfetch/ftperr.h.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/libfetch/http.c.i b/mk/linux/mojosetup/.hg/store/data/libfetch/http.c.i new file mode 100644 index 00000000..4e194edb Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/libfetch/http.c.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/libfetch/http.errors.i b/mk/linux/mojosetup/.hg/store/data/libfetch/http.errors.i new file mode 100644 index 00000000..137bde62 Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/libfetch/http.errors.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/libfetch/httperr.h.i b/mk/linux/mojosetup/.hg/store/data/libfetch/httperr.h.i new file mode 100644 index 00000000..71d56a4a Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/libfetch/httperr.h.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/libfetch/mojosetup__libfetch.h.i b/mk/linux/mojosetup/.hg/store/data/libfetch/mojosetup__libfetch.h.i new file mode 100644 index 00000000..d7fdab60 Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/libfetch/mojosetup__libfetch.h.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/libfetch/regen__error__headers.sh.i b/mk/linux/mojosetup/.hg/store/data/libfetch/regen__error__headers.sh.i new file mode 100644 index 00000000..61610119 Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/libfetch/regen__error__headers.sh.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/lua-5.1.1/_c_o_p_y_r_i_g_h_t.i b/mk/linux/mojosetup/.hg/store/data/lua-5.1.1/_c_o_p_y_r_i_g_h_t.i new file mode 100644 index 00000000..50568a54 Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/lua-5.1.1/_c_o_p_y_r_i_g_h_t.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/lua-5.1.1/_h_i_s_t_o_r_y.i b/mk/linux/mojosetup/.hg/store/data/lua-5.1.1/_h_i_s_t_o_r_y.i new file mode 100644 index 00000000..07696c2c Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/lua-5.1.1/_h_i_s_t_o_r_y.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/lua-5.1.1/_i_n_s_t_a_l_l.i b/mk/linux/mojosetup/.hg/store/data/lua-5.1.1/_i_n_s_t_a_l_l.i new file mode 100644 index 00000000..2095500f Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/lua-5.1.1/_i_n_s_t_a_l_l.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/lua-5.1.1/_makefile.i b/mk/linux/mojosetup/.hg/store/data/lua-5.1.1/_makefile.i new file mode 100644 index 00000000..0fca3a8b Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/lua-5.1.1/_makefile.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/lua-5.1.1/_r_e_a_d_m_e.i b/mk/linux/mojosetup/.hg/store/data/lua-5.1.1/_r_e_a_d_m_e.i new file mode 100644 index 00000000..748cebac Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/lua-5.1.1/_r_e_a_d_m_e.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/lua-5.1.1/doc/amazon.gif.i b/mk/linux/mojosetup/.hg/store/data/lua-5.1.1/doc/amazon.gif.i new file mode 100644 index 00000000..1f980e20 Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/lua-5.1.1/doc/amazon.gif.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/lua-5.1.1/doc/contents.html.i b/mk/linux/mojosetup/.hg/store/data/lua-5.1.1/doc/contents.html.i new file mode 100644 index 00000000..758aec31 Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/lua-5.1.1/doc/contents.html.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/lua-5.1.1/doc/cover.png.i b/mk/linux/mojosetup/.hg/store/data/lua-5.1.1/doc/cover.png.i new file mode 100644 index 00000000..9ca7ca58 Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/lua-5.1.1/doc/cover.png.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/lua-5.1.1/doc/logo.gif.i b/mk/linux/mojosetup/.hg/store/data/lua-5.1.1/doc/logo.gif.i new file mode 100644 index 00000000..8be93363 Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/lua-5.1.1/doc/logo.gif.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/lua-5.1.1/doc/lua.1.i b/mk/linux/mojosetup/.hg/store/data/lua-5.1.1/doc/lua.1.i new file mode 100644 index 00000000..0c39ed93 Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/lua-5.1.1/doc/lua.1.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/lua-5.1.1/doc/lua.css.i b/mk/linux/mojosetup/.hg/store/data/lua-5.1.1/doc/lua.css.i new file mode 100644 index 00000000..86da1343 Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/lua-5.1.1/doc/lua.css.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/lua-5.1.1/doc/lua.html.i b/mk/linux/mojosetup/.hg/store/data/lua-5.1.1/doc/lua.html.i new file mode 100644 index 00000000..cbbd6090 Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/lua-5.1.1/doc/lua.html.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/lua-5.1.1/doc/luac.1.i b/mk/linux/mojosetup/.hg/store/data/lua-5.1.1/doc/luac.1.i new file mode 100644 index 00000000..c6651f83 Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/lua-5.1.1/doc/luac.1.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/lua-5.1.1/doc/luac.html.i b/mk/linux/mojosetup/.hg/store/data/lua-5.1.1/doc/luac.html.i new file mode 100644 index 00000000..6eda8fdf Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/lua-5.1.1/doc/luac.html.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/lua-5.1.1/doc/manual.css.i b/mk/linux/mojosetup/.hg/store/data/lua-5.1.1/doc/manual.css.i new file mode 100644 index 00000000..f5606eb4 Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/lua-5.1.1/doc/manual.css.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/lua-5.1.1/doc/manual.html.i b/mk/linux/mojosetup/.hg/store/data/lua-5.1.1/doc/manual.html.i new file mode 100644 index 00000000..40218f8b Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/lua-5.1.1/doc/manual.html.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/lua-5.1.1/doc/readme.html.i b/mk/linux/mojosetup/.hg/store/data/lua-5.1.1/doc/readme.html.i new file mode 100644 index 00000000..07e73738 Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/lua-5.1.1/doc/readme.html.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/lua-5.1.1/etc/_makefile.i b/mk/linux/mojosetup/.hg/store/data/lua-5.1.1/etc/_makefile.i new file mode 100644 index 00000000..0eabf991 Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/lua-5.1.1/etc/_makefile.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/lua-5.1.1/etc/_r_e_a_d_m_e.i b/mk/linux/mojosetup/.hg/store/data/lua-5.1.1/etc/_r_e_a_d_m_e.i new file mode 100644 index 00000000..96ff2d38 Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/lua-5.1.1/etc/_r_e_a_d_m_e.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/lua-5.1.1/etc/all.c.i b/mk/linux/mojosetup/.hg/store/data/lua-5.1.1/etc/all.c.i new file mode 100644 index 00000000..6d7e429c Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/lua-5.1.1/etc/all.c.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/lua-5.1.1/etc/lua.hpp.i b/mk/linux/mojosetup/.hg/store/data/lua-5.1.1/etc/lua.hpp.i new file mode 100644 index 00000000..cae015e2 Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/lua-5.1.1/etc/lua.hpp.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/lua-5.1.1/etc/lua.ico.i b/mk/linux/mojosetup/.hg/store/data/lua-5.1.1/etc/lua.ico.i new file mode 100644 index 00000000..faa1fb83 Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/lua-5.1.1/etc/lua.ico.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/lua-5.1.1/etc/lua.pc.i b/mk/linux/mojosetup/.hg/store/data/lua-5.1.1/etc/lua.pc.i new file mode 100644 index 00000000..4bc3ec4e Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/lua-5.1.1/etc/lua.pc.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/lua-5.1.1/etc/luavs.bat.i b/mk/linux/mojosetup/.hg/store/data/lua-5.1.1/etc/luavs.bat.i new file mode 100644 index 00000000..4ccdf4fb Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/lua-5.1.1/etc/luavs.bat.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/lua-5.1.1/etc/min.c.i b/mk/linux/mojosetup/.hg/store/data/lua-5.1.1/etc/min.c.i new file mode 100644 index 00000000..ce11d652 Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/lua-5.1.1/etc/min.c.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/lua-5.1.1/etc/noparser.c.i b/mk/linux/mojosetup/.hg/store/data/lua-5.1.1/etc/noparser.c.i new file mode 100644 index 00000000..3e2e668f Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/lua-5.1.1/etc/noparser.c.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/lua-5.1.1/etc/strict.lua.i b/mk/linux/mojosetup/.hg/store/data/lua-5.1.1/etc/strict.lua.i new file mode 100644 index 00000000..4b4d5924 Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/lua-5.1.1/etc/strict.lua.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/lua-5.1.1/src/_makefile.i b/mk/linux/mojosetup/.hg/store/data/lua-5.1.1/src/_makefile.i new file mode 100644 index 00000000..cc7c61f2 Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/lua-5.1.1/src/_makefile.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/lua-5.1.1/src/lapi.c.i b/mk/linux/mojosetup/.hg/store/data/lua-5.1.1/src/lapi.c.i new file mode 100644 index 00000000..6cd7d767 Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/lua-5.1.1/src/lapi.c.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/lua-5.1.1/src/lapi.h.i b/mk/linux/mojosetup/.hg/store/data/lua-5.1.1/src/lapi.h.i new file mode 100644 index 00000000..2fcfde67 Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/lua-5.1.1/src/lapi.h.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/lua-5.1.1/src/lauxlib.c.i b/mk/linux/mojosetup/.hg/store/data/lua-5.1.1/src/lauxlib.c.i new file mode 100644 index 00000000..bcb59cce Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/lua-5.1.1/src/lauxlib.c.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/lua-5.1.1/src/lauxlib.h.i b/mk/linux/mojosetup/.hg/store/data/lua-5.1.1/src/lauxlib.h.i new file mode 100644 index 00000000..47ebbf60 Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/lua-5.1.1/src/lauxlib.h.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/lua-5.1.1/src/lbaselib.c.i b/mk/linux/mojosetup/.hg/store/data/lua-5.1.1/src/lbaselib.c.i new file mode 100644 index 00000000..ee30e014 Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/lua-5.1.1/src/lbaselib.c.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/lua-5.1.1/src/lcode.c.i b/mk/linux/mojosetup/.hg/store/data/lua-5.1.1/src/lcode.c.i new file mode 100644 index 00000000..13f5c6a2 Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/lua-5.1.1/src/lcode.c.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/lua-5.1.1/src/lcode.h.i b/mk/linux/mojosetup/.hg/store/data/lua-5.1.1/src/lcode.h.i new file mode 100644 index 00000000..4a132b9c Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/lua-5.1.1/src/lcode.h.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/lua-5.1.1/src/ldblib.c.i b/mk/linux/mojosetup/.hg/store/data/lua-5.1.1/src/ldblib.c.i new file mode 100644 index 00000000..9a511269 Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/lua-5.1.1/src/ldblib.c.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/lua-5.1.1/src/ldebug.c.i b/mk/linux/mojosetup/.hg/store/data/lua-5.1.1/src/ldebug.c.i new file mode 100644 index 00000000..f3179771 Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/lua-5.1.1/src/ldebug.c.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/lua-5.1.1/src/ldebug.h.i b/mk/linux/mojosetup/.hg/store/data/lua-5.1.1/src/ldebug.h.i new file mode 100644 index 00000000..f341db4a Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/lua-5.1.1/src/ldebug.h.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/lua-5.1.1/src/ldo.c.i b/mk/linux/mojosetup/.hg/store/data/lua-5.1.1/src/ldo.c.i new file mode 100644 index 00000000..dc3069f9 Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/lua-5.1.1/src/ldo.c.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/lua-5.1.1/src/ldo.h.i b/mk/linux/mojosetup/.hg/store/data/lua-5.1.1/src/ldo.h.i new file mode 100644 index 00000000..231feb13 Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/lua-5.1.1/src/ldo.h.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/lua-5.1.1/src/ldump.c.i b/mk/linux/mojosetup/.hg/store/data/lua-5.1.1/src/ldump.c.i new file mode 100644 index 00000000..d58f6576 Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/lua-5.1.1/src/ldump.c.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/lua-5.1.1/src/lfunc.c.i b/mk/linux/mojosetup/.hg/store/data/lua-5.1.1/src/lfunc.c.i new file mode 100644 index 00000000..f2d0461c Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/lua-5.1.1/src/lfunc.c.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/lua-5.1.1/src/lfunc.h.i b/mk/linux/mojosetup/.hg/store/data/lua-5.1.1/src/lfunc.h.i new file mode 100644 index 00000000..00d4d525 Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/lua-5.1.1/src/lfunc.h.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/lua-5.1.1/src/lgc.c.i b/mk/linux/mojosetup/.hg/store/data/lua-5.1.1/src/lgc.c.i new file mode 100644 index 00000000..21f86104 Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/lua-5.1.1/src/lgc.c.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/lua-5.1.1/src/lgc.h.i b/mk/linux/mojosetup/.hg/store/data/lua-5.1.1/src/lgc.h.i new file mode 100644 index 00000000..b93bc8e7 Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/lua-5.1.1/src/lgc.h.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/lua-5.1.1/src/linit.c.i b/mk/linux/mojosetup/.hg/store/data/lua-5.1.1/src/linit.c.i new file mode 100644 index 00000000..bc12f1f2 Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/lua-5.1.1/src/linit.c.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/lua-5.1.1/src/liolib.c.i b/mk/linux/mojosetup/.hg/store/data/lua-5.1.1/src/liolib.c.i new file mode 100644 index 00000000..04fff984 Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/lua-5.1.1/src/liolib.c.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/lua-5.1.1/src/llex.c.i b/mk/linux/mojosetup/.hg/store/data/lua-5.1.1/src/llex.c.i new file mode 100644 index 00000000..e42c2cb1 Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/lua-5.1.1/src/llex.c.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/lua-5.1.1/src/llex.h.i b/mk/linux/mojosetup/.hg/store/data/lua-5.1.1/src/llex.h.i new file mode 100644 index 00000000..031767f2 Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/lua-5.1.1/src/llex.h.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/lua-5.1.1/src/llimits.h.i b/mk/linux/mojosetup/.hg/store/data/lua-5.1.1/src/llimits.h.i new file mode 100644 index 00000000..358f25c9 Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/lua-5.1.1/src/llimits.h.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/lua-5.1.1/src/lmathlib.c.i b/mk/linux/mojosetup/.hg/store/data/lua-5.1.1/src/lmathlib.c.i new file mode 100644 index 00000000..f320abed Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/lua-5.1.1/src/lmathlib.c.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/lua-5.1.1/src/lmem.c.i b/mk/linux/mojosetup/.hg/store/data/lua-5.1.1/src/lmem.c.i new file mode 100644 index 00000000..c494afb4 Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/lua-5.1.1/src/lmem.c.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/lua-5.1.1/src/lmem.h.i b/mk/linux/mojosetup/.hg/store/data/lua-5.1.1/src/lmem.h.i new file mode 100644 index 00000000..fa8675c1 Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/lua-5.1.1/src/lmem.h.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/lua-5.1.1/src/loadlib.c.i b/mk/linux/mojosetup/.hg/store/data/lua-5.1.1/src/loadlib.c.i new file mode 100644 index 00000000..c438b07a Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/lua-5.1.1/src/loadlib.c.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/lua-5.1.1/src/lobject.c.i b/mk/linux/mojosetup/.hg/store/data/lua-5.1.1/src/lobject.c.i new file mode 100644 index 00000000..4839d8d9 Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/lua-5.1.1/src/lobject.c.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/lua-5.1.1/src/lobject.h.i b/mk/linux/mojosetup/.hg/store/data/lua-5.1.1/src/lobject.h.i new file mode 100644 index 00000000..4a451148 Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/lua-5.1.1/src/lobject.h.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/lua-5.1.1/src/lopcodes.c.i b/mk/linux/mojosetup/.hg/store/data/lua-5.1.1/src/lopcodes.c.i new file mode 100644 index 00000000..30e9d383 Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/lua-5.1.1/src/lopcodes.c.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/lua-5.1.1/src/lopcodes.h.i b/mk/linux/mojosetup/.hg/store/data/lua-5.1.1/src/lopcodes.h.i new file mode 100644 index 00000000..8737afe1 Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/lua-5.1.1/src/lopcodes.h.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/lua-5.1.1/src/loslib.c.i b/mk/linux/mojosetup/.hg/store/data/lua-5.1.1/src/loslib.c.i new file mode 100644 index 00000000..5ce7f189 Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/lua-5.1.1/src/loslib.c.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/lua-5.1.1/src/lparser.c.i b/mk/linux/mojosetup/.hg/store/data/lua-5.1.1/src/lparser.c.i new file mode 100644 index 00000000..bc19344f Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/lua-5.1.1/src/lparser.c.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/lua-5.1.1/src/lparser.h.i b/mk/linux/mojosetup/.hg/store/data/lua-5.1.1/src/lparser.h.i new file mode 100644 index 00000000..fa3f12b1 Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/lua-5.1.1/src/lparser.h.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/lua-5.1.1/src/lstate.c.i b/mk/linux/mojosetup/.hg/store/data/lua-5.1.1/src/lstate.c.i new file mode 100644 index 00000000..0c0a437a Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/lua-5.1.1/src/lstate.c.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/lua-5.1.1/src/lstate.h.i b/mk/linux/mojosetup/.hg/store/data/lua-5.1.1/src/lstate.h.i new file mode 100644 index 00000000..547379c6 Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/lua-5.1.1/src/lstate.h.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/lua-5.1.1/src/lstring.c.i b/mk/linux/mojosetup/.hg/store/data/lua-5.1.1/src/lstring.c.i new file mode 100644 index 00000000..1781540b Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/lua-5.1.1/src/lstring.c.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/lua-5.1.1/src/lstring.h.i b/mk/linux/mojosetup/.hg/store/data/lua-5.1.1/src/lstring.h.i new file mode 100644 index 00000000..16ece65d Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/lua-5.1.1/src/lstring.h.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/lua-5.1.1/src/lstrlib.c.i b/mk/linux/mojosetup/.hg/store/data/lua-5.1.1/src/lstrlib.c.i new file mode 100644 index 00000000..9f5d743a Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/lua-5.1.1/src/lstrlib.c.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/lua-5.1.1/src/ltable.c.i b/mk/linux/mojosetup/.hg/store/data/lua-5.1.1/src/ltable.c.i new file mode 100644 index 00000000..3b17b1eb Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/lua-5.1.1/src/ltable.c.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/lua-5.1.1/src/ltable.h.i b/mk/linux/mojosetup/.hg/store/data/lua-5.1.1/src/ltable.h.i new file mode 100644 index 00000000..edc216fd Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/lua-5.1.1/src/ltable.h.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/lua-5.1.1/src/ltablib.c.i b/mk/linux/mojosetup/.hg/store/data/lua-5.1.1/src/ltablib.c.i new file mode 100644 index 00000000..d2bbfcf0 Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/lua-5.1.1/src/ltablib.c.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/lua-5.1.1/src/ltm.c.i b/mk/linux/mojosetup/.hg/store/data/lua-5.1.1/src/ltm.c.i new file mode 100644 index 00000000..1518b5c6 Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/lua-5.1.1/src/ltm.c.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/lua-5.1.1/src/ltm.h.i b/mk/linux/mojosetup/.hg/store/data/lua-5.1.1/src/ltm.h.i new file mode 100644 index 00000000..e79f5ac3 Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/lua-5.1.1/src/ltm.h.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/lua-5.1.1/src/lua.c.i b/mk/linux/mojosetup/.hg/store/data/lua-5.1.1/src/lua.c.i new file mode 100644 index 00000000..5f4b7f05 Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/lua-5.1.1/src/lua.c.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/lua-5.1.1/src/lua.h.i b/mk/linux/mojosetup/.hg/store/data/lua-5.1.1/src/lua.h.i new file mode 100644 index 00000000..12390ccc Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/lua-5.1.1/src/lua.h.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/lua-5.1.1/src/luac.c.i b/mk/linux/mojosetup/.hg/store/data/lua-5.1.1/src/luac.c.i new file mode 100644 index 00000000..a11648aa Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/lua-5.1.1/src/luac.c.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/lua-5.1.1/src/luaconf.h.i b/mk/linux/mojosetup/.hg/store/data/lua-5.1.1/src/luaconf.h.i new file mode 100644 index 00000000..42a159f1 Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/lua-5.1.1/src/luaconf.h.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/lua-5.1.1/src/lualib.h.i b/mk/linux/mojosetup/.hg/store/data/lua-5.1.1/src/lualib.h.i new file mode 100644 index 00000000..e63e8554 Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/lua-5.1.1/src/lualib.h.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/lua-5.1.1/src/lundump.c.i b/mk/linux/mojosetup/.hg/store/data/lua-5.1.1/src/lundump.c.i new file mode 100644 index 00000000..ab3df668 Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/lua-5.1.1/src/lundump.c.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/lua-5.1.1/src/lundump.h.i b/mk/linux/mojosetup/.hg/store/data/lua-5.1.1/src/lundump.h.i new file mode 100644 index 00000000..9bb34dc9 Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/lua-5.1.1/src/lundump.h.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/lua-5.1.1/src/lvm.c.i b/mk/linux/mojosetup/.hg/store/data/lua-5.1.1/src/lvm.c.i new file mode 100644 index 00000000..4e8b239f Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/lua-5.1.1/src/lvm.c.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/lua-5.1.1/src/lvm.h.i b/mk/linux/mojosetup/.hg/store/data/lua-5.1.1/src/lvm.h.i new file mode 100644 index 00000000..593400c6 Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/lua-5.1.1/src/lvm.h.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/lua-5.1.1/src/lzio.c.i b/mk/linux/mojosetup/.hg/store/data/lua-5.1.1/src/lzio.c.i new file mode 100644 index 00000000..23fcb785 Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/lua-5.1.1/src/lzio.c.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/lua-5.1.1/src/lzio.h.i b/mk/linux/mojosetup/.hg/store/data/lua-5.1.1/src/lzio.h.i new file mode 100644 index 00000000..b7062e47 Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/lua-5.1.1/src/lzio.h.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/lua-5.1.1/src/print.c.i b/mk/linux/mojosetup/.hg/store/data/lua-5.1.1/src/print.c.i new file mode 100644 index 00000000..3dcd05fc Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/lua-5.1.1/src/print.c.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/lua-5.1.1/test/_r_e_a_d_m_e.i b/mk/linux/mojosetup/.hg/store/data/lua-5.1.1/test/_r_e_a_d_m_e.i new file mode 100644 index 00000000..3e54e177 Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/lua-5.1.1/test/_r_e_a_d_m_e.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/lua-5.1.1/test/bisect.lua.i b/mk/linux/mojosetup/.hg/store/data/lua-5.1.1/test/bisect.lua.i new file mode 100644 index 00000000..a7c2f337 Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/lua-5.1.1/test/bisect.lua.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/lua-5.1.1/test/cf.lua.i b/mk/linux/mojosetup/.hg/store/data/lua-5.1.1/test/cf.lua.i new file mode 100644 index 00000000..06e2bc33 Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/lua-5.1.1/test/cf.lua.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/lua-5.1.1/test/echo.lua.i b/mk/linux/mojosetup/.hg/store/data/lua-5.1.1/test/echo.lua.i new file mode 100644 index 00000000..5caa8ec7 Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/lua-5.1.1/test/echo.lua.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/lua-5.1.1/test/env.lua.i b/mk/linux/mojosetup/.hg/store/data/lua-5.1.1/test/env.lua.i new file mode 100644 index 00000000..c9a5f302 Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/lua-5.1.1/test/env.lua.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/lua-5.1.1/test/factorial.lua.i b/mk/linux/mojosetup/.hg/store/data/lua-5.1.1/test/factorial.lua.i new file mode 100644 index 00000000..63328b89 Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/lua-5.1.1/test/factorial.lua.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/lua-5.1.1/test/fib.lua.i b/mk/linux/mojosetup/.hg/store/data/lua-5.1.1/test/fib.lua.i new file mode 100644 index 00000000..a884a670 Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/lua-5.1.1/test/fib.lua.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/lua-5.1.1/test/fibfor.lua.i b/mk/linux/mojosetup/.hg/store/data/lua-5.1.1/test/fibfor.lua.i new file mode 100644 index 00000000..ea4de7cb Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/lua-5.1.1/test/fibfor.lua.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/lua-5.1.1/test/globals.lua.i b/mk/linux/mojosetup/.hg/store/data/lua-5.1.1/test/globals.lua.i new file mode 100644 index 00000000..0307556b Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/lua-5.1.1/test/globals.lua.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/lua-5.1.1/test/hello.lua.i b/mk/linux/mojosetup/.hg/store/data/lua-5.1.1/test/hello.lua.i new file mode 100644 index 00000000..b7402863 Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/lua-5.1.1/test/hello.lua.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/lua-5.1.1/test/life.lua.i b/mk/linux/mojosetup/.hg/store/data/lua-5.1.1/test/life.lua.i new file mode 100644 index 00000000..f1d0e3fb Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/lua-5.1.1/test/life.lua.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/lua-5.1.1/test/luac.lua.i b/mk/linux/mojosetup/.hg/store/data/lua-5.1.1/test/luac.lua.i new file mode 100644 index 00000000..b073bdd9 Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/lua-5.1.1/test/luac.lua.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/lua-5.1.1/test/printf.lua.i b/mk/linux/mojosetup/.hg/store/data/lua-5.1.1/test/printf.lua.i new file mode 100644 index 00000000..5dc86ebc Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/lua-5.1.1/test/printf.lua.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/lua-5.1.1/test/readonly.lua.i b/mk/linux/mojosetup/.hg/store/data/lua-5.1.1/test/readonly.lua.i new file mode 100644 index 00000000..5c006ce7 Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/lua-5.1.1/test/readonly.lua.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/lua-5.1.1/test/sieve.lua.i b/mk/linux/mojosetup/.hg/store/data/lua-5.1.1/test/sieve.lua.i new file mode 100644 index 00000000..2dda2914 Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/lua-5.1.1/test/sieve.lua.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/lua-5.1.1/test/sort.lua.i b/mk/linux/mojosetup/.hg/store/data/lua-5.1.1/test/sort.lua.i new file mode 100644 index 00000000..edec3359 Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/lua-5.1.1/test/sort.lua.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/lua-5.1.1/test/table.lua.i b/mk/linux/mojosetup/.hg/store/data/lua-5.1.1/test/table.lua.i new file mode 100644 index 00000000..1da29a11 Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/lua-5.1.1/test/table.lua.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/lua-5.1.1/test/trace-calls.lua.i b/mk/linux/mojosetup/.hg/store/data/lua-5.1.1/test/trace-calls.lua.i new file mode 100644 index 00000000..f323a855 Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/lua-5.1.1/test/trace-calls.lua.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/lua-5.1.1/test/trace-globals.lua.i b/mk/linux/mojosetup/.hg/store/data/lua-5.1.1/test/trace-globals.lua.i new file mode 100644 index 00000000..f0286ba7 Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/lua-5.1.1/test/trace-globals.lua.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/lua-5.1.1/test/xd.lua.i b/mk/linux/mojosetup/.hg/store/data/lua-5.1.1/test/xd.lua.i new file mode 100644 index 00000000..bb8c1364 Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/lua-5.1.1/test/xd.lua.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/lua-5.1.3/_c_o_p_y_r_i_g_h_t.i b/mk/linux/mojosetup/.hg/store/data/lua-5.1.3/_c_o_p_y_r_i_g_h_t.i new file mode 100644 index 00000000..a0715e0e Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/lua-5.1.3/_c_o_p_y_r_i_g_h_t.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/lua-5.1.3/_h_i_s_t_o_r_y.i b/mk/linux/mojosetup/.hg/store/data/lua-5.1.3/_h_i_s_t_o_r_y.i new file mode 100644 index 00000000..f3f8c0ac Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/lua-5.1.3/_h_i_s_t_o_r_y.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/lua-5.1.3/_i_n_s_t_a_l_l.i b/mk/linux/mojosetup/.hg/store/data/lua-5.1.3/_i_n_s_t_a_l_l.i new file mode 100644 index 00000000..918bc8e7 Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/lua-5.1.3/_i_n_s_t_a_l_l.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/lua-5.1.3/_makefile.i b/mk/linux/mojosetup/.hg/store/data/lua-5.1.3/_makefile.i new file mode 100644 index 00000000..83eefccf Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/lua-5.1.3/_makefile.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/lua-5.1.3/_r_e_a_d_m_e.i b/mk/linux/mojosetup/.hg/store/data/lua-5.1.3/_r_e_a_d_m_e.i new file mode 100644 index 00000000..e24f258d Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/lua-5.1.3/_r_e_a_d_m_e.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/lua-5.1.3/doc/amazon.gif.i b/mk/linux/mojosetup/.hg/store/data/lua-5.1.3/doc/amazon.gif.i new file mode 100644 index 00000000..664731c5 Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/lua-5.1.3/doc/amazon.gif.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/lua-5.1.3/doc/contents.html.i b/mk/linux/mojosetup/.hg/store/data/lua-5.1.3/doc/contents.html.i new file mode 100644 index 00000000..1da7212a Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/lua-5.1.3/doc/contents.html.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/lua-5.1.3/doc/cover.png.i b/mk/linux/mojosetup/.hg/store/data/lua-5.1.3/doc/cover.png.i new file mode 100644 index 00000000..3ce62639 Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/lua-5.1.3/doc/cover.png.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/lua-5.1.3/doc/logo.gif.i b/mk/linux/mojosetup/.hg/store/data/lua-5.1.3/doc/logo.gif.i new file mode 100644 index 00000000..bb88174f Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/lua-5.1.3/doc/logo.gif.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/lua-5.1.3/doc/lua.1.i b/mk/linux/mojosetup/.hg/store/data/lua-5.1.3/doc/lua.1.i new file mode 100644 index 00000000..1ae9e2c5 Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/lua-5.1.3/doc/lua.1.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/lua-5.1.3/doc/lua.css.i b/mk/linux/mojosetup/.hg/store/data/lua-5.1.3/doc/lua.css.i new file mode 100644 index 00000000..48c2c05e Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/lua-5.1.3/doc/lua.css.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/lua-5.1.3/doc/lua.html.i b/mk/linux/mojosetup/.hg/store/data/lua-5.1.3/doc/lua.html.i new file mode 100644 index 00000000..bff4a37f Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/lua-5.1.3/doc/lua.html.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/lua-5.1.3/doc/luac.1.i b/mk/linux/mojosetup/.hg/store/data/lua-5.1.3/doc/luac.1.i new file mode 100644 index 00000000..23ff8b8f Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/lua-5.1.3/doc/luac.1.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/lua-5.1.3/doc/luac.html.i b/mk/linux/mojosetup/.hg/store/data/lua-5.1.3/doc/luac.html.i new file mode 100644 index 00000000..f4c3c45b Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/lua-5.1.3/doc/luac.html.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/lua-5.1.3/doc/manual.css.i b/mk/linux/mojosetup/.hg/store/data/lua-5.1.3/doc/manual.css.i new file mode 100644 index 00000000..76c639d6 Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/lua-5.1.3/doc/manual.css.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/lua-5.1.3/doc/manual.html.i b/mk/linux/mojosetup/.hg/store/data/lua-5.1.3/doc/manual.html.i new file mode 100644 index 00000000..1701b9b1 Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/lua-5.1.3/doc/manual.html.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/lua-5.1.3/doc/readme.html.i b/mk/linux/mojosetup/.hg/store/data/lua-5.1.3/doc/readme.html.i new file mode 100644 index 00000000..0b4d67ac Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/lua-5.1.3/doc/readme.html.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/lua-5.1.3/etc/_makefile.i b/mk/linux/mojosetup/.hg/store/data/lua-5.1.3/etc/_makefile.i new file mode 100644 index 00000000..73f8395f Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/lua-5.1.3/etc/_makefile.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/lua-5.1.3/etc/_r_e_a_d_m_e.i b/mk/linux/mojosetup/.hg/store/data/lua-5.1.3/etc/_r_e_a_d_m_e.i new file mode 100644 index 00000000..0946c791 Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/lua-5.1.3/etc/_r_e_a_d_m_e.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/lua-5.1.3/etc/all.c.i b/mk/linux/mojosetup/.hg/store/data/lua-5.1.3/etc/all.c.i new file mode 100644 index 00000000..ac1a05ef Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/lua-5.1.3/etc/all.c.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/lua-5.1.3/etc/lua.hpp.i b/mk/linux/mojosetup/.hg/store/data/lua-5.1.3/etc/lua.hpp.i new file mode 100644 index 00000000..9c61a72f Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/lua-5.1.3/etc/lua.hpp.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/lua-5.1.3/etc/lua.ico.i b/mk/linux/mojosetup/.hg/store/data/lua-5.1.3/etc/lua.ico.i new file mode 100644 index 00000000..4c00e289 Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/lua-5.1.3/etc/lua.ico.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/lua-5.1.3/etc/lua.pc.i b/mk/linux/mojosetup/.hg/store/data/lua-5.1.3/etc/lua.pc.i new file mode 100644 index 00000000..36957391 Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/lua-5.1.3/etc/lua.pc.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/lua-5.1.3/etc/luavs.bat.i b/mk/linux/mojosetup/.hg/store/data/lua-5.1.3/etc/luavs.bat.i new file mode 100644 index 00000000..87666cf6 Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/lua-5.1.3/etc/luavs.bat.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/lua-5.1.3/etc/min.c.i b/mk/linux/mojosetup/.hg/store/data/lua-5.1.3/etc/min.c.i new file mode 100644 index 00000000..bcfae44b Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/lua-5.1.3/etc/min.c.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/lua-5.1.3/etc/noparser.c.i b/mk/linux/mojosetup/.hg/store/data/lua-5.1.3/etc/noparser.c.i new file mode 100644 index 00000000..ff006f64 Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/lua-5.1.3/etc/noparser.c.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/lua-5.1.3/etc/strict.lua.i b/mk/linux/mojosetup/.hg/store/data/lua-5.1.3/etc/strict.lua.i new file mode 100644 index 00000000..ffc5f395 Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/lua-5.1.3/etc/strict.lua.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/lua-5.1.3/src/_makefile.i b/mk/linux/mojosetup/.hg/store/data/lua-5.1.3/src/_makefile.i new file mode 100644 index 00000000..09dd93dc Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/lua-5.1.3/src/_makefile.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/lua-5.1.3/src/lapi.c.i b/mk/linux/mojosetup/.hg/store/data/lua-5.1.3/src/lapi.c.i new file mode 100644 index 00000000..cff794da Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/lua-5.1.3/src/lapi.c.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/lua-5.1.3/src/lapi.h.i b/mk/linux/mojosetup/.hg/store/data/lua-5.1.3/src/lapi.h.i new file mode 100644 index 00000000..05064803 Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/lua-5.1.3/src/lapi.h.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/lua-5.1.3/src/lauxlib.c.i b/mk/linux/mojosetup/.hg/store/data/lua-5.1.3/src/lauxlib.c.i new file mode 100644 index 00000000..71b49dd2 Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/lua-5.1.3/src/lauxlib.c.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/lua-5.1.3/src/lauxlib.h.i b/mk/linux/mojosetup/.hg/store/data/lua-5.1.3/src/lauxlib.h.i new file mode 100644 index 00000000..498767bd Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/lua-5.1.3/src/lauxlib.h.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/lua-5.1.3/src/lbaselib.c.i b/mk/linux/mojosetup/.hg/store/data/lua-5.1.3/src/lbaselib.c.i new file mode 100644 index 00000000..ebd53e47 Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/lua-5.1.3/src/lbaselib.c.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/lua-5.1.3/src/lcode.c.i b/mk/linux/mojosetup/.hg/store/data/lua-5.1.3/src/lcode.c.i new file mode 100644 index 00000000..76ca34af Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/lua-5.1.3/src/lcode.c.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/lua-5.1.3/src/lcode.h.i b/mk/linux/mojosetup/.hg/store/data/lua-5.1.3/src/lcode.h.i new file mode 100644 index 00000000..248b99ea Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/lua-5.1.3/src/lcode.h.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/lua-5.1.3/src/ldblib.c.i b/mk/linux/mojosetup/.hg/store/data/lua-5.1.3/src/ldblib.c.i new file mode 100644 index 00000000..3e536ce3 Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/lua-5.1.3/src/ldblib.c.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/lua-5.1.3/src/ldebug.c.i b/mk/linux/mojosetup/.hg/store/data/lua-5.1.3/src/ldebug.c.i new file mode 100644 index 00000000..2005d4f4 Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/lua-5.1.3/src/ldebug.c.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/lua-5.1.3/src/ldebug.h.i b/mk/linux/mojosetup/.hg/store/data/lua-5.1.3/src/ldebug.h.i new file mode 100644 index 00000000..8aac1129 Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/lua-5.1.3/src/ldebug.h.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/lua-5.1.3/src/ldo.c.i b/mk/linux/mojosetup/.hg/store/data/lua-5.1.3/src/ldo.c.i new file mode 100644 index 00000000..4051e9a8 Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/lua-5.1.3/src/ldo.c.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/lua-5.1.3/src/ldo.h.i b/mk/linux/mojosetup/.hg/store/data/lua-5.1.3/src/ldo.h.i new file mode 100644 index 00000000..2fb44dce Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/lua-5.1.3/src/ldo.h.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/lua-5.1.3/src/ldump.c.i b/mk/linux/mojosetup/.hg/store/data/lua-5.1.3/src/ldump.c.i new file mode 100644 index 00000000..e7bb1c9b Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/lua-5.1.3/src/ldump.c.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/lua-5.1.3/src/lfunc.c.i b/mk/linux/mojosetup/.hg/store/data/lua-5.1.3/src/lfunc.c.i new file mode 100644 index 00000000..0811ca69 Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/lua-5.1.3/src/lfunc.c.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/lua-5.1.3/src/lfunc.h.i b/mk/linux/mojosetup/.hg/store/data/lua-5.1.3/src/lfunc.h.i new file mode 100644 index 00000000..52b11382 Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/lua-5.1.3/src/lfunc.h.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/lua-5.1.3/src/lgc.c.i b/mk/linux/mojosetup/.hg/store/data/lua-5.1.3/src/lgc.c.i new file mode 100644 index 00000000..c0718d04 Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/lua-5.1.3/src/lgc.c.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/lua-5.1.3/src/lgc.h.i b/mk/linux/mojosetup/.hg/store/data/lua-5.1.3/src/lgc.h.i new file mode 100644 index 00000000..86f7d393 Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/lua-5.1.3/src/lgc.h.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/lua-5.1.3/src/linit.c.i b/mk/linux/mojosetup/.hg/store/data/lua-5.1.3/src/linit.c.i new file mode 100644 index 00000000..bd93ae20 Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/lua-5.1.3/src/linit.c.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/lua-5.1.3/src/liolib.c.i b/mk/linux/mojosetup/.hg/store/data/lua-5.1.3/src/liolib.c.i new file mode 100644 index 00000000..e80af49f Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/lua-5.1.3/src/liolib.c.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/lua-5.1.3/src/llex.c.i b/mk/linux/mojosetup/.hg/store/data/lua-5.1.3/src/llex.c.i new file mode 100644 index 00000000..c36544f1 Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/lua-5.1.3/src/llex.c.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/lua-5.1.3/src/llex.h.i b/mk/linux/mojosetup/.hg/store/data/lua-5.1.3/src/llex.h.i new file mode 100644 index 00000000..45df5749 Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/lua-5.1.3/src/llex.h.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/lua-5.1.3/src/llimits.h.i b/mk/linux/mojosetup/.hg/store/data/lua-5.1.3/src/llimits.h.i new file mode 100644 index 00000000..62bcdd94 Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/lua-5.1.3/src/llimits.h.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/lua-5.1.3/src/lmathlib.c.i b/mk/linux/mojosetup/.hg/store/data/lua-5.1.3/src/lmathlib.c.i new file mode 100644 index 00000000..3b3ad2a7 Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/lua-5.1.3/src/lmathlib.c.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/lua-5.1.3/src/lmem.c.i b/mk/linux/mojosetup/.hg/store/data/lua-5.1.3/src/lmem.c.i new file mode 100644 index 00000000..fe0802de Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/lua-5.1.3/src/lmem.c.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/lua-5.1.3/src/lmem.h.i b/mk/linux/mojosetup/.hg/store/data/lua-5.1.3/src/lmem.h.i new file mode 100644 index 00000000..fd5c88d0 Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/lua-5.1.3/src/lmem.h.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/lua-5.1.3/src/loadlib.c.i b/mk/linux/mojosetup/.hg/store/data/lua-5.1.3/src/loadlib.c.i new file mode 100644 index 00000000..6b5241d3 Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/lua-5.1.3/src/loadlib.c.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/lua-5.1.3/src/lobject.c.i b/mk/linux/mojosetup/.hg/store/data/lua-5.1.3/src/lobject.c.i new file mode 100644 index 00000000..140bc7fa Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/lua-5.1.3/src/lobject.c.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/lua-5.1.3/src/lobject.h.i b/mk/linux/mojosetup/.hg/store/data/lua-5.1.3/src/lobject.h.i new file mode 100644 index 00000000..3b67ad6d Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/lua-5.1.3/src/lobject.h.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/lua-5.1.3/src/lopcodes.c.i b/mk/linux/mojosetup/.hg/store/data/lua-5.1.3/src/lopcodes.c.i new file mode 100644 index 00000000..d0c71e9c Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/lua-5.1.3/src/lopcodes.c.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/lua-5.1.3/src/lopcodes.h.i b/mk/linux/mojosetup/.hg/store/data/lua-5.1.3/src/lopcodes.h.i new file mode 100644 index 00000000..550615e3 Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/lua-5.1.3/src/lopcodes.h.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/lua-5.1.3/src/loslib.c.i b/mk/linux/mojosetup/.hg/store/data/lua-5.1.3/src/loslib.c.i new file mode 100644 index 00000000..ad60c690 Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/lua-5.1.3/src/loslib.c.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/lua-5.1.3/src/lparser.c.i b/mk/linux/mojosetup/.hg/store/data/lua-5.1.3/src/lparser.c.i new file mode 100644 index 00000000..9297a9e2 Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/lua-5.1.3/src/lparser.c.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/lua-5.1.3/src/lparser.h.i b/mk/linux/mojosetup/.hg/store/data/lua-5.1.3/src/lparser.h.i new file mode 100644 index 00000000..f28b89b7 Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/lua-5.1.3/src/lparser.h.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/lua-5.1.3/src/lstate.c.i b/mk/linux/mojosetup/.hg/store/data/lua-5.1.3/src/lstate.c.i new file mode 100644 index 00000000..56bf648e Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/lua-5.1.3/src/lstate.c.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/lua-5.1.3/src/lstate.h.i b/mk/linux/mojosetup/.hg/store/data/lua-5.1.3/src/lstate.h.i new file mode 100644 index 00000000..4faf2874 Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/lua-5.1.3/src/lstate.h.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/lua-5.1.3/src/lstring.c.i b/mk/linux/mojosetup/.hg/store/data/lua-5.1.3/src/lstring.c.i new file mode 100644 index 00000000..2d1018a2 Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/lua-5.1.3/src/lstring.c.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/lua-5.1.3/src/lstring.h.i b/mk/linux/mojosetup/.hg/store/data/lua-5.1.3/src/lstring.h.i new file mode 100644 index 00000000..5caed200 Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/lua-5.1.3/src/lstring.h.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/lua-5.1.3/src/lstrlib.c.i b/mk/linux/mojosetup/.hg/store/data/lua-5.1.3/src/lstrlib.c.i new file mode 100644 index 00000000..e93f02c9 Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/lua-5.1.3/src/lstrlib.c.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/lua-5.1.3/src/ltable.c.i b/mk/linux/mojosetup/.hg/store/data/lua-5.1.3/src/ltable.c.i new file mode 100644 index 00000000..f9f48d89 Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/lua-5.1.3/src/ltable.c.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/lua-5.1.3/src/ltable.h.i b/mk/linux/mojosetup/.hg/store/data/lua-5.1.3/src/ltable.h.i new file mode 100644 index 00000000..d341ba50 Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/lua-5.1.3/src/ltable.h.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/lua-5.1.3/src/ltablib.c.i b/mk/linux/mojosetup/.hg/store/data/lua-5.1.3/src/ltablib.c.i new file mode 100644 index 00000000..0965ab9c Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/lua-5.1.3/src/ltablib.c.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/lua-5.1.3/src/ltm.c.i b/mk/linux/mojosetup/.hg/store/data/lua-5.1.3/src/ltm.c.i new file mode 100644 index 00000000..120ccc1b Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/lua-5.1.3/src/ltm.c.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/lua-5.1.3/src/ltm.h.i b/mk/linux/mojosetup/.hg/store/data/lua-5.1.3/src/ltm.h.i new file mode 100644 index 00000000..535bc0dc Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/lua-5.1.3/src/ltm.h.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/lua-5.1.3/src/lua.c.i b/mk/linux/mojosetup/.hg/store/data/lua-5.1.3/src/lua.c.i new file mode 100644 index 00000000..55d3d52e Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/lua-5.1.3/src/lua.c.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/lua-5.1.3/src/lua.h.i b/mk/linux/mojosetup/.hg/store/data/lua-5.1.3/src/lua.h.i new file mode 100644 index 00000000..b7f48df8 Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/lua-5.1.3/src/lua.h.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/lua-5.1.3/src/luac.c.i b/mk/linux/mojosetup/.hg/store/data/lua-5.1.3/src/luac.c.i new file mode 100644 index 00000000..1d4b8074 Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/lua-5.1.3/src/luac.c.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/lua-5.1.3/src/luaconf.h.i b/mk/linux/mojosetup/.hg/store/data/lua-5.1.3/src/luaconf.h.i new file mode 100644 index 00000000..1090ed1f Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/lua-5.1.3/src/luaconf.h.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/lua-5.1.3/src/lualib.h.i b/mk/linux/mojosetup/.hg/store/data/lua-5.1.3/src/lualib.h.i new file mode 100644 index 00000000..c19df61a Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/lua-5.1.3/src/lualib.h.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/lua-5.1.3/src/lundump.c.i b/mk/linux/mojosetup/.hg/store/data/lua-5.1.3/src/lundump.c.i new file mode 100644 index 00000000..8e110509 Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/lua-5.1.3/src/lundump.c.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/lua-5.1.3/src/lundump.h.i b/mk/linux/mojosetup/.hg/store/data/lua-5.1.3/src/lundump.h.i new file mode 100644 index 00000000..518d3aef Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/lua-5.1.3/src/lundump.h.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/lua-5.1.3/src/lvm.c.i b/mk/linux/mojosetup/.hg/store/data/lua-5.1.3/src/lvm.c.i new file mode 100644 index 00000000..09aa6019 Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/lua-5.1.3/src/lvm.c.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/lua-5.1.3/src/lvm.h.i b/mk/linux/mojosetup/.hg/store/data/lua-5.1.3/src/lvm.h.i new file mode 100644 index 00000000..0b2b775d Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/lua-5.1.3/src/lvm.h.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/lua-5.1.3/src/lzio.c.i b/mk/linux/mojosetup/.hg/store/data/lua-5.1.3/src/lzio.c.i new file mode 100644 index 00000000..e2f7d92a Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/lua-5.1.3/src/lzio.c.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/lua-5.1.3/src/lzio.h.i b/mk/linux/mojosetup/.hg/store/data/lua-5.1.3/src/lzio.h.i new file mode 100644 index 00000000..63d73762 Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/lua-5.1.3/src/lzio.h.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/lua-5.1.3/src/print.c.i b/mk/linux/mojosetup/.hg/store/data/lua-5.1.3/src/print.c.i new file mode 100644 index 00000000..8f597905 Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/lua-5.1.3/src/print.c.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/lua-5.1.3/test/_r_e_a_d_m_e.i b/mk/linux/mojosetup/.hg/store/data/lua-5.1.3/test/_r_e_a_d_m_e.i new file mode 100644 index 00000000..3add93ef Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/lua-5.1.3/test/_r_e_a_d_m_e.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/lua-5.1.3/test/bisect.lua.i b/mk/linux/mojosetup/.hg/store/data/lua-5.1.3/test/bisect.lua.i new file mode 100644 index 00000000..232cfc20 Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/lua-5.1.3/test/bisect.lua.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/lua-5.1.3/test/cf.lua.i b/mk/linux/mojosetup/.hg/store/data/lua-5.1.3/test/cf.lua.i new file mode 100644 index 00000000..960f347f Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/lua-5.1.3/test/cf.lua.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/lua-5.1.3/test/echo.lua.i b/mk/linux/mojosetup/.hg/store/data/lua-5.1.3/test/echo.lua.i new file mode 100644 index 00000000..362c53fa Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/lua-5.1.3/test/echo.lua.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/lua-5.1.3/test/env.lua.i b/mk/linux/mojosetup/.hg/store/data/lua-5.1.3/test/env.lua.i new file mode 100644 index 00000000..87a69777 Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/lua-5.1.3/test/env.lua.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/lua-5.1.3/test/factorial.lua.i b/mk/linux/mojosetup/.hg/store/data/lua-5.1.3/test/factorial.lua.i new file mode 100644 index 00000000..b60da077 Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/lua-5.1.3/test/factorial.lua.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/lua-5.1.3/test/fib.lua.i b/mk/linux/mojosetup/.hg/store/data/lua-5.1.3/test/fib.lua.i new file mode 100644 index 00000000..c3094db7 Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/lua-5.1.3/test/fib.lua.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/lua-5.1.3/test/fibfor.lua.i b/mk/linux/mojosetup/.hg/store/data/lua-5.1.3/test/fibfor.lua.i new file mode 100644 index 00000000..64d2fa47 Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/lua-5.1.3/test/fibfor.lua.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/lua-5.1.3/test/globals.lua.i b/mk/linux/mojosetup/.hg/store/data/lua-5.1.3/test/globals.lua.i new file mode 100644 index 00000000..aeca8e3f Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/lua-5.1.3/test/globals.lua.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/lua-5.1.3/test/hello.lua.i b/mk/linux/mojosetup/.hg/store/data/lua-5.1.3/test/hello.lua.i new file mode 100644 index 00000000..c395d6e3 Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/lua-5.1.3/test/hello.lua.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/lua-5.1.3/test/life.lua.i b/mk/linux/mojosetup/.hg/store/data/lua-5.1.3/test/life.lua.i new file mode 100644 index 00000000..808bd9a0 Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/lua-5.1.3/test/life.lua.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/lua-5.1.3/test/luac.lua.i b/mk/linux/mojosetup/.hg/store/data/lua-5.1.3/test/luac.lua.i new file mode 100644 index 00000000..9c281f19 Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/lua-5.1.3/test/luac.lua.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/lua-5.1.3/test/printf.lua.i b/mk/linux/mojosetup/.hg/store/data/lua-5.1.3/test/printf.lua.i new file mode 100644 index 00000000..0c198944 Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/lua-5.1.3/test/printf.lua.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/lua-5.1.3/test/readonly.lua.i b/mk/linux/mojosetup/.hg/store/data/lua-5.1.3/test/readonly.lua.i new file mode 100644 index 00000000..20c6d315 Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/lua-5.1.3/test/readonly.lua.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/lua-5.1.3/test/sieve.lua.i b/mk/linux/mojosetup/.hg/store/data/lua-5.1.3/test/sieve.lua.i new file mode 100644 index 00000000..44cf088d Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/lua-5.1.3/test/sieve.lua.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/lua-5.1.3/test/sort.lua.i b/mk/linux/mojosetup/.hg/store/data/lua-5.1.3/test/sort.lua.i new file mode 100644 index 00000000..104405f0 Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/lua-5.1.3/test/sort.lua.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/lua-5.1.3/test/table.lua.i b/mk/linux/mojosetup/.hg/store/data/lua-5.1.3/test/table.lua.i new file mode 100644 index 00000000..e9916fa3 Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/lua-5.1.3/test/table.lua.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/lua-5.1.3/test/trace-calls.lua.i b/mk/linux/mojosetup/.hg/store/data/lua-5.1.3/test/trace-calls.lua.i new file mode 100644 index 00000000..85294b07 Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/lua-5.1.3/test/trace-calls.lua.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/lua-5.1.3/test/trace-globals.lua.i b/mk/linux/mojosetup/.hg/store/data/lua-5.1.3/test/trace-globals.lua.i new file mode 100644 index 00000000..c125e99e Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/lua-5.1.3/test/trace-globals.lua.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/lua-5.1.3/test/xd.lua.i b/mk/linux/mojosetup/.hg/store/data/lua-5.1.3/test/xd.lua.i new file mode 100644 index 00000000..7c2f3d28 Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/lua-5.1.3/test/xd.lua.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/lua/_c_o_p_y_r_i_g_h_t.i b/mk/linux/mojosetup/.hg/store/data/lua/_c_o_p_y_r_i_g_h_t.i new file mode 100644 index 00000000..774a3155 Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/lua/_c_o_p_y_r_i_g_h_t.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/lua/_h_i_s_t_o_r_y.i b/mk/linux/mojosetup/.hg/store/data/lua/_h_i_s_t_o_r_y.i new file mode 100644 index 00000000..b3aef445 Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/lua/_h_i_s_t_o_r_y.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/lua/_i_n_s_t_a_l_l.i b/mk/linux/mojosetup/.hg/store/data/lua/_i_n_s_t_a_l_l.i new file mode 100644 index 00000000..c123e1c2 Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/lua/_i_n_s_t_a_l_l.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/lua/_makefile.i b/mk/linux/mojosetup/.hg/store/data/lua/_makefile.i new file mode 100644 index 00000000..8f372f2d Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/lua/_makefile.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/lua/_r_e_a_d_m_e.i b/mk/linux/mojosetup/.hg/store/data/lua/_r_e_a_d_m_e.i new file mode 100644 index 00000000..e45a6f1b Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/lua/_r_e_a_d_m_e.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/lua/config.lua.i b/mk/linux/mojosetup/.hg/store/data/lua/config.lua.i new file mode 100644 index 00000000..f3a79e15 Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/lua/config.lua.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/lua/doc/amazon.gif.i b/mk/linux/mojosetup/.hg/store/data/lua/doc/amazon.gif.i new file mode 100644 index 00000000..cfe7f968 Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/lua/doc/amazon.gif.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/lua/doc/contents.html.i b/mk/linux/mojosetup/.hg/store/data/lua/doc/contents.html.i new file mode 100644 index 00000000..a55d37b0 Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/lua/doc/contents.html.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/lua/doc/cover.png.i b/mk/linux/mojosetup/.hg/store/data/lua/doc/cover.png.i new file mode 100644 index 00000000..95e32c4e Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/lua/doc/cover.png.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/lua/doc/logo.gif.i b/mk/linux/mojosetup/.hg/store/data/lua/doc/logo.gif.i new file mode 100644 index 00000000..79ec0fdc Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/lua/doc/logo.gif.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/lua/doc/lua.1.i b/mk/linux/mojosetup/.hg/store/data/lua/doc/lua.1.i new file mode 100644 index 00000000..de12a317 Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/lua/doc/lua.1.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/lua/doc/lua.css.i b/mk/linux/mojosetup/.hg/store/data/lua/doc/lua.css.i new file mode 100644 index 00000000..8e9b180d Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/lua/doc/lua.css.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/lua/doc/lua.html.i b/mk/linux/mojosetup/.hg/store/data/lua/doc/lua.html.i new file mode 100644 index 00000000..bce0ba11 Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/lua/doc/lua.html.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/lua/doc/luac.1.i b/mk/linux/mojosetup/.hg/store/data/lua/doc/luac.1.i new file mode 100644 index 00000000..d7ef8c7a Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/lua/doc/luac.1.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/lua/doc/luac.html.i b/mk/linux/mojosetup/.hg/store/data/lua/doc/luac.html.i new file mode 100644 index 00000000..5958d539 Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/lua/doc/luac.html.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/lua/doc/manual.css.i b/mk/linux/mojosetup/.hg/store/data/lua/doc/manual.css.i new file mode 100644 index 00000000..5a4b08c6 Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/lua/doc/manual.css.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/lua/doc/manual.html.i b/mk/linux/mojosetup/.hg/store/data/lua/doc/manual.html.i new file mode 100644 index 00000000..fb972134 Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/lua/doc/manual.html.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/lua/doc/readme.html.i b/mk/linux/mojosetup/.hg/store/data/lua/doc/readme.html.i new file mode 100644 index 00000000..318659a5 Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/lua/doc/readme.html.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/lua/etc/_makefile.i b/mk/linux/mojosetup/.hg/store/data/lua/etc/_makefile.i new file mode 100644 index 00000000..1d3fa49a Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/lua/etc/_makefile.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/lua/etc/_r_e_a_d_m_e.i b/mk/linux/mojosetup/.hg/store/data/lua/etc/_r_e_a_d_m_e.i new file mode 100644 index 00000000..fee6ae8f Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/lua/etc/_r_e_a_d_m_e.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/lua/etc/all.c.i b/mk/linux/mojosetup/.hg/store/data/lua/etc/all.c.i new file mode 100644 index 00000000..c06e8b98 Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/lua/etc/all.c.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/lua/etc/lua.hpp.i b/mk/linux/mojosetup/.hg/store/data/lua/etc/lua.hpp.i new file mode 100644 index 00000000..52657169 Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/lua/etc/lua.hpp.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/lua/etc/lua.ico.i b/mk/linux/mojosetup/.hg/store/data/lua/etc/lua.ico.i new file mode 100644 index 00000000..6c3bdc25 Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/lua/etc/lua.ico.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/lua/etc/lua.pc.i b/mk/linux/mojosetup/.hg/store/data/lua/etc/lua.pc.i new file mode 100644 index 00000000..e0f2d392 Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/lua/etc/lua.pc.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/lua/etc/luavs.bat.i b/mk/linux/mojosetup/.hg/store/data/lua/etc/luavs.bat.i new file mode 100644 index 00000000..59a9a8d8 Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/lua/etc/luavs.bat.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/lua/etc/min.c.i b/mk/linux/mojosetup/.hg/store/data/lua/etc/min.c.i new file mode 100644 index 00000000..677ace28 Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/lua/etc/min.c.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/lua/etc/noparser.c.i b/mk/linux/mojosetup/.hg/store/data/lua/etc/noparser.c.i new file mode 100644 index 00000000..7182bdfc Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/lua/etc/noparser.c.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/lua/etc/strict.lua.i b/mk/linux/mojosetup/.hg/store/data/lua/etc/strict.lua.i new file mode 100644 index 00000000..34691617 Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/lua/etc/strict.lua.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/lua/localization.lua.i b/mk/linux/mojosetup/.hg/store/data/lua/localization.lua.i new file mode 100644 index 00000000..d61831e9 Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/lua/localization.lua.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/lua/mojosetup__init.lua.i b/mk/linux/mojosetup/.hg/store/data/lua/mojosetup__init.lua.i new file mode 100644 index 00000000..d5df9f49 Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/lua/mojosetup__init.lua.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/lua/mojosetup__mainline.lua.i b/mk/linux/mojosetup/.hg/store/data/lua/mojosetup__mainline.lua.i new file mode 100644 index 00000000..c1bd1e8f Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/lua/mojosetup__mainline.lua.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/lua/setup.lua.i b/mk/linux/mojosetup/.hg/store/data/lua/setup.lua.i new file mode 100644 index 00000000..c0403ea4 Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/lua/setup.lua.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/lua/src/_makefile.i b/mk/linux/mojosetup/.hg/store/data/lua/src/_makefile.i new file mode 100644 index 00000000..8c0350c1 Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/lua/src/_makefile.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/lua/src/lapi.c.i b/mk/linux/mojosetup/.hg/store/data/lua/src/lapi.c.i new file mode 100644 index 00000000..601b698b Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/lua/src/lapi.c.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/lua/src/lapi.h.i b/mk/linux/mojosetup/.hg/store/data/lua/src/lapi.h.i new file mode 100644 index 00000000..4bd3c3a5 Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/lua/src/lapi.h.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/lua/src/lauxlib.c.i b/mk/linux/mojosetup/.hg/store/data/lua/src/lauxlib.c.i new file mode 100644 index 00000000..978ac609 Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/lua/src/lauxlib.c.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/lua/src/lauxlib.h.i b/mk/linux/mojosetup/.hg/store/data/lua/src/lauxlib.h.i new file mode 100644 index 00000000..96f650c7 Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/lua/src/lauxlib.h.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/lua/src/lbaselib.c.i b/mk/linux/mojosetup/.hg/store/data/lua/src/lbaselib.c.i new file mode 100644 index 00000000..e9db4339 Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/lua/src/lbaselib.c.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/lua/src/lcode.c.i b/mk/linux/mojosetup/.hg/store/data/lua/src/lcode.c.i new file mode 100644 index 00000000..360e0979 Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/lua/src/lcode.c.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/lua/src/lcode.h.i b/mk/linux/mojosetup/.hg/store/data/lua/src/lcode.h.i new file mode 100644 index 00000000..78830087 Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/lua/src/lcode.h.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/lua/src/ldblib.c.i b/mk/linux/mojosetup/.hg/store/data/lua/src/ldblib.c.i new file mode 100644 index 00000000..ba540682 Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/lua/src/ldblib.c.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/lua/src/ldebug.c.i b/mk/linux/mojosetup/.hg/store/data/lua/src/ldebug.c.i new file mode 100644 index 00000000..9722cd00 Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/lua/src/ldebug.c.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/lua/src/ldebug.h.i b/mk/linux/mojosetup/.hg/store/data/lua/src/ldebug.h.i new file mode 100644 index 00000000..2f7c46e8 Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/lua/src/ldebug.h.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/lua/src/ldo.c.i b/mk/linux/mojosetup/.hg/store/data/lua/src/ldo.c.i new file mode 100644 index 00000000..1db2f733 Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/lua/src/ldo.c.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/lua/src/ldo.h.i b/mk/linux/mojosetup/.hg/store/data/lua/src/ldo.h.i new file mode 100644 index 00000000..bfd690b6 Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/lua/src/ldo.h.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/lua/src/ldump.c.i b/mk/linux/mojosetup/.hg/store/data/lua/src/ldump.c.i new file mode 100644 index 00000000..4c97a47c Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/lua/src/ldump.c.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/lua/src/lfunc.c.i b/mk/linux/mojosetup/.hg/store/data/lua/src/lfunc.c.i new file mode 100644 index 00000000..5ec7fd26 Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/lua/src/lfunc.c.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/lua/src/lfunc.h.i b/mk/linux/mojosetup/.hg/store/data/lua/src/lfunc.h.i new file mode 100644 index 00000000..132bf6cd Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/lua/src/lfunc.h.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/lua/src/lgc.c.i b/mk/linux/mojosetup/.hg/store/data/lua/src/lgc.c.i new file mode 100644 index 00000000..6cf22405 Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/lua/src/lgc.c.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/lua/src/lgc.h.i b/mk/linux/mojosetup/.hg/store/data/lua/src/lgc.h.i new file mode 100644 index 00000000..c8649995 Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/lua/src/lgc.h.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/lua/src/linit.c.i b/mk/linux/mojosetup/.hg/store/data/lua/src/linit.c.i new file mode 100644 index 00000000..4c5fc82f Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/lua/src/linit.c.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/lua/src/liolib.c.i b/mk/linux/mojosetup/.hg/store/data/lua/src/liolib.c.i new file mode 100644 index 00000000..f2395865 Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/lua/src/liolib.c.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/lua/src/llex.c.i b/mk/linux/mojosetup/.hg/store/data/lua/src/llex.c.i new file mode 100644 index 00000000..a8ec7320 Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/lua/src/llex.c.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/lua/src/llex.h.i b/mk/linux/mojosetup/.hg/store/data/lua/src/llex.h.i new file mode 100644 index 00000000..62295da6 Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/lua/src/llex.h.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/lua/src/llimits.h.i b/mk/linux/mojosetup/.hg/store/data/lua/src/llimits.h.i new file mode 100644 index 00000000..2a4f305f Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/lua/src/llimits.h.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/lua/src/lmathlib.c.i b/mk/linux/mojosetup/.hg/store/data/lua/src/lmathlib.c.i new file mode 100644 index 00000000..72e113ac Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/lua/src/lmathlib.c.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/lua/src/lmem.c.i b/mk/linux/mojosetup/.hg/store/data/lua/src/lmem.c.i new file mode 100644 index 00000000..2901224b Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/lua/src/lmem.c.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/lua/src/lmem.h.i b/mk/linux/mojosetup/.hg/store/data/lua/src/lmem.h.i new file mode 100644 index 00000000..6ebd0b14 Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/lua/src/lmem.h.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/lua/src/loadlib.c.i b/mk/linux/mojosetup/.hg/store/data/lua/src/loadlib.c.i new file mode 100644 index 00000000..d2008cac Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/lua/src/loadlib.c.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/lua/src/lobject.c.i b/mk/linux/mojosetup/.hg/store/data/lua/src/lobject.c.i new file mode 100644 index 00000000..da82cabb Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/lua/src/lobject.c.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/lua/src/lobject.h.i b/mk/linux/mojosetup/.hg/store/data/lua/src/lobject.h.i new file mode 100644 index 00000000..8130b547 Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/lua/src/lobject.h.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/lua/src/lopcodes.c.i b/mk/linux/mojosetup/.hg/store/data/lua/src/lopcodes.c.i new file mode 100644 index 00000000..6e3f56b7 Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/lua/src/lopcodes.c.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/lua/src/lopcodes.h.i b/mk/linux/mojosetup/.hg/store/data/lua/src/lopcodes.h.i new file mode 100644 index 00000000..cd6539b7 Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/lua/src/lopcodes.h.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/lua/src/loslib.c.i b/mk/linux/mojosetup/.hg/store/data/lua/src/loslib.c.i new file mode 100644 index 00000000..af932c8d Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/lua/src/loslib.c.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/lua/src/lparser.c.i b/mk/linux/mojosetup/.hg/store/data/lua/src/lparser.c.i new file mode 100644 index 00000000..60e1809b Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/lua/src/lparser.c.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/lua/src/lparser.h.i b/mk/linux/mojosetup/.hg/store/data/lua/src/lparser.h.i new file mode 100644 index 00000000..4dccdd8d Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/lua/src/lparser.h.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/lua/src/lstate.c.i b/mk/linux/mojosetup/.hg/store/data/lua/src/lstate.c.i new file mode 100644 index 00000000..c1f1e0eb Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/lua/src/lstate.c.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/lua/src/lstate.h.i b/mk/linux/mojosetup/.hg/store/data/lua/src/lstate.h.i new file mode 100644 index 00000000..aac97556 Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/lua/src/lstate.h.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/lua/src/lstring.c.i b/mk/linux/mojosetup/.hg/store/data/lua/src/lstring.c.i new file mode 100644 index 00000000..e5bd5f8f Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/lua/src/lstring.c.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/lua/src/lstring.h.i b/mk/linux/mojosetup/.hg/store/data/lua/src/lstring.h.i new file mode 100644 index 00000000..88c636b6 Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/lua/src/lstring.h.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/lua/src/lstrlib.c.i b/mk/linux/mojosetup/.hg/store/data/lua/src/lstrlib.c.i new file mode 100644 index 00000000..3031dd6f Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/lua/src/lstrlib.c.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/lua/src/ltable.c.i b/mk/linux/mojosetup/.hg/store/data/lua/src/ltable.c.i new file mode 100644 index 00000000..6055ec2c Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/lua/src/ltable.c.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/lua/src/ltable.h.i b/mk/linux/mojosetup/.hg/store/data/lua/src/ltable.h.i new file mode 100644 index 00000000..d6947c2d Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/lua/src/ltable.h.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/lua/src/ltablib.c.i b/mk/linux/mojosetup/.hg/store/data/lua/src/ltablib.c.i new file mode 100644 index 00000000..776813e2 Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/lua/src/ltablib.c.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/lua/src/ltm.c.i b/mk/linux/mojosetup/.hg/store/data/lua/src/ltm.c.i new file mode 100644 index 00000000..696b75ef Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/lua/src/ltm.c.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/lua/src/ltm.h.i b/mk/linux/mojosetup/.hg/store/data/lua/src/ltm.h.i new file mode 100644 index 00000000..8c6fd44b Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/lua/src/ltm.h.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/lua/src/lua.c.i b/mk/linux/mojosetup/.hg/store/data/lua/src/lua.c.i new file mode 100644 index 00000000..313ef78a Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/lua/src/lua.c.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/lua/src/lua.h.i b/mk/linux/mojosetup/.hg/store/data/lua/src/lua.h.i new file mode 100644 index 00000000..7b37c6ec Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/lua/src/lua.h.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/lua/src/luac.c.i b/mk/linux/mojosetup/.hg/store/data/lua/src/luac.c.i new file mode 100644 index 00000000..8dec26be Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/lua/src/luac.c.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/lua/src/luaconf.h.i b/mk/linux/mojosetup/.hg/store/data/lua/src/luaconf.h.i new file mode 100644 index 00000000..c7e29fd1 Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/lua/src/luaconf.h.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/lua/src/lualib.h.i b/mk/linux/mojosetup/.hg/store/data/lua/src/lualib.h.i new file mode 100644 index 00000000..c577b84e Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/lua/src/lualib.h.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/lua/src/lundump.c.i b/mk/linux/mojosetup/.hg/store/data/lua/src/lundump.c.i new file mode 100644 index 00000000..8123bbd3 Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/lua/src/lundump.c.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/lua/src/lundump.h.i b/mk/linux/mojosetup/.hg/store/data/lua/src/lundump.h.i new file mode 100644 index 00000000..246ddc4a Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/lua/src/lundump.h.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/lua/src/lvm.c.i b/mk/linux/mojosetup/.hg/store/data/lua/src/lvm.c.i new file mode 100644 index 00000000..8e60dd24 Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/lua/src/lvm.c.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/lua/src/lvm.h.i b/mk/linux/mojosetup/.hg/store/data/lua/src/lvm.h.i new file mode 100644 index 00000000..a62a9bfc Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/lua/src/lvm.h.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/lua/src/lzio.c.i b/mk/linux/mojosetup/.hg/store/data/lua/src/lzio.c.i new file mode 100644 index 00000000..d148f763 Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/lua/src/lzio.c.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/lua/src/lzio.h.i b/mk/linux/mojosetup/.hg/store/data/lua/src/lzio.h.i new file mode 100644 index 00000000..a8c1c138 Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/lua/src/lzio.h.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/lua/src/print.c.i b/mk/linux/mojosetup/.hg/store/data/lua/src/print.c.i new file mode 100644 index 00000000..6e865ee7 Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/lua/src/print.c.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/lua/test/_r_e_a_d_m_e.i b/mk/linux/mojosetup/.hg/store/data/lua/test/_r_e_a_d_m_e.i new file mode 100644 index 00000000..696c865b Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/lua/test/_r_e_a_d_m_e.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/lua/test/bisect.lua.i b/mk/linux/mojosetup/.hg/store/data/lua/test/bisect.lua.i new file mode 100644 index 00000000..54b8cdbd Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/lua/test/bisect.lua.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/lua/test/cf.lua.i b/mk/linux/mojosetup/.hg/store/data/lua/test/cf.lua.i new file mode 100644 index 00000000..c0d1fd73 Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/lua/test/cf.lua.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/lua/test/echo.lua.i b/mk/linux/mojosetup/.hg/store/data/lua/test/echo.lua.i new file mode 100644 index 00000000..aa91afc7 Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/lua/test/echo.lua.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/lua/test/env.lua.i b/mk/linux/mojosetup/.hg/store/data/lua/test/env.lua.i new file mode 100644 index 00000000..d66de54d Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/lua/test/env.lua.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/lua/test/factorial.lua.i b/mk/linux/mojosetup/.hg/store/data/lua/test/factorial.lua.i new file mode 100644 index 00000000..6cbc26d2 Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/lua/test/factorial.lua.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/lua/test/fib.lua.i b/mk/linux/mojosetup/.hg/store/data/lua/test/fib.lua.i new file mode 100644 index 00000000..59f4a0e0 Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/lua/test/fib.lua.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/lua/test/fibfor.lua.i b/mk/linux/mojosetup/.hg/store/data/lua/test/fibfor.lua.i new file mode 100644 index 00000000..a3f96e58 Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/lua/test/fibfor.lua.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/lua/test/globals.lua.i b/mk/linux/mojosetup/.hg/store/data/lua/test/globals.lua.i new file mode 100644 index 00000000..f5aa8aca Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/lua/test/globals.lua.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/lua/test/hello.lua.i b/mk/linux/mojosetup/.hg/store/data/lua/test/hello.lua.i new file mode 100644 index 00000000..53724005 Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/lua/test/hello.lua.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/lua/test/life.lua.i b/mk/linux/mojosetup/.hg/store/data/lua/test/life.lua.i new file mode 100644 index 00000000..b3b5a03a Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/lua/test/life.lua.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/lua/test/luac.lua.i b/mk/linux/mojosetup/.hg/store/data/lua/test/luac.lua.i new file mode 100644 index 00000000..6f761c8b Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/lua/test/luac.lua.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/lua/test/printf.lua.i b/mk/linux/mojosetup/.hg/store/data/lua/test/printf.lua.i new file mode 100644 index 00000000..6aaaa261 Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/lua/test/printf.lua.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/lua/test/readonly.lua.i b/mk/linux/mojosetup/.hg/store/data/lua/test/readonly.lua.i new file mode 100644 index 00000000..f911ffd9 Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/lua/test/readonly.lua.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/lua/test/sieve.lua.i b/mk/linux/mojosetup/.hg/store/data/lua/test/sieve.lua.i new file mode 100644 index 00000000..a3f93d96 Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/lua/test/sieve.lua.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/lua/test/sort.lua.i b/mk/linux/mojosetup/.hg/store/data/lua/test/sort.lua.i new file mode 100644 index 00000000..cd236590 Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/lua/test/sort.lua.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/lua/test/table.lua.i b/mk/linux/mojosetup/.hg/store/data/lua/test/table.lua.i new file mode 100644 index 00000000..bf8ddf95 Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/lua/test/table.lua.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/lua/test/trace-calls.lua.i b/mk/linux/mojosetup/.hg/store/data/lua/test/trace-calls.lua.i new file mode 100644 index 00000000..9e3ab8dd Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/lua/test/trace-calls.lua.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/lua/test/trace-globals.lua.i b/mk/linux/mojosetup/.hg/store/data/lua/test/trace-globals.lua.i new file mode 100644 index 00000000..a23f2ac2 Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/lua/test/trace-globals.lua.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/lua/test/xd.lua.i b/mk/linux/mojosetup/.hg/store/data/lua/test/xd.lua.i new file mode 100644 index 00000000..d0daa623 Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/lua/test/xd.lua.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/lua/translations.lua.i b/mk/linux/mojosetup/.hg/store/data/lua/translations.lua.i new file mode 100644 index 00000000..e127b2ad Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/lua/translations.lua.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/lua__glue.c.i b/mk/linux/mojosetup/.hg/store/data/lua__glue.c.i new file mode 100644 index 00000000..669f7b07 Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/lua__glue.c.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/lua__glue.h.i b/mk/linux/mojosetup/.hg/store/data/lua__glue.h.i new file mode 100644 index 00000000..4eacdd04 Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/lua__glue.h.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/makefile.i b/mk/linux/mojosetup/.hg/store/data/makefile.i new file mode 100644 index 00000000..f15153f1 Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/makefile.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/meta/xdg-utils/xdg-desktop-menu.i b/mk/linux/mojosetup/.hg/store/data/meta/xdg-utils/xdg-desktop-menu.i new file mode 100644 index 00000000..8f6357a0 Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/meta/xdg-utils/xdg-desktop-menu.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/meta/xdg-utils/xdg-open.i b/mk/linux/mojosetup/.hg/store/data/meta/xdg-utils/xdg-open.i new file mode 100644 index 00000000..cc1c48ff Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/meta/xdg-utils/xdg-open.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/misc.c.i b/mk/linux/mojosetup/.hg/store/data/misc.c.i new file mode 100644 index 00000000..c0269bcb Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/misc.c.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/misc/_find_curses.cmake.i b/mk/linux/mojosetup/.hg/store/data/misc/_find_curses.cmake.i new file mode 100644 index 00000000..030a9f8a Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/misc/_find_curses.cmake.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/misc/_mac_app_bundle_skeleton/_contents/_info.plist.i b/mk/linux/mojosetup/.hg/store/data/misc/_mac_app_bundle_skeleton/_contents/_info.plist.i new file mode 100644 index 00000000..e576eaaa Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/misc/_mac_app_bundle_skeleton/_contents/_info.plist.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/misc/_mac_app_bundle_skeleton/_contents/_pkg_info.i b/mk/linux/mojosetup/.hg/store/data/misc/_mac_app_bundle_skeleton/_contents/_pkg_info.i new file mode 100644 index 00000000..810c6a7f Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/misc/_mac_app_bundle_skeleton/_contents/_pkg_info.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/misc/_mac_app_bundle_skeleton/_contents/_resources/mojosetup.icns.d b/mk/linux/mojosetup/.hg/store/data/misc/_mac_app_bundle_skeleton/_contents/_resources/mojosetup.icns.d new file mode 100644 index 00000000..df3189d1 Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/misc/_mac_app_bundle_skeleton/_contents/_resources/mojosetup.icns.d differ diff --git a/mk/linux/mojosetup/.hg/store/data/misc/_mac_app_bundle_skeleton/_contents/_resources/mojosetup.icns.i b/mk/linux/mojosetup/.hg/store/data/misc/_mac_app_bundle_skeleton/_contents/_resources/mojosetup.icns.i new file mode 100644 index 00000000..39cc885f Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/misc/_mac_app_bundle_skeleton/_contents/_resources/mojosetup.icns.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/misc/_mojo_setup.xib.i b/mk/linux/mojosetup/.hg/store/data/misc/_mojo_setup.xib.i new file mode 100644 index 00000000..5aa02741 Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/misc/_mojo_setup.xib.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/misc/cp.cmake.i b/mk/linux/mojosetup/.hg/store/data/misc/cp.cmake.i new file mode 100644 index 00000000..39680298 Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/misc/cp.cmake.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/misc/find__localizable__strings.sh.i b/mk/linux/mojosetup/.hg/store/data/misc/find__localizable__strings.sh.i new file mode 100644 index 00000000..37b7e5e6 Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/misc/find__localizable__strings.sh.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/misc/launchpad-import.sh.i b/mk/linux/mojosetup/.hg/store/data/misc/launchpad-import.sh.i new file mode 100644 index 00000000..cafc38bf Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/misc/launchpad-import.sh.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/misc/localization2pot.pl.i b/mk/linux/mojosetup/.hg/store/data/misc/localization2pot.pl.i new file mode 100644 index 00000000..282c28df Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/misc/localization2pot.pl.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/misc/mkdir.cmake.i b/mk/linux/mojosetup/.hg/store/data/misc/mkdir.cmake.i new file mode 100644 index 00000000..24f26d8d Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/misc/mkdir.cmake.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/misc/po2localization.pl.i b/mk/linux/mojosetup/.hg/store/data/misc/po2localization.pl.i new file mode 100644 index 00000000..346972c5 Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/misc/po2localization.pl.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/misc/poize.lua.i b/mk/linux/mojosetup/.hg/store/data/misc/poize.lua.i new file mode 100644 index 00000000..4f0158c7 Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/misc/poize.lua.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/misc/rm__recurse.cmake.i b/mk/linux/mojosetup/.hg/store/data/misc/rm__recurse.cmake.i new file mode 100644 index 00000000..22b9d58f Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/misc/rm__recurse.cmake.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/misc/shrinksh.pl.i b/mk/linux/mojosetup/.hg/store/data/misc/shrinksh.pl.i new file mode 100644 index 00000000..3e90424d Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/misc/shrinksh.pl.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/mojosetup.c.i b/mk/linux/mojosetup/.hg/store/data/mojosetup.c.i new file mode 100644 index 00000000..ce5fb3da Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/mojosetup.c.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/platform.h.i b/mk/linux/mojosetup/.hg/store/data/platform.h.i new file mode 100644 index 00000000..472f9cff Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/platform.h.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/platform/beos.c.i b/mk/linux/mojosetup/.hg/store/data/platform/beos.c.i new file mode 100644 index 00000000..5c14fbc3 Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/platform/beos.c.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/platform/beos.cpp.i b/mk/linux/mojosetup/.hg/store/data/platform/beos.cpp.i new file mode 100644 index 00000000..b7d2f285 Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/platform/beos.cpp.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/platform/unix.c.i b/mk/linux/mojosetup/.hg/store/data/platform/unix.c.i new file mode 100644 index 00000000..e02a6f33 Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/platform/unix.c.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/platform__beos.c.i b/mk/linux/mojosetup/.hg/store/data/platform__beos.c.i new file mode 100644 index 00000000..8514bca1 Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/platform__beos.c.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/platform__beos.cpp.i b/mk/linux/mojosetup/.hg/store/data/platform__beos.cpp.i new file mode 100644 index 00000000..667f151e Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/platform__beos.cpp.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/platform__unix.c.i b/mk/linux/mojosetup/.hg/store/data/platform__unix.c.i new file mode 100644 index 00000000..a5686f03 Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/platform__unix.c.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/platform__windows.c.i b/mk/linux/mojosetup/.hg/store/data/platform__windows.c.i new file mode 100644 index 00000000..f4e52cea Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/platform__windows.c.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/schema.lua.i b/mk/linux/mojosetup/.hg/store/data/schema.lua.i new file mode 100644 index 00000000..0eb899ec Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/schema.lua.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/scripts/app__localization.lua.i b/mk/linux/mojosetup/.hg/store/data/scripts/app__localization.lua.i new file mode 100644 index 00000000..3b944e01 Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/scripts/app__localization.lua.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/scripts/config.lua.i b/mk/linux/mojosetup/.hg/store/data/scripts/config.lua.i new file mode 100644 index 00000000..0b45c265 Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/scripts/config.lua.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/scripts/localization.lua.i b/mk/linux/mojosetup/.hg/store/data/scripts/localization.lua.i new file mode 100644 index 00000000..eb888406 Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/scripts/localization.lua.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/scripts/loki__setup__compat.lua.i b/mk/linux/mojosetup/.hg/store/data/scripts/loki__setup__compat.lua.i new file mode 100644 index 00000000..c63cad46 Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/scripts/loki__setup__compat.lua.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/scripts/mojosetup__init.lua.i b/mk/linux/mojosetup/.hg/store/data/scripts/mojosetup__init.lua.i new file mode 100644 index 00000000..1ec7ef05 Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/scripts/mojosetup__init.lua.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/scripts/mojosetup__mainline.lua.i b/mk/linux/mojosetup/.hg/store/data/scripts/mojosetup__mainline.lua.i new file mode 100644 index 00000000..502b64f6 Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/scripts/mojosetup__mainline.lua.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/setup.lua.i b/mk/linux/mojosetup/.hg/store/data/setup.lua.i new file mode 100644 index 00000000..06d54e0e Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/setup.lua.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/stb__image.c.i b/mk/linux/mojosetup/.hg/store/data/stb__image.c.i new file mode 100644 index 00000000..45b9da9a Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/stb__image.c.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/translations.lua.i b/mk/linux/mojosetup/.hg/store/data/translations.lua.i new file mode 100644 index 00000000..5706f090 Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/translations.lua.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/universal.h.i b/mk/linux/mojosetup/.hg/store/data/universal.h.i new file mode 100644 index 00000000..91bd9551 Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/universal.h.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/zlib-1.2.3/adler32.c.i b/mk/linux/mojosetup/.hg/store/data/zlib-1.2.3/adler32.c.i new file mode 100644 index 00000000..2754a2d0 Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/zlib-1.2.3/adler32.c.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/zlib-1.2.3/compress.c.i b/mk/linux/mojosetup/.hg/store/data/zlib-1.2.3/compress.c.i new file mode 100644 index 00000000..4b3e65c8 Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/zlib-1.2.3/compress.c.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/zlib-1.2.3/crc32.c.i b/mk/linux/mojosetup/.hg/store/data/zlib-1.2.3/crc32.c.i new file mode 100644 index 00000000..59b599ca Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/zlib-1.2.3/crc32.c.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/zlib-1.2.3/crc32.h.i b/mk/linux/mojosetup/.hg/store/data/zlib-1.2.3/crc32.h.i new file mode 100644 index 00000000..0011a6a9 Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/zlib-1.2.3/crc32.h.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/zlib-1.2.3/deflate.c.i b/mk/linux/mojosetup/.hg/store/data/zlib-1.2.3/deflate.c.i new file mode 100644 index 00000000..7dcc5f0d Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/zlib-1.2.3/deflate.c.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/zlib-1.2.3/deflate.h.i b/mk/linux/mojosetup/.hg/store/data/zlib-1.2.3/deflate.h.i new file mode 100644 index 00000000..adc428a5 Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/zlib-1.2.3/deflate.h.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/zlib-1.2.3/gzio.c.i b/mk/linux/mojosetup/.hg/store/data/zlib-1.2.3/gzio.c.i new file mode 100644 index 00000000..f380cf49 Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/zlib-1.2.3/gzio.c.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/zlib-1.2.3/infback.c.i b/mk/linux/mojosetup/.hg/store/data/zlib-1.2.3/infback.c.i new file mode 100644 index 00000000..04efc89e Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/zlib-1.2.3/infback.c.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/zlib-1.2.3/inffast.c.i b/mk/linux/mojosetup/.hg/store/data/zlib-1.2.3/inffast.c.i new file mode 100644 index 00000000..3b5066de Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/zlib-1.2.3/inffast.c.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/zlib-1.2.3/inffast.h.i b/mk/linux/mojosetup/.hg/store/data/zlib-1.2.3/inffast.h.i new file mode 100644 index 00000000..1cc6e1ca Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/zlib-1.2.3/inffast.h.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/zlib-1.2.3/inffixed.h.i b/mk/linux/mojosetup/.hg/store/data/zlib-1.2.3/inffixed.h.i new file mode 100644 index 00000000..65e8f4f4 Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/zlib-1.2.3/inffixed.h.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/zlib-1.2.3/inflate.c.i b/mk/linux/mojosetup/.hg/store/data/zlib-1.2.3/inflate.c.i new file mode 100644 index 00000000..0569f71b Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/zlib-1.2.3/inflate.c.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/zlib-1.2.3/inflate.h.i b/mk/linux/mojosetup/.hg/store/data/zlib-1.2.3/inflate.h.i new file mode 100644 index 00000000..eb4bb8c5 Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/zlib-1.2.3/inflate.h.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/zlib-1.2.3/inftrees.c.i b/mk/linux/mojosetup/.hg/store/data/zlib-1.2.3/inftrees.c.i new file mode 100644 index 00000000..d8c1d76f Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/zlib-1.2.3/inftrees.c.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/zlib-1.2.3/inftrees.h.i b/mk/linux/mojosetup/.hg/store/data/zlib-1.2.3/inftrees.h.i new file mode 100644 index 00000000..ba8fdb39 Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/zlib-1.2.3/inftrees.h.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/zlib-1.2.3/trees.c.i b/mk/linux/mojosetup/.hg/store/data/zlib-1.2.3/trees.c.i new file mode 100644 index 00000000..d7ab3f8c Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/zlib-1.2.3/trees.c.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/zlib-1.2.3/trees.h.i b/mk/linux/mojosetup/.hg/store/data/zlib-1.2.3/trees.h.i new file mode 100644 index 00000000..56156780 Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/zlib-1.2.3/trees.h.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/zlib-1.2.3/uncompr.c.i b/mk/linux/mojosetup/.hg/store/data/zlib-1.2.3/uncompr.c.i new file mode 100644 index 00000000..5a36e9a3 Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/zlib-1.2.3/uncompr.c.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/zlib-1.2.3/zconf.h.i b/mk/linux/mojosetup/.hg/store/data/zlib-1.2.3/zconf.h.i new file mode 100644 index 00000000..8b80de13 Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/zlib-1.2.3/zconf.h.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/zlib-1.2.3/zlib.h.i b/mk/linux/mojosetup/.hg/store/data/zlib-1.2.3/zlib.h.i new file mode 100644 index 00000000..08ac4584 Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/zlib-1.2.3/zlib.h.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/zlib-1.2.3/zutil.c.i b/mk/linux/mojosetup/.hg/store/data/zlib-1.2.3/zutil.c.i new file mode 100644 index 00000000..4432f04a Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/zlib-1.2.3/zutil.c.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/zlib-1.2.3/zutil.h.i b/mk/linux/mojosetup/.hg/store/data/zlib-1.2.3/zutil.h.i new file mode 100644 index 00000000..fb2b58f8 Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/zlib-1.2.3/zutil.h.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/zlib/adler32.c.i b/mk/linux/mojosetup/.hg/store/data/zlib/adler32.c.i new file mode 100644 index 00000000..d6e1e69f Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/zlib/adler32.c.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/zlib/compress.c.i b/mk/linux/mojosetup/.hg/store/data/zlib/compress.c.i new file mode 100644 index 00000000..c67762c4 Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/zlib/compress.c.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/zlib/crc32.c.i b/mk/linux/mojosetup/.hg/store/data/zlib/crc32.c.i new file mode 100644 index 00000000..0d60a1c0 Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/zlib/crc32.c.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/zlib/crc32.h.i b/mk/linux/mojosetup/.hg/store/data/zlib/crc32.h.i new file mode 100644 index 00000000..a7ec8f16 Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/zlib/crc32.h.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/zlib/deflate.c.i b/mk/linux/mojosetup/.hg/store/data/zlib/deflate.c.i new file mode 100644 index 00000000..0dd1be16 Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/zlib/deflate.c.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/zlib/deflate.h.i b/mk/linux/mojosetup/.hg/store/data/zlib/deflate.h.i new file mode 100644 index 00000000..58cf36b9 Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/zlib/deflate.h.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/zlib/infback.c.i b/mk/linux/mojosetup/.hg/store/data/zlib/infback.c.i new file mode 100644 index 00000000..c36354cd Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/zlib/infback.c.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/zlib/inffast.c.i b/mk/linux/mojosetup/.hg/store/data/zlib/inffast.c.i new file mode 100644 index 00000000..ce0dc62f Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/zlib/inffast.c.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/zlib/inffast.h.i b/mk/linux/mojosetup/.hg/store/data/zlib/inffast.h.i new file mode 100644 index 00000000..980f90ac Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/zlib/inffast.h.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/zlib/inffixed.h.i b/mk/linux/mojosetup/.hg/store/data/zlib/inffixed.h.i new file mode 100644 index 00000000..07844d02 Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/zlib/inffixed.h.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/zlib/inflate.c.i b/mk/linux/mojosetup/.hg/store/data/zlib/inflate.c.i new file mode 100644 index 00000000..c0b1198f Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/zlib/inflate.c.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/zlib/inflate.h.i b/mk/linux/mojosetup/.hg/store/data/zlib/inflate.h.i new file mode 100644 index 00000000..2e61233d Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/zlib/inflate.h.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/zlib/inftrees.c.i b/mk/linux/mojosetup/.hg/store/data/zlib/inftrees.c.i new file mode 100644 index 00000000..5e27d252 Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/zlib/inftrees.c.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/zlib/inftrees.h.i b/mk/linux/mojosetup/.hg/store/data/zlib/inftrees.h.i new file mode 100644 index 00000000..5ab5572b Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/zlib/inftrees.h.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/zlib/trees.c.i b/mk/linux/mojosetup/.hg/store/data/zlib/trees.c.i new file mode 100644 index 00000000..fd049287 Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/zlib/trees.c.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/zlib/trees.h.i b/mk/linux/mojosetup/.hg/store/data/zlib/trees.h.i new file mode 100644 index 00000000..762125f4 Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/zlib/trees.h.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/zlib/uncompr.c.i b/mk/linux/mojosetup/.hg/store/data/zlib/uncompr.c.i new file mode 100644 index 00000000..e54ef70a Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/zlib/uncompr.c.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/zlib/version.txt.i b/mk/linux/mojosetup/.hg/store/data/zlib/version.txt.i new file mode 100644 index 00000000..51570b9e Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/zlib/version.txt.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/zlib/zconf.h.i b/mk/linux/mojosetup/.hg/store/data/zlib/zconf.h.i new file mode 100644 index 00000000..b4c76a91 Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/zlib/zconf.h.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/zlib/zlib.h.i b/mk/linux/mojosetup/.hg/store/data/zlib/zlib.h.i new file mode 100644 index 00000000..ac0146d7 Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/zlib/zlib.h.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/zlib/zutil.c.i b/mk/linux/mojosetup/.hg/store/data/zlib/zutil.c.i new file mode 100644 index 00000000..4c83dd7b Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/zlib/zutil.c.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/zlib/zutil.h.i b/mk/linux/mojosetup/.hg/store/data/zlib/zutil.h.i new file mode 100644 index 00000000..8be5f8ee Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/zlib/zutil.h.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/zlib123/adler32.c.i b/mk/linux/mojosetup/.hg/store/data/zlib123/adler32.c.i new file mode 100644 index 00000000..82d906e7 Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/zlib123/adler32.c.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/zlib123/compress.c.i b/mk/linux/mojosetup/.hg/store/data/zlib123/compress.c.i new file mode 100644 index 00000000..de9ef94a Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/zlib123/compress.c.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/zlib123/crc32.c.i b/mk/linux/mojosetup/.hg/store/data/zlib123/crc32.c.i new file mode 100644 index 00000000..97e661f5 Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/zlib123/crc32.c.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/zlib123/crc32.h.i b/mk/linux/mojosetup/.hg/store/data/zlib123/crc32.h.i new file mode 100644 index 00000000..2f7e368e Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/zlib123/crc32.h.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/zlib123/deflate.c.i b/mk/linux/mojosetup/.hg/store/data/zlib123/deflate.c.i new file mode 100644 index 00000000..7f200369 Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/zlib123/deflate.c.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/zlib123/deflate.h.i b/mk/linux/mojosetup/.hg/store/data/zlib123/deflate.h.i new file mode 100644 index 00000000..a9de1ead Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/zlib123/deflate.h.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/zlib123/gzio.c.i b/mk/linux/mojosetup/.hg/store/data/zlib123/gzio.c.i new file mode 100644 index 00000000..0d171adb Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/zlib123/gzio.c.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/zlib123/infback.c.i b/mk/linux/mojosetup/.hg/store/data/zlib123/infback.c.i new file mode 100644 index 00000000..d10c20ba Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/zlib123/infback.c.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/zlib123/inffast.c.i b/mk/linux/mojosetup/.hg/store/data/zlib123/inffast.c.i new file mode 100644 index 00000000..bffee970 Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/zlib123/inffast.c.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/zlib123/inffast.h.i b/mk/linux/mojosetup/.hg/store/data/zlib123/inffast.h.i new file mode 100644 index 00000000..461bbc72 Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/zlib123/inffast.h.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/zlib123/inffixed.h.i b/mk/linux/mojosetup/.hg/store/data/zlib123/inffixed.h.i new file mode 100644 index 00000000..1ab06c10 Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/zlib123/inffixed.h.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/zlib123/inflate.c.i b/mk/linux/mojosetup/.hg/store/data/zlib123/inflate.c.i new file mode 100644 index 00000000..d4dfad11 Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/zlib123/inflate.c.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/zlib123/inflate.h.i b/mk/linux/mojosetup/.hg/store/data/zlib123/inflate.h.i new file mode 100644 index 00000000..e7bd919f Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/zlib123/inflate.h.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/zlib123/inftrees.c.i b/mk/linux/mojosetup/.hg/store/data/zlib123/inftrees.c.i new file mode 100644 index 00000000..0b3faa9c Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/zlib123/inftrees.c.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/zlib123/inftrees.h.i b/mk/linux/mojosetup/.hg/store/data/zlib123/inftrees.h.i new file mode 100644 index 00000000..7abfc5b1 Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/zlib123/inftrees.h.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/zlib123/trees.c.i b/mk/linux/mojosetup/.hg/store/data/zlib123/trees.c.i new file mode 100644 index 00000000..52937a96 Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/zlib123/trees.c.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/zlib123/trees.h.i b/mk/linux/mojosetup/.hg/store/data/zlib123/trees.h.i new file mode 100644 index 00000000..6e3a362a Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/zlib123/trees.h.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/zlib123/uncompr.c.i b/mk/linux/mojosetup/.hg/store/data/zlib123/uncompr.c.i new file mode 100644 index 00000000..5d77a79a Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/zlib123/uncompr.c.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/zlib123/zconf.h.i b/mk/linux/mojosetup/.hg/store/data/zlib123/zconf.h.i new file mode 100644 index 00000000..4ee6d020 Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/zlib123/zconf.h.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/zlib123/zlib.h.i b/mk/linux/mojosetup/.hg/store/data/zlib123/zlib.h.i new file mode 100644 index 00000000..12888e3a Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/zlib123/zlib.h.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/zlib123/zutil.c.i b/mk/linux/mojosetup/.hg/store/data/zlib123/zutil.c.i new file mode 100644 index 00000000..921aeb61 Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/zlib123/zutil.c.i differ diff --git a/mk/linux/mojosetup/.hg/store/data/zlib123/zutil.h.i b/mk/linux/mojosetup/.hg/store/data/zlib123/zutil.h.i new file mode 100644 index 00000000..391c2f27 Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/data/zlib123/zutil.h.i differ diff --git a/mk/linux/mojosetup/.hg/store/fncache b/mk/linux/mojosetup/.hg/store/fncache new file mode 100644 index 00000000..929447c8 --- /dev/null +++ b/mk/linux/mojosetup/.hg/store/fncache @@ -0,0 +1,582 @@ +data/.hgignore.i +data/.hgtags.i +data/BUILD_REVISION.txt.i +data/CMakeLists.txt.i +data/LICENSE.i +data/LICENSE.txt.i +data/archive_pck.c.i +data/archive_tar.c.i +data/archive_uz2.c.i +data/archive_zip.c.i +data/buildver.c.i +data/bzip2-1.0.4/CHANGES.i +data/bzip2-1.0.4/LICENSE.i +data/bzip2-1.0.4/Makefile.i +data/bzip2-1.0.4/Makefile-libbz2_so.i +data/bzip2-1.0.4/README.i +data/bzip2-1.0.4/README.COMPILATION.PROBLEMS.i +data/bzip2-1.0.4/README.XML.STUFF.i +data/bzip2-1.0.4/blocksort.c.i +data/bzip2-1.0.4/bz-common.xsl.i +data/bzip2-1.0.4/bz-fo.xsl.i +data/bzip2-1.0.4/bz-html.xsl.i +data/bzip2-1.0.4/bzdiff.i +data/bzip2-1.0.4/bzdiff.1.i +data/bzip2-1.0.4/bzgrep.i +data/bzip2-1.0.4/bzgrep.1.i +data/bzip2-1.0.4/bzip.css.i +data/bzip2-1.0.4/bzip2.1.i +data/bzip2-1.0.4/bzip2.1.preformatted.i +data/bzip2-1.0.4/bzip2.c.i +data/bzip2-1.0.4/bzip2.txt.i +data/bzip2-1.0.4/bzip2recover.c.i +data/bzip2-1.0.4/bzlib.c.i +data/bzip2-1.0.4/bzlib.h.i +data/bzip2-1.0.4/bzlib_private.h.i +data/bzip2-1.0.4/bzmore.i +data/bzip2-1.0.4/bzmore.1.i +data/bzip2-1.0.4/compress.c.i +data/bzip2-1.0.4/crctable.c.i +data/bzip2-1.0.4/decompress.c.i +data/bzip2-1.0.4/dlltest.c.i +data/bzip2-1.0.4/dlltest.dsp.i +data/bzip2-1.0.4/entities.xml.i +data/bzip2-1.0.4/format.pl.i +data/bzip2-1.0.4/huffman.c.i +data/bzip2-1.0.4/libbz2.def.i +data/bzip2-1.0.4/libbz2.dsp.i +data/bzip2-1.0.4/makefile.msc.i +data/bzip2-1.0.4/manual.html.i +data/bzip2-1.0.4/manual.pdf.i +data/bzip2-1.0.4/manual.pdf.d +data/bzip2-1.0.4/manual.pdf.i +data/bzip2-1.0.4/manual.pdf.d +data/bzip2-1.0.4/manual.pdf.i +data/bzip2-1.0.4/manual.ps.i +data/bzip2-1.0.4/manual.ps.d +data/bzip2-1.0.4/manual.ps.i +data/bzip2-1.0.4/manual.ps.d +data/bzip2-1.0.4/manual.ps.i +data/bzip2-1.0.4/manual.xml.i +data/bzip2-1.0.4/mk251.c.i +data/bzip2-1.0.4/randtable.c.i +data/bzip2-1.0.4/sample1.bz2.i +data/bzip2-1.0.4/sample1.ref.i +data/bzip2-1.0.4/sample2.bz2.i +data/bzip2-1.0.4/sample2.ref.i +data/bzip2-1.0.4/sample3.bz2.i +data/bzip2-1.0.4/sample3.ref.i +data/bzip2-1.0.4/spewG.c.i +data/bzip2-1.0.4/unzcrash.c.i +data/bzip2-1.0.4/words0.i +data/bzip2-1.0.4/words1.i +data/bzip2-1.0.4/words2.i +data/bzip2-1.0.4/words3.i +data/bzip2-1.0.4/xmlproc.sh.i +data/bzip2/blocksort.c.i +data/bzip2/bzlib.c.i +data/bzip2/bzlib.h.i +data/bzip2/bzlib_private.h.i +data/bzip2/compress.c.i +data/bzip2/crctable.c.i +data/bzip2/decompress.c.i +data/bzip2/huffman.c.i +data/bzip2/randtable.c.i +data/bzip2/version.txt.i +data/checksum_crc32.c.i +data/checksum_md5.c.i +data/checksum_sha1.c.i +data/docs.txt.i +data/examples/aquaria/make.sh.i +data/examples/aquaria/meta/splash.bmp.i +data/examples/aquaria/scripts/app_localization.lua.i +data/examples/aquaria/scripts/config.lua.i +data/examples/duke3d/data/duke3d.png.i +data/examples/duke3d/data/duke3d_readme.txt.i +data/examples/duke3d/data/gpl.txt.i +data/examples/duke3d/data/mojosetup_readme.txt.i +data/examples/duke3d/make.sh.i +data/examples/duke3d/meta/splash.bmp.i +data/examples/duke3d/scripts/app_localization.lua.i +data/examples/duke3d/scripts/config.lua.i +data/examples/lugaru/make.sh.i +data/examples/lugaru/meta/splash.bmp.i +data/examples/lugaru/scripts/app_localization.lua.i +data/examples/lugaru/scripts/config.lua.i +data/examples/postal1/make.sh.i +data/examples/postal1/meta/splash.bmp.i +data/examples/postal1/scripts/app_localization.lua.i +data/examples/postal1/scripts/config.lua.i +data/examples/postal2/make.sh.i +data/examples/postal2/meta/splash.bmp.i +data/examples/postal2/scripts/app_localization.lua.i +data/examples/postal2/scripts/config.lua.i +data/examples/postal2aw/make.sh.i +data/examples/postal2aw/meta/splash.bmp.i +data/examples/postal2aw/scripts/app_localization.lua.i +data/examples/postal2aw/scripts/config.lua.i +data/examples/prey-demo/make.sh.i +data/examples/prey-demo/meta/splash.bmp.i +data/examples/prey-demo/scripts/app_localization.lua.i +data/examples/prey-demo/scripts/config.lua.i +data/examples/prey/make.sh.i +data/examples/prey/meta/splash.bmp.i +data/examples/prey/scripts/app_localization.lua.i +data/examples/prey/scripts/config.lua.i +data/examples/ut3-dedicated-patches/data/README-ut3-patch2.txt.i +data/examples/ut3-dedicated-patches/data/UT3-linux-server-EULA.txt.i +data/examples/ut3-dedicated-patches/make.sh.i +data/examples/ut3-dedicated-patches/scripts/config.lua.i +data/examples/ut3-dedicated/make.sh.i +data/examples/ut3-dedicated/scripts/config.lua.i +data/fileio.c.i +data/fileio.h.i +data/gui.c.i +data/gui.h.i +data/gui/gui_macosx.c.i +data/gui/gui_stdio.c.i +data/gui_cocoa.m.i +data/gui_gtkplus2.c.i +data/gui_macosx.c.i +data/gui_ncurses.c.i +data/gui_stdio.c.i +data/gui_www.c.i +data/libfetch/README.txt.i +data/libfetch/common.c.i +data/libfetch/common.h.i +data/libfetch/fetch.c.i +data/libfetch/fetch.h.i +data/libfetch/file.c.i +data/libfetch/ftp.c.i +data/libfetch/ftp.errors.i +data/libfetch/ftperr.h.i +data/libfetch/http.c.i +data/libfetch/http.errors.i +data/libfetch/httperr.h.i +data/libfetch/mojosetup_libfetch.h.i +data/libfetch/regen_error_headers.sh.i +data/lua-5.1.1/COPYRIGHT.i +data/lua-5.1.1/HISTORY.i +data/lua-5.1.1/INSTALL.i +data/lua-5.1.1/Makefile.i +data/lua-5.1.1/README.i +data/lua-5.1.1/doc/amazon.gif.i +data/lua-5.1.1/doc/contents.html.i +data/lua-5.1.1/doc/cover.png.i +data/lua-5.1.1/doc/logo.gif.i +data/lua-5.1.1/doc/lua.1.i +data/lua-5.1.1/doc/lua.css.i +data/lua-5.1.1/doc/lua.html.i +data/lua-5.1.1/doc/luac.1.i +data/lua-5.1.1/doc/luac.html.i +data/lua-5.1.1/doc/manual.css.i +data/lua-5.1.1/doc/manual.html.i +data/lua-5.1.1/doc/readme.html.i +data/lua-5.1.1/etc/Makefile.i +data/lua-5.1.1/etc/README.i +data/lua-5.1.1/etc/all.c.i +data/lua-5.1.1/etc/lua.hpp.i +data/lua-5.1.1/etc/lua.ico.i +data/lua-5.1.1/etc/lua.pc.i +data/lua-5.1.1/etc/luavs.bat.i +data/lua-5.1.1/etc/min.c.i +data/lua-5.1.1/etc/noparser.c.i +data/lua-5.1.1/etc/strict.lua.i +data/lua-5.1.1/src/Makefile.i +data/lua-5.1.1/src/lapi.c.i +data/lua-5.1.1/src/lapi.h.i +data/lua-5.1.1/src/lauxlib.c.i +data/lua-5.1.1/src/lauxlib.h.i +data/lua-5.1.1/src/lbaselib.c.i +data/lua-5.1.1/src/lcode.c.i +data/lua-5.1.1/src/lcode.h.i +data/lua-5.1.1/src/ldblib.c.i +data/lua-5.1.1/src/ldebug.c.i +data/lua-5.1.1/src/ldebug.h.i +data/lua-5.1.1/src/ldo.c.i +data/lua-5.1.1/src/ldo.h.i +data/lua-5.1.1/src/ldump.c.i +data/lua-5.1.1/src/lfunc.c.i +data/lua-5.1.1/src/lfunc.h.i +data/lua-5.1.1/src/lgc.c.i +data/lua-5.1.1/src/lgc.h.i +data/lua-5.1.1/src/linit.c.i +data/lua-5.1.1/src/liolib.c.i +data/lua-5.1.1/src/llex.c.i +data/lua-5.1.1/src/llex.h.i +data/lua-5.1.1/src/llimits.h.i +data/lua-5.1.1/src/lmathlib.c.i +data/lua-5.1.1/src/lmem.c.i +data/lua-5.1.1/src/lmem.h.i +data/lua-5.1.1/src/loadlib.c.i +data/lua-5.1.1/src/lobject.c.i +data/lua-5.1.1/src/lobject.h.i +data/lua-5.1.1/src/lopcodes.c.i +data/lua-5.1.1/src/lopcodes.h.i +data/lua-5.1.1/src/loslib.c.i +data/lua-5.1.1/src/lparser.c.i +data/lua-5.1.1/src/lparser.h.i +data/lua-5.1.1/src/lstate.c.i +data/lua-5.1.1/src/lstate.h.i +data/lua-5.1.1/src/lstring.c.i +data/lua-5.1.1/src/lstring.h.i +data/lua-5.1.1/src/lstrlib.c.i +data/lua-5.1.1/src/ltable.c.i +data/lua-5.1.1/src/ltable.h.i +data/lua-5.1.1/src/ltablib.c.i +data/lua-5.1.1/src/ltm.c.i +data/lua-5.1.1/src/ltm.h.i +data/lua-5.1.1/src/lua.c.i +data/lua-5.1.1/src/lua.h.i +data/lua-5.1.1/src/luac.c.i +data/lua-5.1.1/src/luaconf.h.i +data/lua-5.1.1/src/lualib.h.i +data/lua-5.1.1/src/lundump.c.i +data/lua-5.1.1/src/lundump.h.i +data/lua-5.1.1/src/lvm.c.i +data/lua-5.1.1/src/lvm.h.i +data/lua-5.1.1/src/lzio.c.i +data/lua-5.1.1/src/lzio.h.i +data/lua-5.1.1/src/print.c.i +data/lua-5.1.1/test/README.i +data/lua-5.1.1/test/bisect.lua.i +data/lua-5.1.1/test/cf.lua.i +data/lua-5.1.1/test/echo.lua.i +data/lua-5.1.1/test/env.lua.i +data/lua-5.1.1/test/factorial.lua.i +data/lua-5.1.1/test/fib.lua.i +data/lua-5.1.1/test/fibfor.lua.i +data/lua-5.1.1/test/globals.lua.i +data/lua-5.1.1/test/hello.lua.i +data/lua-5.1.1/test/life.lua.i +data/lua-5.1.1/test/luac.lua.i +data/lua-5.1.1/test/printf.lua.i +data/lua-5.1.1/test/readonly.lua.i +data/lua-5.1.1/test/sieve.lua.i +data/lua-5.1.1/test/sort.lua.i +data/lua-5.1.1/test/table.lua.i +data/lua-5.1.1/test/trace-calls.lua.i +data/lua-5.1.1/test/trace-globals.lua.i +data/lua-5.1.1/test/xd.lua.i +data/lua-5.1.3/COPYRIGHT.i +data/lua-5.1.3/HISTORY.i +data/lua-5.1.3/INSTALL.i +data/lua-5.1.3/Makefile.i +data/lua-5.1.3/README.i +data/lua-5.1.3/doc/amazon.gif.i +data/lua-5.1.3/doc/contents.html.i +data/lua-5.1.3/doc/cover.png.i +data/lua-5.1.3/doc/logo.gif.i +data/lua-5.1.3/doc/lua.1.i +data/lua-5.1.3/doc/lua.css.i +data/lua-5.1.3/doc/lua.html.i +data/lua-5.1.3/doc/luac.1.i +data/lua-5.1.3/doc/luac.html.i +data/lua-5.1.3/doc/manual.css.i +data/lua-5.1.3/doc/manual.html.i +data/lua-5.1.3/doc/readme.html.i +data/lua-5.1.3/etc/Makefile.i +data/lua-5.1.3/etc/README.i +data/lua-5.1.3/etc/all.c.i +data/lua-5.1.3/etc/lua.hpp.i +data/lua-5.1.3/etc/lua.ico.i +data/lua-5.1.3/etc/lua.pc.i +data/lua-5.1.3/etc/luavs.bat.i +data/lua-5.1.3/etc/min.c.i +data/lua-5.1.3/etc/noparser.c.i +data/lua-5.1.3/etc/strict.lua.i +data/lua-5.1.3/src/Makefile.i +data/lua-5.1.3/src/lapi.c.i +data/lua-5.1.3/src/lapi.h.i +data/lua-5.1.3/src/lauxlib.c.i +data/lua-5.1.3/src/lauxlib.h.i +data/lua-5.1.3/src/lbaselib.c.i +data/lua-5.1.3/src/lcode.c.i +data/lua-5.1.3/src/lcode.h.i +data/lua-5.1.3/src/ldblib.c.i +data/lua-5.1.3/src/ldebug.c.i +data/lua-5.1.3/src/ldebug.h.i +data/lua-5.1.3/src/ldo.c.i +data/lua-5.1.3/src/ldo.h.i +data/lua-5.1.3/src/ldump.c.i +data/lua-5.1.3/src/lfunc.c.i +data/lua-5.1.3/src/lfunc.h.i +data/lua-5.1.3/src/lgc.c.i +data/lua-5.1.3/src/lgc.h.i +data/lua-5.1.3/src/linit.c.i +data/lua-5.1.3/src/liolib.c.i +data/lua-5.1.3/src/llex.c.i +data/lua-5.1.3/src/llex.h.i +data/lua-5.1.3/src/llimits.h.i +data/lua-5.1.3/src/lmathlib.c.i +data/lua-5.1.3/src/lmem.c.i +data/lua-5.1.3/src/lmem.h.i +data/lua-5.1.3/src/loadlib.c.i +data/lua-5.1.3/src/lobject.c.i +data/lua-5.1.3/src/lobject.h.i +data/lua-5.1.3/src/lopcodes.c.i +data/lua-5.1.3/src/lopcodes.h.i +data/lua-5.1.3/src/loslib.c.i +data/lua-5.1.3/src/lparser.c.i +data/lua-5.1.3/src/lparser.h.i +data/lua-5.1.3/src/lstate.c.i +data/lua-5.1.3/src/lstate.h.i +data/lua-5.1.3/src/lstring.c.i +data/lua-5.1.3/src/lstring.h.i +data/lua-5.1.3/src/lstrlib.c.i +data/lua-5.1.3/src/ltable.c.i +data/lua-5.1.3/src/ltable.h.i +data/lua-5.1.3/src/ltablib.c.i +data/lua-5.1.3/src/ltm.c.i +data/lua-5.1.3/src/ltm.h.i +data/lua-5.1.3/src/lua.c.i +data/lua-5.1.3/src/lua.h.i +data/lua-5.1.3/src/luac.c.i +data/lua-5.1.3/src/luaconf.h.i +data/lua-5.1.3/src/lualib.h.i +data/lua-5.1.3/src/lundump.c.i +data/lua-5.1.3/src/lundump.h.i +data/lua-5.1.3/src/lvm.c.i +data/lua-5.1.3/src/lvm.h.i +data/lua-5.1.3/src/lzio.c.i +data/lua-5.1.3/src/lzio.h.i +data/lua-5.1.3/src/print.c.i +data/lua-5.1.3/test/README.i +data/lua-5.1.3/test/bisect.lua.i +data/lua-5.1.3/test/cf.lua.i +data/lua-5.1.3/test/echo.lua.i +data/lua-5.1.3/test/env.lua.i +data/lua-5.1.3/test/factorial.lua.i +data/lua-5.1.3/test/fib.lua.i +data/lua-5.1.3/test/fibfor.lua.i +data/lua-5.1.3/test/globals.lua.i +data/lua-5.1.3/test/hello.lua.i +data/lua-5.1.3/test/life.lua.i +data/lua-5.1.3/test/luac.lua.i +data/lua-5.1.3/test/printf.lua.i +data/lua-5.1.3/test/readonly.lua.i +data/lua-5.1.3/test/sieve.lua.i +data/lua-5.1.3/test/sort.lua.i +data/lua-5.1.3/test/table.lua.i +data/lua-5.1.3/test/trace-calls.lua.i +data/lua-5.1.3/test/trace-globals.lua.i +data/lua-5.1.3/test/xd.lua.i +data/lua/COPYRIGHT.i +data/lua/HISTORY.i +data/lua/INSTALL.i +data/lua/Makefile.i +data/lua/README.i +data/lua/config.lua.i +data/lua/doc/amazon.gif.i +data/lua/doc/contents.html.i +data/lua/doc/cover.png.i +data/lua/doc/logo.gif.i +data/lua/doc/lua.1.i +data/lua/doc/lua.css.i +data/lua/doc/lua.html.i +data/lua/doc/luac.1.i +data/lua/doc/luac.html.i +data/lua/doc/manual.css.i +data/lua/doc/manual.html.i +data/lua/doc/readme.html.i +data/lua/etc/Makefile.i +data/lua/etc/README.i +data/lua/etc/all.c.i +data/lua/etc/lua.hpp.i +data/lua/etc/lua.ico.i +data/lua/etc/lua.pc.i +data/lua/etc/luavs.bat.i +data/lua/etc/min.c.i +data/lua/etc/noparser.c.i +data/lua/etc/strict.lua.i +data/lua/localization.lua.i +data/lua/mojosetup_init.lua.i +data/lua/mojosetup_mainline.lua.i +data/lua/setup.lua.i +data/lua/src/Makefile.i +data/lua/src/lapi.c.i +data/lua/src/lapi.h.i +data/lua/src/lauxlib.c.i +data/lua/src/lauxlib.h.i +data/lua/src/lbaselib.c.i +data/lua/src/lcode.c.i +data/lua/src/lcode.h.i +data/lua/src/ldblib.c.i +data/lua/src/ldebug.c.i +data/lua/src/ldebug.h.i +data/lua/src/ldo.c.i +data/lua/src/ldo.h.i +data/lua/src/ldump.c.i +data/lua/src/lfunc.c.i +data/lua/src/lfunc.h.i +data/lua/src/lgc.c.i +data/lua/src/lgc.h.i +data/lua/src/linit.c.i +data/lua/src/liolib.c.i +data/lua/src/llex.c.i +data/lua/src/llex.h.i +data/lua/src/llimits.h.i +data/lua/src/lmathlib.c.i +data/lua/src/lmem.c.i +data/lua/src/lmem.h.i +data/lua/src/loadlib.c.i +data/lua/src/lobject.c.i +data/lua/src/lobject.h.i +data/lua/src/lopcodes.c.i +data/lua/src/lopcodes.h.i +data/lua/src/loslib.c.i +data/lua/src/lparser.c.i +data/lua/src/lparser.h.i +data/lua/src/lstate.c.i +data/lua/src/lstate.h.i +data/lua/src/lstring.c.i +data/lua/src/lstring.h.i +data/lua/src/lstrlib.c.i +data/lua/src/ltable.c.i +data/lua/src/ltable.h.i +data/lua/src/ltablib.c.i +data/lua/src/ltm.c.i +data/lua/src/ltm.h.i +data/lua/src/lua.c.i +data/lua/src/lua.h.i +data/lua/src/luac.c.i +data/lua/src/luaconf.h.i +data/lua/src/lualib.h.i +data/lua/src/lundump.c.i +data/lua/src/lundump.h.i +data/lua/src/lvm.c.i +data/lua/src/lvm.h.i +data/lua/src/lzio.c.i +data/lua/src/lzio.h.i +data/lua/src/print.c.i +data/lua/test/README.i +data/lua/test/bisect.lua.i +data/lua/test/cf.lua.i +data/lua/test/echo.lua.i +data/lua/test/env.lua.i +data/lua/test/factorial.lua.i +data/lua/test/fib.lua.i +data/lua/test/fibfor.lua.i +data/lua/test/globals.lua.i +data/lua/test/hello.lua.i +data/lua/test/life.lua.i +data/lua/test/luac.lua.i +data/lua/test/printf.lua.i +data/lua/test/readonly.lua.i +data/lua/test/sieve.lua.i +data/lua/test/sort.lua.i +data/lua/test/table.lua.i +data/lua/test/trace-calls.lua.i +data/lua/test/trace-globals.lua.i +data/lua/test/xd.lua.i +data/lua/translations.lua.i +data/lua_glue.c.i +data/lua_glue.h.i +data/makefile.i +data/meta/xdg-utils/xdg-desktop-menu.i +data/meta/xdg-utils/xdg-open.i +data/misc.c.i +data/misc/FindCurses.cmake.i +data/misc/MacAppBundleSkeleton/Contents/Info.plist.i +data/misc/MacAppBundleSkeleton/Contents/PkgInfo.i +data/misc/MacAppBundleSkeleton/Contents/Resources/mojosetup.icns.i +data/misc/MacAppBundleSkeleton/Contents/Resources/mojosetup.icns.d +data/misc/MacAppBundleSkeleton/Contents/Resources/mojosetup.icns.i +data/misc/MacAppBundleSkeleton/Contents/Resources/mojosetup.icns.d +data/misc/MacAppBundleSkeleton/Contents/Resources/mojosetup.icns.i +data/misc/MojoSetup.xib.i +data/misc/cp.cmake.i +data/misc/find_localizable_strings.sh.i +data/misc/launchpad-import.sh.i +data/misc/localization2pot.pl.i +data/misc/mkdir.cmake.i +data/misc/po2localization.pl.i +data/misc/poize.lua.i +data/misc/rm_recurse.cmake.i +data/misc/shrinksh.pl.i +data/mojosetup.c.i +data/platform.h.i +data/platform/beos.c.i +data/platform/beos.cpp.i +data/platform/unix.c.i +data/platform_beos.c.i +data/platform_beos.cpp.i +data/platform_unix.c.i +data/platform_windows.c.i +data/schema.lua.i +data/scripts/app_localization.lua.i +data/scripts/config.lua.i +data/scripts/localization.lua.i +data/scripts/loki_setup_compat.lua.i +data/scripts/mojosetup_init.lua.i +data/scripts/mojosetup_mainline.lua.i +data/setup.lua.i +data/stb_image.c.i +data/translations.lua.i +data/universal.h.i +data/zlib-1.2.3/adler32.c.i +data/zlib-1.2.3/compress.c.i +data/zlib-1.2.3/crc32.c.i +data/zlib-1.2.3/crc32.h.i +data/zlib-1.2.3/deflate.c.i +data/zlib-1.2.3/deflate.h.i +data/zlib-1.2.3/gzio.c.i +data/zlib-1.2.3/infback.c.i +data/zlib-1.2.3/inffast.c.i +data/zlib-1.2.3/inffast.h.i +data/zlib-1.2.3/inffixed.h.i +data/zlib-1.2.3/inflate.c.i +data/zlib-1.2.3/inflate.h.i +data/zlib-1.2.3/inftrees.c.i +data/zlib-1.2.3/inftrees.h.i +data/zlib-1.2.3/trees.c.i +data/zlib-1.2.3/trees.h.i +data/zlib-1.2.3/uncompr.c.i +data/zlib-1.2.3/zconf.h.i +data/zlib-1.2.3/zlib.h.i +data/zlib-1.2.3/zutil.c.i +data/zlib-1.2.3/zutil.h.i +data/zlib/adler32.c.i +data/zlib/compress.c.i +data/zlib/crc32.c.i +data/zlib/crc32.h.i +data/zlib/deflate.c.i +data/zlib/deflate.h.i +data/zlib/infback.c.i +data/zlib/inffast.c.i +data/zlib/inffast.h.i +data/zlib/inffixed.h.i +data/zlib/inflate.c.i +data/zlib/inflate.h.i +data/zlib/inftrees.c.i +data/zlib/inftrees.h.i +data/zlib/trees.c.i +data/zlib/trees.h.i +data/zlib/uncompr.c.i +data/zlib/version.txt.i +data/zlib/zconf.h.i +data/zlib/zlib.h.i +data/zlib/zutil.c.i +data/zlib/zutil.h.i +data/zlib123/adler32.c.i +data/zlib123/compress.c.i +data/zlib123/crc32.c.i +data/zlib123/crc32.h.i +data/zlib123/deflate.c.i +data/zlib123/deflate.h.i +data/zlib123/gzio.c.i +data/zlib123/infback.c.i +data/zlib123/inffast.c.i +data/zlib123/inffast.h.i +data/zlib123/inffixed.h.i +data/zlib123/inflate.c.i +data/zlib123/inflate.h.i +data/zlib123/inftrees.c.i +data/zlib123/inftrees.h.i +data/zlib123/trees.c.i +data/zlib123/trees.h.i +data/zlib123/uncompr.c.i +data/zlib123/zconf.h.i +data/zlib123/zlib.h.i +data/zlib123/zutil.c.i +data/zlib123/zutil.h.i diff --git a/mk/linux/mojosetup/.hg/store/undo b/mk/linux/mojosetup/.hg/store/undo new file mode 100644 index 00000000..68fa443f Binary files /dev/null and b/mk/linux/mojosetup/.hg/store/undo differ diff --git a/mk/linux/mojosetup/.hg/undo.branch b/mk/linux/mojosetup/.hg/undo.branch new file mode 100644 index 00000000..331d858c --- /dev/null +++ b/mk/linux/mojosetup/.hg/undo.branch @@ -0,0 +1 @@ +default \ No newline at end of file diff --git a/mk/linux/mojosetup/.hg/undo.dirstate b/mk/linux/mojosetup/.hg/undo.dirstate new file mode 100644 index 00000000..e69de29b diff --git a/mk/linux/mojosetup/.hgignore b/mk/linux/mojosetup/.hgignore new file mode 100644 index 00000000..7e763411 --- /dev/null +++ b/mk/linux/mojosetup/.hgignore @@ -0,0 +1,3 @@ +syntax:glob +cmake-build + diff --git a/mk/linux/mojosetup/.hgtags b/mk/linux/mojosetup/.hgtags new file mode 100644 index 00000000..10fce451 --- /dev/null +++ b/mk/linux/mojosetup/.hgtags @@ -0,0 +1,19 @@ +68e6c68e6cb50c045ba23496e7819ad49ed64df8 ut3-dedicated-server-installer +582c5bea1bf178b60cdc0bf0e6cf4feee67a9bdd ut3-dedicated-server-installer-1.3-patch +f786a260ac935e2555450cf2865e0640c907c4ab ut3-dedicated-server-installer-1.2-patch +068bc402ef1e4e8d31bd7425e29c9947c2a6bb62 ut3-dedicated-server-installer-1.3-patch +a8411b842201073be6ed73ab5f89905c67919306 prey-demo-installer +b67fa87feb5aeea9e449b16490e8416ec5c37dd7 prey-demo-installer-2 +7255ef72254048a6073ae90cf47d3e49610092ee prey-demo-installer-2 +8e4f3f53c34c5e82bc381384308616fae5eb63f7 prey-installer +3a019c36e58407439917f16f90f4c0a2075f4a7c prey-installer +46f3479c8070896f678e23fc52b61a2233633c3a prey-installer-2 +b7e19cb7b56d1e897a3f08a3210491ec2e7fc1d3 prey-demo-installer-3 +7c5406e784ffa9d7d4e778ef1596ab1d8ca36de4 ut3-dedicated-server-installer-2.1-patch +e1029725218c2dbd2d2b414331ecadae9f922334 postal-installers +2dfd6a1dccf9836cadee39c2a74ba56f4a9a2866 lugaru-installer +d5b64da74949842b4c69f98dbfbf791a522501bb aquaria-beta-installer +86d47398583d2d7e3aa174361c9cfc32d9608c05 aquaria-beta2-installer +922f5797c45070e72a8a34b87e3d25ac5d87071c aquaria-beta3-installer +390eb58cb9ceb35cd86facad0cbd1692a85820fa lugaru-1.0c-installer +92cfa8a3a6be8ae533b17f191e46c9fe47052402 lugaru-1.0c-installer diff --git a/mk/linux/mojosetup/CMakeLists.txt b/mk/linux/mojosetup/CMakeLists.txt new file mode 100644 index 00000000..1b2f0f25 --- /dev/null +++ b/mk/linux/mojosetup/CMakeLists.txt @@ -0,0 +1,749 @@ +# MojoSetup; a portable, flexible installation application. +# +# Please see the file LICENSE.txt in the source's root directory. +# +# This file written by Ryan C. Gordon. + + + +# The "BINARY SIZE +=" comments note about how much bulk, in kilobytes, a +# given option adds to the binary on x86 Linux (built with gcc 3.3.6 +# MinSizeRel options and stripped, uncompressed). These numbers will vary, +# and even on the original test system, become incorrect over time. +# Only choose options you want/need to squeeze every byte off the download. + + +# !!! FIXME: this is stupid. +IF(NOT BEOS) + IF(APPLE) + PROJECT(MojoSetup) + ELSE(APPLE) + PROJECT(MojoSetup C) + ENDIF(APPLE) +ELSE(NOT BEOS) + PROJECT(MojoSetup CXX) +ENDIF(NOT BEOS) + +CMAKE_MINIMUM_REQUIRED(VERSION 2.4.4) + +EXECUTE_PROCESS( + COMMAND hg tip --template hg-{rev}:{node|short} + WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}" + RESULT_VARIABLE HGVERSION_RC + OUTPUT_VARIABLE MOJOSETUP_VERSION + ERROR_QUIET + OUTPUT_STRIP_TRAILING_WHITESPACE +) + +IF(HGVERSION_RC) + SET(MOJOSETUP_VERSION "???") +ENDIF(HGVERSION_RC) + +# !!! FIXME: ditch this when Gary's curses patches go into a formal CMake +# !!! FIXME: release, and just bump the minimum required version to it. +# Search our own cmakemodules first. +SET(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${PROJECT_SOURCE_DIR}/misc") + +# I hate that they define "WIN32" ... we're about to move to Win64...I hope! +IF(WIN32 AND NOT WINDOWS) + SET(WINDOWS TRUE) +ENDIF(WIN32 AND NOT WINDOWS) + +# Bleh, let's do it for "APPLE" too. +IF(APPLE AND NOT MACOSX) + SET(MACOSX TRUE) +ENDIF(APPLE AND NOT MACOSX) + +# And this might be wrong... +IF (CMAKE_SYSTEM MATCHES OS2) + SET(OS2 TRUE) +ENDIF (CMAKE_SYSTEM MATCHES OS2) + +IF(CMAKE_SYSTEM_NAME STREQUAL "SunOS") + SET(SOLARIS TRUE) +ENDIF(CMAKE_SYSTEM_NAME STREQUAL "SunOS") + +INCLUDE(CheckIncludeFile) +INCLUDE(CheckLibraryExists) +INCLUDE(CheckCSourceCompiles) +INCLUDE(CheckCCompilerFlag) +INCLUDE(TestBigEndian) + +# !!! FIXME: correct this to new policy and bump minimum cmake requirement. +IF(COMMAND CMAKE_POLICY) + # Use old policy when it comes to escaping macros, + # Specifically the one in quotes below. + CMAKE_POLICY(SET CMP0005 OLD) +ENDIF(COMMAND CMAKE_POLICY) + +ADD_DEFINITIONS(-D__MOJOSETUP__=1) +ADD_DEFINITIONS(-DAPPID=mojosetup) +ADD_DEFINITIONS(-DAPPREV="${MOJOSETUP_VERSION}") +ADD_DEFINITIONS(-D_REENTRANT) +ADD_DEFINITIONS(-D_THREAD_SAFE) + +INCLUDE_DIRECTORIES(.) +INCLUDE_DIRECTORIES(lua/src) + +IF(WINDOWS) + ADD_DEFINITIONS(-DPLATFORM_WINDOWS=1) + ADD_DEFINITIONS(-D_CRT_SECURE_NO_WARNINGS=1) + SET(USES_WINMAIN WIN32) + SET(OPTIONAL_LIBS ${OPTIONAL_LIBS} shell32) +ENDIF(WINDOWS) + +IF(MACOSX) + ADD_DEFINITIONS(-DPLATFORM_MACOSX=1) + IF(CMAKE_OSX_ARCHITECTURES MATCHES ppc) + ADD_DEFINITIONS(-DMAC_OS_X_VERSION_MIN_REQUIRED=1020) + SET(OPTIONAL_LIBS ${OPTIONAL_LIBS} "-mmacosx-version-min=10.2") + ENDIF(CMAKE_OSX_ARCHITECTURES MATCHES ppc) + SET(OPTIONAL_LIBS ${OPTIONAL_LIBS} "-framework Carbon") +ENDIF(MACOSX) + +IF(BEOS) + ADD_DEFINITIONS(-DPLATFORM_BEOS=1) +ENDIF(BEOS) + +IF(UNIX) + ADD_DEFINITIONS(-DPLATFORM_UNIX=1) + ADD_DEFINITIONS(-DLUA_USE_MKSTEMP=1) # as opposed to tmpnam(), yuck! + # No _setjmp/_longjmp in BeOS 5 (or Haiku, at the moment). + IF(NOT BEOS) + ADD_DEFINITIONS(-DLUA_USE_ULONGJMP=1) + ENDIF(NOT BEOS) +ENDIF(UNIX) + +IF(CMAKE_COMPILER_IS_GNUCC) + ADD_DEFINITIONS(-pipe -Wall -Werror -fsigned-char) + + # See if -fvisibility=hidden is available to us. + CHECK_C_SOURCE_COMPILES(" + #if ((defined(__GNUC__)) && (__GNUC__ >= 4)) + int main(int argc, char **argv) { int is_gcc4 = 1; return 0; } + #else + #error This is not gcc4. + #endif + " MOJOSETUP_IS_GCC4) + + IF(MOJOSETUP_IS_GCC4) + IF(NOT OS2 AND NOT SOLARIS) # Not supported on OS/2 or Solaris. + ADD_DEFINITIONS(-fvisibility=hidden) + ENDIF(NOT OS2 AND NOT SOLARIS) + ENDIF(MOJOSETUP_IS_GCC4) + + # See if -fno-stack-protector is available to us. + # It doesn't seem to work well, and it adds bulk to the binary. + CHECK_C_COMPILER_FLAG("-fno-stack-protector" MOJOSETUP_GCC_HAS_STACKPROT) + IF(MOJOSETUP_GCC_HAS_STACKPROT) + ADD_DEFINITIONS(-fno-stack-protector) + ENDIF(MOJOSETUP_GCC_HAS_STACKPROT) + + # !!! FIXME: probably not safe long-term. + # CMake mailing list had this hack for getting rid of -rdynamic: + # http://public.kitware.com/pipermail/cmake/2006-July/010404.html + IF(CMAKE_SYSTEM_NAME STREQUAL "Linux") + SET(CMAKE_SHARED_LIBRARY_LINK_C_FLAGS) + SET(CMAKE_SHARED_LIBRARY_LINK_CXX_FLAGS) + ENDIF(CMAKE_SYSTEM_NAME STREQUAL "Linux") + + # Don't use -rpath. + SET(CMAKE_SKIP_RPATH ON CACHE BOOL "Skip RPATH" FORCE) +ENDIF(CMAKE_COMPILER_IS_GNUCC) + +IF(CMAKE_C_COMPILER_ID STREQUAL "SunPro") + ADD_DEFINITIONS(-erroff=E_EMPTY_TRANSLATION_UNIT) + ADD_DEFINITIONS(-xldscope=hidden) +ENDIF(CMAKE_C_COMPILER_ID STREQUAL "SunPro") + + + +TEST_BIG_ENDIAN(MOJOSETUP_IS_BIGENDIAN) +IF(MOJOSETUP_IS_BIGENDIAN) + ADD_DEFINITIONS(-DPLATFORM_BIGENDIAN=1) +ELSE(MOJOSETUP_IS_BIGENDIAN) + ADD_DEFINITIONS(-DPLATFORM_LITTLEENDIAN=1) +ENDIF(MOJOSETUP_IS_BIGENDIAN) + +SET(ZLIB_DIR zlib) +SET(ZLIB_SRCS + ${ZLIB_DIR}/adler32.c + ${ZLIB_DIR}/compress.c + ${ZLIB_DIR}/crc32.c + ${ZLIB_DIR}/deflate.c + ${ZLIB_DIR}/infback.c + ${ZLIB_DIR}/inffast.c + ${ZLIB_DIR}/inflate.c + ${ZLIB_DIR}/inftrees.c + ${ZLIB_DIR}/trees.c + ${ZLIB_DIR}/uncompr.c + ${ZLIB_DIR}/zutil.c +) + +SET(BZLIB_DIR bzip2) +SET(BZLIB_SRCS + ${BZLIB_DIR}/blocksort.c + ${BZLIB_DIR}/huffman.c + ${BZLIB_DIR}/crctable.c + ${BZLIB_DIR}/randtable.c + ${BZLIB_DIR}/compress.c + ${BZLIB_DIR}/decompress.c + ${BZLIB_DIR}/bzlib.c +) + +SET(LIBFETCH_DIR libfetch) +SET(LIBFETCH_SRCS + ${LIBFETCH_DIR}/fetch.c + ${LIBFETCH_DIR}/common.c + ${LIBFETCH_DIR}/ftp.c + ${LIBFETCH_DIR}/http.c +) + +SET(LUA_DIR lua) +SET(LUA_SRCS + ${LUA_DIR}/src/lapi.c + ${LUA_DIR}/src/ldebug.c + ${LUA_DIR}/src/ldo.c + ${LUA_DIR}/src/ldump.c + ${LUA_DIR}/src/lfunc.c + ${LUA_DIR}/src/lgc.c + ${LUA_DIR}/src/lmem.c + ${LUA_DIR}/src/lobject.c + ${LUA_DIR}/src/lopcodes.c + ${LUA_DIR}/src/lstate.c + ${LUA_DIR}/src/lstring.c + ${LUA_DIR}/src/ltable.c + ${LUA_DIR}/src/ltm.c + ${LUA_DIR}/src/lundump.c + ${LUA_DIR}/src/lvm.c + ${LUA_DIR}/src/lzio.c + ${LUA_DIR}/src/lauxlib.c + ${LUA_DIR}/src/lbaselib.c + ${LUA_DIR}/src/lstrlib.c + ${LUA_DIR}/src/ltablib.c +) + +SET(LUA_PARSER_SRCS + ${LUA_DIR}/src/lparser.c + ${LUA_DIR}/src/llex.c + ${LUA_DIR}/src/lcode.c +) + +SET(MOJOSETUP_SRCS + buildver.c + mojosetup.c + gui.c + fileio.c + archive_zip.c + archive_tar.c + archive_uz2.c + archive_pck.c + checksum_crc32.c + checksum_md5.c + checksum_sha1.c + platform_unix.c + platform_windows.c + lua_glue.c + ${LUA_SRCS} +) + +# Have to separate this, so CMake doesn't try to link in C++ support on other +# platforms. +IF(BEOS) + SET(MOJOSETUP_SRCS ${MOJOSETUP_SRCS} platform_beos.cpp) +ENDIF(BEOS) + +SET(MOJOLUAC_SRCS + ${LUA_SRCS} + ${LUA_PARSER_SRCS} + ${LUA_DIR}/src/luac.c + ${LUA_DIR}/src/print.c + ${LUA_DIR}/src/linit.c + ${LUA_DIR}/src/ldblib.c + ${LUA_DIR}/src/liolib.c + ${LUA_DIR}/src/lmathlib.c + ${LUA_DIR}/src/loslib.c + ${LUA_DIR}/src/loadlib.c +) + +SET(STBIMAGE_SRCS + stb_image.c +) + +# Disabling the parser cuts the Lua binary bits by about 35%, plus .luac files +# are almost always smaller than the original scripts. The downside is you +# (and end users in the field) can't just tweak a script without recompiling +# it, but even that's not an unclimbable obstacle. +# In reality, you probably want to keep the parser, though, unless you REALLY +# must save every single byte in the download. +# YOU NEED THE PARSER IF YOU WANT MANIFESTS WRITTEN OUT. +# YOU NEED THE PARSER IF YOU WANT THE UNINSTALLER TO WORK. +# DON'T DISABLE THIS NOW IF YOU DON'T ABSOLUTELY HAVE TO. +# BINARY SIZE += 19 +OPTION(MOJOSETUP_LUA_PARSER "Bigger binary but scripts don't need to be compiled." TRUE) +IF(MOJOSETUP_LUA_PARSER) + SET(OPTIONAL_SRCS ${OPTIONAL_SRCS} ${LUA_PARSER_SRCS}) +ELSE(MOJOSETUP_LUA_PARSER) + SET(OPTIONAL_SRCS ${OPTIONAL_SRCS} ${LUA_DIR}/etc/noparser.c) + ADD_DEFINITIONS(-DDISABLE_LUA_PARSER=1) +ENDIF(MOJOSETUP_LUA_PARSER) + + +# Kludge for Linux x86/amd64 bins... +IF(UNIX AND NOT MACOSX) # Just use Mach-O Universal/"fat" binaries on OS X. + OPTION(MOJOSETUP_MULTIARCH "Allow multiarch hack." FALSE) + MARK_AS_ADVANCED(MOJOSETUP_MULTIARCH) + IF(MOJOSETUP_MULTIARCH) + ADD_DEFINITIONS(-DSUPPORT_MULTIARCH=1) + ENDIF(MOJOSETUP_MULTIARCH) +ENDIF(UNIX AND NOT MACOSX) + + +# Optional bits of the Lua runtime library... + +# BINARY SIZE += 4.5 +OPTION(MOJOSETUP_LUALIB_IO "Add Lua 'io' library" TRUE) +MARK_AS_ADVANCED(MOJOSETUP_LUALIB_IO) +IF(MOJOSETUP_LUALIB_IO) + ADD_DEFINITIONS(-DSUPPORT_LUALIB_IO=1) + SET(OPTIONAL_SRCS ${OPTIONAL_SRCS} ${LUA_DIR}/src/liolib.c) +ENDIF(MOJOSETUP_LUALIB_IO) + +# BINARY SIZE += 2.5 +OPTION(MOJOSETUP_LUALIB_OS "Add Lua 'os' library" TRUE) +MARK_AS_ADVANCED(MOJOSETUP_LUALIB_OS) +IF(MOJOSETUP_LUALIB_OS) + ADD_DEFINITIONS(-DSUPPORT_LUALIB_OS=1) + SET(OPTIONAL_SRCS ${OPTIONAL_SRCS} ${LUA_DIR}/src/loslib.c) +ENDIF(MOJOSETUP_LUALIB_OS) + +# BINARY SIZE += 3.5 +OPTION(MOJOSETUP_LUALIB_MATH "Add Lua 'math' library" TRUE) +MARK_AS_ADVANCED(MOJOSETUP_LUALIB_MATH) +IF(MOJOSETUP_LUALIB_MATH) + ADD_DEFINITIONS(-DSUPPORT_LUALIB_MATH=1) + SET(OPTIONAL_SRCS ${OPTIONAL_SRCS} ${LUA_DIR}/src/lmathlib.c) +ENDIF(MOJOSETUP_LUALIB_MATH) + +# BINARY SIZE += 3.5 +OPTION(MOJOSETUP_LUALIB_DB "Add Lua 'db' library" TRUE) +MARK_AS_ADVANCED(MOJOSETUP_LUALIB_DB) +IF(MOJOSETUP_LUALIB_DB) + ADD_DEFINITIONS(-DSUPPORT_LUALIB_DB=1) + SET(OPTIONAL_SRCS ${OPTIONAL_SRCS} ${LUA_DIR}/src/ldblib.c) +ENDIF(MOJOSETUP_LUALIB_DB) + +# BINARY SIZE += 4 +OPTION(MOJOSETUP_LUALIB_PACKAGE "Add Lua 'package' library" TRUE) +MARK_AS_ADVANCED(MOJOSETUP_LUALIB_PACKAGE) +IF(MOJOSETUP_LUALIB_PACKAGE) + ADD_DEFINITIONS(-DSUPPORT_LUALIB_PACKAGE=1) + SET(OPTIONAL_SRCS ${OPTIONAL_SRCS} ${LUA_DIR}/src/loadlib.c) +ENDIF(MOJOSETUP_LUALIB_PACKAGE) + + +# Checksums... + +# BINARY SIZE += !!! FIXME: check this. +OPTION(MOJOSETUP_CHECKSUM_CRC32 "Enable CRC-32 checksum support" TRUE) +IF(MOJOSETUP_CHECKSUM_CRC32) + ADD_DEFINITIONS(-DSUPPORT_CRC32=1) +ENDIF(MOJOSETUP_CHECKSUM_CRC32) + +# BINARY SIZE += !!! FIXME: check this. +OPTION(MOJOSETUP_CHECKSUM_MD5 "Enable MD5 checksum support" TRUE) +IF(MOJOSETUP_CHECKSUM_MD5) + ADD_DEFINITIONS(-DSUPPORT_MD5=1) +ENDIF(MOJOSETUP_CHECKSUM_MD5) + +# BINARY SIZE += !!! FIXME: check this. +OPTION(MOJOSETUP_CHECKSUM_SHA1 "Enable SHA-1 checksum support" TRUE) +IF(MOJOSETUP_CHECKSUM_SHA1) + ADD_DEFINITIONS(-DSUPPORT_SHA1=1) +ENDIF(MOJOSETUP_CHECKSUM_SHA1) + + +# GUI plugins... + +MACRO(MOJOSETUP_ADD_LIBRARY _TARGET _SRCS) + ADD_LIBRARY(${_TARGET} SHARED ${_SRCS}) + SET(MOJOSETUP_TARGETS "${MOJOSETUP_TARGETS};${_TARGET}") +ENDMACRO(MOJOSETUP_ADD_LIBRARY) + + +# BINARY SIZE += 2.5 +OPTION(MOJOSETUP_GUI_STDIO "Enable stdio GUI" TRUE) +IF(MOJOSETUP_GUI_STDIO) + ADD_DEFINITIONS(-DSUPPORT_GUI_STDIO=1) + OPTION(MOJOSETUP_GUI_STDIO_STATIC "Statically link stdio GUI" TRUE) + IF(MOJOSETUP_GUI_STDIO_STATIC) + ADD_DEFINITIONS(-DGUI_STATIC_LINK_STDIO=1) + SET(OPTIONAL_SRCS ${OPTIONAL_SRCS} gui_stdio.c) + ELSE(MOJOSETUP_GUI_STDIO_STATIC) + MOJOSETUP_ADD_LIBRARY(mojosetupgui_stdio gui_stdio.c) + ENDIF(MOJOSETUP_GUI_STDIO_STATIC) +ENDIF(MOJOSETUP_GUI_STDIO) + +# BINARY SIZE += !!! FIXME: check this. +SET(CURSES_NEED_WIDE TRUE) +SET(CURSES_NEED_NCURSES TRUE) +FIND_PACKAGE(Curses) +IF(CURSES_FOUND) + OPTION(MOJOSETUP_GUI_NCURSES "Enable ncurses GUI" TRUE) + IF(MOJOSETUP_GUI_NCURSES) + ADD_DEFINITIONS(-DSUPPORT_GUI_NCURSES=1) + INCLUDE_DIRECTORIES(CURSES_INCLUDE_DIR) + + IF(CURSES_HAVE_NCURSESW_NCURSES_H) + ADD_DEFINITIONS(-DHAVE_NCURSESW_NCURSES_H) + ELSEIF(CURSES_HAVE_NCURSESW_CURSES_H) + ADD_DEFINITIONS(-DHAVE_NCURSESW_CURSES_H) + ELSEIF(CURSES_HAVE_NCURSESW_H) + ADD_DEFINITIONS(-DHAVE_NCURSESW_H) + ENDIF(CURSES_HAVE_NCURSESW_NCURSES_H) + + OPTION(MOJOSETUP_GUI_NCURSES_STATIC "Statically link ncurses GUI" FALSE) + IF(MOJOSETUP_GUI_NCURSES_STATIC) + ADD_DEFINITIONS(-DGUI_STATIC_LINK_NCURSES=1) + SET(OPTIONAL_SRCS ${OPTIONAL_SRCS} gui_ncurses.c) + SET(OPTIONAL_LIBS ${OPTIONAL_LIBS} ${CURSES_LIBRARIES}) + ELSE(MOJOSETUP_GUI_NCURSES_STATIC) + MOJOSETUP_ADD_LIBRARY(mojosetupgui_ncurses gui_ncurses.c) + TARGET_LINK_LIBRARIES(mojosetupgui_ncurses ${CURSES_LIBRARIES}) + ENDIF(MOJOSETUP_GUI_NCURSES_STATIC) + ENDIF(MOJOSETUP_GUI_NCURSES) +ENDIF(CURSES_FOUND) + +IF(MACOSX) + OPTION(MOJOSETUP_GUI_COCOA "Enable Cocoa GUI" TRUE) + IF(MOJOSETUP_GUI_COCOA) + ADD_DEFINITIONS(-DSUPPORT_GUI_COCOA=1) + OPTION(MOJOSETUP_GUI_COCOA_STATIC "Statically link Cocoa GUI" TRUE) + IF(MOJOSETUP_GUI_COCOA_STATIC) + ADD_DEFINITIONS(-DGUI_STATIC_LINK_COCOA=1) + SET(OPTIONAL_SRCS ${OPTIONAL_SRCS} gui_cocoa.m) + SET(OPTIONAL_LIBS ${OPTIONAL_LIBS} "-framework Cocoa") + ELSE(MOJOSETUP_GUI_COCOA_STATIC) + MOJOSETUP_ADD_LIBRARY(mojosetupgui_cocoa gui_cocoa.m) + TARGET_LINK_LIBRARIES(mojosetupgui_cocoa + "-framework Carbon -framework Cocoa -mmacosx-version-min=10.2" + ) + ENDIF(MOJOSETUP_GUI_COCOA_STATIC) + ENDIF(MOJOSETUP_GUI_COCOA) +ENDIF(MACOSX) + +IF(UNIX) +IF(NOT BEOS) +IF(NOT MACOSX) +#FIND_PACKAGE(PkgConfig) +#PKGCONFIG(libgtk-2.0 LIBGTK_INCLUDE_DIR LIBGTK_LINK_DIR LIBGTK_LINK_FLAGS LIBGTK_CFLAGS) +# !!! FIXME +SET(LIBGTK_LINK_FLAGS "-lgtk-x11-2.0") +SET(LIBGTK_CFLAGS "-DPNG_NO_MMX_CODE -I/usr/include/gtk-2.0 -I/usr/lib/gtk-2.0/include -I/usr/include/atk-1.0 -I/usr/include/cairo -I/usr/include/pango-1.0 -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include -I/usr/include/freetype2 -I/usr/include/libpng12") +IF(NOT LIBGTK_LINK_FLAGS) + MESSAGE(STATUS "Can't find GTK+v2 headers/libraries. Can't build GTK+ GUI.") +ELSE(NOT LIBGTK_LINK_FLAGS) + OPTION(MOJOSETUP_GUI_GTKPLUS2 "Enable GTK+ 2.0 GUI" TRUE) + IF(MOJOSETUP_GUI_GTKPLUS2) + ADD_DEFINITIONS(-DSUPPORT_GUI_GTKPLUS2=1) + #INCLUDE_DIRECTORIES(${LIBGTK_INCLUDE_DIR}) + OPTION(MOJOSETUP_GUI_GTKPLUS2_STATIC "Statically link GTK+ GUI" FALSE) + IF(MOJOSETUP_GUI_GTKPLUS2_STATIC) + ADD_DEFINITIONS(-DGUI_STATIC_LINK_GTKPLUS2=1 ${LIBGTK_CFLAGS}) + SET(OPTIONAL_SRCS ${OPTIONAL_SRCS} gui_gtkplus2.c) + SET(OPTIONAL_LIBS ${OPTIONAL_LIBS} ${LIBGTK_LINK_FLAGS}) + ELSE(MOJOSETUP_GUI_GTKPLUS2_STATIC) + MOJOSETUP_ADD_LIBRARY(mojosetupgui_gtkplus2 gui_gtkplus2.c) + ADD_DEFINITIONS(${LIBGTK_CFLAGS}) + TARGET_LINK_LIBRARIES(mojosetupgui_gtkplus2 ${LIBGTK_LINK_FLAGS}) + ENDIF(MOJOSETUP_GUI_GTKPLUS2_STATIC) + ENDIF(MOJOSETUP_GUI_GTKPLUS2) +ENDIF(NOT LIBGTK_LINK_FLAGS) +ENDIF(NOT MACOSX) +ENDIF(NOT BEOS) +ENDIF(UNIX) + +# BINARY SIZE += !!! FIXME: check this. +OPTION(MOJOSETUP_GUI_WWW "Enable www GUI" FALSE) # !!! FIXME: make TRUE +IF(MOJOSETUP_GUI_WWW) + ADD_DEFINITIONS(-DSUPPORT_GUI_WWW=1) + OPTION(MOJOSETUP_GUI_WWW_STATIC "Statically link www GUI" FALSE) + IF(MOJOSETUP_GUI_WWW_STATIC) + ADD_DEFINITIONS(-DGUI_STATIC_LINK_WWW=1) + SET(OPTIONAL_SRCS ${OPTIONAL_SRCS} gui_www.c) + IF(WINDOWS) + SET(OPTIONAL_LIBS ${OPTIONAL_LIBS} wsock32) + ENDIF(WINDOWS) + ELSE(MOJOSETUP_GUI_WWW_STATIC) + MOJOSETUP_ADD_LIBRARY(mojosetupgui_www gui_www.c) + IF(WINDOWS) + TARGET_LINK_LIBRARIES(mojosetupgui_www wsock32) + ENDIF(WINDOWS) + ENDIF(MOJOSETUP_GUI_WWW_STATIC) + SET(MOJOSETUP_USES_SOCKETS TRUE) +ENDIF(MOJOSETUP_GUI_WWW) + + +# Archivers... + +# BINARY SIZE += 8 +OPTION(MOJOSETUP_ARCHIVE_ZIP "Enable ZIP support" TRUE) +IF(MOJOSETUP_ARCHIVE_ZIP) + ADD_DEFINITIONS(-DSUPPORT_ZIP=1) + SET(MOJOSETUP_NEED_ZLIB TRUE) +ENDIF(MOJOSETUP_ARCHIVE_ZIP) + +# BINARY SIZE += 2 +OPTION(MOJOSETUP_ARCHIVE_TAR "Enable TAR support" TRUE) +IF(MOJOSETUP_ARCHIVE_TAR) + ADD_DEFINITIONS(-DSUPPORT_TAR=1) + OPTION(MOJOSETUP_ARCHIVE_TAR_GZ "Enable TAR.GZ support" TRUE) + IF(MOJOSETUP_ARCHIVE_TAR_GZ) + SET(MOJOSETUP_INPUT_GZIP TRUE) + ENDIF(MOJOSETUP_ARCHIVE_TAR_GZ) + + OPTION(MOJOSETUP_ARCHIVE_TAR_BZ2 "Enable TAR.BZ2 support" TRUE) + IF(MOJOSETUP_ARCHIVE_TAR_BZ2) + SET(MOJOSETUP_INPUT_BZIP2 TRUE) + ENDIF(MOJOSETUP_ARCHIVE_TAR_BZ2) +ENDIF(MOJOSETUP_ARCHIVE_TAR) + +OPTION(MOJOSETUP_ARCHIVE_UZ2 "Enable UZ2 support" FALSE) +IF(MOJOSETUP_ARCHIVE_UZ2) + ADD_DEFINITIONS(-DSUPPORT_UZ2=1) + SET(MOJOSETUP_NEED_ZLIB TRUE) +ENDIF(MOJOSETUP_ARCHIVE_UZ2) + +OPTION(MOJOSETUP_ARCHIVE_PCK "Enable PCK support" FALSE) +IF(MOJOSETUP_ARCHIVE_PCK) + ADD_DEFINITIONS(-DSUPPORT_PCK=1) + SET(MOJOSETUP_INPUT_GZIP TRUE) +ENDIF(MOJOSETUP_ARCHIVE_PCK) + +# Input decoders... + +# BINARY SIZE += 1.5 +IF(NOT MOJOSETUP_INPUT_GZIP) # optional if something didn't force it. + OPTION(MOJOSETUP_INPUT_GZIP "Enable GZIP support" FALSE) +ENDIF(NOT MOJOSETUP_INPUT_GZIP) + +IF(MOJOSETUP_INPUT_GZIP) + ADD_DEFINITIONS(-DSUPPORT_GZIP=1) + SET(MOJOSETUP_NEED_ZLIB TRUE) +ENDIF(MOJOSETUP_INPUT_GZIP) + +# BINARY SIZE += 1.5 +IF(NOT MOJOSETUP_INPUT_BZIP2) # optional if something didn't force it. + OPTION(MOJOSETUP_INPUT_BZIP2 "Enable BZIP2 support" FALSE) +ENDIF(NOT MOJOSETUP_INPUT_BZIP2) + +IF(MOJOSETUP_INPUT_BZIP2) + ADD_DEFINITIONS(-DSUPPORT_BZIP2=1) + ADD_DEFINITIONS(-DBZ_NO_STDIO=1) + SET(MOJOSETUP_NEED_BZLIB TRUE) +ENDIF(MOJOSETUP_INPUT_BZIP2) + + + +# Image decoders for GUIs... + +OPTION(MOJOSETUP_IMAGE_JPG "Enable JPG support" TRUE) +IF(MOJOSETUP_IMAGE_JPG) + ADD_DEFINITIONS(-DSUPPORT_JPG=1) + SET(MOJOSETUP_NEED_STBIMAGE TRUE) +ENDIF(MOJOSETUP_IMAGE_JPG) + +OPTION(MOJOSETUP_IMAGE_PNG "Enable PNG support" TRUE) +IF(MOJOSETUP_IMAGE_PNG) + ADD_DEFINITIONS(-DSUPPORT_PNG=1) + SET(MOJOSETUP_NEED_STBIMAGE TRUE) +ENDIF(MOJOSETUP_IMAGE_PNG) + +OPTION(MOJOSETUP_IMAGE_TGA "Enable TGA support" FALSE) +IF(MOJOSETUP_IMAGE_TGA) + ADD_DEFINITIONS(-DSUPPORT_TGA=1) + SET(MOJOSETUP_NEED_STBIMAGE TRUE) +ENDIF(MOJOSETUP_IMAGE_TGA) + +OPTION(MOJOSETUP_IMAGE_BMP "Enable BMP support" FALSE) +IF(MOJOSETUP_IMAGE_BMP) + ADD_DEFINITIONS(-DSUPPORT_BMP=1) + SET(MOJOSETUP_NEED_STBIMAGE TRUE) +ENDIF(MOJOSETUP_IMAGE_BMP) + +OPTION(MOJOSETUP_IMAGE_PSD "Enable PSD support" FALSE) +IF(MOJOSETUP_IMAGE_PSD) + ADD_DEFINITIONS(-DSUPPORT_PSD=1) + SET(MOJOSETUP_NEED_STBIMAGE TRUE) +ENDIF(MOJOSETUP_IMAGE_PSD) + +OPTION(MOJOSETUP_IMAGE_HDR "Enable HDR support" FALSE) +IF(MOJOSETUP_IMAGE_HDR) + ADD_DEFINITIONS(-DSUPPORT_HDR=1) + SET(MOJOSETUP_NEED_STBIMAGE TRUE) +ENDIF(MOJOSETUP_IMAGE_HDR) + +IF(MOJOSETUP_NEED_STBIMAGE) + ADD_DEFINITIONS(-DSUPPORT_STBIMAGE=1) + SET(OPTIONAL_SRCS ${OPTIONAL_SRCS} ${STBIMAGE_SRCS}) +ENDIF(MOJOSETUP_NEED_STBIMAGE) + + +# Networking... + +# BINARY SIZE += 5 ...plus libfetch +OPTION(MOJOSETUP_URL_HTTP "Enable http:// support" TRUE) +IF(MOJOSETUP_URL_HTTP) + ADD_DEFINITIONS(-DSUPPORT_URL_HTTP=1) + SET(MOJOSETUP_NEED_LIBFETCH TRUE) +ENDIF(MOJOSETUP_URL_HTTP) + +# BINARY SIZE += 9 ...plus libfetch +OPTION(MOJOSETUP_URL_FTP "Enable ftp:// support" TRUE) +IF(MOJOSETUP_URL_FTP) + ADD_DEFINITIONS(-DSUPPORT_URL_FTP=1) + SET(MOJOSETUP_NEED_LIBFETCH TRUE) +ENDIF(MOJOSETUP_URL_FTP) + +# BINARY SIZE += 10 +IF(MOJOSETUP_NEED_LIBFETCH) + SET(OPTIONAL_SRCS ${OPTIONAL_SRCS} ${LIBFETCH_SRCS}) + # Had to spin up some threads in libfetch...lame. + # !!! FIXME: CMake will do -lpthread on Mac OS X, but it doesn't need it. + IF(NOT MACOSX) + FIND_PACKAGE(Threads) + ENDIF(NOT MACOSX) + SET(OPTIONAL_LIBS ${OPTIONAL_LIBS} ${CMAKE_THREAD_LIBS_INIT}) + SET(MOJOSETUP_USES_SOCKETS TRUE) +ENDIF(MOJOSETUP_NEED_LIBFETCH) + +IF(MOJOSETUP_USES_SOCKETS) + IF(SOLARIS) + SET(OPTIONAL_LIBS ${OPTIONAL_LIBS} "socket") + ENDIF(SOLARIS) +ENDIF(MOJOSETUP_USES_SOCKETS) + + +# Middleware... + +IF(MOJOSETUP_NEED_ZLIB) + SET(HAVE_SYSTEM_ZLIB FALSE) + CHECK_INCLUDE_FILE(zlib.h HAVE_ZLIB_H) + IF(HAVE_ZLIB_H) + CHECK_LIBRARY_EXISTS("z" "inflate" "" HAVE_LIBZ) + IF(HAVE_LIBZ) + SET(HAVE_SYSTEM_ZLIB TRUE) + ENDIF(HAVE_LIBZ) + ENDIF(HAVE_ZLIB_H) + + IF(HAVE_SYSTEM_ZLIB) + OPTION(MOJOSETUP_INTERNAL_ZLIB "Link own zlib instead of system library" FALSE) + ELSE(HAVE_SYSTEM_ZLIB) + SET(MOJOSETUP_INTERNAL_ZLIB TRUE) + ENDIF(HAVE_SYSTEM_ZLIB) + + # BINARY SIZE += 50 + IF(MOJOSETUP_INTERNAL_ZLIB) + INCLUDE_DIRECTORIES(${ZLIB_DIR}) + ADD_DEFINITIONS(-DZ_PREFIX=1) + SET(OPTIONAL_SRCS ${OPTIONAL_SRCS} ${ZLIB_SRCS}) + ELSE(MOJOSETUP_INTERNAL_ZLIB) + SET(OPTIONAL_LIBS ${OPTIONAL_LIBS} z) + ENDIF(MOJOSETUP_INTERNAL_ZLIB) +ENDIF(MOJOSETUP_NEED_ZLIB) + +IF(MOJOSETUP_NEED_BZLIB) + SET(HAVE_SYSTEM_BZLIB FALSE) + CHECK_INCLUDE_FILE(bzlib.h HAVE_BZLIB_H) + IF(HAVE_BZLIB_H) + CHECK_LIBRARY_EXISTS("bz2" "BZ2_bzDecompress" "" HAVE_LIBBZ2) + IF(HAVE_LIBBZ2) + SET(HAVE_SYSTEM_BZLIB TRUE) + ENDIF(HAVE_LIBBZ2) + ENDIF(HAVE_BZLIB_H) + + IF(HAVE_SYSTEM_BZLIB) + OPTION(MOJOSETUP_INTERNAL_BZLIB "Link own bzlib instead of system library" FALSE) + ELSE(HAVE_SYSTEM_BZLIB) + SET(MOJOSETUP_INTERNAL_BZLIB TRUE) + ENDIF(HAVE_SYSTEM_BZLIB) + + # BINARY SIZE += 46 + IF(MOJOSETUP_INTERNAL_BZLIB) + ADD_DEFINITIONS(-DMOJOSETUP_INTERNAL_BZLIB=1) + INCLUDE_DIRECTORIES(${BZLIB_DIR}) + SET(OPTIONAL_SRCS ${OPTIONAL_SRCS} ${BZLIB_SRCS}) + ELSE(MOJOSETUP_INTERNAL_BZLIB) + SET(OPTIONAL_LIBS ${OPTIONAL_LIBS} bz2) + ENDIF(MOJOSETUP_INTERNAL_BZLIB) +ENDIF(MOJOSETUP_NEED_BZLIB) + +IF(UNIX) + CHECK_INCLUDE_FILE(sys/ucred.h HAVE_UCRED_H) + IF(HAVE_UCRED_H) + ADD_DEFINITIONS(-DMOJOSETUP_HAVE_SYS_UCRED_H=1) + ENDIF(HAVE_UCRED_H) + + CHECK_INCLUDE_FILE(mntent.h HAVE_MNTENT_H) + IF(HAVE_MNTENT_H) + ADD_DEFINITIONS(-DMOJOSETUP_HAVE_MNTENT_H=1) + ENDIF(HAVE_MNTENT_H) + + # !!! FIXME: Solaris fails this, because mnttab.h implicitly + # !!! FIXME: depends on other system headers. :( + #CHECK_INCLUDE_FILE(sys/mnttab.h HAVE_SYS_MNTTAB_H) + CHECK_C_SOURCE_COMPILES(" + #include + #include + int main(int argc, char **argv) { return 0; } + " HAVE_SYS_MNTTAB_H) + + IF(HAVE_SYS_MNTTAB_H) + ADD_DEFINITIONS(-DMOJOSETUP_HAVE_SYS_MNTTAB_H=1) + ENDIF(HAVE_SYS_MNTTAB_H) + + IF(NOT MACOSX) + CHECK_LIBRARY_EXISTS("dl" "dlopen" "" HAVE_LIBDL) + IF(HAVE_LIBDL) + SET(OPTIONAL_LIBS ${OPTIONAL_LIBS} dl) + ENDIF(HAVE_LIBDL) + CHECK_LIBRARY_EXISTS("m" "sin" "" HAVE_LIBM) + IF(HAVE_LIBM) + SET(OPTIONAL_LIBS ${OPTIONAL_LIBS} m) + ENDIF(HAVE_LIBM) + ENDIF(NOT MACOSX) +ENDIF(UNIX) + +OPTION(MOJOSETUP_BUILD_LUAC "Build separate Lua compiler" TRUE) +IF(MOJOSETUP_BUILD_LUAC) + ADD_EXECUTABLE(mojoluac ${MOJOLUAC_SRCS}) + TARGET_LINK_LIBRARIES(mojoluac ${OPTIONAL_LIBS}) + GET_TARGET_PROPERTY(MOJOLUAC_LOCATION mojoluac LOCATION) + # !!! FIXME: actually compile this. + ADD_CUSTOM_TARGET(lua "${MOJOLUAC_LOCATION}" -p ${CMAKE_CURRENT_SOURCE_DIR}/scripts/*.lua) +ENDIF(MOJOSETUP_BUILD_LUAC) + +ADD_EXECUTABLE(mojosetup ${USES_WINMAIN} ${MOJOSETUP_SRCS} ${OPTIONAL_SRCS}) +GET_TARGET_PROPERTY(MOJOSETUP_BINARY_LOCATION mojosetup LOCATION) +TARGET_LINK_LIBRARIES(mojosetup ${OPTIONAL_LIBS}) +SET(MOJOSETUP_TARGETS "${MOJOSETUP_TARGETS};mojosetup") + +# For cobbling together a skeleton installer... + +# !!! FIXME: all of these custom .cmake files are built-in commands in CMake 2.6.(4?) ...! +ADD_CUSTOM_TARGET(skeleton + COMMENT "Assembling Skeleton..." + COMMAND ${CMAKE_COMMAND} -DDIR=${CMAKE_BINARY_DIR}/skeleton -P ${CMAKE_SOURCE_DIR}/misc/rm_recurse.cmake + COMMAND ${CMAKE_COMMAND} -DDIR=${CMAKE_BINARY_DIR}/skeleton -P ${CMAKE_SOURCE_DIR}/misc/mkdir.cmake + COMMAND ${CMAKE_COMMAND} -DDIR=${CMAKE_BINARY_DIR}/skeleton/scripts -P ${CMAKE_SOURCE_DIR}/misc/mkdir.cmake + COMMAND ${CMAKE_COMMAND} -DDIR=${CMAKE_BINARY_DIR}/skeleton/guis -P ${CMAKE_SOURCE_DIR}/misc/mkdir.cmake + COMMAND ${CMAKE_COMMAND} -DDIR=${CMAKE_BINARY_DIR}/skeleton/data -P ${CMAKE_SOURCE_DIR}/misc/mkdir.cmake + COMMAND ${CMAKE_COMMAND} -DFROM=${CMAKE_SOURCE_DIR}/scripts/*.lua -DTO=${CMAKE_BINARY_DIR}/skeleton/scripts -P ${CMAKE_SOURCE_DIR}/misc/cp.cmake + COMMAND ${CMAKE_COMMAND} -DFROM=${CMAKE_SOURCE_DIR}/*mojosetupgui*.* -DTO=${CMAKE_BINARY_DIR}/skeleton/guis -P ${CMAKE_SOURCE_DIR}/misc/cp.cmake + COMMAND ${CMAKE_COMMAND} -DFROM=${MOJOSETUP_BINARY_LOCATION} -DTO=${CMAKE_BINARY_DIR}/skeleton -P ${CMAKE_SOURCE_DIR}/misc/cp.cmake +) + +ADD_DEPENDENCIES(skeleton ${MOJOSETUP_TARGETS}) + +# end of CMakeLists.txt ... + diff --git a/mk/linux/mojosetup/LICENSE.txt b/mk/linux/mojosetup/LICENSE.txt new file mode 100644 index 00000000..7fdefa68 --- /dev/null +++ b/mk/linux/mojosetup/LICENSE.txt @@ -0,0 +1,32 @@ + + Copyright (c) 2006-2010 Ryan C. Gordon and others. + + This software is provided 'as-is', without any express or implied warranty. + In no event will the authors be held liable for any damages arising from + the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software in a + product, an acknowledgment in the product documentation would be + appreciated but is not required. + + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + + 3. This notice may not be removed or altered from any source distribution. + + Ryan C. Gordon + + + +(Please note that other pieces of code in MojoSetup fall under BSD-like and/or + public domain licenses: lua, libfetch, zlib, bzlib, stb_image, etc. All + software statically linked to MojoSetup was explicitly chosen to be friendly + with closed-source software, in case the installer needs a proprietary + change. I am not a lawyer and this is not legal advice. Please have a lawyer + consider the licenses if you have any concerns.) + diff --git a/mk/linux/mojosetup/archive_pck.c b/mk/linux/mojosetup/archive_pck.c new file mode 100644 index 00000000..36e8e9de --- /dev/null +++ b/mk/linux/mojosetup/archive_pck.c @@ -0,0 +1,283 @@ +/** + * MojoSetup; a portable, flexible installation application. + * + * Please see the file LICENSE.txt in the source's root directory. + * + * This file written by Steffen Pankratz. + */ + +#include "fileio.h" +#include "platform.h" + +#if !SUPPORT_PCK +MojoArchive *MojoArchive_createPCK(MojoInput *io) { return NULL; } +#else + +#define PCK_MAGIC 0x534c4850 + +typedef struct +{ + uint32 Magic; // 4 bytes, has to be PCK_MAGIC (0x534c4850) + uint32 StartOfBinaryData; // 4 bytes, offset to the data +} PCKheader; + +typedef struct +{ + int8 filename[60]; // 60 bytes, null terminated + uint32 filesize; // 4 bytes +} PCKentry; + +typedef struct +{ + uint64 fileCount; + uint64 dataStart; + uint64 nextFileStart; + int64 nextEnumPos; + MojoArchiveEntry *archiveEntries; +} PCKinfo; + + +static boolean readui32(MojoInput *io, uint32 *ui32) +{ + uint8 buf[sizeof (uint32)]; + if (io->read(io, buf, sizeof (buf)) != sizeof (buf)) + return false; + + *ui32 = (buf[0] | (buf[1] << 8) | (buf[2] << 16) | (buf[3] << 24)); + return true; +} // readui32 + +static boolean MojoInput_pck_ready(MojoInput *io) +{ + return true; // !!! FIXME? +} // MojoInput_pck_ready + +static int64 MojoInput_pck_read(MojoInput *io, void *buf, uint32 bufsize) +{ + MojoArchive *ar = (MojoArchive *) io->opaque; + const MojoArchiveEntry *entry = &ar->prevEnum; + int64 pos = io->tell(io); + if ((pos + bufsize) > entry->filesize) + bufsize = (uint32) (entry->filesize - pos); + return ar->io->read(ar->io, buf, bufsize); +} // MojoInput_pck_read + +static boolean MojoInput_pck_seek(MojoInput *io, uint64 pos) +{ + MojoArchive *ar = (MojoArchive *) io->opaque; + const PCKinfo *info = (PCKinfo *) ar->opaque; + const MojoArchiveEntry *entry = &ar->prevEnum; + boolean retval = false; + if (pos < ((uint64) entry->filesize)) + { + const uint64 newpos = (info->nextFileStart - entry->filesize) + pos; + retval = ar->io->seek(ar->io, newpos); + } // if + return retval; +} // MojoInput_pck_seek + +static int64 MojoInput_pck_tell(MojoInput *io) +{ + MojoArchive *ar = (MojoArchive *) io->opaque; + const PCKinfo *info = (PCKinfo *) ar->opaque; + const MojoArchiveEntry *entry = &ar->prevEnum; + return ar->io->tell(ar->io) - (info->nextFileStart - entry->filesize); +} // MojoInput_pck_tell + +static int64 MojoInput_pck_length(MojoInput *io) +{ + MojoArchive *ar = (MojoArchive *) io->opaque; + const MojoArchiveEntry *entry = &ar->prevEnum; + return entry->filesize; +} // MojoInput_pck_length + +static MojoInput *MojoInput_pck_duplicate(MojoInput *io) +{ + MojoInput *retval = NULL; + fatal(_("BUG: Can't duplicate pck inputs")); // !!! FIXME: why not? + return retval; +} // MojoInput_pck_duplicate + +static void MojoInput_pck_close(MojoInput *io) +{ + free(io); +} // MojoInput_pck_close + +// MojoArchive implementation... + +static boolean MojoArchive_pck_enumerate(MojoArchive *ar) +{ + MojoArchiveEntry *archiveEntries = NULL; + PCKinfo *info = (PCKinfo *) ar->opaque; + const int dataStart = info->dataStart; + const int fileCount = dataStart / sizeof (PCKentry); + const size_t len = fileCount * sizeof (MojoArchiveEntry); + PCKentry fileEntry; + uint64 i, realFileCount = 0; + char directory[256] = {'\0'}; + MojoInput *io = ar->io; + + MojoArchive_resetEntry(&ar->prevEnum); + + archiveEntries = (MojoArchiveEntry *) xmalloc(len); + + for (i = 0; i < fileCount; i++) + { + int dotdot; + int64 br; + + br = io->read(io, fileEntry.filename, sizeof (fileEntry.filename)); + if (br != sizeof (fileEntry.filename)) + return false; + else if (!readui32(io, &fileEntry.filesize)) + return false; + + dotdot = (strcmp(fileEntry.filename, "..") == 0); + + if ((!dotdot) && (fileEntry.filesize == 0x80000000)) + { + MojoArchiveEntry *entry = &archiveEntries[realFileCount]; + + strcat(directory, fileEntry.filename); + strcat(directory, "/"); + + entry->filename = xstrdup(directory); + entry->type = MOJOARCHIVE_ENTRY_DIR; + entry->perms = MojoPlatform_defaultDirPerms(); + entry->filesize = 0; + realFileCount++; + } // if + + else if ((dotdot) && (fileEntry.filesize == 0x80000000)) + { + // remove trailing path separator + char *pathSep; + const size_t strLength = strlen(directory); + directory[strLength - 1] = '\0'; + + pathSep = strrchr(directory, '/'); + if(pathSep != NULL) + { + pathSep++; + *pathSep = '\0'; + } // if + } // else if + + else + { + MojoArchiveEntry *entry = &archiveEntries[realFileCount]; + if (directory[0] == '\0') + entry->filename = xstrdup(fileEntry.filename); + else + { + const size_t len = sizeof (char) * strlen(directory) + + strlen(fileEntry.filename) + 1; + entry->filename = (char *) xmalloc(len); + strcat(entry->filename, directory); + strcat(entry->filename, fileEntry.filename); + } // else + + entry->perms = MojoPlatform_defaultFilePerms(); + entry->type = MOJOARCHIVE_ENTRY_FILE; + entry->filesize = fileEntry.filesize; + + realFileCount++; + } // else + } // for + + info->fileCount = realFileCount; + info->archiveEntries = archiveEntries; + info->nextEnumPos = 0; + info->nextFileStart = dataStart; + + return true; +} // MojoArchive_pck_enumerate + + +static const MojoArchiveEntry *MojoArchive_pck_enumNext(MojoArchive *ar) +{ + PCKinfo *info = (PCKinfo *) ar->opaque; + const MojoArchiveEntry *entry = &info->archiveEntries[info->nextEnumPos]; + + if (info->nextEnumPos >= info->fileCount) + return NULL; + + if (!ar->io->seek(ar->io, info->nextFileStart)) + return NULL; + + info->nextEnumPos++; + info->nextFileStart += entry->filesize; + + memcpy(&ar->prevEnum, entry, sizeof (ar->prevEnum)); + + return &ar->prevEnum; +} // MojoArchive_pck_enumNext + + +static MojoInput *MojoArchive_pck_openCurrentEntry(MojoArchive *ar) +{ + MojoInput *io = NULL; + io = (MojoInput *) xmalloc(sizeof (MojoInput)); + io->ready = MojoInput_pck_ready; + io->read = MojoInput_pck_read; + io->seek = MojoInput_pck_seek; + io->tell = MojoInput_pck_tell; + io->length = MojoInput_pck_length; + io->duplicate = MojoInput_pck_duplicate; + io->close = MojoInput_pck_close; + io->opaque = ar; + return io; +} // MojoArchive_pck_openCurrentEntry + + +static void MojoArchive_pck_close(MojoArchive *ar) +{ + int i; + PCKinfo *info = (PCKinfo *) ar->opaque; + ar->io->close(ar->io); + + for (i = 0; i < info->fileCount; i++) + { + MojoArchiveEntry *entry = &info->archiveEntries[i]; + free(entry->filename); + } // for + + free(info->archiveEntries); + free(info); + free(ar); +} // MojoArchive_pck_close + + +MojoArchive *MojoArchive_createPCK(MojoInput *io) +{ + MojoArchive *ar = NULL; + PCKinfo *pckInfo = NULL; + PCKheader pckHeader; + + if (!readui32(io, &pckHeader.Magic)) + return NULL; + else if (!readui32(io, &pckHeader.StartOfBinaryData)) + return NULL; + + // Check if this is a *.pck file. + if (pckHeader.Magic != PCK_MAGIC) + return NULL; + + pckInfo = (PCKinfo *) xmalloc(sizeof (PCKinfo)); + pckInfo->dataStart = pckHeader.StartOfBinaryData + sizeof (PCKheader); + + ar = (MojoArchive *) xmalloc(sizeof (MojoArchive)); + ar->opaque = pckInfo; + ar->enumerate = MojoArchive_pck_enumerate; + ar->enumNext = MojoArchive_pck_enumNext; + ar->openCurrentEntry = MojoArchive_pck_openCurrentEntry; + ar->close = MojoArchive_pck_close; + ar->io = io; + + return ar; +} // MojoArchive_createPCK + +#endif // SUPPORT_PCK + +// end of archive_pck.c ... + diff --git a/mk/linux/mojosetup/archive_tar.c b/mk/linux/mojosetup/archive_tar.c new file mode 100644 index 00000000..85e83068 --- /dev/null +++ b/mk/linux/mojosetup/archive_tar.c @@ -0,0 +1,347 @@ +/** + * MojoSetup; a portable, flexible installation application. + * + * Please see the file LICENSE.txt in the source's root directory. + * + * This file written by Ryan C. Gordon. + */ + +// Specs for the tar format can be found here... +// http://www.gnu.org/software/tar/manual/html_section/Standard.html + +#include "fileio.h" + +#if !SUPPORT_TAR +MojoArchive *MojoArchive_createTAR(MojoInput *io) { return NULL; } +#else + +// MojoInput implementation... + +// Decompression is handled in the parent MojoInput, so this just needs to +// make sure we stay within the bounds of the tarfile entry. + +typedef struct TARinput +{ + int64 fsize; + int64 offset; + MojoArchive *ar; +} TARinput; + +typedef struct TARinfo +{ + MojoInput *input; + uint64 curFileStart; + uint64 nextEnumPos; +} TARinfo; + +static boolean MojoInput_tar_ready(MojoInput *io) +{ + return true; // !!! FIXME: ready if there are bytes uncompressed. +} // MojoInput_tar_ready + +static int64 MojoInput_tar_read(MojoInput *io, void *buf, uint32 bufsize) +{ + TARinput *input = (TARinput *) io->opaque; + int64 pos = io->tell(io); + if ((pos + bufsize) > input->fsize) + bufsize = (uint32) (input->fsize - pos); + return input->ar->io->read(input->ar->io, buf, bufsize); +} // MojoInput_tar_read + +static boolean MojoInput_tar_seek(MojoInput *io, uint64 pos) +{ + TARinput *input = (TARinput *) io->opaque; + boolean retval = false; + if (pos < ((uint64) input->fsize)) + retval = input->ar->io->seek(input->ar->io, input->offset + pos); + return retval; +} // MojoInput_tar_seek + +static int64 MojoInput_tar_tell(MojoInput *io) +{ + TARinput *input = (TARinput *) io->opaque; + return input->ar->io->tell(input->ar->io) - input->offset; +} // MojoInput_tar_tell + +static int64 MojoInput_tar_length(MojoInput *io) +{ + return ((TARinput *) io->opaque)->fsize; +} // MojoInput_tar_length + +static MojoInput *MojoInput_tar_duplicate(MojoInput *io) +{ + MojoInput *retval = NULL; + fatal(_("BUG: Can't duplicate tar inputs")); // !!! FIXME: why not? +#if 0 + TARinput *input = (TARinput *) io->opaque; + MojoInput *origio = (MojoInput *) io->opaque; + MojoInput *newio = origio->duplicate(origio); + + if (newio != NULL) + { + TARinput *newopaque = (TARinput *) xmalloc(sizeof (TARinput)); + newopaque->origio = newio; + newopaque->fsize = input->fsize; + newopaque->offset = input->offset; + retval = (MojoInput *) xmalloc(sizeof (MojoInput)); + memcpy(retval, io, sizeof (MojoInput)); + retval->opaque = newopaque; + } // if +#endif + return retval; +} // MojoInput_tar_duplicate + +static void MojoInput_tar_close(MojoInput *io) +{ + TARinput *input = (TARinput *) io->opaque; + TARinfo *info = (TARinfo *) input->ar->opaque; + //input->ar->io->close(input->ar->io); + info->input = NULL; + free(input); + free(io); +} // MojoInput_tar_close + + +// MojoArchive implementation... + +static boolean MojoArchive_tar_enumerate(MojoArchive *ar) +{ + TARinfo *info = (TARinfo *) ar->opaque; + MojoArchive_resetEntry(&ar->prevEnum); + if (info->input != NULL) + fatal("BUG: tar entry still open on new enumeration"); + info->curFileStart = info->nextEnumPos = 0; + return true; +} // MojoArchive_tar_enumerate + + +// These are byte offsets where fields start in the tar header blocks. +#define TAR_FNAME 0 +#define TAR_FNAMELEN 100 +#define TAR_MODE 100 +#define TAR_MODELEN 8 +#define TAR_UID 108 +#define TAR_UIDLEN 8 +#define TAR_GID 116 +#define TAR_GIDLEN 8 +#define TAR_SIZE 124 +#define TAR_SIZELEN 12 +#define TAR_MTIME 136 +#define TAR_MTIMELEN 12 +#define TAR_CHKSUM 148 +#define TAR_CHKSUMLEN 8 +#define TAR_TYPE 156 +#define TAR_TYPELEN 1 +#define TAR_LINKNAME 157 +#define TAR_LINKNAMELEN 100 +#define TAR_MAGIC 257 +#define TAR_MAGICLEN 6 +#define TAR_VERSION 263 +#define TAR_VERSIONLEN 2 +#define TAR_UNAME 265 +#define TAR_UNAMELEN 32 +#define TAR_GNAME 297 +#define TAR_GNAMELEN 32 +#define TAR_DEVMAJOR 329 +#define TAR_DEVMAJORLEN 8 +#define TAR_DEVMINOR 337 +#define TAR_DEVMINORLEN 8 +#define TAR_FNAMEPRE 345 +#define TAR_FNAMEPRELEN 155 + +// tar entry types... +#define TAR_TYPE_FILE '0' +#define TAR_TYPE_HARDLINK '1' +#define TAR_TYPE_SYMLINK '2' +#define TAR_TYPE_CHARDEV '3' +#define TAR_TYPE_BLOCKDEV '4' +#define TAR_TYPE_DIRECTORY '5' +#define TAR_TYPE_FIFO '6' + +static boolean is_ustar(const uint8 *block) +{ + return ( (memcmp(&block[TAR_MAGIC], "ustar ", TAR_MAGICLEN) == 0) || + (memcmp(&block[TAR_MAGIC], "ustar\0", TAR_MAGICLEN) == 0) ); +} // is_ustar + +static int64 octal_convert(const uint8 *str, const size_t len) +{ + int64 retval = 0; + int64 multiplier = 1; + const uint8 *end = str + len; + const uint8 *ptr; + + while ((*str == ' ') && (str != end)) + str++; + + ptr = str; + while ((ptr != end) && (*ptr >= '0') && (*ptr <= '7')) + ptr++; + + while (--ptr >= str) + { + uint64 val = *ptr - '0'; + retval += val * multiplier; + multiplier *= 8; + } // while + + return retval; +} // octal_convert + + +static const MojoArchiveEntry *MojoArchive_tar_enumNext(MojoArchive *ar) +{ + TARinfo *info = (TARinfo *) ar->opaque; + boolean zeroes = true; + boolean ustar = false; + uint8 scratch[512]; + uint8 block[512]; + size_t fnamelen = 0; + int type = 0; + + memset(scratch, '\0', sizeof (scratch)); + + MojoArchive_resetEntry(&ar->prevEnum); + if (info->input != NULL) + fatal("BUG: tar entry still open on new enumeration"); + + if (!ar->io->seek(ar->io, info->nextEnumPos)) + return NULL; + + // Find a non-zero block of data. Tarballs have two 512 blocks filled with + // null bytes at the end of the archive, but you can cat tarballs + // together, so you can't treat them as EOF indicators. Just skip them. + while (zeroes) + { + if (ar->io->read(ar->io, block, sizeof (block)) != sizeof (block)) + return NULL; // !!! FIXME: fatal() ? + zeroes = (memcmp(block, scratch, sizeof (block)) == 0); + } // while + + // !!! FIXME We should probably check the checksum. + + ustar = is_ustar(block); + + ar->prevEnum.perms = (uint16) octal_convert(&block[TAR_MODE], TAR_MODELEN); + ar->prevEnum.filesize = octal_convert(&block[TAR_SIZE], TAR_SIZELEN); + info->curFileStart = info->nextEnumPos + 512; + info->nextEnumPos += 512 + ar->prevEnum.filesize; + if (ar->prevEnum.filesize % 512) + info->nextEnumPos += 512 - (ar->prevEnum.filesize % 512); + + // We count on (scratch) being zeroed out here! + // prefix of filename is at the end for legacy compat. + if (ustar) + memcpy(scratch, &block[TAR_FNAMEPRE], TAR_FNAMEPRELEN); + fnamelen = strlen((const char *) scratch); + memcpy(&scratch[fnamelen], &block[TAR_FNAME], TAR_FNAMELEN); + fnamelen += strlen((const char *) &scratch[fnamelen]); + + if (fnamelen == 0) + return NULL; // corrupt file. !!! FIXME: fatal() ? + + ar->prevEnum.filename = xstrdup((const char *) scratch); + + type = block[TAR_TYPE]; + if (type == 0) // some archivers do the file type as 0 instead of '0'. + type = TAR_TYPE_FILE; + + if (ar->prevEnum.filename[fnamelen-1] == '/') + { + while (ar->prevEnum.filename[fnamelen-1] == '/') + ar->prevEnum.filename[--fnamelen] = '\0'; + + // legacy tar entries don't have a dir type, they just append a '/' to + // the filename... + if ((!ustar) && (type == TAR_TYPE_FILE)) + type = TAR_TYPE_DIRECTORY; + } // if + + ar->prevEnum.type = MOJOARCHIVE_ENTRY_UNKNOWN; + if (type == TAR_TYPE_FILE) + ar->prevEnum.type = MOJOARCHIVE_ENTRY_FILE; + else if (type == TAR_TYPE_DIRECTORY) + ar->prevEnum.type = MOJOARCHIVE_ENTRY_DIR; + else if (type == TAR_TYPE_SYMLINK) + { + ar->prevEnum.type = MOJOARCHIVE_ENTRY_SYMLINK; + memcpy(scratch, &block[TAR_LINKNAME], TAR_LINKNAMELEN); + scratch[TAR_LINKNAMELEN] = '\0'; // just in case. + ar->prevEnum.linkdest = xstrdup((const char *) scratch); + } // else if + + return &ar->prevEnum; +} // MojoArchive_tar_enumNext + + +static MojoInput *MojoArchive_tar_openCurrentEntry(MojoArchive *ar) +{ + TARinfo *info = (TARinfo *) ar->opaque; + MojoInput *io = NULL; + TARinput *opaque = NULL; + + if (info->curFileStart == 0) + return NULL; + + // Can't open multiple, since we would end up decompressing twice + // to enumerate the next file, so I imposed this limitation for now. + if (info->input != NULL) + fatal("BUG: tar entry double open"); + + opaque = (TARinput *) xmalloc(sizeof (TARinput)); + opaque->ar = ar; + opaque->fsize = ar->prevEnum.filesize; + opaque->offset = info->curFileStart; + + io = (MojoInput *) xmalloc(sizeof (MojoInput)); + io->ready = MojoInput_tar_ready; + io->read = MojoInput_tar_read; + io->seek = MojoInput_tar_seek; + io->tell = MojoInput_tar_tell; + io->length = MojoInput_tar_length; + io->duplicate = MojoInput_tar_duplicate; + io->close = MojoInput_tar_close; + io->opaque = opaque; + info->input = io; + return io; +} // MojoArchive_tar_openCurrentEntry + + +static void MojoArchive_tar_close(MojoArchive *ar) +{ + TARinfo *info = (TARinfo *) ar->opaque; + MojoArchive_resetEntry(&ar->prevEnum); + ar->io->close(ar->io); + free(info); + free(ar); +} // MojoArchive_tar_close + + +MojoArchive *MojoArchive_createTAR(MojoInput *io) +{ + MojoArchive *ar = NULL; + uint8 sig[512]; + const int64 br = io->read(io, sig, sizeof (sig)); + + // See if this is a tar archive. We only support "USTAR" format, + // since it has a detectable header. GNU and BSD tar has been creating + // these for years, so it's okay to ignore other ones, I guess. + if ((!io->seek(io, 0)) || (br != sizeof (sig)) || (!is_ustar(sig)) ) + return NULL; + + // okay, it's a tarball, we're good to go. + + ar = (MojoArchive *) xmalloc(sizeof (MojoArchive)); + ar->opaque = (TARinfo *) xmalloc(sizeof (TARinfo)); + ar->enumerate = MojoArchive_tar_enumerate; + ar->enumNext = MojoArchive_tar_enumNext; + ar->openCurrentEntry = MojoArchive_tar_openCurrentEntry; + ar->close = MojoArchive_tar_close; + ar->io = io; + return ar; +} // MojoArchive_createTAR + +#endif // SUPPORT_TAR + +// end of archive_tar.c ... + diff --git a/mk/linux/mojosetup/archive_uz2.c b/mk/linux/mojosetup/archive_uz2.c new file mode 100644 index 00000000..1fa02a8e --- /dev/null +++ b/mk/linux/mojosetup/archive_uz2.c @@ -0,0 +1,361 @@ +/** + * MojoSetup; a portable, flexible installation application. + * + * Please see the file LICENSE.txt in the source's root directory. + * + * This file written by Ryan C. Gordon. + */ + +#include "fileio.h" +#include "platform.h" + +#if !SUPPORT_UZ2 +MojoArchive *MojoArchive_createUZ2(MojoInput *io) { return NULL; } +#else + +// UZ2 format is a simple compressed file format used by UnrealEngine2. +// it's just a stream of blocks like this: +// uint32 compressed size +// uint32 uncompressed size +// uint8 data[compressed size] <-- unpacks to (uncompressed size) bytes. +// Decompression is handled by zlib's "uncompress" function. + +#include "zlib/zlib.h" + +#define MAXCOMPSIZE 32768 +#define MAXUNCOMPSIZE 33096 // MAXCOMPSIZE + 1% + + +// MojoInput implementation... + +// Decompression is handled in the parent MojoInput, so this just needs to +// make sure we stay within the bounds of the tarfile entry. + +typedef struct UZ2input +{ + MojoInput *io; + int64 fsize; + uint64 position; + uint32 compsize; + uint8 compbuf[MAXCOMPSIZE]; + uint32 uncompsize; + uint8 uncompbuf[MAXUNCOMPSIZE]; + uint32 uncompindex; +} UZ2input; + +typedef struct UZ2info +{ + char *outname; + int64 outsize; + boolean enumerated; +} UZ2info; + + +static boolean readui32(MojoInput *io, uint32 *ui32) +{ + uint8 buf[sizeof (uint32)]; + if (io->read(io, buf, sizeof (buf)) != sizeof (buf)) + return false; + + *ui32 = (buf[0] | (buf[1] << 8) | (buf[2] << 16) | (buf[3] << 24)); + return true; +} // readui32 + +static boolean unpack(UZ2input *inp) +{ + MojoInput *io = inp->io; + uLongf ul = (uLongf) inp->uncompsize; + + // we checked these formally elsewhere. + assert(inp->compsize > 0); + assert(inp->uncompsize > 0); + assert(inp->compsize <= MAXCOMPSIZE); + assert(inp->uncompsize <= MAXUNCOMPSIZE); + + if (io->read(io, inp->compbuf, inp->compsize) != inp->compsize) + return false; + if (uncompress(inp->uncompbuf, &ul, inp->compbuf, inp->compsize) != Z_OK) + return false; + if (ul != ((uLongf) inp->uncompsize)) // corrupt data. + return false; + + inp->uncompindex = 0; + return true; +} // unpack + +static boolean MojoInput_uz2_ready(MojoInput *io) +{ + UZ2input *input = (UZ2input *) io->opaque; + if (input->uncompsize > 0) + return true; + return true; // !!! FIXME: need to know we have a full compressed block. +} // MojoInput_uz2_ready + +static int64 MojoInput_uz2_read(MojoInput *io, void *_buf, uint32 bufsize) +{ + uint8 *buf = (uint8 *) _buf; + UZ2input *input = (UZ2input *) io->opaque; + int64 retval = 0; + while (bufsize > 0) + { + const uint32 available = input->uncompsize - input->uncompindex; + const uint32 cpy = (available < bufsize) ? available : bufsize; + if (available == 0) + { + if (input->position == input->fsize) + return 0; + else if (!readui32(input->io, &input->compsize)) + return (retval == 0) ? -1 : retval; + else if (!readui32(input->io, &input->uncompsize)) + return (retval == 0) ? -1 : retval; + else if (!unpack(input)) + return (retval == 0) ? -1 : retval; + continue; // try again. + } // if + + memcpy(buf, input->uncompbuf + input->uncompindex, cpy); + buf += cpy; + bufsize -= cpy; + retval += cpy; + input->uncompindex += cpy; + input->position += cpy; + } // while + + return retval; +} // MojoInput_uz2_read + +static boolean MojoInput_uz2_seek(MojoInput *io, uint64 pos) +{ + UZ2input *input = (UZ2input *) io->opaque; + int64 seekpos = 0; + + // in a perfect world, this wouldn't seek from the start if moving + // forward. But oh well. + input->position = 0; + while (input->position < pos) + { + if (!input->io->seek(input->io, seekpos)) + return false; + else if (!readui32(io, &input->compsize)) + return false; + else if (!readui32(io, &input->uncompsize)) + return false; + + // we checked these formally elsewhere. + assert(input->compsize > 0); + assert(input->uncompsize > 0); + assert(input->compsize <= MAXCOMPSIZE); + assert(input->uncompsize <= MAXUNCOMPSIZE); + + input->position += input->uncompsize; + seekpos += (sizeof (uint32) * 2) + input->compsize; + } // while + + // we are positioned on the compressed block that contains the seek target. + if (!unpack(input)) + return false; + + input->position -= input->uncompsize; + input->uncompindex = (uint32) (pos - input->position); + input->position += input->uncompindex; + + return true; +} // MojoInput_uz2_seek + +static int64 MojoInput_uz2_tell(MojoInput *io) +{ + return (int64) (((UZ2input *) io->opaque)->position); +} // MojoInput_uz2_tell + +static int64 MojoInput_uz2_length(MojoInput *io) +{ + return ((UZ2input *) io->opaque)->fsize; +} // MojoInput_uz2_length + +static MojoInput *MojoInput_uz2_duplicate(MojoInput *io) +{ + MojoInput *retval = NULL; + UZ2input *input = (UZ2input *) io->opaque; + MojoInput *newio = input->io->duplicate(input->io); + + if (newio != NULL) + { + UZ2input *newopaque = (UZ2input *) xmalloc(sizeof (UZ2input)); + newopaque->io = newio; + newopaque->fsize = input->fsize; + // everything else is properly zero'd by xmalloc(). + retval = (MojoInput *) xmalloc(sizeof (MojoInput)); + memcpy(retval, io, sizeof (MojoInput)); + retval->opaque = newopaque; + } // if + + return retval; +} // MojoInput_uz2_duplicate + +static void MojoInput_uz2_close(MojoInput *io) +{ + UZ2input *input = (UZ2input *) io->opaque; + input->io->close(input->io); + free(input); + free(io); +} // MojoInput_uz2_close + + +// MojoArchive implementation... + +static boolean MojoArchive_uz2_enumerate(MojoArchive *ar) +{ + UZ2info *info = (UZ2info *) ar->opaque; + MojoArchive_resetEntry(&ar->prevEnum); + info->enumerated = false; + return true; +} // MojoArchive_uz2_enumerate + + +static const MojoArchiveEntry *MojoArchive_uz2_enumNext(MojoArchive *ar) +{ + UZ2info *info = (UZ2info *) ar->opaque; + + MojoArchive_resetEntry(&ar->prevEnum); + if (info->enumerated) + return NULL; // only one file in this "archive". + + ar->prevEnum.perms = MojoPlatform_defaultFilePerms(); + ar->prevEnum.filesize = info->outsize; + ar->prevEnum.filename = xstrdup(info->outname); + ar->prevEnum.type = MOJOARCHIVE_ENTRY_FILE; + + info->enumerated = true; + return &ar->prevEnum; +} // MojoArchive_uz2_enumNext + + +static MojoInput *MojoArchive_uz2_openCurrentEntry(MojoArchive *ar) +{ + UZ2info *info = (UZ2info *) ar->opaque; + MojoInput *io = NULL; + UZ2input *opaque = NULL; + MojoInput *dupio = NULL; + + if (!info->enumerated) + return NULL; + + dupio = ar->io->duplicate(ar->io); + if (dupio == NULL) + return NULL; + + opaque = (UZ2input *) xmalloc(sizeof (UZ2input)); + opaque->io = dupio; + opaque->fsize = info->outsize; + // rest is zero'd by xmalloc(). + + io = (MojoInput *) xmalloc(sizeof (MojoInput)); + io->ready = MojoInput_uz2_ready; + io->read = MojoInput_uz2_read; + io->seek = MojoInput_uz2_seek; + io->tell = MojoInput_uz2_tell; + io->length = MojoInput_uz2_length; + io->duplicate = MojoInput_uz2_duplicate; + io->close = MojoInput_uz2_close; + io->opaque = opaque; + + return io; +} // MojoArchive_uz2_openCurrentEntry + + +static void MojoArchive_uz2_close(MojoArchive *ar) +{ + UZ2info *info = (UZ2info *) ar->opaque; + MojoArchive_resetEntry(&ar->prevEnum); + ar->io->close(ar->io); + free(info->outname); + free(info); + free(ar); +} // MojoArchive_uz2_close + + +// Unfortunately, we have to walk the whole file, but we don't have to actually +// do any decompression work here. Just seek, read 8 bytes, repeat until EOF. +static int64 calculate_uz2_outsize(MojoInput *io) +{ + int64 retval = 0; + uint32 compsize = 0; + uint32 uncompsize = 0; + int64 pos = 0; + + if (!io->seek(io, 0)) + return -1; + + while (readui32(io, &compsize)) + { + if (!readui32(io, &uncompsize)) + return -1; + else if ((compsize > MAXCOMPSIZE) || (uncompsize > MAXUNCOMPSIZE)) + return -1; + else if ((compsize == 0) || (uncompsize == 0)) + return -1; + retval += uncompsize; + pos += (sizeof (uint32) * 2) + compsize; + if (!io->seek(io, pos)) + return -1; + } // while + + if (!io->seek(io, 0)) // make sure we're back to the start. + return -1; + + return retval; +} // calculate_uz2_outsize + + +MojoArchive *MojoArchive_createUZ2(MojoInput *io, const char *origfname) +{ + MojoArchive *ar = NULL; + const char *fname = NULL; + char *outname = NULL; + size_t len = 0; + int64 outsize = 0; + UZ2info *uz2info = NULL; + + // There's no magic in a UZ2 that allows us to identify the format. + // The higher-level won't call this unless the file extension in + // (origfname) is ".uz2" + + // Figure out the output name ("x.uz2" would produce "x"). + if (origfname == NULL) + return NULL; // just in case. + fname = strrchr(origfname, '/'); + if (fname == NULL) + fname = origfname; + else + fname++; + + len = strlen(fname) - 4; // -4 == ".uz2" + if (strcasecmp(fname + len, ".uz2") != 0) + return NULL; // just in case. + + outsize = calculate_uz2_outsize(io); + if (outsize < 0) + return NULL; // wasn't really a uz2? Corrupt/truncated file? + outname = (char *) xmalloc(len+1); + memcpy(outname, fname, len); + outname[len] = '\0'; + + uz2info = (UZ2info *) xmalloc(sizeof (UZ2info)); + uz2info->enumerated = false; + uz2info->outname = outname; + uz2info->outsize = outsize; + + ar = (MojoArchive *) xmalloc(sizeof (MojoArchive)); + ar->opaque = uz2info; + ar->enumerate = MojoArchive_uz2_enumerate; + ar->enumNext = MojoArchive_uz2_enumNext; + ar->openCurrentEntry = MojoArchive_uz2_openCurrentEntry; + ar->close = MojoArchive_uz2_close; + ar->io = io; + return ar; +} // MojoArchive_createUZ2 + +#endif // SUPPORT_UZ2 + +// end of archive_uz2.c ... + diff --git a/mk/linux/mojosetup/archive_zip.c b/mk/linux/mojosetup/archive_zip.c new file mode 100644 index 00000000..996f04a1 --- /dev/null +++ b/mk/linux/mojosetup/archive_zip.c @@ -0,0 +1,1849 @@ +/** + * MojoSetup; a portable, flexible installation application. + * + * Please see the file LICENSE.txt in the source's root directory. + * + * This file written by Ryan C. Gordon. + */ + +#include "fileio.h" + +#if !SUPPORT_ZIP +MojoArchive *MojoArchive_createZIP(MojoInput *io) { return NULL; } +#else + +#include +#include + +#include "zlib/zlib.h" + +/* + * ZIP support routines, adapted from PhysicsFS (http://icculus.org/physfs/) + */ + +#if __MOJOSETUP__ +// Glue from PhysicsFS to MojoSetup follows... +typedef int8 PHYSFS_sint8; +typedef uint8 PHYSFS_uint8; +typedef int16 PHYSFS_sint16; +typedef uint16 PHYSFS_uint16; +typedef int32 PHYSFS_sint32; +typedef uint32 PHYSFS_uint32; +typedef int64 PHYSFS_sint64; +typedef uint64 PHYSFS_uint64; + +#define BAIL_IF_MACRO(cond, err, ret) if (cond) return ret; +#define BAIL_MACRO(err, ret) return ret; + +static void *mallocWrap(PHYSFS_uint64 s) { return xmalloc((uint32) s); } +static void *reallocWrap(void *p,PHYSFS_uint64 s){return xrealloc(p,(uint32)s);} +static void freeWrap(void *p) { free(p); } +typedef struct +{ + int (*Init)(void); /**< Initialize. Can be NULL. Zero on failure. */ + void (*Deinit)(void); /**< Deinitialize your allocator. Can be NULL. */ + void *(*Malloc)(PHYSFS_uint64); /**< Allocate like malloc(). */ + void *(*Realloc)(void *, PHYSFS_uint64); /**< Reallocate like realloc(). */ + void (*Free)(void *); /**< Free memory from Malloc or Realloc. */ +} PHYSFS_Allocator; + +static PHYSFS_Allocator allocator = { 0, 0, mallocWrap, reallocWrap, freeWrap }; + +#define ERR_ZLIB_NEED_DICT _("need dictionary") +#define ERR_ZLIB_DATA_ERROR _("data error") +#define ERR_ZLIB_MEMORY_ERROR _("memory error") +#define ERR_ZLIB_BUFFER_ERROR _("buffer error") +#define ERR_ZLIB_VERSION_ERROR _("version error") +#define ERR_ZLIB_UNKNOWN_ERROR _("unknown error") + +#define __PHYSFS_setError(x) + +#define fvoid void +#define dvoid void + +#if PLATFORM_BIGENDIAN +static PHYSFS_uint32 PHYSFS_swapULE32(PHYSFS_uint32 D) +{ + return((D<<24)|((D<<8)&0x00FF0000)|((D>>8)&0x0000FF00)|(D>>24)); +} +static PHYSFS_uint16 PHYSFS_swapULE16(PHYSFS_uint16 D) +{ + return((D<<8)|(D>>8)); +} +#else +static PHYSFS_uint32 PHYSFS_swapULE32(PHYSFS_uint32 D) { return D; } +static PHYSFS_uint16 PHYSFS_swapULE16(PHYSFS_uint16 D) { return D; } +#endif + +static PHYSFS_sint64 __PHYSFS_platformRead(void *opaque, void *buffer, + PHYSFS_uint32 size, PHYSFS_uint32 count) +{ + MojoInput *io = (MojoInput *) opaque; + int64 rc = io->read(io, buffer, size * count); + return rc / size; // !!! FIXME: what if rc == -1? +} + +static int __PHYSFS_platformSeek(void *opaque, PHYSFS_uint64 pos) +{ + MojoInput *io = (MojoInput *) opaque; + return io->seek(io, pos) ? 1 : 0; +} + +static int __PHYSFS_platformClose(void *opaque) +{ + MojoInput *io = (MojoInput *) opaque; + io->close(io); + return 1; +} + +static PHYSFS_sint64 __PHYSFS_platformFileLength(void *opaque) +{ + MojoInput *io = (MojoInput *) opaque; + return io->length(io); +} + +static PHYSFS_sint64 __PHYSFS_platformTell(void *opaque) +{ + MojoInput *io = (MojoInput *) opaque; + return io->tell(io); +} + +#define PHYSFS_QUICKSORT_THRESHOLD 4 +static void __PHYSFS_bubble_sort(void *a, PHYSFS_uint32 lo, PHYSFS_uint32 hi, + int (*cmpfn)(void *, PHYSFS_uint32, PHYSFS_uint32), + void (*swapfn)(void *, PHYSFS_uint32, PHYSFS_uint32)) +{ + PHYSFS_uint32 i; + int sorted; + + do + { + sorted = 1; + for (i = lo; i < hi; i++) + { + if (cmpfn(a, i, i + 1) > 0) + { + swapfn(a, i, i + 1); + sorted = 0; + } /* if */ + } /* for */ + } while (!sorted); +} /* __PHYSFS_bubble_sort */ + + +static void __PHYSFS_quick_sort(void *a, PHYSFS_uint32 lo, PHYSFS_uint32 hi, + int (*cmpfn)(void *, PHYSFS_uint32, PHYSFS_uint32), + void (*swapfn)(void *, PHYSFS_uint32, PHYSFS_uint32)) +{ + PHYSFS_uint32 i; + PHYSFS_uint32 j; + PHYSFS_uint32 v; + + if ((hi - lo) <= PHYSFS_QUICKSORT_THRESHOLD) + __PHYSFS_bubble_sort(a, lo, hi, cmpfn, swapfn); + else + { + i = (hi + lo) / 2; + + if (cmpfn(a, lo, i) > 0) swapfn(a, lo, i); + if (cmpfn(a, lo, hi) > 0) swapfn(a, lo, hi); + if (cmpfn(a, i, hi) > 0) swapfn(a, i, hi); + + j = hi - 1; + swapfn(a, i, j); + i = lo; + v = j; + while (1) + { + while(cmpfn(a, ++i, v) < 0) { /* do nothing */ } + while(cmpfn(a, --j, v) > 0) { /* do nothing */ } + if (j < i) + break; + swapfn(a, i, j); + } /* while */ + swapfn(a, i, hi-1); + __PHYSFS_quick_sort(a, lo, j, cmpfn, swapfn); + __PHYSFS_quick_sort(a, i+1, hi, cmpfn, swapfn); + } /* else */ +} /* __PHYSFS_quick_sort */ + + +void __PHYSFS_sort(void *entries, PHYSFS_uint32 max, + int (*cmpfn)(void *, PHYSFS_uint32, PHYSFS_uint32), + void (*swapfn)(void *, PHYSFS_uint32, PHYSFS_uint32)) +{ + /* + * Quicksort w/ Bubblesort fallback algorithm inspired by code from here: + * http://www.cs.ubc.ca/spider/harrison/Java/sorting-demo.html + */ + __PHYSFS_quick_sort(entries, 0, max - 1, cmpfn, swapfn); +} /* __PHYSFS_sort */ + + +typedef void (*PHYSFS_EnumFilesCallback)(void *, const char *, const char *); +#endif + + +/* + * A buffer of ZIP_READBUFSIZE is allocated for each compressed file opened, + * and is freed when you close the file; compressed data is read into + * this buffer, and then is decompressed into the buffer passed to + * PHYSFS_read(). + * + * Uncompressed entries in a zipfile do not allocate this buffer; they just + * read data directly into the buffer passed to PHYSFS_read(). + * + * Depending on your speed and memory requirements, you should tweak this + * value. + */ +#if __MOJOSETUP__ +#define ZIP_READBUFSIZE (128 * 1024) +#else +#define ZIP_READBUFSIZE (16 * 1024) +#endif + +/* + * Entries are "unresolved" until they are first opened. At that time, + * local file headers parsed/validated, data offsets will be updated to look + * at the actual file data instead of the header, and symlinks will be + * followed and optimized. This means that we don't seek and read around the + * archive until forced to do so, and after the first time, we had to do + * less reading and parsing, which is very CD-ROM friendly. + */ +typedef enum +{ + ZIP_UNRESOLVED_FILE, + ZIP_UNRESOLVED_SYMLINK, + ZIP_RESOLVING, + ZIP_RESOLVED, + ZIP_BROKEN_FILE, + ZIP_BROKEN_SYMLINK +} ZipResolveType; + + +/* + * One ZIPentry is kept for each file in an open ZIP archive. + */ +typedef struct _ZIPentry +{ + char *name; /* Name of file in archive */ + struct _ZIPentry *symlink; /* NULL or file we symlink to */ + #if __MOJOSETUP__ + PHYSFS_uint16 perms; + char *linkdest; + #endif + ZipResolveType resolved; /* Have we resolved file/symlink? */ + PHYSFS_uint32 offset; /* offset of data in archive */ + PHYSFS_uint16 version; /* version made by */ + PHYSFS_uint16 version_needed; /* version needed to extract */ + PHYSFS_uint16 compression_method; /* compression method */ + PHYSFS_uint32 crc; /* crc-32 */ + PHYSFS_uint32 compressed_size; /* compressed size */ + PHYSFS_uint32 uncompressed_size; /* uncompressed size */ + PHYSFS_sint64 last_mod_time; /* last file mod time */ +} ZIPentry; + +/* + * One ZIPinfo is kept for each open ZIP archive. + */ +typedef struct +{ + char *archiveName; /* path to ZIP in platform-dependent notation. */ + #if __MOJOSETUP__ + void *io; /* a MojoInput pointer */ + int32 enumIndex; /* index of last entry enumerated. */ + int64 offset; /* byte offset from start of MojoInput where zip starts. */ + #endif + PHYSFS_uint16 entryCount; /* Number of files in ZIP. */ + ZIPentry *entries; /* info on all files in ZIP. */ +} ZIPinfo; + +/* + * One ZIPfileinfo is kept for each open file in a ZIP archive. + */ +typedef struct +{ + #if __MOJOSETUP__ + ZIPinfo *archive; /* archive this belongs to, for duplication. */ + #endif + ZIPentry *entry; /* Info on file. */ + void *handle; /* physical file handle. */ + PHYSFS_uint32 compressed_position; /* offset in compressed data. */ + PHYSFS_uint32 uncompressed_position; /* tell() position. */ + PHYSFS_uint8 *buffer; /* decompression buffer. */ + z_stream stream; /* zlib stream state. */ +} ZIPfileinfo; + + +/* Magic numbers... */ +#define ZIP_LOCAL_FILE_SIG 0x04034b50 +#define ZIP_CENTRAL_DIR_SIG 0x02014b50 +#define ZIP_END_OF_CENTRAL_DIR_SIG 0x06054b50 + +/* compression methods... */ +#define COMPMETH_NONE 0 +/* ...and others... */ + + +#define UNIX_FILETYPE_MASK 0170000 +#define UNIX_FILETYPE_SYMLINK 0120000 + +/* + * Bridge physfs allocation functions to zlib's format... + */ +static voidpf zlibPhysfsAlloc(voidpf opaque, uInt items, uInt size) +{ + return(((PHYSFS_Allocator *) opaque)->Malloc(items * size)); +} /* zlibPhysfsAlloc */ + +/* + * Bridge physfs allocation functions to zlib's format... + */ +static void zlibPhysfsFree(voidpf opaque, voidpf address) +{ + ((PHYSFS_Allocator *) opaque)->Free(address); +} /* zlibPhysfsFree */ + + +/* + * Construct a new z_stream to a sane state. + */ +static void initializeZStream(z_stream *pstr) +{ + memset(pstr, '\0', sizeof (z_stream)); + pstr->zalloc = zlibPhysfsAlloc; + pstr->zfree = zlibPhysfsFree; + pstr->opaque = &allocator; +} /* initializeZStream */ + + +static const char *zlib_error_string(int rc) +{ + switch (rc) + { + case Z_OK: return(NULL); /* not an error. */ + case Z_STREAM_END: return(NULL); /* not an error. */ +#ifndef _WIN32_WCE + case Z_ERRNO: return(strerror(errno)); +#endif + case Z_NEED_DICT: return(ERR_ZLIB_NEED_DICT); + case Z_DATA_ERROR: return(ERR_ZLIB_DATA_ERROR); + case Z_MEM_ERROR: return(ERR_ZLIB_MEMORY_ERROR); + case Z_BUF_ERROR: return(ERR_ZLIB_BUFFER_ERROR); + case Z_VERSION_ERROR: return(ERR_ZLIB_VERSION_ERROR); + default: return(ERR_ZLIB_UNKNOWN_ERROR); + } /* switch */ +} /* zlib_error_string */ + + +/* + * Wrap all zlib calls in this, so the physfs error state is set appropriately. + */ +static int zlib_err(int rc) +{ + const char *str = zlib_error_string(rc); + if (str != NULL) + __PHYSFS_setError(str); + return(rc); +} /* zlib_err */ + + +/* + * Read an unsigned 32-bit int and swap to native byte order. + */ +static int readui32(void *in, PHYSFS_uint32 *val) +{ + PHYSFS_uint32 v; + BAIL_IF_MACRO(__PHYSFS_platformRead(in, &v, sizeof (v), 1) != 1, NULL, 0); + *val = PHYSFS_swapULE32(v); + return(1); +} /* readui32 */ + + +/* + * Read an unsigned 16-bit int and swap to native byte order. + */ +static int readui16(void *in, PHYSFS_uint16 *val) +{ + PHYSFS_uint16 v; + BAIL_IF_MACRO(__PHYSFS_platformRead(in, &v, sizeof (v), 1) != 1, NULL, 0); + *val = PHYSFS_swapULE16(v); + return(1); +} /* readui16 */ + + +static PHYSFS_sint64 ZIP_read(fvoid *opaque, void *buf, + PHYSFS_uint32 objSize, PHYSFS_uint32 objCount) +{ + ZIPfileinfo *finfo = (ZIPfileinfo *) opaque; + ZIPentry *entry = finfo->entry; + PHYSFS_sint64 retval = 0; + PHYSFS_sint64 maxread = ((PHYSFS_sint64) objSize) * objCount; + PHYSFS_sint64 avail = entry->uncompressed_size - + finfo->uncompressed_position; + + BAIL_IF_MACRO(maxread == 0, NULL, 0); /* quick rejection. */ + + if (avail < maxread) + { + maxread = avail - (avail % objSize); + objCount = (PHYSFS_uint32) (maxread / objSize); + BAIL_IF_MACRO(objCount == 0, ERR_PAST_EOF, 0); /* quick rejection. */ + __PHYSFS_setError(ERR_PAST_EOF); /* this is always true here. */ + } /* if */ + + if (entry->compression_method == COMPMETH_NONE) + { + retval = __PHYSFS_platformRead(finfo->handle, buf, objSize, objCount); + } /* if */ + + else + { + finfo->stream.next_out = buf; + finfo->stream.avail_out = objSize * objCount; + + while (retval < maxread) + { + PHYSFS_uint32 before = finfo->stream.total_out; + int rc; + + if (finfo->stream.avail_in == 0) + { + PHYSFS_sint64 br; + + br = entry->compressed_size - finfo->compressed_position; + if (br > 0) + { + if (br > ZIP_READBUFSIZE) + br = ZIP_READBUFSIZE; + + br = __PHYSFS_platformRead(finfo->handle, + finfo->buffer, + 1, (PHYSFS_uint32) br); + if (br <= 0) + break; + + finfo->compressed_position += (PHYSFS_uint32) br; + finfo->stream.next_in = finfo->buffer; + finfo->stream.avail_in = (PHYSFS_uint32) br; + } /* if */ + } /* if */ + + rc = zlib_err(inflate(&finfo->stream, Z_SYNC_FLUSH)); + retval += (finfo->stream.total_out - before); + + if (rc != Z_OK) + break; + } /* while */ + + retval /= objSize; + } /* else */ + + if (retval > 0) + finfo->uncompressed_position += (PHYSFS_uint32) (retval * objSize); + + return(retval); +} /* ZIP_read */ + + +#if !__MOJOSETUP__ +static PHYSFS_sint64 ZIP_write(fvoid *opaque, const void *buf, + PHYSFS_uint32 objSize, PHYSFS_uint32 objCount) +{ + BAIL_MACRO(ERR_NOT_SUPPORTED, -1); +} /* ZIP_write */ + + +static int ZIP_eof(fvoid *opaque) +{ + ZIPfileinfo *finfo = (ZIPfileinfo *) opaque; + return(finfo->uncompressed_position >= finfo->entry->uncompressed_size); +} /* ZIP_eof */ +#endif + + +static PHYSFS_sint64 ZIP_tell(fvoid *opaque) +{ + return(((ZIPfileinfo *) opaque)->uncompressed_position); +} /* ZIP_tell */ + + +static int ZIP_seek(fvoid *opaque, PHYSFS_uint64 offset) +{ + ZIPfileinfo *finfo = (ZIPfileinfo *) opaque; + ZIPentry *entry = finfo->entry; + void *in = finfo->handle; + + BAIL_IF_MACRO(offset > entry->uncompressed_size, ERR_PAST_EOF, 0); + + if (entry->compression_method == COMPMETH_NONE) + { + PHYSFS_sint64 newpos = offset + entry->offset; + BAIL_IF_MACRO(!__PHYSFS_platformSeek(in, newpos), NULL, 0); + finfo->uncompressed_position = (PHYSFS_uint32) offset; + } /* if */ + + else + { + /* + * If seeking backwards, we need to redecode the file + * from the start and throw away the compressed bits until we hit + * the offset we need. If seeking forward, we still need to + * decode, but we don't rewind first. + */ + if (offset < finfo->uncompressed_position) + { + /* we do a copy so state is sane if inflateInit2() fails. */ + z_stream str; + initializeZStream(&str); + if (zlib_err(inflateInit2(&str, -MAX_WBITS)) != Z_OK) + return(0); + + if (!__PHYSFS_platformSeek(in, entry->offset)) + return(0); + + inflateEnd(&finfo->stream); + memcpy(&finfo->stream, &str, sizeof (z_stream)); + finfo->uncompressed_position = finfo->compressed_position = 0; + } /* if */ + + while (finfo->uncompressed_position != offset) + { + PHYSFS_uint8 buf[512]; + PHYSFS_uint32 maxread; + + maxread = (PHYSFS_uint32) (offset - finfo->uncompressed_position); + if (maxread > sizeof (buf)) + maxread = sizeof (buf); + + if (ZIP_read(opaque, buf, maxread, 1) != 1) + return(0); + } /* while */ + } /* else */ + + return(1); +} /* ZIP_seek */ + + +static PHYSFS_sint64 ZIP_fileLength(fvoid *opaque) +{ + ZIPfileinfo *finfo = (ZIPfileinfo *) opaque; + return(finfo->entry->uncompressed_size); +} /* ZIP_fileLength */ + + +static int ZIP_fileClose(fvoid *opaque) +{ + ZIPfileinfo *finfo = (ZIPfileinfo *) opaque; + BAIL_IF_MACRO(!__PHYSFS_platformClose(finfo->handle), NULL, 0); + + if (finfo->entry->compression_method != COMPMETH_NONE) + inflateEnd(&finfo->stream); + + if (finfo->buffer != NULL) + allocator.Free(finfo->buffer); + + allocator.Free(finfo); + return(1); +} /* ZIP_fileClose */ + + +static PHYSFS_sint64 zip_find_end_of_central_dir(void *in, PHYSFS_sint64 *len) +{ + PHYSFS_uint8 buf[256]; + PHYSFS_sint32 i = 0; + PHYSFS_sint64 filelen; + PHYSFS_sint64 filepos; + PHYSFS_sint32 maxread; + PHYSFS_sint32 totalread = 0; + int found = 0; + PHYSFS_uint32 extra = 0; + + filelen = __PHYSFS_platformFileLength(in); + BAIL_IF_MACRO(filelen == -1, NULL, 0); /* !!! FIXME: unlocalized string */ + BAIL_IF_MACRO(filelen > 0xFFFFFFFF, "ZIP bigger than 2 gigs?!", 0); + + /* + * Jump to the end of the file and start reading backwards. + * The last thing in the file is the zipfile comment, which is variable + * length, and the field that specifies its size is before it in the + * file (argh!)...this means that we need to scan backwards until we + * hit the end-of-central-dir signature. We can then sanity check that + * the comment was as big as it should be to make sure we're in the + * right place. The comment length field is 16 bits, so we can stop + * searching for that signature after a little more than 64k at most, + * and call it a corrupted zipfile. + */ + + if (sizeof (buf) < filelen) + { + filepos = filelen - sizeof (buf); + maxread = sizeof (buf); + } /* if */ + else + { + filepos = 0; + maxread = (PHYSFS_uint32) filelen; + } /* else */ + + while ((totalread < filelen) && (totalread < 65557)) + { + BAIL_IF_MACRO(!__PHYSFS_platformSeek(in, filepos), NULL, -1); + + /* make sure we catch a signature between buffers. */ + if (totalread != 0) + { + if (__PHYSFS_platformRead(in, buf, maxread - 4, 1) != 1) + return(-1); + *((PHYSFS_uint32 *) (&buf[maxread - 4])) = extra; + totalread += maxread - 4; + } /* if */ + else + { + if (__PHYSFS_platformRead(in, buf, maxread, 1) != 1) + return(-1); + totalread += maxread; + } /* else */ + + PHYSFS_uint32 *pPhysBuf = (PHYSFS_uint32 *) (&buf[0]); + extra = *pPhysBuf; + + for (i = maxread - 4; i > 0; i--) + { + if ((buf[i + 0] == 0x50) && + (buf[i + 1] == 0x4B) && + (buf[i + 2] == 0x05) && + (buf[i + 3] == 0x06) ) + { + found = 1; /* that's the signature! */ + break; + } /* if */ + } /* for */ + + if (found) + break; + + filepos -= (maxread - 4); + if (filepos < 0) + filepos = 0; + } /* while */ + + BAIL_IF_MACRO(!found, ERR_NOT_AN_ARCHIVE, -1); + + if (len != NULL) + *len = filelen; + + return(filepos + i); +} /* zip_find_end_of_central_dir */ + + +#if !__MOJOSETUP__ +static int ZIP_isArchive(const char *filename, int forWriting) +{ + PHYSFS_uint32 sig; + int retval = 0; + void *in; + + in = __PHYSFS_platformOpenRead(filename); + BAIL_IF_MACRO(in == NULL, NULL, 0); + + /* + * The first thing in a zip file might be the signature of the + * first local file record, so it makes for a quick determination. + */ + if (readui32(in, &sig)) + { + retval = (sig == ZIP_LOCAL_FILE_SIG); + if (!retval) + { + /* + * No sig...might be a ZIP with data at the start + * (a self-extracting executable, etc), so we'll have to do + * it the hard way... + */ + retval = (zip_find_end_of_central_dir(in, NULL) != -1); + } /* if */ + } /* if */ + + __PHYSFS_platformClose(in); + return(retval); +} /* ZIP_isArchive */ +#endif + +static void zip_free_entries(ZIPentry *entries, PHYSFS_uint32 max) +{ + PHYSFS_uint32 i; + for (i = 0; i < max; i++) + { + ZIPentry *entry = &entries[i]; + if (entry->name != NULL) + allocator.Free(entry->name); + #if __MOJOSETUP__ + if (entry->linkdest != NULL) + allocator.Free(entry->linkdest); + #endif + } /* for */ + + allocator.Free(entries); +} /* zip_free_entries */ + + +/* + * This will find the ZIPentry associated with a path in platform-independent + * notation. Directories don't have ZIPentries associated with them, but + * (*isDir) will be set to non-zero if a dir was hit. + */ +static ZIPentry *zip_find_entry(ZIPinfo *info, const char *path, int *isDir) +{ + ZIPentry *a = info->entries; + PHYSFS_sint32 pathlen = strlen(path); + PHYSFS_sint32 lo = 0; + PHYSFS_sint32 hi = (PHYSFS_sint32) (info->entryCount - 1); + PHYSFS_sint32 middle; + const char *thispath = NULL; + int rc; + + while (lo <= hi) + { + middle = lo + ((hi - lo) / 2); + thispath = a[middle].name; + rc = strncmp(path, thispath, pathlen); + + if (rc > 0) + lo = middle + 1; + + else if (rc < 0) + hi = middle - 1; + + else /* substring match...might be dir or entry or nothing. */ + { + if (isDir != NULL) + { + *isDir = (thispath[pathlen] == '/'); + if (*isDir) + return(NULL); + } /* if */ + + if (thispath[pathlen] == '\0') /* found entry? */ + return(&a[middle]); + else + hi = middle - 1; /* adjust search params, try again. */ + } /* if */ + } /* while */ + + if (isDir != NULL) + *isDir = 0; + + BAIL_MACRO(ERR_NO_SUCH_FILE, NULL); +} /* zip_find_entry */ + + +/* Convert paths from old, buggy DOS zippers... */ +static void zip_convert_dos_path(ZIPentry *entry, char *path) +{ + PHYSFS_uint8 hosttype = (PHYSFS_uint8) ((entry->version >> 8) & 0xFF); + if (hosttype == 0) /* FS_FAT_ */ + { + while (*path) + { + if (*path == '\\') + *path = '/'; + path++; + } /* while */ + } /* if */ +} /* zip_convert_dos_path */ + + +static void zip_expand_symlink_path(char *path) +{ + char *ptr = path; + char *prevptr = path; + + while (1) + { + ptr = strchr(ptr, '/'); + if (ptr == NULL) + break; + + if (*(ptr + 1) == '.') + { + if (*(ptr + 2) == '/') + { + /* current dir in middle of string: ditch it. */ + memmove(ptr, ptr + 2, strlen(ptr + 2) + 1); + } /* else if */ + + else if (*(ptr + 2) == '\0') + { + /* current dir at end of string: ditch it. */ + *ptr = '\0'; + } /* else if */ + + else if (*(ptr + 2) == '.') + { + if (*(ptr + 3) == '/') + { + /* parent dir in middle: move back one, if possible. */ + memmove(prevptr, ptr + 4, strlen(ptr + 4) + 1); + ptr = prevptr; + while (prevptr != path) + { + prevptr--; + if (*prevptr == '/') + { + prevptr++; + break; + } /* if */ + } /* while */ + } /* if */ + + if (*(ptr + 3) == '\0') + { + /* parent dir at end: move back one, if possible. */ + *prevptr = '\0'; + } /* if */ + } /* if */ + } /* if */ + else + { + prevptr = ptr; + } /* else */ + } /* while */ +} /* zip_expand_symlink_path */ + +/* (forward reference: zip_follow_symlink and zip_resolve call each other.) */ +static int zip_resolve(void *in, ZIPinfo *info, ZIPentry *entry); + +/* + * Look for the entry named by (path). If it exists, resolve it, and return + * a pointer to that entry. If it's another symlink, keep resolving until you + * hit a real file and then return a pointer to the final non-symlink entry. + * If there's a problem, return NULL. (path) is always free()'d by this + * function. + */ +static ZIPentry *zip_follow_symlink(void *in, ZIPinfo *info, char *path) +{ + ZIPentry *entry; + + zip_expand_symlink_path(path); + entry = zip_find_entry(info, path, NULL); + if (entry != NULL) + { + if (!zip_resolve(in, info, entry)) /* recursive! */ + entry = NULL; + else + { + if (entry->symlink != NULL) + entry = entry->symlink; + } /* else */ + } /* if */ + + allocator.Free(path); + return(entry); +} /* zip_follow_symlink */ + + +static int zip_resolve_symlink(void *in, ZIPinfo *info, ZIPentry *entry) +{ + char *path; + PHYSFS_uint32 size = entry->uncompressed_size; + int rc = 0; + + /* + * We've already parsed the local file header of the symlink at this + * point. Now we need to read the actual link from the file data and + * follow it. + */ + + BAIL_IF_MACRO(!__PHYSFS_platformSeek(in, entry->offset), NULL, 0); + + path = (char *) allocator.Malloc(size + 1); + BAIL_IF_MACRO(path == NULL, ERR_OUT_OF_MEMORY, 0); + + if (entry->compression_method == COMPMETH_NONE) + rc = (__PHYSFS_platformRead(in, path, size, 1) == 1); + + else /* symlink target path is compressed... */ + { + z_stream stream; + PHYSFS_uint32 compsize = entry->compressed_size; + PHYSFS_uint8 *compressed = (PHYSFS_uint8 *) allocator.Malloc(compsize); + if (compressed != NULL) + { + if (__PHYSFS_platformRead(in, compressed, compsize, 1) == 1) + { + initializeZStream(&stream); + stream.next_in = compressed; + stream.avail_in = compsize; + stream.next_out = (unsigned char *) path; + stream.avail_out = size; + if (zlib_err(inflateInit2(&stream, -MAX_WBITS)) == Z_OK) + { + rc = zlib_err(inflate(&stream, Z_FINISH)); + inflateEnd(&stream); + + /* both are acceptable outcomes... */ + rc = ((rc == Z_OK) || (rc == Z_STREAM_END)); + } /* if */ + } /* if */ + allocator.Free(compressed); + } /* if */ + } /* else */ + + if (!rc) + allocator.Free(path); + else + { + path[entry->uncompressed_size] = '\0'; /* null-terminate it. */ + zip_convert_dos_path(entry, path); + #if __MOJOSETUP__ + entry->linkdest = xstrdup(path); + #endif + entry->symlink = zip_follow_symlink(in, info, path); + } /* else */ + + return(entry->symlink != NULL); +} /* zip_resolve_symlink */ + + +/* + * Parse the local file header of an entry, and update entry->offset. + */ +static int zip_parse_local(void *in, ZIPentry *entry) +{ + PHYSFS_uint32 ui32; + PHYSFS_uint16 ui16; + PHYSFS_uint16 fnamelen; + PHYSFS_uint16 extralen; + + /* + * crc and (un)compressed_size are always zero if this is a "JAR" + * archive created with Sun's Java tools, apparently. We only + * consider this archive corrupted if those entries don't match and + * aren't zero. That seems to work well. + */ + + BAIL_IF_MACRO(!__PHYSFS_platformSeek(in, entry->offset), NULL, 0); + BAIL_IF_MACRO(!readui32(in, &ui32), NULL, 0); + BAIL_IF_MACRO(ui32 != ZIP_LOCAL_FILE_SIG, ERR_CORRUPTED, 0); + BAIL_IF_MACRO(!readui16(in, &ui16), NULL, 0); + BAIL_IF_MACRO(ui16 != entry->version_needed, ERR_CORRUPTED, 0); + BAIL_IF_MACRO(!readui16(in, &ui16), NULL, 0); /* general bits. */ + BAIL_IF_MACRO(!readui16(in, &ui16), NULL, 0); + BAIL_IF_MACRO(ui16 != entry->compression_method, ERR_CORRUPTED, 0); + BAIL_IF_MACRO(!readui32(in, &ui32), NULL, 0); /* date/time */ + BAIL_IF_MACRO(!readui32(in, &ui32), NULL, 0); + BAIL_IF_MACRO(ui32 && (ui32 != entry->crc), ERR_CORRUPTED, 0); + BAIL_IF_MACRO(!readui32(in, &ui32), NULL, 0); + BAIL_IF_MACRO(ui32 && (ui32 != entry->compressed_size), ERR_CORRUPTED, 0); + BAIL_IF_MACRO(!readui32(in, &ui32), NULL, 0); + BAIL_IF_MACRO(ui32 && (ui32 != entry->uncompressed_size),ERR_CORRUPTED,0); + BAIL_IF_MACRO(!readui16(in, &fnamelen), NULL, 0); + BAIL_IF_MACRO(!readui16(in, &extralen), NULL, 0); + + entry->offset += fnamelen + extralen + 30; + return(1); +} /* zip_parse_local */ + + +static int zip_resolve(void *in, ZIPinfo *info, ZIPentry *entry) +{ + int retval = 1; + ZipResolveType resolve_type = entry->resolved; + + /* Don't bother if we've failed to resolve this entry before. */ + BAIL_IF_MACRO(resolve_type == ZIP_BROKEN_FILE, ERR_CORRUPTED, 0); + BAIL_IF_MACRO(resolve_type == ZIP_BROKEN_SYMLINK, ERR_CORRUPTED, 0); + + /* uhoh...infinite symlink loop! */ + BAIL_IF_MACRO(resolve_type == ZIP_RESOLVING, ERR_SYMLINK_LOOP, 0); + + /* + * We fix up the offset to point to the actual data on the + * first open, since we don't want to seek across the whole file on + * archive open (can be SLOW on large, CD-stored files), but we + * need to check the local file header...not just for corruption, + * but since it stores offset info the central directory does not. + */ + if (resolve_type != ZIP_RESOLVED) + { + entry->resolved = ZIP_RESOLVING; + + retval = zip_parse_local(in, entry); + if (retval) + { + /* + * If it's a symlink, find the original file. This will cause + * resolution of other entries (other symlinks and, eventually, + * the real file) if all goes well. + */ + if (resolve_type == ZIP_UNRESOLVED_SYMLINK) + retval = zip_resolve_symlink(in, info, entry); + } /* if */ + + if (resolve_type == ZIP_UNRESOLVED_SYMLINK) + entry->resolved = ((retval) ? ZIP_RESOLVED : ZIP_BROKEN_SYMLINK); + else if (resolve_type == ZIP_UNRESOLVED_FILE) + entry->resolved = ((retval) ? ZIP_RESOLVED : ZIP_BROKEN_FILE); + } /* if */ + + return(retval); +} /* zip_resolve */ + + +static int zip_version_does_symlinks(PHYSFS_uint32 version) +{ + int retval = 0; + PHYSFS_uint8 hosttype = (PHYSFS_uint8) ((version >> 8) & 0xFF); + + switch (hosttype) + { + /* + * These are the platforms that can NOT build an archive with + * symlinks, according to the Info-ZIP project. + */ + case 0: /* FS_FAT_ */ + case 1: /* AMIGA_ */ + case 2: /* VMS_ */ + case 4: /* VM_CSM_ */ + case 6: /* FS_HPFS_ */ + case 11: /* FS_NTFS_ */ + case 14: /* FS_VFAT_ */ + case 13: /* ACORN_ */ + case 15: /* MVS_ */ + case 18: /* THEOS_ */ + break; /* do nothing. */ + + default: /* assume the rest to be unix-like. */ + retval = 1; + break; + } /* switch */ + + return(retval); +} /* zip_version_does_symlinks */ + + +static int zip_entry_is_symlink(const ZIPentry *entry) +{ + return((entry->resolved == ZIP_UNRESOLVED_SYMLINK) || + (entry->resolved == ZIP_BROKEN_SYMLINK) || + (entry->symlink)); +} /* zip_entry_is_symlink */ + + +static int zip_has_symlink_attr(ZIPentry *entry, PHYSFS_uint32 extern_attr) +{ + PHYSFS_uint16 xattr = ((extern_attr >> 16) & 0xFFFF); + + return ( + (zip_version_does_symlinks(entry->version)) && + (entry->uncompressed_size > 0) && + ((xattr & UNIX_FILETYPE_MASK) == UNIX_FILETYPE_SYMLINK) + ); +} /* zip_has_symlink_attr */ + + +static PHYSFS_sint64 zip_dos_time_to_physfs_time(PHYSFS_uint32 dostime) +{ +#ifdef _WIN32_WCE + /* We have no struct tm and no mktime right now. + FIXME: This should probably be fixed at some point. + */ + return -1; +#else + PHYSFS_uint32 dosdate; + struct tm unixtime; + memset(&unixtime, '\0', sizeof (unixtime)); + + dosdate = (PHYSFS_uint32) ((dostime >> 16) & 0xFFFF); + dostime &= 0xFFFF; + + /* dissect date */ + unixtime.tm_year = ((dosdate >> 9) & 0x7F) + 80; + unixtime.tm_mon = ((dosdate >> 5) & 0x0F) - 1; + unixtime.tm_mday = ((dosdate ) & 0x1F); + + /* dissect time */ + unixtime.tm_hour = ((dostime >> 11) & 0x1F); + unixtime.tm_min = ((dostime >> 5) & 0x3F); + unixtime.tm_sec = ((dostime << 1) & 0x3E); + + /* let mktime calculate daylight savings time. */ + unixtime.tm_isdst = -1; + + return((PHYSFS_sint64) mktime(&unixtime)); +#endif +} /* zip_dos_time_to_physfs_time */ + + +static int zip_load_entry(void *in, ZIPentry *entry, PHYSFS_uint32 ofs_fixup) +{ + PHYSFS_uint16 fnamelen, extralen, commentlen; + PHYSFS_uint32 external_attr; + PHYSFS_uint16 ui16; + PHYSFS_uint32 ui32; + PHYSFS_sint64 si64; + + /* sanity check with central directory signature... */ + BAIL_IF_MACRO(!readui32(in, &ui32), NULL, 0); + BAIL_IF_MACRO(ui32 != ZIP_CENTRAL_DIR_SIG, ERR_CORRUPTED, 0); + + /* Get the pertinent parts of the record... */ + BAIL_IF_MACRO(!readui16(in, &entry->version), NULL, 0); + BAIL_IF_MACRO(!readui16(in, &entry->version_needed), NULL, 0); + BAIL_IF_MACRO(!readui16(in, &ui16), NULL, 0); /* general bits */ + BAIL_IF_MACRO(!readui16(in, &entry->compression_method), NULL, 0); + BAIL_IF_MACRO(!readui32(in, &ui32), NULL, 0); + entry->last_mod_time = zip_dos_time_to_physfs_time(ui32); + BAIL_IF_MACRO(!readui32(in, &entry->crc), NULL, 0); + BAIL_IF_MACRO(!readui32(in, &entry->compressed_size), NULL, 0); + BAIL_IF_MACRO(!readui32(in, &entry->uncompressed_size), NULL, 0); + BAIL_IF_MACRO(!readui16(in, &fnamelen), NULL, 0); + BAIL_IF_MACRO(!readui16(in, &extralen), NULL, 0); + BAIL_IF_MACRO(!readui16(in, &commentlen), NULL, 0); + BAIL_IF_MACRO(!readui16(in, &ui16), NULL, 0); /* disk number start */ + BAIL_IF_MACRO(!readui16(in, &ui16), NULL, 0); /* internal file attribs */ + BAIL_IF_MACRO(!readui32(in, &external_attr), NULL, 0); + BAIL_IF_MACRO(!readui32(in, &entry->offset), NULL, 0); + entry->offset += ofs_fixup; + + #if __MOJOSETUP__ + entry->perms = (external_attr >> 16) & 0xFFFF; + entry->linkdest = NULL; + #endif + + entry->symlink = NULL; /* will be resolved later, if necessary. */ + entry->resolved = (zip_has_symlink_attr(entry, external_attr)) ? + ZIP_UNRESOLVED_SYMLINK : ZIP_UNRESOLVED_FILE; + + entry->name = (char *) allocator.Malloc(fnamelen + 1); + BAIL_IF_MACRO(entry->name == NULL, ERR_OUT_OF_MEMORY, 0); + if (__PHYSFS_platformRead(in, entry->name, fnamelen, 1) != 1) + goto zip_load_entry_puked; + + entry->name[fnamelen] = '\0'; /* null-terminate the filename. */ + zip_convert_dos_path(entry, entry->name); + + si64 = __PHYSFS_platformTell(in); + if (si64 == -1) + goto zip_load_entry_puked; + + /* seek to the start of the next entry in the central directory... */ + if (!__PHYSFS_platformSeek(in, si64 + extralen + commentlen)) + goto zip_load_entry_puked; + + return(1); /* success. */ + +zip_load_entry_puked: + allocator.Free(entry->name); + return(0); /* failure. */ +} /* zip_load_entry */ + + +static int zip_entry_cmp(void *_a, PHYSFS_uint32 one, PHYSFS_uint32 two) +{ + if (one != two) + { + const ZIPentry *a = (const ZIPentry *) _a; + return(strcmp(a[one].name, a[two].name)); + } /* if */ + + return 0; +} /* zip_entry_cmp */ + + +static void zip_entry_swap(void *_a, PHYSFS_uint32 one, PHYSFS_uint32 two) +{ + if (one != two) + { + ZIPentry tmp; + ZIPentry *first = &(((ZIPentry *) _a)[one]); + ZIPentry *second = &(((ZIPentry *) _a)[two]); + memcpy(&tmp, first, sizeof (ZIPentry)); + memcpy(first, second, sizeof (ZIPentry)); + memcpy(second, &tmp, sizeof (ZIPentry)); + } /* if */ +} /* zip_entry_swap */ + + +static int zip_load_entries(void *in, ZIPinfo *info, + PHYSFS_uint32 data_ofs, PHYSFS_uint32 central_ofs) +{ + PHYSFS_uint32 max = info->entryCount; + PHYSFS_uint32 i; + + BAIL_IF_MACRO(!__PHYSFS_platformSeek(in, central_ofs), NULL, 0); + + info->entries = (ZIPentry *) allocator.Malloc(sizeof (ZIPentry) * max); + BAIL_IF_MACRO(info->entries == NULL, ERR_OUT_OF_MEMORY, 0); + + for (i = 0; i < max; i++) + { + if (!zip_load_entry(in, &info->entries[i], data_ofs)) + { + zip_free_entries(info->entries, i); + return(0); + } /* if */ + } /* for */ + + __PHYSFS_sort(info->entries, max, zip_entry_cmp, zip_entry_swap); + return(1); +} /* zip_load_entries */ + + +static int zip_parse_end_of_central_dir(void *in, ZIPinfo *info, + PHYSFS_uint32 *data_start, + PHYSFS_uint32 *central_dir_ofs) +{ + PHYSFS_uint32 ui32; + PHYSFS_uint16 ui16; + PHYSFS_sint64 len = 0; + PHYSFS_sint64 pos; + + /* find the end-of-central-dir record, and seek to it. */ + pos = zip_find_end_of_central_dir(in, &len); + BAIL_IF_MACRO(pos == -1, NULL, 0); + BAIL_IF_MACRO(!__PHYSFS_platformSeek(in, pos), NULL, 0); + + /* check signature again, just in case. */ + BAIL_IF_MACRO(!readui32(in, &ui32), NULL, 0); + BAIL_IF_MACRO(ui32 != ZIP_END_OF_CENTRAL_DIR_SIG, ERR_NOT_AN_ARCHIVE, 0); + + /* number of this disk */ + BAIL_IF_MACRO(!readui16(in, &ui16), NULL, 0); + BAIL_IF_MACRO(ui16 != 0, ERR_UNSUPPORTED_ARCHIVE, 0); + + /* number of the disk with the start of the central directory */ + BAIL_IF_MACRO(!readui16(in, &ui16), NULL, 0); + BAIL_IF_MACRO(ui16 != 0, ERR_UNSUPPORTED_ARCHIVE, 0); + + /* total number of entries in the central dir on this disk */ + BAIL_IF_MACRO(!readui16(in, &ui16), NULL, 0); + + /* total number of entries in the central dir */ + BAIL_IF_MACRO(!readui16(in, &info->entryCount), NULL, 0); + BAIL_IF_MACRO(ui16 != info->entryCount, ERR_UNSUPPORTED_ARCHIVE, 0); + + /* size of the central directory */ + BAIL_IF_MACRO(!readui32(in, &ui32), NULL, 0); + + /* offset of central directory */ + BAIL_IF_MACRO(!readui32(in, central_dir_ofs), NULL, 0); + BAIL_IF_MACRO(pos < *central_dir_ofs + ui32, ERR_UNSUPPORTED_ARCHIVE, 0); + + /* + * For self-extracting archives, etc, there's crapola in the file + * before the zipfile records; we calculate how much data there is + * prepended by determining how far the central directory offset is + * from where it is supposed to be (start of end-of-central-dir minus + * sizeof central dir)...the difference in bytes is how much arbitrary + * data is at the start of the physical file. + */ + *data_start = (PHYSFS_uint32) (pos - (*central_dir_ofs + ui32)); + + /* Now that we know the difference, fix up the central dir offset... */ + *central_dir_ofs += *data_start; + + /* zipfile comment length */ + BAIL_IF_MACRO(!readui16(in, &ui16), NULL, 0); + + /* + * Make sure that the comment length matches to the end of file... + * If it doesn't, we're either in the wrong part of the file, or the + * file is corrupted, but we give up either way. + */ + BAIL_IF_MACRO((pos + 22 + ui16) != len, ERR_UNSUPPORTED_ARCHIVE, 0); + + return(1); /* made it. */ +} /* zip_parse_end_of_central_dir */ + + +#if __MOJOSETUP__ +static ZIPinfo *zip_create_zipinfo(void *in, const char *name) +#else +static ZIPinfo *zip_create_zipinfo(const char *name) +#endif +{ + char *ptr; + ZIPinfo *info = (ZIPinfo *) allocator.Malloc(sizeof (ZIPinfo)); + BAIL_IF_MACRO(info == NULL, ERR_OUT_OF_MEMORY, 0); + memset(info, '\0', sizeof (ZIPinfo)); + + ptr = (char *) allocator.Malloc(strlen(name) + 1); + if (ptr == NULL) + { + allocator.Free(info); + BAIL_MACRO(ERR_OUT_OF_MEMORY, NULL); + } /* if */ + + info->archiveName = ptr; + strcpy(info->archiveName, name); +#if __MOJOSETUP__ + info->io = in; + info->enumIndex = -1; +#endif + return(info); +} /* zip_create_zipinfo */ + + +#if __MOJOSETUP__ +static void *ZIP_openArchive(void *in, const char *name, int forWriting) +#else +static void *ZIP_openArchive(const char *name, int forWriting) +#endif +{ +#if !__MOJOSETUP__ + void *in = NULL; +#endif + + ZIPinfo *info = NULL; + PHYSFS_uint32 data_start; + PHYSFS_uint32 cent_dir_ofs; + + BAIL_IF_MACRO(forWriting, ERR_ARC_IS_READ_ONLY, NULL); + +#if __MOJOSETUP__ + if ((info = zip_create_zipinfo(in, name)) == NULL) + goto zip_openarchive_failed; +#else + if ((in = __PHYSFS_platformOpenRead(name)) == NULL) + goto zip_openarchive_failed; + if ((info = zip_create_zipinfo(name)) == NULL) + goto zip_openarchive_failed; +#endif + + if (!zip_parse_end_of_central_dir(in, info, &data_start, ¢_dir_ofs)) + goto zip_openarchive_failed; + +#if __MOJOSETUP__ + info->offset = (int64) data_start; +#endif + + if (!zip_load_entries(in, info, data_start, cent_dir_ofs)) + goto zip_openarchive_failed; + +#if !__MOJOSETUP__ + __PHYSFS_platformClose(in); +#endif + + return(info); + +zip_openarchive_failed: + if (info != NULL) + { + if (info->archiveName != NULL) + allocator.Free(info->archiveName); + allocator.Free(info); + } /* if */ + +#if !__MOJOSETUP__ + if (in != NULL) + __PHYSFS_platformClose(in); +#endif + + return(NULL); +} /* ZIP_openArchive */ + + +#if !__MOJOSETUP__ +static PHYSFS_sint32 zip_find_start_of_dir(ZIPinfo *info, const char *path, + int stop_on_first_find) +{ + PHYSFS_sint32 lo = 0; + PHYSFS_sint32 hi = (PHYSFS_sint32) (info->entryCount - 1); + PHYSFS_sint32 middle; + PHYSFS_uint32 dlen = strlen(path); + PHYSFS_sint32 retval = -1; + const char *name; + int rc; + + if (*path == '\0') /* root dir? */ + return(0); + + if ((dlen > 0) && (path[dlen - 1] == '/')) /* ignore trailing slash. */ + dlen--; + + while (lo <= hi) + { + middle = lo + ((hi - lo) / 2); + name = info->entries[middle].name; + rc = strncmp(path, name, dlen); + if (rc == 0) + { + char ch = name[dlen]; + if ('/' < ch) /* make sure this isn't just a substr match. */ + rc = -1; + else if ('/' > ch) + rc = 1; + else + { + if (stop_on_first_find) /* Just checking dir's existance? */ + return(middle); + + if (name[dlen + 1] == '\0') /* Skip initial dir entry. */ + return(middle + 1); + + /* there might be more entries earlier in the list. */ + retval = middle; + hi = middle - 1; + } /* else */ + } /* if */ + + if (rc > 0) + lo = middle + 1; + else + hi = middle - 1; + } /* while */ + + return(retval); +} /* zip_find_start_of_dir */ + + +/* + * Moved to seperate function so we can use alloca then immediately throw + * away the allocated stack space... + */ +static void doEnumCallback(PHYSFS_EnumFilesCallback cb, void *callbackdata, + const char *odir, const char *str, PHYSFS_sint32 ln) +{ + char *newstr = alloca(ln + 1); + if (newstr == NULL) + return; + + memcpy(newstr, str, ln); + newstr[ln] = '\0'; + cb(callbackdata, odir, newstr); +} /* doEnumCallback */ + + +static void ZIP_enumerateFiles(dvoid *opaque, const char *dname, + int omitSymLinks, PHYSFS_EnumFilesCallback cb, + const char *origdir, void *callbackdata) +{ + ZIPinfo *info = ((ZIPinfo *) opaque); + PHYSFS_sint32 dlen, dlen_inc, max, i; + + i = zip_find_start_of_dir(info, dname, 0); + if (i == -1) /* no such directory. */ + return; + + dlen = strlen(dname); + if ((dlen > 0) && (dname[dlen - 1] == '/')) /* ignore trailing slash. */ + dlen--; + + dlen_inc = ((dlen > 0) ? 1 : 0) + dlen; + max = (PHYSFS_sint32) info->entryCount; + while (i < max) + { + char *e = info->entries[i].name; + if ((dlen) && ((strncmp(e, dname, dlen) != 0) || (e[dlen] != '/'))) + break; /* past end of this dir; we're done. */ + + if ((omitSymLinks) && (zip_entry_is_symlink(&info->entries[i]))) + i++; + else + { + char *add = e + dlen_inc; + char *ptr = strchr(add, '/'); + PHYSFS_sint32 ln = (PHYSFS_sint32) ((ptr) ? ptr-add : strlen(add)); + doEnumCallback(cb, callbackdata, origdir, add, ln); + ln += dlen_inc; /* point past entry to children... */ + + /* increment counter and skip children of subdirs... */ + while ((++i < max) && (ptr != NULL)) + { + char *e_new = info->entries[i].name; + if ((strncmp(e, e_new, ln) != 0) || (e_new[ln] != '/')) + break; + } /* while */ + } /* else */ + } /* while */ +} /* ZIP_enumerateFiles */ + + +static int ZIP_exists(dvoid *opaque, const char *name) +{ + int isDir; + ZIPinfo *info = (ZIPinfo *) opaque; + ZIPentry *entry = zip_find_entry(info, name, &isDir); + return((entry != NULL) || (isDir)); +} /* ZIP_exists */ + + +static PHYSFS_sint64 ZIP_getLastModTime(dvoid *opaque, + const char *name, + int *fileExists) +{ + int isDir; + ZIPinfo *info = (ZIPinfo *) opaque; + ZIPentry *entry = zip_find_entry(info, name, &isDir); + + *fileExists = ((isDir) || (entry != NULL)); + if (isDir) + return(1); /* Best I can do for a dir... */ + + BAIL_IF_MACRO(entry == NULL, NULL, -1); + return(entry->last_mod_time); +} /* ZIP_getLastModTime */ + + +static int ZIP_isDirectory(dvoid *opaque, const char *name, int *fileExists) +{ + ZIPinfo *info = (ZIPinfo *) opaque; + int isDir; + ZIPentry *entry = zip_find_entry(info, name, &isDir); + + *fileExists = ((isDir) || (entry != NULL)); + if (isDir) + return(1); /* definitely a dir. */ + + /* Follow symlinks. This means we might need to resolve entries. */ + BAIL_IF_MACRO(entry == NULL, ERR_NO_SUCH_FILE, 0); + + if (entry->resolved == ZIP_UNRESOLVED_SYMLINK) /* gotta resolve it. */ + { + int rc; +#if __MOJOSETUP__ + rc = zip_resolve(info->io, info, entry); +#else + void *in = __PHYSFS_platformOpenRead(info->archiveName); + BAIL_IF_MACRO(in == NULL, NULL, 0); + rc = zip_resolve(in, info, entry); + __PHYSFS_platformClose(in); +#endif + if (!rc) + return(0); + } /* if */ + + BAIL_IF_MACRO(entry->resolved == ZIP_BROKEN_SYMLINK, NULL, 0); + BAIL_IF_MACRO(entry->symlink == NULL, ERR_NOT_A_DIR, 0); + + return(zip_find_start_of_dir(info, entry->symlink->name, 1) >= 0); +} /* ZIP_isDirectory */ + + +static int ZIP_isSymLink(dvoid *opaque, const char *name, int *fileExists) +{ + int isDir; + ZIPentry *entry = zip_find_entry((ZIPinfo *) opaque, name, &isDir); + *fileExists = ((isDir) || (entry != NULL)); + BAIL_IF_MACRO(entry == NULL, NULL, 0); + return(zip_entry_is_symlink(entry)); +} /* ZIP_isSymLink */ +#endif + +static void *zip_get_file_handle(const char *fn, ZIPinfo *inf, ZIPentry *entry) +{ + int success; +#if __MOJOSETUP__ + MojoInput *io = (MojoInput *) inf->io; + void *retval = io->duplicate(io); +#else + void *retval = __PHYSFS_platformOpenRead(fn); +#endif + BAIL_IF_MACRO(retval == NULL, NULL, NULL); + + success = zip_resolve(retval, inf, entry); + if (success) + { + PHYSFS_sint64 offset; + offset = ((entry->symlink) ? entry->symlink->offset : entry->offset); + success = __PHYSFS_platformSeek(retval, offset); + } /* if */ + + if (!success) + { + __PHYSFS_platformClose(retval); + retval = NULL; + } /* if */ + + return(retval); +} /* zip_get_file_handle */ + + +static fvoid *ZIP_openRead(dvoid *opaque, const char *fnm, int *fileExists) +{ + ZIPinfo *info = (ZIPinfo *) opaque; + ZIPentry *entry = zip_find_entry(info, fnm, NULL); + ZIPfileinfo *finfo = NULL; + void *in; + + *fileExists = (entry != NULL); + BAIL_IF_MACRO(entry == NULL, NULL, NULL); + + in = zip_get_file_handle(info->archiveName, info, entry); + BAIL_IF_MACRO(in == NULL, NULL, NULL); + + finfo = (ZIPfileinfo *) allocator.Malloc(sizeof (ZIPfileinfo)); + if (finfo == NULL) + { + __PHYSFS_platformClose(in); + BAIL_MACRO(ERR_OUT_OF_MEMORY, NULL); + } /* if */ + + memset(finfo, '\0', sizeof (ZIPfileinfo)); + finfo->handle = in; + finfo->entry = ((entry->symlink != NULL) ? entry->symlink : entry); + initializeZStream(&finfo->stream); + if (finfo->entry->compression_method != COMPMETH_NONE) + { + if (zlib_err(inflateInit2(&finfo->stream, -MAX_WBITS)) != Z_OK) + { + ZIP_fileClose(finfo); + return(NULL); + } /* if */ + + finfo->buffer = (PHYSFS_uint8 *) allocator.Malloc(ZIP_READBUFSIZE); + if (finfo->buffer == NULL) + { + ZIP_fileClose(finfo); + BAIL_MACRO(ERR_OUT_OF_MEMORY, NULL); + } /* if */ + } /* if */ + + #if __MOJOSETUP__ + finfo->archive = info; + #endif + + return(finfo); +} /* ZIP_openRead */ + + +#if !__MOJOSETUP__ +static fvoid *ZIP_openWrite(dvoid *opaque, const char *filename) +{ + BAIL_MACRO(ERR_NOT_SUPPORTED, NULL); +} /* ZIP_openWrite */ + + +static fvoid *ZIP_openAppend(dvoid *opaque, const char *filename) +{ + BAIL_MACRO(ERR_NOT_SUPPORTED, NULL); +} /* ZIP_openAppend */ +#endif + + +static void ZIP_dirClose(dvoid *opaque) +{ + ZIPinfo *zi = (ZIPinfo *) (opaque); + zip_free_entries(zi->entries, zi->entryCount); + allocator.Free(zi->archiveName); + allocator.Free(zi); +} /* ZIP_dirClose */ + + +#if !__MOJOSETUP__ +static int ZIP_remove(dvoid *opaque, const char *name) +{ + BAIL_MACRO(ERR_NOT_SUPPORTED, 0); +} /* ZIP_remove */ + + +static int ZIP_mkdir(dvoid *opaque, const char *name) +{ + BAIL_MACRO(ERR_NOT_SUPPORTED, 0); +} /* ZIP_mkdir */ + + +const PHYSFS_ArchiveInfo __PHYSFS_ArchiveInfo_ZIP = +{ + "ZIP", + ZIP_ARCHIVE_DESCRIPTION, + "Ryan C. Gordon ", + "http://icculus.org/physfs/", +}; + + +const PHYSFS_Archiver __PHYSFS_Archiver_ZIP = +{ + &__PHYSFS_ArchiveInfo_ZIP, + ZIP_isArchive, /* isArchive() method */ + ZIP_openArchive, /* openArchive() method */ + ZIP_enumerateFiles, /* enumerateFiles() method */ + ZIP_exists, /* exists() method */ + ZIP_isDirectory, /* isDirectory() method */ + ZIP_isSymLink, /* isSymLink() method */ + ZIP_getLastModTime, /* getLastModTime() method */ + ZIP_openRead, /* openRead() method */ + ZIP_openWrite, /* openWrite() method */ + ZIP_openAppend, /* openAppend() method */ + ZIP_remove, /* remove() method */ + ZIP_mkdir, /* mkdir() method */ + ZIP_dirClose, /* dirClose() method */ + ZIP_read, /* read() method */ + ZIP_write, /* write() method */ + ZIP_eof, /* eof() method */ + ZIP_tell, /* tell() method */ + ZIP_seek, /* seek() method */ + ZIP_fileLength, /* fileLength() method */ + ZIP_fileClose /* fileClose() method */ +}; + +#else // Glue from MojoSetup to PhysicsFS follows... + + +// MojoInput implementation... + +static boolean MojoInput_zip_ready(MojoInput *io) +{ + return true; // !!! FIXME: ready if there are bytes uncompressed. +} // MojoInput_zip_ready + +static int64 MojoInput_zip_read(MojoInput *io, void *buf, uint32 bufsize) +{ + return ZIP_read(io->opaque, buf, 1, bufsize); +} // MojoInput_zip_read + +static boolean MojoInput_zip_seek(MojoInput *io, uint64 pos) +{ + return ((ZIP_seek(io->opaque, pos)) ? true : false); +} // MojoInput_zip_seek + +static int64 MojoInput_zip_tell(MojoInput *io) +{ + return ZIP_tell(io->opaque); +} // MojoInput_zip_tell + +static int64 MojoInput_zip_length(MojoInput *io) +{ + return ZIP_fileLength(io->opaque); +} // MojoInput_zip_length + +static MojoInput *buildZipMojoInput(ZIPinfo *info, const char *fullpath); + +static MojoInput *MojoInput_zip_duplicate(MojoInput *io) +{ + ZIPfileinfo *finfo = (ZIPfileinfo *) io->opaque; + return buildZipMojoInput(finfo->archive, finfo->entry->name); +} // MojoInput_zip_duplicate + +static void MojoInput_zip_close(MojoInput *io) +{ + ZIP_fileClose(io->opaque); + free(io); +} // MojoInput_zip_close + + +// MojoArchive implementation... + +static int MojoArchive_zip_entry_is_symlink(ZIPinfo *info, ZIPentry *entry) +{ + if (entry->resolved == ZIP_UNRESOLVED_SYMLINK) /* gotta resolve it. */ + zip_resolve(info->io, info, entry); + return zip_entry_is_symlink(entry); +} // MojoArchive_zip_entry_is_symlink + + +static boolean MojoArchive_zip_enumerate(MojoArchive *ar) +{ + ZIPinfo *info = (ZIPinfo *) ar->opaque; + MojoArchive_resetEntry(&ar->prevEnum); + info->enumIndex = 0; + return true; +} // MojoArchive_zip_enumerate + + +static const MojoArchiveEntry *MojoArchive_zip_enumNext(MojoArchive *ar) +{ + ZIPinfo *info = (ZIPinfo *) ar->opaque; + MojoArchiveEntry *retval = NULL; + + MojoArchive_resetEntry(&ar->prevEnum); + + if ((info->enumIndex >= 0) && (info->enumIndex < info->entryCount)) + { + ZIPentry *entry = &info->entries[info->enumIndex]; + ar->prevEnum.filename = xstrdup(entry->name); + ar->prevEnum.filesize = entry->uncompressed_size; + ar->prevEnum.type = MOJOARCHIVE_ENTRY_FILE; + ar->prevEnum.perms = entry->perms; + + if (entry->name[strlen(entry->name) - 1] == '/') + ar->prevEnum.type = MOJOARCHIVE_ENTRY_DIR; + else if (MojoArchive_zip_entry_is_symlink(info, entry)) + { + ar->prevEnum.type = MOJOARCHIVE_ENTRY_SYMLINK; + ar->prevEnum.linkdest = xstrdup(entry->linkdest); + } // else if + + info->enumIndex++; + retval = &ar->prevEnum; + } // if + + return retval; +} // MojoArchive_zip_enumNext + + +static MojoInput *buildZipMojoInput(ZIPinfo *info, const char *fullpath) +{ + MojoInput *io = NULL; + int exists = 0; + void *opaque = ZIP_openRead(info, fullpath, &exists); + if (opaque == NULL) + return NULL; + + io = (MojoInput *) xmalloc(sizeof (MojoInput)); + io->ready = MojoInput_zip_ready; + io->read = MojoInput_zip_read; + io->seek = MojoInput_zip_seek; + io->tell = MojoInput_zip_tell; + io->length = MojoInput_zip_length; + io->duplicate = MojoInput_zip_duplicate; + io->close = MojoInput_zip_close; + io->opaque = opaque; + return io; +} // buildZipMojoInput + + +static MojoInput *MojoArchive_zip_openCurrentEntry(MojoArchive *ar) +{ + MojoInput *retval = NULL; + ZIPinfo *info = (ZIPinfo *) ar->opaque; + const int32 enumIndex = info->enumIndex - 1; + + if ((enumIndex >= 0) && (enumIndex < info->entryCount) && + (ar->prevEnum.type == MOJOARCHIVE_ENTRY_FILE)) + { + char *fullpath = (char *) xmalloc(strlen(ar->prevEnum.filename) + 1); + strcpy(fullpath, ar->prevEnum.filename); + retval = buildZipMojoInput(info, fullpath); + free(fullpath); + } // if + + return retval; +} // MojoArchive_zip_openCurrentEntry + + +static void MojoArchive_zip_close(MojoArchive *ar) +{ + ZIP_dirClose(ar->opaque); + ar->io->close(ar->io); + MojoArchive_resetEntry(&ar->prevEnum); + free(ar); +} // MojoArchive_zip_close + + +MojoArchive *MojoArchive_createZIP(MojoInput *io) +{ + MojoArchive *ar = NULL; + void *opaque = ZIP_openArchive(io, "", 0); + if (opaque == NULL) + return NULL; + + ar = (MojoArchive *) xmalloc(sizeof (MojoArchive)); + ar->enumerate = MojoArchive_zip_enumerate; + ar->enumNext = MojoArchive_zip_enumNext; + ar->openCurrentEntry = MojoArchive_zip_openCurrentEntry; + ar->close = MojoArchive_zip_close; + ar->offsetOfStart = ((const ZIPinfo *) opaque)->offset; + ar->opaque = opaque; + ar->io = io; + return ar; +} // MojoArchive_createZIP + +#endif // __MOJOSETUP__ + +#endif // SUPPORT_ZIP + +// end of archive_zip.c ... + diff --git a/mk/linux/mojosetup/build/CMakeCache.txt b/mk/linux/mojosetup/build/CMakeCache.txt new file mode 100644 index 00000000..9838b819 --- /dev/null +++ b/mk/linux/mojosetup/build/CMakeCache.txt @@ -0,0 +1,460 @@ +# This is the CMakeCache file. +# For build in directory: /home/softcoder/Code/mojosetup/build +# It was generated by CMake: /usr/bin/cmake +# You can edit this file to change values found and used by cmake. +# If you do not want to change any of the values, simply exit the editor. +# If you do want to change a value, simply edit, save, and exit the editor. +# The syntax for the file is as follows: +# KEY:TYPE=VALUE +# KEY is the name of a variable in the cache. +# TYPE is a hint to GUI's for the type of VALUE, DO NOT EDIT TYPE!. +# VALUE is the current value for the KEY. + +######################## +# EXTERNAL cache entries +######################## + +//Path to a program. +CMAKE_AR:FILEPATH=/usr/bin/ar + +//For backwards compatibility, what version of CMake commands and +// syntax should this version of CMake try to support. +CMAKE_BACKWARDS_COMPATIBILITY:STRING=2.4 + +//Choose the type of build, options are: None(CMAKE_CXX_FLAGS or +// CMAKE_C_FLAGS used) Debug Release RelWithDebInfo MinSizeRel. +CMAKE_BUILD_TYPE:STRING= + +//Enable/Disable color output during build. +CMAKE_COLOR_MAKEFILE:BOOL=ON + +//C compiler. +CMAKE_C_COMPILER:FILEPATH=/usr/bin/gcc + +//Flags used by the compiler during all build types. +CMAKE_C_FLAGS:STRING= + +//Flags used by the compiler during debug builds. +CMAKE_C_FLAGS_DEBUG:STRING=-g + +//Flags used by the compiler during release minsize builds. +CMAKE_C_FLAGS_MINSIZEREL:STRING=-Os -DNDEBUG + +//Flags used by the compiler during release builds (/MD /Ob1 /Oi +// /Ot /Oy /Gs will produce slightly less optimized but smaller +// files). +CMAKE_C_FLAGS_RELEASE:STRING=-O3 -DNDEBUG + +//Flags used by the compiler during Release with Debug Info builds. +CMAKE_C_FLAGS_RELWITHDEBINFO:STRING=-O2 -g + +//Flags used by the linker. +CMAKE_EXE_LINKER_FLAGS:STRING= + +//Flags used by the linker during debug builds. +CMAKE_EXE_LINKER_FLAGS_DEBUG:STRING= + +//Flags used by the linker during release minsize builds. +CMAKE_EXE_LINKER_FLAGS_MINSIZEREL:STRING= + +//Flags used by the linker during release builds. +CMAKE_EXE_LINKER_FLAGS_RELEASE:STRING= + +//Flags used by the linker during Release with Debug Info builds. +CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO:STRING= + +//Install path prefix, prepended onto install directories. +CMAKE_INSTALL_PREFIX:PATH=/usr/local + +//Path to a program. +CMAKE_LINKER:FILEPATH=/usr/bin/ld + +//Path to a program. +CMAKE_MAKE_PROGRAM:FILEPATH=/usr/bin/make + +//Flags used by the linker during the creation of modules. +CMAKE_MODULE_LINKER_FLAGS:STRING= + +//Flags used by the linker during debug builds. +CMAKE_MODULE_LINKER_FLAGS_DEBUG:STRING= + +//Flags used by the linker during release minsize builds. +CMAKE_MODULE_LINKER_FLAGS_MINSIZEREL:STRING= + +//Flags used by the linker during release builds. +CMAKE_MODULE_LINKER_FLAGS_RELEASE:STRING= + +//Flags used by the linker during Release with Debug Info builds. +CMAKE_MODULE_LINKER_FLAGS_RELWITHDEBINFO:STRING= + +//Path to a program. +CMAKE_NM:FILEPATH=/usr/bin/nm + +//Path to a program. +CMAKE_OBJCOPY:FILEPATH=/usr/bin/objcopy + +//Path to a program. +CMAKE_OBJDUMP:FILEPATH=/usr/bin/objdump + +//Value Computed by CMake +CMAKE_PROJECT_NAME:STATIC=MojoSetup + +//Path to a program. +CMAKE_RANLIB:FILEPATH=/usr/bin/ranlib + +//Flags used by the linker during the creation of dll's. +CMAKE_SHARED_LINKER_FLAGS:STRING= + +//Flags used by the linker during debug builds. +CMAKE_SHARED_LINKER_FLAGS_DEBUG:STRING= + +//Flags used by the linker during release minsize builds. +CMAKE_SHARED_LINKER_FLAGS_MINSIZEREL:STRING= + +//Flags used by the linker during release builds. +CMAKE_SHARED_LINKER_FLAGS_RELEASE:STRING= + +//Flags used by the linker during Release with Debug Info builds. +CMAKE_SHARED_LINKER_FLAGS_RELWITHDEBINFO:STRING= + +//Skip RPATH +CMAKE_SKIP_RPATH:BOOL=ON + +//Path to a program. +CMAKE_STRIP:FILEPATH=/usr/bin/strip + +//If true, cmake will use relative paths in makefiles and projects. +CMAKE_USE_RELATIVE_PATHS:BOOL=OFF + +//If this value is on, makefiles will be generated without the +// .SILENT directive, and all commands will be echoed to the console +// during the make. This is useful for debugging only. With Visual +// Studio IDE projects all commands are done without /nologo. +CMAKE_VERBOSE_MAKEFILE:BOOL=FALSE + +//Path to a file. +CURSES_CURSESW_H_PATH:PATH=/usr/include + +//Path to a file. +CURSES_CURSES_H_PATH:PATH=/usr/include + +//Path to a library. +CURSES_CURSES_LIBRARY:FILEPATH=CURSES_CURSES_LIBRARY-NOTFOUND + +//Path to a library. +CURSES_EXTRA_LIBRARY:FILEPATH=CURSES_EXTRA_LIBRARY-NOTFOUND + +//Path to a library. +CURSES_FORM_LIBRARY:FILEPATH=CURSES_FORM_LIBRARY-NOTFOUND + +//Path to a file. +CURSES_HAVE_CURSESW_H:FILEPATH=/usr/include/cursesw.h + +//Path to a file. +CURSES_HAVE_CURSES_H:FILEPATH=/usr/include/curses.h + +//The curses include path +CURSES_INCLUDE_PATH:FILEPATH=/usr/include /usr/include + +//The curses library +CURSES_LIBRARY:FILEPATH=CURSES_CURSES_LIBRARY-NOTFOUND + +//Path to a library. +CURSES_NCURSES_LIBRARY:FILEPATH=CURSES_NCURSES_LIBRARY-NOTFOUND + +//Single output directory for building all executables. +EXECUTABLE_OUTPUT_PATH:PATH= + +//The curses form library +FORM_LIBRARY:FILEPATH=CURSES_FORM_LIBRARY-NOTFOUND + +//Single output directory for building all libraries. +LIBRARY_OUTPUT_PATH:PATH= + +//Enable PCK support +MOJOSETUP_ARCHIVE_PCK:BOOL=OFF + +//Enable TAR support +MOJOSETUP_ARCHIVE_TAR:BOOL=ON + +//Enable TAR.BZ2 support +MOJOSETUP_ARCHIVE_TAR_BZ2:BOOL=ON + +//Enable TAR.GZ support +MOJOSETUP_ARCHIVE_TAR_GZ:BOOL=ON + +//Enable UZ2 support +MOJOSETUP_ARCHIVE_UZ2:BOOL=OFF + +//Enable ZIP support +MOJOSETUP_ARCHIVE_ZIP:BOOL=ON + +//Build separate Lua compiler +MOJOSETUP_BUILD_LUAC:BOOL=ON + +//Enable CRC-32 checksum support +MOJOSETUP_CHECKSUM_CRC32:BOOL=ON + +//Enable MD5 checksum support +MOJOSETUP_CHECKSUM_MD5:BOOL=ON + +//Enable SHA-1 checksum support +MOJOSETUP_CHECKSUM_SHA1:BOOL=ON + +//Enable GTK+ 2.0 GUI +MOJOSETUP_GUI_GTKPLUS2:BOOL=ON + +//Statically link GTK+ GUI +MOJOSETUP_GUI_GTKPLUS2_STATIC:BOOL=OFF + +//Enable stdio GUI +MOJOSETUP_GUI_STDIO:BOOL=ON + +//Statically link stdio GUI +MOJOSETUP_GUI_STDIO_STATIC:BOOL=ON + +//Enable www GUI +MOJOSETUP_GUI_WWW:BOOL=OFF + +//Enable BMP support +MOJOSETUP_IMAGE_BMP:BOOL=OFF + +//Enable HDR support +MOJOSETUP_IMAGE_HDR:BOOL=OFF + +//Enable JPG support +MOJOSETUP_IMAGE_JPG:BOOL=ON + +//Enable PNG support +MOJOSETUP_IMAGE_PNG:BOOL=ON + +//Enable PSD support +MOJOSETUP_IMAGE_PSD:BOOL=OFF + +//Enable TGA support +MOJOSETUP_IMAGE_TGA:BOOL=OFF + +//Link own bzlib instead of system library +MOJOSETUP_INTERNAL_BZLIB:BOOL=OFF + +//Link own zlib instead of system library +MOJOSETUP_INTERNAL_ZLIB:BOOL=OFF + +//Add Lua 'db' library +MOJOSETUP_LUALIB_DB:BOOL=ON + +//Add Lua 'io' library +MOJOSETUP_LUALIB_IO:BOOL=ON + +//Add Lua 'math' library +MOJOSETUP_LUALIB_MATH:BOOL=ON + +//Add Lua 'os' library +MOJOSETUP_LUALIB_OS:BOOL=ON + +//Add Lua 'package' library +MOJOSETUP_LUALIB_PACKAGE:BOOL=ON + +//Bigger binary but scripts don't need to be compiled. +MOJOSETUP_LUA_PARSER:BOOL=ON + +//Allow multiarch hack. +MOJOSETUP_MULTIARCH:BOOL=OFF + +//Enable ftp:// support +MOJOSETUP_URL_FTP:BOOL=ON + +//Enable http:// support +MOJOSETUP_URL_HTTP:BOOL=ON + +//Value Computed by CMake +MojoSetup_BINARY_DIR:STATIC=/home/softcoder/Code/mojosetup/build + +//Value Computed by CMake +MojoSetup_SOURCE_DIR:STATIC=/home/softcoder/Code/mojosetup + +//Dependencies for the target +mojosetupgui_gtkplus2_LIB_DEPENDS:STATIC=general;-lgtk-x11-2.0; + + +######################## +# INTERNAL cache entries +######################## + +//ADVANCED property for variable: CMAKE_AR +CMAKE_AR-ADVANCED:INTERNAL=1 +//ADVANCED property for variable: CMAKE_BUILD_TOOL +CMAKE_BUILD_TOOL-ADVANCED:INTERNAL=1 +//What is the target build tool cmake is generating for. +CMAKE_BUILD_TOOL:INTERNAL=/usr/bin/make +//This is the directory where this CMakeCache.txt was created +CMAKE_CACHEFILE_DIR:INTERNAL=/home/softcoder/Code/mojosetup/build +//Major version of cmake used to create the current loaded cache +CMAKE_CACHE_MAJOR_VERSION:INTERNAL=2 +//Minor version of cmake used to create the current loaded cache +CMAKE_CACHE_MINOR_VERSION:INTERNAL=8 +//Patch version of cmake used to create the current loaded cache +CMAKE_CACHE_PATCH_VERSION:INTERNAL=0 +//ADVANCED property for variable: CMAKE_COLOR_MAKEFILE +CMAKE_COLOR_MAKEFILE-ADVANCED:INTERNAL=1 +//Path to CMake executable. +CMAKE_COMMAND:INTERNAL=/usr/bin/cmake +//Path to cpack program executable. +CMAKE_CPACK_COMMAND:INTERNAL=/usr/bin/cpack +//Path to ctest program executable. +CMAKE_CTEST_COMMAND:INTERNAL=/usr/bin/ctest +//ADVANCED property for variable: CMAKE_C_COMPILER +CMAKE_C_COMPILER-ADVANCED:INTERNAL=1 +CMAKE_C_COMPILER_WORKS:INTERNAL=1 +//ADVANCED property for variable: CMAKE_C_FLAGS +CMAKE_C_FLAGS-ADVANCED:INTERNAL=1 +//ADVANCED property for variable: CMAKE_C_FLAGS_DEBUG +CMAKE_C_FLAGS_DEBUG-ADVANCED:INTERNAL=1 +//ADVANCED property for variable: CMAKE_C_FLAGS_MINSIZEREL +CMAKE_C_FLAGS_MINSIZEREL-ADVANCED:INTERNAL=1 +//ADVANCED property for variable: CMAKE_C_FLAGS_RELEASE +CMAKE_C_FLAGS_RELEASE-ADVANCED:INTERNAL=1 +//ADVANCED property for variable: CMAKE_C_FLAGS_RELWITHDEBINFO +CMAKE_C_FLAGS_RELWITHDEBINFO-ADVANCED:INTERNAL=1 +//Result of TRY_COMPILE +CMAKE_DETERMINE_C_ABI_COMPILED:INTERNAL=TRUE +//Executable file format +CMAKE_EXECUTABLE_FORMAT:INTERNAL=ELF +//ADVANCED property for variable: CMAKE_EXE_LINKER_FLAGS +CMAKE_EXE_LINKER_FLAGS-ADVANCED:INTERNAL=1 +//ADVANCED property for variable: CMAKE_EXE_LINKER_FLAGS_DEBUG +CMAKE_EXE_LINKER_FLAGS_DEBUG-ADVANCED:INTERNAL=1 +//ADVANCED property for variable: CMAKE_EXE_LINKER_FLAGS_MINSIZEREL +CMAKE_EXE_LINKER_FLAGS_MINSIZEREL-ADVANCED:INTERNAL=1 +//ADVANCED property for variable: CMAKE_EXE_LINKER_FLAGS_RELEASE +CMAKE_EXE_LINKER_FLAGS_RELEASE-ADVANCED:INTERNAL=1 +//ADVANCED property for variable: CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO +CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO-ADVANCED:INTERNAL=1 +//Name of generator. +CMAKE_GENERATOR:INTERNAL=Unix Makefiles +//Have library pthreads +CMAKE_HAVE_PTHREADS_CREATE:INTERNAL= +//Have library pthread +CMAKE_HAVE_PTHREAD_CREATE:INTERNAL=1 +//Have include CMAKE_HAVE_PTHREAD_H +CMAKE_HAVE_PTHREAD_H:INTERNAL=1 +//Start directory with the top level CMakeLists.txt file for this +// project +CMAKE_HOME_DIRECTORY:INTERNAL=/home/softcoder/Code/mojosetup +//Install .so files without execute permission. +CMAKE_INSTALL_SO_NO_EXE:INTERNAL=1 +//ADVANCED property for variable: CMAKE_LINKER +CMAKE_LINKER-ADVANCED:INTERNAL=1 +//ADVANCED property for variable: CMAKE_MAKE_PROGRAM +CMAKE_MAKE_PROGRAM-ADVANCED:INTERNAL=1 +//ADVANCED property for variable: CMAKE_MODULE_LINKER_FLAGS +CMAKE_MODULE_LINKER_FLAGS-ADVANCED:INTERNAL=1 +//ADVANCED property for variable: CMAKE_MODULE_LINKER_FLAGS_DEBUG +CMAKE_MODULE_LINKER_FLAGS_DEBUG-ADVANCED:INTERNAL=1 +//ADVANCED property for variable: CMAKE_MODULE_LINKER_FLAGS_MINSIZEREL +CMAKE_MODULE_LINKER_FLAGS_MINSIZEREL-ADVANCED:INTERNAL=1 +//ADVANCED property for variable: CMAKE_MODULE_LINKER_FLAGS_RELEASE +CMAKE_MODULE_LINKER_FLAGS_RELEASE-ADVANCED:INTERNAL=1 +//ADVANCED property for variable: CMAKE_MODULE_LINKER_FLAGS_RELWITHDEBINFO +CMAKE_MODULE_LINKER_FLAGS_RELWITHDEBINFO-ADVANCED:INTERNAL=1 +//ADVANCED property for variable: CMAKE_NM +CMAKE_NM-ADVANCED:INTERNAL=1 +//number of local generators +CMAKE_NUMBER_OF_LOCAL_GENERATORS:INTERNAL=1 +//ADVANCED property for variable: CMAKE_OBJCOPY +CMAKE_OBJCOPY-ADVANCED:INTERNAL=1 +//ADVANCED property for variable: CMAKE_OBJDUMP +CMAKE_OBJDUMP-ADVANCED:INTERNAL=1 +//ADVANCED property for variable: CMAKE_RANLIB +CMAKE_RANLIB-ADVANCED:INTERNAL=1 +//Path to CMake installation. +CMAKE_ROOT:INTERNAL=/usr/share/cmake-2.8 +//ADVANCED property for variable: CMAKE_SHARED_LINKER_FLAGS +CMAKE_SHARED_LINKER_FLAGS-ADVANCED:INTERNAL=1 +//ADVANCED property for variable: CMAKE_SHARED_LINKER_FLAGS_DEBUG +CMAKE_SHARED_LINKER_FLAGS_DEBUG-ADVANCED:INTERNAL=1 +//ADVANCED property for variable: CMAKE_SHARED_LINKER_FLAGS_MINSIZEREL +CMAKE_SHARED_LINKER_FLAGS_MINSIZEREL-ADVANCED:INTERNAL=1 +//ADVANCED property for variable: CMAKE_SHARED_LINKER_FLAGS_RELEASE +CMAKE_SHARED_LINKER_FLAGS_RELEASE-ADVANCED:INTERNAL=1 +//ADVANCED property for variable: CMAKE_SHARED_LINKER_FLAGS_RELWITHDEBINFO +CMAKE_SHARED_LINKER_FLAGS_RELWITHDEBINFO-ADVANCED:INTERNAL=1 +//Result of CHECK_TYPE_SIZE +CMAKE_SIZEOF_UNSIGNED_SHORT:INTERNAL=2 +//ADVANCED property for variable: CMAKE_SKIP_RPATH +CMAKE_SKIP_RPATH-ADVANCED:INTERNAL=1 +//ADVANCED property for variable: CMAKE_STRIP +CMAKE_STRIP-ADVANCED:INTERNAL=1 +//uname command +CMAKE_UNAME:INTERNAL=/bin/uname +//ADVANCED property for variable: CMAKE_USE_RELATIVE_PATHS +CMAKE_USE_RELATIVE_PATHS-ADVANCED:INTERNAL=1 +//ADVANCED property for variable: CMAKE_VERBOSE_MAKEFILE +CMAKE_VERBOSE_MAKEFILE-ADVANCED:INTERNAL=1 +//ADVANCED property for variable: CURSES_CURSES_LIBRARY +CURSES_CURSES_LIBRARY-ADVANCED:INTERNAL=1 +//ADVANCED property for variable: CURSES_EXTRA_LIBRARY +CURSES_EXTRA_LIBRARY-ADVANCED:INTERNAL=1 +//ADVANCED property for variable: CURSES_FORM_LIBRARY +CURSES_FORM_LIBRARY-ADVANCED:INTERNAL=1 +//ADVANCED property for variable: CURSES_HAVE_CURSESW_H +CURSES_HAVE_CURSESW_H-ADVANCED:INTERNAL=1 +//ADVANCED property for variable: CURSES_HAVE_CURSES_H +CURSES_HAVE_CURSES_H-ADVANCED:INTERNAL=1 +//ADVANCED property for variable: CURSES_INCLUDE_PATH +CURSES_INCLUDE_PATH-ADVANCED:INTERNAL=1 +//ADVANCED property for variable: CURSES_LIBRARY +CURSES_LIBRARY-ADVANCED:INTERNAL=1 +//ADVANCED property for variable: CURSES_NCURSES_LIBRARY +CURSES_NCURSES_LIBRARY-ADVANCED:INTERNAL=1 +//Details about finding Threads +FIND_PACKAGE_MESSAGE_DETAILS_Threads:INTERNAL=[TRUE] +//ADVANCED property for variable: FORM_LIBRARY +FORM_LIBRARY-ADVANCED:INTERNAL=1 +//Have include bzlib.h +HAVE_BZLIB_H:INTERNAL=1 +//Result of TRY_COMPILE +HAVE_CMAKE_SIZEOF_UNSIGNED_SHORT:INTERNAL=TRUE +//Have library bz2 +HAVE_LIBBZ2:INTERNAL=1 +//Have library dl +HAVE_LIBDL:INTERNAL=1 +//Have library m +HAVE_LIBM:INTERNAL=1 +//Have library z +HAVE_LIBZ:INTERNAL=1 +//Have include mntent.h +HAVE_MNTENT_H:INTERNAL=1 +//Result of TRY_COMPILE +HAVE_MOJOSETUP_IS_BIGENDIAN:INTERNAL=TRUE +//Have include stddef.h +HAVE_STDDEF_H:INTERNAL=1 +//Have include stdint.h +HAVE_STDINT_H:INTERNAL=1 +//Test HAVE_SYS_MNTTAB_H +HAVE_SYS_MNTTAB_H:INTERNAL= +//Have include sys/types.h +HAVE_SYS_TYPES_H:INTERNAL=1 +//Have include sys/ucred.h +HAVE_UCRED_H:INTERNAL= +//Have include zlib.h +HAVE_ZLIB_H:INTERNAL=1 +//Test MOJOSETUP_GCC_HAS_STACKPROT +MOJOSETUP_GCC_HAS_STACKPROT:INTERNAL=1 +//Result of TEST_BIG_ENDIAN +MOJOSETUP_IS_BIGENDIAN:INTERNAL=0 +//Test MOJOSETUP_IS_GCC4 +MOJOSETUP_IS_GCC4:INTERNAL=1 +//ADVANCED property for variable: MOJOSETUP_LUALIB_DB +MOJOSETUP_LUALIB_DB-ADVANCED:INTERNAL=1 +//ADVANCED property for variable: MOJOSETUP_LUALIB_IO +MOJOSETUP_LUALIB_IO-ADVANCED:INTERNAL=1 +//ADVANCED property for variable: MOJOSETUP_LUALIB_MATH +MOJOSETUP_LUALIB_MATH-ADVANCED:INTERNAL=1 +//ADVANCED property for variable: MOJOSETUP_LUALIB_OS +MOJOSETUP_LUALIB_OS-ADVANCED:INTERNAL=1 +//ADVANCED property for variable: MOJOSETUP_LUALIB_PACKAGE +MOJOSETUP_LUALIB_PACKAGE-ADVANCED:INTERNAL=1 +//ADVANCED property for variable: MOJOSETUP_MULTIARCH +MOJOSETUP_MULTIARCH-ADVANCED:INTERNAL=1 + diff --git a/mk/linux/mojosetup/build/CMakeFiles/CMakeCCompiler.cmake b/mk/linux/mojosetup/build/CMakeFiles/CMakeCCompiler.cmake new file mode 100644 index 00000000..acd3f79b --- /dev/null +++ b/mk/linux/mojosetup/build/CMakeFiles/CMakeCCompiler.cmake @@ -0,0 +1,41 @@ +SET(CMAKE_C_COMPILER "/usr/bin/gcc") +SET(CMAKE_C_COMPILER_ARG1 "") +SET(CMAKE_C_COMPILER_ID "GNU") +SET(CMAKE_C_PLATFORM_ID "Linux") +SET(CMAKE_AR "/usr/bin/ar") +SET(CMAKE_RANLIB "/usr/bin/ranlib") +SET(CMAKE_COMPILER_IS_GNUCC 1) +SET(CMAKE_C_COMPILER_LOADED 1) +SET(CMAKE_COMPILER_IS_MINGW ) +SET(CMAKE_COMPILER_IS_CYGWIN ) +IF(CMAKE_COMPILER_IS_CYGWIN) + SET(CYGWIN 1) + SET(UNIX 1) +ENDIF(CMAKE_COMPILER_IS_CYGWIN) + +SET(CMAKE_C_COMPILER_ENV_VAR "CC") + +IF(CMAKE_COMPILER_IS_MINGW) + SET(MINGW 1) +ENDIF(CMAKE_COMPILER_IS_MINGW) +SET(CMAKE_C_COMPILER_ID_RUN 1) +SET(CMAKE_C_SOURCE_FILE_EXTENSIONS c) +SET(CMAKE_C_IGNORE_EXTENSIONS h;H;o;O;obj;OBJ;def;DEF;rc;RC) +SET(CMAKE_C_LINKER_PREFERENCE 10) + +# Save compiler ABI information. +SET(CMAKE_C_SIZEOF_DATA_PTR "4") +SET(CMAKE_C_COMPILER_ABI "ELF") + +IF(CMAKE_C_SIZEOF_DATA_PTR) + SET(CMAKE_SIZEOF_VOID_P "${CMAKE_C_SIZEOF_DATA_PTR}") +ENDIF(CMAKE_C_SIZEOF_DATA_PTR) + +IF(CMAKE_C_COMPILER_ABI) + SET(CMAKE_INTERNAL_PLATFORM_ABI "${CMAKE_C_COMPILER_ABI}") +ENDIF(CMAKE_C_COMPILER_ABI) + +SET(CMAKE_C_HAS_ISYSROOT "") + +SET(CMAKE_C_IMPLICIT_LINK_LIBRARIES "c") +SET(CMAKE_C_IMPLICIT_LINK_DIRECTORIES "/usr/lib/gcc/i486-linux-gnu/4.4.1;/usr/lib;/lib;/usr/lib/i486-linux-gnu") diff --git a/mk/linux/mojosetup/build/CMakeFiles/CMakeDetermineCompilerABI_C.bin b/mk/linux/mojosetup/build/CMakeFiles/CMakeDetermineCompilerABI_C.bin new file mode 100755 index 00000000..da7f565f Binary files /dev/null and b/mk/linux/mojosetup/build/CMakeFiles/CMakeDetermineCompilerABI_C.bin differ diff --git a/mk/linux/mojosetup/build/CMakeFiles/CMakeDirectoryInformation.cmake b/mk/linux/mojosetup/build/CMakeFiles/CMakeDirectoryInformation.cmake new file mode 100644 index 00000000..a881441f --- /dev/null +++ b/mk/linux/mojosetup/build/CMakeFiles/CMakeDirectoryInformation.cmake @@ -0,0 +1,23 @@ +# CMAKE generated file: DO NOT EDIT! +# Generated by "Unix Makefiles" Generator, CMake Version 2.8 + +# Relative path conversion top directories. +SET(CMAKE_RELATIVE_PATH_TOP_SOURCE "/home/softcoder/Code/mojosetup") +SET(CMAKE_RELATIVE_PATH_TOP_BINARY "/home/softcoder/Code/mojosetup/build") + +# Force unix paths in dependencies. +SET(CMAKE_FORCE_UNIX_PATHS 1) + +# The C and CXX include file search paths: +SET(CMAKE_C_INCLUDE_PATH + "../." + "../lua/src" + ) +SET(CMAKE_CXX_INCLUDE_PATH ${CMAKE_C_INCLUDE_PATH}) +SET(CMAKE_Fortran_INCLUDE_PATH ${CMAKE_C_INCLUDE_PATH}) + +# The C and CXX include file regular expressions for this directory. +SET(CMAKE_C_INCLUDE_REGEX_SCAN "^.*$") +SET(CMAKE_C_INCLUDE_REGEX_COMPLAIN "^$") +SET(CMAKE_CXX_INCLUDE_REGEX_SCAN ${CMAKE_C_INCLUDE_REGEX_SCAN}) +SET(CMAKE_CXX_INCLUDE_REGEX_COMPLAIN ${CMAKE_C_INCLUDE_REGEX_COMPLAIN}) diff --git a/mk/linux/mojosetup/build/CMakeFiles/CMakeError.log b/mk/linux/mojosetup/build/CMakeFiles/CMakeError.log new file mode 100644 index 00000000..56fe17da --- /dev/null +++ b/mk/linux/mojosetup/build/CMakeFiles/CMakeError.log @@ -0,0 +1,94 @@ +Determining if the system is big endian passed with the following output: +Change Dir: /home/softcoder/Code/mojosetup/build/CMakeFiles/CMakeTmp + +Run Build Command:/usr/bin/make "cmTryCompileExec/fast" +/usr/bin/make -f CMakeFiles/cmTryCompileExec.dir/build.make CMakeFiles/cmTryCompileExec.dir/build +make[1]: Entering directory `/home/softcoder/Code/mojosetup/build/CMakeFiles/CMakeTmp' +/usr/bin/cmake -E cmake_progress_report /home/softcoder/Code/mojosetup/build/CMakeFiles/CMakeTmp/CMakeFiles 1 +Building C object CMakeFiles/cmTryCompileExec.dir/TestEndianess.c.o +/usr/bin/gcc -o CMakeFiles/cmTryCompileExec.dir/TestEndianess.c.o -c /home/softcoder/Code/mojosetup/build/CMakeFiles/CMakeTmp/TestEndianess.c +Linking C executable cmTryCompileExec +/usr/bin/cmake -E cmake_link_script CMakeFiles/cmTryCompileExec.dir/link.txt --verbose=1 +/usr/bin/gcc CMakeFiles/cmTryCompileExec.dir/TestEndianess.c.o -o cmTryCompileExec -rdynamic +make[1]: Leaving directory `/home/softcoder/Code/mojosetup/build/CMakeFiles/CMakeTmp' + +TestEndianess.c: +/* A 16 bit integer is required. */ +typedef unsigned short cmakeint16; + +/* On a little endian machine, these 16bit ints will give "THIS IS LITTLE ENDIAN." + On a big endian machine the characters will be exchanged pairwise. */ +const cmakeint16 info_little[] = {0x4854, 0x5349, 0x4920, 0x2053, 0x494c, 0x5454, 0x454c, 0x4520, 0x444e, 0x4149, 0x2e4e, 0x0000}; + +/* on a big endian machine, these 16bit ints will give "THIS IS BIG ENDIAN." + On a little endian machine the characters will be exchanged pairwise. */ +const cmakeint16 info_big[] = {0x5448, 0x4953, 0x2049, 0x5320, 0x4249, 0x4720, 0x454e, 0x4449, 0x414e, 0x2e2e, 0x0000}; + +#ifdef __CLASSIC_C__ +int main(argc, argv) int argc; char *argv[]; +#else +int main(int argc, char *argv[]) +#endif +{ + int require = 0; + require += info_little[argc]; + require += info_big[argc]; + (void)argv; + return require; +} + + +Determining if the function pthread_create exists in the pthreads failed with the following output: +Change Dir: /home/softcoder/Code/mojosetup/build/CMakeFiles/CMakeTmp + +Run Build Command:/usr/bin/make "cmTryCompileExec/fast" +/usr/bin/make -f CMakeFiles/cmTryCompileExec.dir/build.make CMakeFiles/cmTryCompileExec.dir/build +make[1]: Entering directory `/home/softcoder/Code/mojosetup/build/CMakeFiles/CMakeTmp' +/usr/bin/cmake -E cmake_progress_report /home/softcoder/Code/mojosetup/build/CMakeFiles/CMakeTmp/CMakeFiles 1 +Building C object CMakeFiles/cmTryCompileExec.dir/CheckFunctionExists.c.o +/usr/bin/gcc -DCHECK_FUNCTION_EXISTS=pthread_create -o CMakeFiles/cmTryCompileExec.dir/CheckFunctionExists.c.o -c /usr/share/cmake-2.8/Modules/CheckFunctionExists.c +Linking C executable cmTryCompileExec +/usr/bin/cmake -E cmake_link_script CMakeFiles/cmTryCompileExec.dir/link.txt --verbose=1 +/usr/bin/gcc -DCHECK_FUNCTION_EXISTS=pthread_create CMakeFiles/cmTryCompileExec.dir/CheckFunctionExists.c.o -o cmTryCompileExec -rdynamic -lpthreads +/usr/bin/ld: cannot find -lpthreads +collect2: ld returned 1 exit status +make[1]: Leaving directory `/home/softcoder/Code/mojosetup/build/CMakeFiles/CMakeTmp' +make[1]: *** [cmTryCompileExec] Error 1 +make: *** [cmTryCompileExec/fast] Error 2 + + +Determining if the include file sys/ucred.h exists failed with the following output: +Change Dir: /home/softcoder/Code/mojosetup/build/CMakeFiles/CMakeTmp + +Run Build Command:/usr/bin/make "cmTryCompileExec/fast" +/usr/bin/make -f CMakeFiles/cmTryCompileExec.dir/build.make CMakeFiles/cmTryCompileExec.dir/build +make[1]: Entering directory `/home/softcoder/Code/mojosetup/build/CMakeFiles/CMakeTmp' +/usr/bin/cmake -E cmake_progress_report /home/softcoder/Code/mojosetup/build/CMakeFiles/CMakeTmp/CMakeFiles 1 +Building C object CMakeFiles/cmTryCompileExec.dir/CheckIncludeFile.c.o +/usr/bin/gcc -o CMakeFiles/cmTryCompileExec.dir/CheckIncludeFile.c.o -c /home/softcoder/Code/mojosetup/build/CMakeFiles/CMakeTmp/CheckIncludeFile.c +/home/softcoder/Code/mojosetup/build/CMakeFiles/CMakeTmp/CheckIncludeFile.c:1:23: error: sys/ucred.h: No such file or directory +make[1]: Leaving directory `/home/softcoder/Code/mojosetup/build/CMakeFiles/CMakeTmp' +make[1]: *** [CMakeFiles/cmTryCompileExec.dir/CheckIncludeFile.c.o] Error 1 +make: *** [cmTryCompileExec/fast] Error 2 + + +Performing C SOURCE FILE Test HAVE_SYS_MNTTAB_H failed with the following output: +Change Dir: /home/softcoder/Code/mojosetup/build/CMakeFiles/CMakeTmp + +Run Build Command:/usr/bin/make "cmTryCompileExec/fast" +/usr/bin/make -f CMakeFiles/cmTryCompileExec.dir/build.make CMakeFiles/cmTryCompileExec.dir/build +make[1]: Entering directory `/home/softcoder/Code/mojosetup/build/CMakeFiles/CMakeTmp' +/usr/bin/cmake -E cmake_progress_report /home/softcoder/Code/mojosetup/build/CMakeFiles/CMakeTmp/CMakeFiles 1 +Building C object CMakeFiles/cmTryCompileExec.dir/src.c.o +/usr/bin/gcc -DHAVE_SYS_MNTTAB_H -o CMakeFiles/cmTryCompileExec.dir/src.c.o -c /home/softcoder/Code/mojosetup/build/CMakeFiles/CMakeTmp/src.c +/home/softcoder/Code/mojosetup/build/CMakeFiles/CMakeTmp/src.c:3:32: error: sys/mnttab.h: No such file or directory +make[1]: Leaving directory `/home/softcoder/Code/mojosetup/build/CMakeFiles/CMakeTmp' +make[1]: *** [CMakeFiles/cmTryCompileExec.dir/src.c.o] Error 1 +make: *** [cmTryCompileExec/fast] Error 2 + +Source file was: + + #include + #include + int main(int argc, char **argv) { return 0; } + diff --git a/mk/linux/mojosetup/build/CMakeFiles/CMakeOutput.log b/mk/linux/mojosetup/build/CMakeFiles/CMakeOutput.log new file mode 100644 index 00000000..aa90fa9a --- /dev/null +++ b/mk/linux/mojosetup/build/CMakeFiles/CMakeOutput.log @@ -0,0 +1,358 @@ +The system is: Linux - 2.6.31-21-generic-pae - i686 +Compiling the C compiler identification source file "CMakeCCompilerId.c" succeeded. +Compiler: /usr/bin/gcc +Build flags: +Id flags: + +The output was: +0 + + +Compilation of the C compiler identification source "CMakeCCompilerId.c" produced "a.out" + +The C compiler identification is GNU, found in "/home/softcoder/Code/mojosetup/build/CMakeFiles/CompilerIdC/a.out" + +Determining if the C compiler works passed with the following output: +Change Dir: /home/softcoder/Code/mojosetup/build/CMakeFiles/CMakeTmp + +Run Build Command:/usr/bin/make "cmTryCompileExec/fast" +/usr/bin/make -f CMakeFiles/cmTryCompileExec.dir/build.make CMakeFiles/cmTryCompileExec.dir/build +make[1]: Entering directory `/home/softcoder/Code/mojosetup/build/CMakeFiles/CMakeTmp' +/usr/bin/cmake -E cmake_progress_report /home/softcoder/Code/mojosetup/build/CMakeFiles/CMakeTmp/CMakeFiles 1 +Building C object CMakeFiles/cmTryCompileExec.dir/testCCompiler.c.o +/usr/bin/gcc -o CMakeFiles/cmTryCompileExec.dir/testCCompiler.c.o -c /home/softcoder/Code/mojosetup/build/CMakeFiles/CMakeTmp/testCCompiler.c +Linking C executable cmTryCompileExec +/usr/bin/cmake -E cmake_link_script CMakeFiles/cmTryCompileExec.dir/link.txt --verbose=1 +/usr/bin/gcc CMakeFiles/cmTryCompileExec.dir/testCCompiler.c.o -o cmTryCompileExec -rdynamic +make[1]: Leaving directory `/home/softcoder/Code/mojosetup/build/CMakeFiles/CMakeTmp' + + +Detecting C compiler ABI info compiled with the following output: +Change Dir: /home/softcoder/Code/mojosetup/build/CMakeFiles/CMakeTmp + +Run Build Command:/usr/bin/make "cmTryCompileExec/fast" +/usr/bin/make -f CMakeFiles/cmTryCompileExec.dir/build.make CMakeFiles/cmTryCompileExec.dir/build +make[1]: Entering directory `/home/softcoder/Code/mojosetup/build/CMakeFiles/CMakeTmp' +/usr/bin/cmake -E cmake_progress_report /home/softcoder/Code/mojosetup/build/CMakeFiles/CMakeTmp/CMakeFiles 1 +Building C object CMakeFiles/cmTryCompileExec.dir/CMakeCCompilerABI.c.o +/usr/bin/gcc -o CMakeFiles/cmTryCompileExec.dir/CMakeCCompilerABI.c.o -c /usr/share/cmake-2.8/Modules/CMakeCCompilerABI.c +Linking C executable cmTryCompileExec +/usr/bin/cmake -E cmake_link_script CMakeFiles/cmTryCompileExec.dir/link.txt --verbose=1 +/usr/bin/gcc -v CMakeFiles/cmTryCompileExec.dir/CMakeCCompilerABI.c.o -o cmTryCompileExec -rdynamic +Using built-in specs. +Target: i486-linux-gnu +Configured with: ../src/configure -v --with-pkgversion='Ubuntu 4.4.1-4ubuntu9' --with-bugurl=file:///usr/share/doc/gcc-4.4/README.Bugs --enable-languages=c,c++,fortran,objc,obj-c++ --prefix=/usr --enable-shared --enable-multiarch --enable-linker-build-id --with-system-zlib --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --with-gxx-include-dir=/usr/include/c++/4.4 --program-suffix=-4.4 --enable-nls --enable-clocale=gnu --enable-libstdcxx-debug --enable-objc-gc --enable-targets=all --disable-werror --with-arch-32=i486 --with-tune=generic --enable-checking=release --build=i486-linux-gnu --host=i486-linux-gnu --target=i486-linux-gnu +Thread model: posix +gcc version 4.4.1 (Ubuntu 4.4.1-4ubuntu9) +COMPILER_PATH=/usr/lib/gcc/i486-linux-gnu/4.4.1/:/usr/lib/gcc/i486-linux-gnu/4.4.1/:/usr/lib/gcc/i486-linux-gnu/:/usr/lib/gcc/i486-linux-gnu/4.4.1/:/usr/lib/gcc/i486-linux-gnu/:/usr/lib/gcc/i486-linux-gnu/4.4.1/:/usr/lib/gcc/i486-linux-gnu/ +LIBRARY_PATH=/usr/lib/gcc/i486-linux-gnu/4.4.1/:/usr/lib/gcc/i486-linux-gnu/4.4.1/:/usr/lib/gcc/i486-linux-gnu/4.4.1/../../../../lib/:/lib/../lib/:/usr/lib/../lib/:/usr/lib/gcc/i486-linux-gnu/4.4.1/../../../:/lib/:/usr/lib/:/usr/lib/i486-linux-gnu/ +COLLECT_GCC_OPTIONS='-v' '-o' 'cmTryCompileExec' '-rdynamic' '-mtune=generic' '-march=i486' + /usr/lib/gcc/i486-linux-gnu/4.4.1/collect2 --build-id --eh-frame-hdr -m elf_i386 --hash-style=both -export-dynamic -dynamic-linker /lib/ld-linux.so.2 -o cmTryCompileExec -z relro /usr/lib/gcc/i486-linux-gnu/4.4.1/../../../../lib/crt1.o /usr/lib/gcc/i486-linux-gnu/4.4.1/../../../../lib/crti.o /usr/lib/gcc/i486-linux-gnu/4.4.1/crtbegin.o -L/usr/lib/gcc/i486-linux-gnu/4.4.1 -L/usr/lib/gcc/i486-linux-gnu/4.4.1 -L/usr/lib/gcc/i486-linux-gnu/4.4.1/../../../../lib -L/lib/../lib -L/usr/lib/../lib -L/usr/lib/gcc/i486-linux-gnu/4.4.1/../../.. -L/usr/lib/i486-linux-gnu CMakeFiles/cmTryCompileExec.dir/CMakeCCompilerABI.c.o -lgcc --as-needed -lgcc_s --no-as-needed -lc -lgcc --as-needed -lgcc_s --no-as-needed /usr/lib/gcc/i486-linux-gnu/4.4.1/crtend.o /usr/lib/gcc/i486-linux-gnu/4.4.1/../../../../lib/crtn.o +make[1]: Leaving directory `/home/softcoder/Code/mojosetup/build/CMakeFiles/CMakeTmp' + + +Parsed C implicit link information from above output: + link line regex: [^( *|.*[/\])(ld|ld|collect2)[^/\]*( |$)] + ignore line: [Change Dir: /home/softcoder/Code/mojosetup/build/CMakeFiles/CMakeTmp] + ignore line: [] + ignore line: [Run Build Command:/usr/bin/make "cmTryCompileExec/fast"] + ignore line: [/usr/bin/make -f CMakeFiles/cmTryCompileExec.dir/build.make CMakeFiles/cmTryCompileExec.dir/build] + ignore line: [make[1]: Entering directory `/home/softcoder/Code/mojosetup/build/CMakeFiles/CMakeTmp'] + ignore line: [/usr/bin/cmake -E cmake_progress_report /home/softcoder/Code/mojosetup/build/CMakeFiles/CMakeTmp/CMakeFiles 1] + ignore line: [Building C object CMakeFiles/cmTryCompileExec.dir/CMakeCCompilerABI.c.o] + ignore line: [/usr/bin/gcc -o CMakeFiles/cmTryCompileExec.dir/CMakeCCompilerABI.c.o -c /usr/share/cmake-2.8/Modules/CMakeCCompilerABI.c] + ignore line: [Linking C executable cmTryCompileExec] + ignore line: [/usr/bin/cmake -E cmake_link_script CMakeFiles/cmTryCompileExec.dir/link.txt --verbose=1] + ignore line: [/usr/bin/gcc -v CMakeFiles/cmTryCompileExec.dir/CMakeCCompilerABI.c.o -o cmTryCompileExec -rdynamic ] + ignore line: [Using built-in specs.] + ignore line: [Target: i486-linux-gnu] + ignore line: [Configured with: ../src/configure -v --with-pkgversion='Ubuntu 4.4.1-4ubuntu9' --with-bugurl=file:///usr/share/doc/gcc-4.4/README.Bugs --enable-languages=c,c++,fortran,objc,obj-c++ --prefix=/usr --enable-shared --enable-multiarch --enable-linker-build-id --with-system-zlib --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --with-gxx-include-dir=/usr/include/c++/4.4 --program-suffix=-4.4 --enable-nls --enable-clocale=gnu --enable-libstdcxx-debug --enable-objc-gc --enable-targets=all --disable-werror --with-arch-32=i486 --with-tune=generic --enable-checking=release --build=i486-linux-gnu --host=i486-linux-gnu --target=i486-linux-gnu] + ignore line: [Thread model: posix] + ignore line: [gcc version 4.4.1 (Ubuntu 4.4.1-4ubuntu9) ] + ignore line: [COMPILER_PATH=/usr/lib/gcc/i486-linux-gnu/4.4.1/:/usr/lib/gcc/i486-linux-gnu/4.4.1/:/usr/lib/gcc/i486-linux-gnu/:/usr/lib/gcc/i486-linux-gnu/4.4.1/:/usr/lib/gcc/i486-linux-gnu/:/usr/lib/gcc/i486-linux-gnu/4.4.1/:/usr/lib/gcc/i486-linux-gnu/] + ignore line: [LIBRARY_PATH=/usr/lib/gcc/i486-linux-gnu/4.4.1/:/usr/lib/gcc/i486-linux-gnu/4.4.1/:/usr/lib/gcc/i486-linux-gnu/4.4.1/../../../../lib/:/lib/../lib/:/usr/lib/../lib/:/usr/lib/gcc/i486-linux-gnu/4.4.1/../../../:/lib/:/usr/lib/:/usr/lib/i486-linux-gnu/] + ignore line: [COLLECT_GCC_OPTIONS='-v' '-o' 'cmTryCompileExec' '-rdynamic' '-mtune=generic' '-march=i486'] + link line: [ /usr/lib/gcc/i486-linux-gnu/4.4.1/collect2 --build-id --eh-frame-hdr -m elf_i386 --hash-style=both -export-dynamic -dynamic-linker /lib/ld-linux.so.2 -o cmTryCompileExec -z relro /usr/lib/gcc/i486-linux-gnu/4.4.1/../../../../lib/crt1.o /usr/lib/gcc/i486-linux-gnu/4.4.1/../../../../lib/crti.o /usr/lib/gcc/i486-linux-gnu/4.4.1/crtbegin.o -L/usr/lib/gcc/i486-linux-gnu/4.4.1 -L/usr/lib/gcc/i486-linux-gnu/4.4.1 -L/usr/lib/gcc/i486-linux-gnu/4.4.1/../../../../lib -L/lib/../lib -L/usr/lib/../lib -L/usr/lib/gcc/i486-linux-gnu/4.4.1/../../.. -L/usr/lib/i486-linux-gnu CMakeFiles/cmTryCompileExec.dir/CMakeCCompilerABI.c.o -lgcc --as-needed -lgcc_s --no-as-needed -lc -lgcc --as-needed -lgcc_s --no-as-needed /usr/lib/gcc/i486-linux-gnu/4.4.1/crtend.o /usr/lib/gcc/i486-linux-gnu/4.4.1/../../../../lib/crtn.o] + arg [/usr/lib/gcc/i486-linux-gnu/4.4.1/collect2] ==> ignore + arg [--build-id] ==> ignore + arg [--eh-frame-hdr] ==> ignore + arg [-m] ==> ignore + arg [elf_i386] ==> ignore + arg [--hash-style=both] ==> ignore + arg [-export-dynamic] ==> ignore + arg [-dynamic-linker] ==> ignore + arg [/lib/ld-linux.so.2] ==> ignore + arg [-o] ==> ignore + arg [cmTryCompileExec] ==> ignore + arg [-zrelro] ==> ignore + arg [/usr/lib/gcc/i486-linux-gnu/4.4.1/../../../../lib/crt1.o] ==> ignore + arg [/usr/lib/gcc/i486-linux-gnu/4.4.1/../../../../lib/crti.o] ==> ignore + arg [/usr/lib/gcc/i486-linux-gnu/4.4.1/crtbegin.o] ==> ignore + arg [-L/usr/lib/gcc/i486-linux-gnu/4.4.1] ==> dir [/usr/lib/gcc/i486-linux-gnu/4.4.1] + arg [-L/usr/lib/gcc/i486-linux-gnu/4.4.1] ==> dir [/usr/lib/gcc/i486-linux-gnu/4.4.1] + arg [-L/usr/lib/gcc/i486-linux-gnu/4.4.1/../../../../lib] ==> dir [/usr/lib/gcc/i486-linux-gnu/4.4.1/../../../../lib] + arg [-L/lib/../lib] ==> dir [/lib/../lib] + arg [-L/usr/lib/../lib] ==> dir [/usr/lib/../lib] + arg [-L/usr/lib/gcc/i486-linux-gnu/4.4.1/../../..] ==> dir [/usr/lib/gcc/i486-linux-gnu/4.4.1/../../..] + arg [-L/usr/lib/i486-linux-gnu] ==> dir [/usr/lib/i486-linux-gnu] + arg [CMakeFiles/cmTryCompileExec.dir/CMakeCCompilerABI.c.o] ==> ignore + arg [-lgcc] ==> lib [gcc] + arg [--as-needed] ==> ignore + arg [-lgcc_s] ==> lib [gcc_s] + arg [--no-as-needed] ==> ignore + arg [-lc] ==> lib [c] + arg [-lgcc] ==> lib [gcc] + arg [--as-needed] ==> ignore + arg [-lgcc_s] ==> lib [gcc_s] + arg [--no-as-needed] ==> ignore + arg [/usr/lib/gcc/i486-linux-gnu/4.4.1/crtend.o] ==> ignore + arg [/usr/lib/gcc/i486-linux-gnu/4.4.1/../../../../lib/crtn.o] ==> ignore + remove lib [gcc] + remove lib [gcc_s] + remove lib [gcc] + remove lib [gcc_s] + collapse dir [/usr/lib/gcc/i486-linux-gnu/4.4.1] ==> [/usr/lib/gcc/i486-linux-gnu/4.4.1] + collapse dir [/usr/lib/gcc/i486-linux-gnu/4.4.1] ==> [/usr/lib/gcc/i486-linux-gnu/4.4.1] + collapse dir [/usr/lib/gcc/i486-linux-gnu/4.4.1/../../../../lib] ==> [/usr/lib] + collapse dir [/lib/../lib] ==> [/lib] + collapse dir [/usr/lib/../lib] ==> [/usr/lib] + collapse dir [/usr/lib/gcc/i486-linux-gnu/4.4.1/../../..] ==> [/usr/lib] + collapse dir [/usr/lib/i486-linux-gnu] ==> [/usr/lib/i486-linux-gnu] + implicit libs: [c] + implicit dirs: [/usr/lib/gcc/i486-linux-gnu/4.4.1;/usr/lib;/lib;/usr/lib/i486-linux-gnu] + + +Performing C SOURCE FILE Test MOJOSETUP_IS_GCC4 succeded with the following output: +Change Dir: /home/softcoder/Code/mojosetup/build/CMakeFiles/CMakeTmp + +Run Build Command:/usr/bin/make "cmTryCompileExec/fast" +/usr/bin/make -f CMakeFiles/cmTryCompileExec.dir/build.make CMakeFiles/cmTryCompileExec.dir/build +make[1]: Entering directory `/home/softcoder/Code/mojosetup/build/CMakeFiles/CMakeTmp' +/usr/bin/cmake -E cmake_progress_report /home/softcoder/Code/mojosetup/build/CMakeFiles/CMakeTmp/CMakeFiles 1 +Building C object CMakeFiles/cmTryCompileExec.dir/src.c.o +/usr/bin/gcc -DMOJOSETUP_IS_GCC4 -o CMakeFiles/cmTryCompileExec.dir/src.c.o -c /home/softcoder/Code/mojosetup/build/CMakeFiles/CMakeTmp/src.c +Linking C executable cmTryCompileExec +/usr/bin/cmake -E cmake_link_script CMakeFiles/cmTryCompileExec.dir/link.txt --verbose=1 +/usr/bin/gcc -DMOJOSETUP_IS_GCC4 CMakeFiles/cmTryCompileExec.dir/src.c.o -o cmTryCompileExec -rdynamic +make[1]: Leaving directory `/home/softcoder/Code/mojosetup/build/CMakeFiles/CMakeTmp' + +Source file was: + + #if ((defined(__GNUC__)) && (__GNUC__ >= 4)) + int main(int argc, char **argv) { int is_gcc4 = 1; return 0; } + #else + #error This is not gcc4. + #endif + +Performing C SOURCE FILE Test MOJOSETUP_GCC_HAS_STACKPROT succeded with the following output: +Change Dir: /home/softcoder/Code/mojosetup/build/CMakeFiles/CMakeTmp + +Run Build Command:/usr/bin/make "cmTryCompileExec/fast" +/usr/bin/make -f CMakeFiles/cmTryCompileExec.dir/build.make CMakeFiles/cmTryCompileExec.dir/build +make[1]: Entering directory `/home/softcoder/Code/mojosetup/build/CMakeFiles/CMakeTmp' +/usr/bin/cmake -E cmake_progress_report /home/softcoder/Code/mojosetup/build/CMakeFiles/CMakeTmp/CMakeFiles 1 +Building C object CMakeFiles/cmTryCompileExec.dir/src.c.o +/usr/bin/gcc -DMOJOSETUP_GCC_HAS_STACKPROT -fno-stack-protector -o CMakeFiles/cmTryCompileExec.dir/src.c.o -c /home/softcoder/Code/mojosetup/build/CMakeFiles/CMakeTmp/src.c +Linking C executable cmTryCompileExec +/usr/bin/cmake -E cmake_link_script CMakeFiles/cmTryCompileExec.dir/link.txt --verbose=1 +/usr/bin/gcc -DMOJOSETUP_GCC_HAS_STACKPROT CMakeFiles/cmTryCompileExec.dir/src.c.o -o cmTryCompileExec -rdynamic +make[1]: Leaving directory `/home/softcoder/Code/mojosetup/build/CMakeFiles/CMakeTmp' + +Source file was: +int main() { return 0;} +Determining if the include file sys/types.h exists passed with the following output: +Change Dir: /home/softcoder/Code/mojosetup/build/CMakeFiles/CMakeTmp + +Run Build Command:/usr/bin/make "cmTryCompileExec/fast" +/usr/bin/make -f CMakeFiles/cmTryCompileExec.dir/build.make CMakeFiles/cmTryCompileExec.dir/build +make[1]: Entering directory `/home/softcoder/Code/mojosetup/build/CMakeFiles/CMakeTmp' +/usr/bin/cmake -E cmake_progress_report /home/softcoder/Code/mojosetup/build/CMakeFiles/CMakeTmp/CMakeFiles 1 +Building C object CMakeFiles/cmTryCompileExec.dir/CheckIncludeFile.c.o +/usr/bin/gcc -o CMakeFiles/cmTryCompileExec.dir/CheckIncludeFile.c.o -c /home/softcoder/Code/mojosetup/build/CMakeFiles/CMakeTmp/CheckIncludeFile.c +Linking C executable cmTryCompileExec +/usr/bin/cmake -E cmake_link_script CMakeFiles/cmTryCompileExec.dir/link.txt --verbose=1 +/usr/bin/gcc CMakeFiles/cmTryCompileExec.dir/CheckIncludeFile.c.o -o cmTryCompileExec -rdynamic +make[1]: Leaving directory `/home/softcoder/Code/mojosetup/build/CMakeFiles/CMakeTmp' + + +Determining if the include file stdint.h exists passed with the following output: +Change Dir: /home/softcoder/Code/mojosetup/build/CMakeFiles/CMakeTmp + +Run Build Command:/usr/bin/make "cmTryCompileExec/fast" +/usr/bin/make -f CMakeFiles/cmTryCompileExec.dir/build.make CMakeFiles/cmTryCompileExec.dir/build +make[1]: Entering directory `/home/softcoder/Code/mojosetup/build/CMakeFiles/CMakeTmp' +/usr/bin/cmake -E cmake_progress_report /home/softcoder/Code/mojosetup/build/CMakeFiles/CMakeTmp/CMakeFiles 1 +Building C object CMakeFiles/cmTryCompileExec.dir/CheckIncludeFile.c.o +/usr/bin/gcc -o CMakeFiles/cmTryCompileExec.dir/CheckIncludeFile.c.o -c /home/softcoder/Code/mojosetup/build/CMakeFiles/CMakeTmp/CheckIncludeFile.c +Linking C executable cmTryCompileExec +/usr/bin/cmake -E cmake_link_script CMakeFiles/cmTryCompileExec.dir/link.txt --verbose=1 +/usr/bin/gcc CMakeFiles/cmTryCompileExec.dir/CheckIncludeFile.c.o -o cmTryCompileExec -rdynamic +make[1]: Leaving directory `/home/softcoder/Code/mojosetup/build/CMakeFiles/CMakeTmp' + + +Determining if the include file stddef.h exists passed with the following output: +Change Dir: /home/softcoder/Code/mojosetup/build/CMakeFiles/CMakeTmp + +Run Build Command:/usr/bin/make "cmTryCompileExec/fast" +/usr/bin/make -f CMakeFiles/cmTryCompileExec.dir/build.make CMakeFiles/cmTryCompileExec.dir/build +make[1]: Entering directory `/home/softcoder/Code/mojosetup/build/CMakeFiles/CMakeTmp' +/usr/bin/cmake -E cmake_progress_report /home/softcoder/Code/mojosetup/build/CMakeFiles/CMakeTmp/CMakeFiles 1 +Building C object CMakeFiles/cmTryCompileExec.dir/CheckIncludeFile.c.o +/usr/bin/gcc -o CMakeFiles/cmTryCompileExec.dir/CheckIncludeFile.c.o -c /home/softcoder/Code/mojosetup/build/CMakeFiles/CMakeTmp/CheckIncludeFile.c +Linking C executable cmTryCompileExec +/usr/bin/cmake -E cmake_link_script CMakeFiles/cmTryCompileExec.dir/link.txt --verbose=1 +/usr/bin/gcc CMakeFiles/cmTryCompileExec.dir/CheckIncludeFile.c.o -o cmTryCompileExec -rdynamic +make[1]: Leaving directory `/home/softcoder/Code/mojosetup/build/CMakeFiles/CMakeTmp' + + +Determining size of unsigned short passed with the following output: +Change Dir: /home/softcoder/Code/mojosetup/build/CMakeFiles/CMakeTmp + +Run Build Command:/usr/bin/make "cmTryCompileExec/fast" +/usr/bin/make -f CMakeFiles/cmTryCompileExec.dir/build.make CMakeFiles/cmTryCompileExec.dir/build +make[1]: Entering directory `/home/softcoder/Code/mojosetup/build/CMakeFiles/CMakeTmp' +/usr/bin/cmake -E cmake_progress_report /home/softcoder/Code/mojosetup/build/CMakeFiles/CMakeTmp/CMakeFiles 1 +Building C object CMakeFiles/cmTryCompileExec.dir/CheckTypeSizeC.c.o +/usr/bin/gcc -DHAVE_SYS_TYPES_H -DHAVE_STDINT_H -DHAVE_STDDEF_H -o CMakeFiles/cmTryCompileExec.dir/CheckTypeSizeC.c.o -c /home/softcoder/Code/mojosetup/build/CMakeFiles/CMakeTmp/CheckTypeSizeC.c +Linking C executable cmTryCompileExec +/usr/bin/cmake -E cmake_link_script CMakeFiles/cmTryCompileExec.dir/link.txt --verbose=1 +/usr/bin/gcc -DHAVE_SYS_TYPES_H -DHAVE_STDINT_H -DHAVE_STDDEF_H CMakeFiles/cmTryCompileExec.dir/CheckTypeSizeC.c.o -o cmTryCompileExec -rdynamic +make[1]: Leaving directory `/home/softcoder/Code/mojosetup/build/CMakeFiles/CMakeTmp' + + +Determining if files pthread.h exist passed with the following output: +Change Dir: /home/softcoder/Code/mojosetup/build/CMakeFiles/CMakeTmp + +Run Build Command:/usr/bin/make "cmTryCompileExec/fast" +/usr/bin/make -f CMakeFiles/cmTryCompileExec.dir/build.make CMakeFiles/cmTryCompileExec.dir/build +make[1]: Entering directory `/home/softcoder/Code/mojosetup/build/CMakeFiles/CMakeTmp' +/usr/bin/cmake -E cmake_progress_report /home/softcoder/Code/mojosetup/build/CMakeFiles/CMakeTmp/CMakeFiles 1 +Building C object CMakeFiles/cmTryCompileExec.dir/CheckIncludeFiles.c.o +/usr/bin/gcc -o CMakeFiles/cmTryCompileExec.dir/CheckIncludeFiles.c.o -c /home/softcoder/Code/mojosetup/build/CMakeFiles/CMakeTmp/CheckIncludeFiles.c +Linking C executable cmTryCompileExec +/usr/bin/cmake -E cmake_link_script CMakeFiles/cmTryCompileExec.dir/link.txt --verbose=1 +/usr/bin/gcc CMakeFiles/cmTryCompileExec.dir/CheckIncludeFiles.c.o -o cmTryCompileExec -rdynamic +make[1]: Leaving directory `/home/softcoder/Code/mojosetup/build/CMakeFiles/CMakeTmp' + + +Determining if the function pthread_create exists in the pthread passed with the following output: +Change Dir: /home/softcoder/Code/mojosetup/build/CMakeFiles/CMakeTmp + +Run Build Command:/usr/bin/make "cmTryCompileExec/fast" +/usr/bin/make -f CMakeFiles/cmTryCompileExec.dir/build.make CMakeFiles/cmTryCompileExec.dir/build +make[1]: Entering directory `/home/softcoder/Code/mojosetup/build/CMakeFiles/CMakeTmp' +/usr/bin/cmake -E cmake_progress_report /home/softcoder/Code/mojosetup/build/CMakeFiles/CMakeTmp/CMakeFiles 1 +Building C object CMakeFiles/cmTryCompileExec.dir/CheckFunctionExists.c.o +/usr/bin/gcc -DCHECK_FUNCTION_EXISTS=pthread_create -o CMakeFiles/cmTryCompileExec.dir/CheckFunctionExists.c.o -c /usr/share/cmake-2.8/Modules/CheckFunctionExists.c +Linking C executable cmTryCompileExec +/usr/bin/cmake -E cmake_link_script CMakeFiles/cmTryCompileExec.dir/link.txt --verbose=1 +/usr/bin/gcc -DCHECK_FUNCTION_EXISTS=pthread_create CMakeFiles/cmTryCompileExec.dir/CheckFunctionExists.c.o -o cmTryCompileExec -rdynamic -lpthread +make[1]: Leaving directory `/home/softcoder/Code/mojosetup/build/CMakeFiles/CMakeTmp' + + +Determining if the include file zlib.h exists passed with the following output: +Change Dir: /home/softcoder/Code/mojosetup/build/CMakeFiles/CMakeTmp + +Run Build Command:/usr/bin/make "cmTryCompileExec/fast" +/usr/bin/make -f CMakeFiles/cmTryCompileExec.dir/build.make CMakeFiles/cmTryCompileExec.dir/build +make[1]: Entering directory `/home/softcoder/Code/mojosetup/build/CMakeFiles/CMakeTmp' +/usr/bin/cmake -E cmake_progress_report /home/softcoder/Code/mojosetup/build/CMakeFiles/CMakeTmp/CMakeFiles 1 +Building C object CMakeFiles/cmTryCompileExec.dir/CheckIncludeFile.c.o +/usr/bin/gcc -o CMakeFiles/cmTryCompileExec.dir/CheckIncludeFile.c.o -c /home/softcoder/Code/mojosetup/build/CMakeFiles/CMakeTmp/CheckIncludeFile.c +Linking C executable cmTryCompileExec +/usr/bin/cmake -E cmake_link_script CMakeFiles/cmTryCompileExec.dir/link.txt --verbose=1 +/usr/bin/gcc CMakeFiles/cmTryCompileExec.dir/CheckIncludeFile.c.o -o cmTryCompileExec -rdynamic +make[1]: Leaving directory `/home/softcoder/Code/mojosetup/build/CMakeFiles/CMakeTmp' + + +Determining if the function inflate exists in the z passed with the following output: +Change Dir: /home/softcoder/Code/mojosetup/build/CMakeFiles/CMakeTmp + +Run Build Command:/usr/bin/make "cmTryCompileExec/fast" +/usr/bin/make -f CMakeFiles/cmTryCompileExec.dir/build.make CMakeFiles/cmTryCompileExec.dir/build +make[1]: Entering directory `/home/softcoder/Code/mojosetup/build/CMakeFiles/CMakeTmp' +/usr/bin/cmake -E cmake_progress_report /home/softcoder/Code/mojosetup/build/CMakeFiles/CMakeTmp/CMakeFiles 1 +Building C object CMakeFiles/cmTryCompileExec.dir/CheckFunctionExists.c.o +/usr/bin/gcc -DCHECK_FUNCTION_EXISTS=inflate -o CMakeFiles/cmTryCompileExec.dir/CheckFunctionExists.c.o -c /usr/share/cmake-2.8/Modules/CheckFunctionExists.c +Linking C executable cmTryCompileExec +/usr/bin/cmake -E cmake_link_script CMakeFiles/cmTryCompileExec.dir/link.txt --verbose=1 +/usr/bin/gcc -DCHECK_FUNCTION_EXISTS=inflate CMakeFiles/cmTryCompileExec.dir/CheckFunctionExists.c.o -o cmTryCompileExec -rdynamic -lz +make[1]: Leaving directory `/home/softcoder/Code/mojosetup/build/CMakeFiles/CMakeTmp' + + +Determining if the include file bzlib.h exists passed with the following output: +Change Dir: /home/softcoder/Code/mojosetup/build/CMakeFiles/CMakeTmp + +Run Build Command:/usr/bin/make "cmTryCompileExec/fast" +/usr/bin/make -f CMakeFiles/cmTryCompileExec.dir/build.make CMakeFiles/cmTryCompileExec.dir/build +make[1]: Entering directory `/home/softcoder/Code/mojosetup/build/CMakeFiles/CMakeTmp' +/usr/bin/cmake -E cmake_progress_report /home/softcoder/Code/mojosetup/build/CMakeFiles/CMakeTmp/CMakeFiles 1 +Building C object CMakeFiles/cmTryCompileExec.dir/CheckIncludeFile.c.o +/usr/bin/gcc -o CMakeFiles/cmTryCompileExec.dir/CheckIncludeFile.c.o -c /home/softcoder/Code/mojosetup/build/CMakeFiles/CMakeTmp/CheckIncludeFile.c +Linking C executable cmTryCompileExec +/usr/bin/cmake -E cmake_link_script CMakeFiles/cmTryCompileExec.dir/link.txt --verbose=1 +/usr/bin/gcc CMakeFiles/cmTryCompileExec.dir/CheckIncludeFile.c.o -o cmTryCompileExec -rdynamic +make[1]: Leaving directory `/home/softcoder/Code/mojosetup/build/CMakeFiles/CMakeTmp' + + +Determining if the function BZ2_bzDecompress exists in the bz2 passed with the following output: +Change Dir: /home/softcoder/Code/mojosetup/build/CMakeFiles/CMakeTmp + +Run Build Command:/usr/bin/make "cmTryCompileExec/fast" +/usr/bin/make -f CMakeFiles/cmTryCompileExec.dir/build.make CMakeFiles/cmTryCompileExec.dir/build +make[1]: Entering directory `/home/softcoder/Code/mojosetup/build/CMakeFiles/CMakeTmp' +/usr/bin/cmake -E cmake_progress_report /home/softcoder/Code/mojosetup/build/CMakeFiles/CMakeTmp/CMakeFiles 1 +Building C object CMakeFiles/cmTryCompileExec.dir/CheckFunctionExists.c.o +/usr/bin/gcc -DCHECK_FUNCTION_EXISTS=BZ2_bzDecompress -o CMakeFiles/cmTryCompileExec.dir/CheckFunctionExists.c.o -c /usr/share/cmake-2.8/Modules/CheckFunctionExists.c +Linking C executable cmTryCompileExec +/usr/bin/cmake -E cmake_link_script CMakeFiles/cmTryCompileExec.dir/link.txt --verbose=1 +/usr/bin/gcc -DCHECK_FUNCTION_EXISTS=BZ2_bzDecompress CMakeFiles/cmTryCompileExec.dir/CheckFunctionExists.c.o -o cmTryCompileExec -rdynamic -lbz2 +make[1]: Leaving directory `/home/softcoder/Code/mojosetup/build/CMakeFiles/CMakeTmp' + + +Determining if the include file mntent.h exists passed with the following output: +Change Dir: /home/softcoder/Code/mojosetup/build/CMakeFiles/CMakeTmp + +Run Build Command:/usr/bin/make "cmTryCompileExec/fast" +/usr/bin/make -f CMakeFiles/cmTryCompileExec.dir/build.make CMakeFiles/cmTryCompileExec.dir/build +make[1]: Entering directory `/home/softcoder/Code/mojosetup/build/CMakeFiles/CMakeTmp' +/usr/bin/cmake -E cmake_progress_report /home/softcoder/Code/mojosetup/build/CMakeFiles/CMakeTmp/CMakeFiles 1 +Building C object CMakeFiles/cmTryCompileExec.dir/CheckIncludeFile.c.o +/usr/bin/gcc -o CMakeFiles/cmTryCompileExec.dir/CheckIncludeFile.c.o -c /home/softcoder/Code/mojosetup/build/CMakeFiles/CMakeTmp/CheckIncludeFile.c +Linking C executable cmTryCompileExec +/usr/bin/cmake -E cmake_link_script CMakeFiles/cmTryCompileExec.dir/link.txt --verbose=1 +/usr/bin/gcc CMakeFiles/cmTryCompileExec.dir/CheckIncludeFile.c.o -o cmTryCompileExec -rdynamic +make[1]: Leaving directory `/home/softcoder/Code/mojosetup/build/CMakeFiles/CMakeTmp' + + +Determining if the function dlopen exists in the dl passed with the following output: +Change Dir: /home/softcoder/Code/mojosetup/build/CMakeFiles/CMakeTmp + +Run Build Command:/usr/bin/make "cmTryCompileExec/fast" +/usr/bin/make -f CMakeFiles/cmTryCompileExec.dir/build.make CMakeFiles/cmTryCompileExec.dir/build +make[1]: Entering directory `/home/softcoder/Code/mojosetup/build/CMakeFiles/CMakeTmp' +/usr/bin/cmake -E cmake_progress_report /home/softcoder/Code/mojosetup/build/CMakeFiles/CMakeTmp/CMakeFiles 1 +Building C object CMakeFiles/cmTryCompileExec.dir/CheckFunctionExists.c.o +/usr/bin/gcc -DCHECK_FUNCTION_EXISTS=dlopen -o CMakeFiles/cmTryCompileExec.dir/CheckFunctionExists.c.o -c /usr/share/cmake-2.8/Modules/CheckFunctionExists.c +Linking C executable cmTryCompileExec +/usr/bin/cmake -E cmake_link_script CMakeFiles/cmTryCompileExec.dir/link.txt --verbose=1 +/usr/bin/gcc -DCHECK_FUNCTION_EXISTS=dlopen CMakeFiles/cmTryCompileExec.dir/CheckFunctionExists.c.o -o cmTryCompileExec -rdynamic -ldl +make[1]: Leaving directory `/home/softcoder/Code/mojosetup/build/CMakeFiles/CMakeTmp' + + +Determining if the function sin exists in the m passed with the following output: +Change Dir: /home/softcoder/Code/mojosetup/build/CMakeFiles/CMakeTmp + +Run Build Command:/usr/bin/make "cmTryCompileExec/fast" +/usr/bin/make -f CMakeFiles/cmTryCompileExec.dir/build.make CMakeFiles/cmTryCompileExec.dir/build +make[1]: Entering directory `/home/softcoder/Code/mojosetup/build/CMakeFiles/CMakeTmp' +/usr/bin/cmake -E cmake_progress_report /home/softcoder/Code/mojosetup/build/CMakeFiles/CMakeTmp/CMakeFiles 1 +Building C object CMakeFiles/cmTryCompileExec.dir/CheckFunctionExists.c.o +/usr/bin/gcc -DCHECK_FUNCTION_EXISTS=sin -o CMakeFiles/cmTryCompileExec.dir/CheckFunctionExists.c.o -c /usr/share/cmake-2.8/Modules/CheckFunctionExists.c +/usr/share/cmake-2.8/Modules/CheckFunctionExists.c:3: warning: conflicting types for built-in function ‘sin’ +Linking C executable cmTryCompileExec +/usr/bin/cmake -E cmake_link_script CMakeFiles/cmTryCompileExec.dir/link.txt --verbose=1 +/usr/bin/gcc -DCHECK_FUNCTION_EXISTS=sin CMakeFiles/cmTryCompileExec.dir/CheckFunctionExists.c.o -o cmTryCompileExec -rdynamic -lm +make[1]: Leaving directory `/home/softcoder/Code/mojosetup/build/CMakeFiles/CMakeTmp' + + diff --git a/mk/linux/mojosetup/build/CMakeFiles/CMakeRuleHashes.txt b/mk/linux/mojosetup/build/CMakeFiles/CMakeRuleHashes.txt new file mode 100644 index 00000000..21c66364 --- /dev/null +++ b/mk/linux/mojosetup/build/CMakeFiles/CMakeRuleHashes.txt @@ -0,0 +1,3 @@ +# Hashes of file build rules. +a8c5d4326890019286024eb8a86d285d CMakeFiles/lua +7655e56c0923725ca6a81de43e4da44f CMakeFiles/skeleton diff --git a/mk/linux/mojosetup/build/CMakeFiles/CMakeSystem.cmake b/mk/linux/mojosetup/build/CMakeFiles/CMakeSystem.cmake new file mode 100644 index 00000000..fb57b36a --- /dev/null +++ b/mk/linux/mojosetup/build/CMakeFiles/CMakeSystem.cmake @@ -0,0 +1,15 @@ + + +SET(CMAKE_SYSTEM "Linux-2.6.31-21-generic-pae") +SET(CMAKE_SYSTEM_NAME "Linux") +SET(CMAKE_SYSTEM_VERSION "2.6.31-21-generic-pae") +SET(CMAKE_SYSTEM_PROCESSOR "i686") + +SET(CMAKE_HOST_SYSTEM "Linux-2.6.31-21-generic-pae") +SET(CMAKE_HOST_SYSTEM_NAME "Linux") +SET(CMAKE_HOST_SYSTEM_VERSION "2.6.31-21-generic-pae") +SET(CMAKE_HOST_SYSTEM_PROCESSOR "i686") + +SET(CMAKE_CROSSCOMPILING "FALSE") + +SET(CMAKE_SYSTEM_LOADED 1) diff --git a/mk/linux/mojosetup/build/CMakeFiles/CheckTypeSize.bin b/mk/linux/mojosetup/build/CMakeFiles/CheckTypeSize.bin new file mode 100755 index 00000000..f6e79c93 Binary files /dev/null and b/mk/linux/mojosetup/build/CMakeFiles/CheckTypeSize.bin differ diff --git a/mk/linux/mojosetup/build/CMakeFiles/CompilerIdC/CMakeCCompilerId.c b/mk/linux/mojosetup/build/CMakeFiles/CompilerIdC/CMakeCCompilerId.c new file mode 100644 index 00000000..f262e307 --- /dev/null +++ b/mk/linux/mojosetup/build/CMakeFiles/CompilerIdC/CMakeCCompilerId.c @@ -0,0 +1,188 @@ +#ifdef __cplusplus +# error "A C++ compiler has been selected for C." +#endif + +#if defined(__18CXX) +# define ID_VOID_MAIN +#endif + +#if defined(__INTEL_COMPILER) || defined(__ICC) +# define COMPILER_ID "Intel" + +#elif defined(__BORLANDC__) +# define COMPILER_ID "Borland" + +#elif defined(__WATCOMC__) +# define COMPILER_ID "Watcom" + +#elif defined(__SUNPRO_C) +# define COMPILER_ID "SunPro" + +#elif defined(__HP_cc) +# define COMPILER_ID "HP" + +#elif defined(__DECC) +# define COMPILER_ID "Compaq" + +#elif defined(__IBMC__) +# if defined(__COMPILER_VER__) +# define COMPILER_ID "zOS" +# elif __IBMC__ >= 800 +# define COMPILER_ID "XL" +# else +# define COMPILER_ID "VisualAge" +# endif + +#elif defined(__PGI) +# define COMPILER_ID "PGI" + +#elif defined(__GNUC__) +# define COMPILER_ID "GNU" + +#elif defined(_MSC_VER) +# define COMPILER_ID "MSVC" + +#elif defined(__ADSPBLACKFIN__) || defined(__ADSPTS__) || defined(__ADSP21000__) +/* Analog Devices C++ compiler for Blackfin, TigerSHARC and + SHARC (21000) DSPs */ +# define COMPILER_ID "ADSP" + +/* IAR Systems compiler for embedded systems. + http://www.iar.com + Not supported yet by CMake +#elif defined(__IAR_SYSTEMS_ICC__) +# define COMPILER_ID "IAR" */ + +/* sdcc, the small devices C compiler for embedded systems, + http://sdcc.sourceforge.net */ +#elif defined(SDCC) +# define COMPILER_ID "SDCC" + +#elif defined(_SGI_COMPILER_VERSION) || defined(_COMPILER_VERSION) +# define COMPILER_ID "MIPSpro" + +/* This compiler is either not known or is too old to define an + identification macro. Try to identify the platform and guess that + it is the native compiler. */ +#elif defined(__sgi) +# define COMPILER_ID "MIPSpro" + +#elif defined(__hpux) || defined(__hpua) +# define COMPILER_ID "HP" + +#else /* unknown compiler */ +# define COMPILER_ID "" + +#endif + +/* Construct the string literal in pieces to prevent the source from + getting matched. Store it in a pointer rather than an array + because some compilers will just produce instructions to fill the + array rather than assigning a pointer to a static array. */ +char* info_compiler = "INFO" ":" "compiler[" COMPILER_ID "]"; + +/* Identify known platforms by name. */ +#if defined(__linux) || defined(__linux__) || defined(linux) +# define PLATFORM_ID "Linux" + +#elif defined(__CYGWIN__) +# define PLATFORM_ID "Cygwin" + +#elif defined(__MINGW32__) +# define PLATFORM_ID "MinGW" + +#elif defined(__APPLE__) +# define PLATFORM_ID "Darwin" + +#elif defined(_WIN32) || defined(__WIN32__) || defined(WIN32) +# define PLATFORM_ID "Windows" + +#elif defined(__FreeBSD__) || defined(__FreeBSD) +# define PLATFORM_ID "FreeBSD" + +#elif defined(__NetBSD__) || defined(__NetBSD) +# define PLATFORM_ID "NetBSD" + +#elif defined(__OpenBSD__) || defined(__OPENBSD) +# define PLATFORM_ID "OpenBSD" + +#elif defined(__sun) || defined(sun) +# define PLATFORM_ID "SunOS" + +#elif defined(_AIX) || defined(__AIX) || defined(__AIX__) || defined(__aix) || defined(__aix__) +# define PLATFORM_ID "AIX" + +#elif defined(__sgi) || defined(__sgi__) || defined(_SGI) +# define PLATFORM_ID "IRIX" + +#elif defined(__hpux) || defined(__hpux__) +# define PLATFORM_ID "HP-UX" + +#elif defined(__HAIKU) || defined(__HAIKU__) || defined(_HAIKU) +# define PLATFORM_ID "Haiku" +/* Haiku also defines __BEOS__ so we must + put it prior to the check for __BEOS__ +*/ + +#elif defined(__BeOS) || defined(__BEOS__) || defined(_BEOS) +# define PLATFORM_ID "BeOS" + +#elif defined(__QNX__) || defined(__QNXNTO__) +# define PLATFORM_ID "QNX" + +#elif defined(__tru64) || defined(_tru64) || defined(__TRU64__) +# define PLATFORM_ID "Tru64" + +#elif defined(__riscos) || defined(__riscos__) +# define PLATFORM_ID "RISCos" + +#elif defined(__sinix) || defined(__sinix__) || defined(__SINIX__) +# define PLATFORM_ID "SINIX" + +#elif defined(__UNIX_SV__) +# define PLATFORM_ID "UNIX_SV" + +#elif defined(__bsdos__) +# define PLATFORM_ID "BSDOS" + +#elif defined(_MPRAS) || defined(MPRAS) +# define PLATFORM_ID "MP-RAS" + +#elif defined(__osf) || defined(__osf__) +# define PLATFORM_ID "OSF1" + +#elif defined(_SCO_SV) || defined(SCO_SV) || defined(sco_sv) +# define PLATFORM_ID "SCO_SV" + +#elif defined(__ultrix) || defined(__ultrix__) || defined(_ULTRIX) +# define PLATFORM_ID "ULTRIX" + +#elif defined(__XENIX__) || defined(_XENIX) || defined(XENIX) +# define PLATFORM_ID "Xenix" + +#else /* unknown platform */ +# define PLATFORM_ID "" + +#endif + +/* Construct the string literal in pieces to prevent the source from + getting matched. Store it in a pointer rather than an array + because some compilers will just produce instructions to fill the + array rather than assigning a pointer to a static array. */ +char* info_platform = "INFO" ":" "platform[" PLATFORM_ID "]"; + + +/*--------------------------------------------------------------------------*/ + +#ifdef ID_VOID_MAIN +void main() {} +#else +int main(int argc, char* argv[]) +{ + int require = 0; + require += info_compiler[argc]; + require += info_platform[argc]; + (void)argv; + return require; +} +#endif diff --git a/mk/linux/mojosetup/build/CMakeFiles/CompilerIdC/a.out b/mk/linux/mojosetup/build/CMakeFiles/CompilerIdC/a.out new file mode 100755 index 00000000..b18090c8 Binary files /dev/null and b/mk/linux/mojosetup/build/CMakeFiles/CompilerIdC/a.out differ diff --git a/mk/linux/mojosetup/build/CMakeFiles/Makefile.cmake b/mk/linux/mojosetup/build/CMakeFiles/Makefile.cmake new file mode 100644 index 00000000..5901e4e3 --- /dev/null +++ b/mk/linux/mojosetup/build/CMakeFiles/Makefile.cmake @@ -0,0 +1,68 @@ +# CMAKE generated file: DO NOT EDIT! +# Generated by "Unix Makefiles" Generator, CMake Version 2.8 + +# The generator used is: +SET(CMAKE_DEPENDS_GENERATOR "Unix Makefiles") + +# The top level Makefile was generated from the following files: +SET(CMAKE_MAKEFILE_DEPENDS + "CMakeCache.txt" + "../CMakeLists.txt" + "CMakeFiles/CMakeCCompiler.cmake" + "CMakeFiles/CMakeSystem.cmake" + "../misc/FindCurses.cmake" + "/usr/share/cmake-2.8/Modules/CMakeCCompiler.cmake.in" + "/usr/share/cmake-2.8/Modules/CMakeCCompilerABI.c" + "/usr/share/cmake-2.8/Modules/CMakeCInformation.cmake" + "/usr/share/cmake-2.8/Modules/CMakeCommonLanguageInclude.cmake" + "/usr/share/cmake-2.8/Modules/CMakeConfigurableFile.in" + "/usr/share/cmake-2.8/Modules/CMakeDetermineCCompiler.cmake" + "/usr/share/cmake-2.8/Modules/CMakeDetermineCompilerABI.cmake" + "/usr/share/cmake-2.8/Modules/CMakeDetermineCompilerId.cmake" + "/usr/share/cmake-2.8/Modules/CMakeDetermineSystem.cmake" + "/usr/share/cmake-2.8/Modules/CMakeFindBinUtils.cmake" + "/usr/share/cmake-2.8/Modules/CMakeGenericSystem.cmake" + "/usr/share/cmake-2.8/Modules/CMakeParseImplicitLinkInfo.cmake" + "/usr/share/cmake-2.8/Modules/CMakeSystem.cmake.in" + "/usr/share/cmake-2.8/Modules/CMakeSystemSpecificInformation.cmake" + "/usr/share/cmake-2.8/Modules/CMakeTestCCompiler.cmake" + "/usr/share/cmake-2.8/Modules/CMakeUnixFindMake.cmake" + "/usr/share/cmake-2.8/Modules/CheckCCompilerFlag.cmake" + "/usr/share/cmake-2.8/Modules/CheckCSourceCompiles.cmake" + "/usr/share/cmake-2.8/Modules/CheckFunctionExists.c" + "/usr/share/cmake-2.8/Modules/CheckIncludeFile.c.in" + "/usr/share/cmake-2.8/Modules/CheckIncludeFile.cmake" + "/usr/share/cmake-2.8/Modules/CheckIncludeFiles.cmake" + "/usr/share/cmake-2.8/Modules/CheckLibraryExists.cmake" + "/usr/share/cmake-2.8/Modules/CheckTypeSize.cmake" + "/usr/share/cmake-2.8/Modules/CheckTypeSizeC.c.in" + "/usr/share/cmake-2.8/Modules/Compiler/GNU-C.cmake" + "/usr/share/cmake-2.8/Modules/FindPackageHandleStandardArgs.cmake" + "/usr/share/cmake-2.8/Modules/FindPackageMessage.cmake" + "/usr/share/cmake-2.8/Modules/FindThreads.cmake" + "/usr/share/cmake-2.8/Modules/Platform/Linux.cmake" + "/usr/share/cmake-2.8/Modules/Platform/UnixPaths.cmake" + "/usr/share/cmake-2.8/Modules/Platform/gcc.cmake" + "/usr/share/cmake-2.8/Modules/TestBigEndian.cmake" + "/usr/share/cmake-2.8/Modules/TestEndianess.c.in" + ) + +# The corresponding makefile is: +SET(CMAKE_MAKEFILE_OUTPUTS + "Makefile" + "CMakeFiles/cmake.check_cache" + ) + +# Byproducts of CMake generate step: +SET(CMAKE_MAKEFILE_PRODUCTS + "CMakeFiles/CMakeDirectoryInformation.cmake" + ) + +# Dependency information for all targets: +SET(CMAKE_DEPEND_INFO_FILES + "CMakeFiles/lua.dir/DependInfo.cmake" + "CMakeFiles/mojoluac.dir/DependInfo.cmake" + "CMakeFiles/mojosetup.dir/DependInfo.cmake" + "CMakeFiles/mojosetupgui_gtkplus2.dir/DependInfo.cmake" + "CMakeFiles/skeleton.dir/DependInfo.cmake" + ) diff --git a/mk/linux/mojosetup/build/CMakeFiles/Makefile2 b/mk/linux/mojosetup/build/CMakeFiles/Makefile2 new file mode 100644 index 00000000..6d57b6fa --- /dev/null +++ b/mk/linux/mojosetup/build/CMakeFiles/Makefile2 @@ -0,0 +1,229 @@ +# CMAKE generated file: DO NOT EDIT! +# Generated by "Unix Makefiles" Generator, CMake Version 2.8 + +# Default target executed when no arguments are given to make. +default_target: all +.PHONY : default_target + +# The main recursive all target +all: +.PHONY : all + +# The main recursive preinstall target +preinstall: +.PHONY : preinstall + +#============================================================================= +# Special targets provided by cmake. + +# Disable implicit rules so canoncical targets will work. +.SUFFIXES: + +# Remove some rules from gmake that .SUFFIXES does not remove. +SUFFIXES = + +.SUFFIXES: .hpux_make_needs_suffix_list + +# Suppress display of executed commands. +$(VERBOSE).SILENT: + +# A target that is always out of date. +cmake_force: +.PHONY : cmake_force + +#============================================================================= +# Set environment variables for the build. + +# The shell in which to execute make rules. +SHELL = /bin/sh + +# The CMake executable. +CMAKE_COMMAND = /usr/bin/cmake + +# The command to remove a file. +RM = /usr/bin/cmake -E remove -f + +# The top-level source directory on which CMake was run. +CMAKE_SOURCE_DIR = /home/softcoder/Code/mojosetup + +# The top-level build directory on which CMake was run. +CMAKE_BINARY_DIR = /home/softcoder/Code/mojosetup/build + +#============================================================================= +# Target rules for target CMakeFiles/lua.dir + +# All Build rule for target. +CMakeFiles/lua.dir/all: + $(MAKE) -f CMakeFiles/lua.dir/build.make CMakeFiles/lua.dir/depend + $(MAKE) -f CMakeFiles/lua.dir/build.make CMakeFiles/lua.dir/build + $(CMAKE_COMMAND) -E cmake_progress_report /home/softcoder/Code/mojosetup/build/CMakeFiles + @echo "Built target lua" +.PHONY : CMakeFiles/lua.dir/all + +# Build rule for subdir invocation for target. +CMakeFiles/lua.dir/rule: cmake_check_build_system + $(CMAKE_COMMAND) -E cmake_progress_start /home/softcoder/Code/mojosetup/build/CMakeFiles 0 + $(MAKE) -f CMakeFiles/Makefile2 CMakeFiles/lua.dir/all + $(CMAKE_COMMAND) -E cmake_progress_start /home/softcoder/Code/mojosetup/build/CMakeFiles 0 +.PHONY : CMakeFiles/lua.dir/rule + +# Convenience name for target. +lua: CMakeFiles/lua.dir/rule +.PHONY : lua + +# clean rule for target. +CMakeFiles/lua.dir/clean: + $(MAKE) -f CMakeFiles/lua.dir/build.make CMakeFiles/lua.dir/clean +.PHONY : CMakeFiles/lua.dir/clean + +# clean rule for target. +clean: CMakeFiles/lua.dir/clean +.PHONY : clean + +#============================================================================= +# Target rules for target CMakeFiles/mojoluac.dir + +# All Build rule for target. +CMakeFiles/mojoluac.dir/all: + $(MAKE) -f CMakeFiles/mojoluac.dir/build.make CMakeFiles/mojoluac.dir/depend + $(MAKE) -f CMakeFiles/mojoluac.dir/build.make CMakeFiles/mojoluac.dir/build + $(CMAKE_COMMAND) -E cmake_progress_report /home/softcoder/Code/mojosetup/build/CMakeFiles 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 + @echo "Built target mojoluac" +.PHONY : CMakeFiles/mojoluac.dir/all + +# Include target in all. +all: CMakeFiles/mojoluac.dir/all +.PHONY : all + +# Build rule for subdir invocation for target. +CMakeFiles/mojoluac.dir/rule: cmake_check_build_system + $(CMAKE_COMMAND) -E cmake_progress_start /home/softcoder/Code/mojosetup/build/CMakeFiles 31 + $(MAKE) -f CMakeFiles/Makefile2 CMakeFiles/mojoluac.dir/all + $(CMAKE_COMMAND) -E cmake_progress_start /home/softcoder/Code/mojosetup/build/CMakeFiles 0 +.PHONY : CMakeFiles/mojoluac.dir/rule + +# Convenience name for target. +mojoluac: CMakeFiles/mojoluac.dir/rule +.PHONY : mojoluac + +# clean rule for target. +CMakeFiles/mojoluac.dir/clean: + $(MAKE) -f CMakeFiles/mojoluac.dir/build.make CMakeFiles/mojoluac.dir/clean +.PHONY : CMakeFiles/mojoluac.dir/clean + +# clean rule for target. +clean: CMakeFiles/mojoluac.dir/clean +.PHONY : clean + +#============================================================================= +# Target rules for target CMakeFiles/mojosetup.dir + +# All Build rule for target. +CMakeFiles/mojosetup.dir/all: + $(MAKE) -f CMakeFiles/mojosetup.dir/build.make CMakeFiles/mojosetup.dir/depend + $(MAKE) -f CMakeFiles/mojosetup.dir/build.make CMakeFiles/mojosetup.dir/build + $(CMAKE_COMMAND) -E cmake_progress_report /home/softcoder/Code/mojosetup/build/CMakeFiles 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 + @echo "Built target mojosetup" +.PHONY : CMakeFiles/mojosetup.dir/all + +# Include target in all. +all: CMakeFiles/mojosetup.dir/all +.PHONY : all + +# Build rule for subdir invocation for target. +CMakeFiles/mojosetup.dir/rule: cmake_check_build_system + $(CMAKE_COMMAND) -E cmake_progress_start /home/softcoder/Code/mojosetup/build/CMakeFiles 48 + $(MAKE) -f CMakeFiles/Makefile2 CMakeFiles/mojosetup.dir/all + $(CMAKE_COMMAND) -E cmake_progress_start /home/softcoder/Code/mojosetup/build/CMakeFiles 0 +.PHONY : CMakeFiles/mojosetup.dir/rule + +# Convenience name for target. +mojosetup: CMakeFiles/mojosetup.dir/rule +.PHONY : mojosetup + +# clean rule for target. +CMakeFiles/mojosetup.dir/clean: + $(MAKE) -f CMakeFiles/mojosetup.dir/build.make CMakeFiles/mojosetup.dir/clean +.PHONY : CMakeFiles/mojosetup.dir/clean + +# clean rule for target. +clean: CMakeFiles/mojosetup.dir/clean +.PHONY : clean + +#============================================================================= +# Target rules for target CMakeFiles/mojosetupgui_gtkplus2.dir + +# All Build rule for target. +CMakeFiles/mojosetupgui_gtkplus2.dir/all: + $(MAKE) -f CMakeFiles/mojosetupgui_gtkplus2.dir/build.make CMakeFiles/mojosetupgui_gtkplus2.dir/depend + $(MAKE) -f CMakeFiles/mojosetupgui_gtkplus2.dir/build.make CMakeFiles/mojosetupgui_gtkplus2.dir/build + $(CMAKE_COMMAND) -E cmake_progress_report /home/softcoder/Code/mojosetup/build/CMakeFiles 80 + @echo "Built target mojosetupgui_gtkplus2" +.PHONY : CMakeFiles/mojosetupgui_gtkplus2.dir/all + +# Include target in all. +all: CMakeFiles/mojosetupgui_gtkplus2.dir/all +.PHONY : all + +# Build rule for subdir invocation for target. +CMakeFiles/mojosetupgui_gtkplus2.dir/rule: cmake_check_build_system + $(CMAKE_COMMAND) -E cmake_progress_start /home/softcoder/Code/mojosetup/build/CMakeFiles 1 + $(MAKE) -f CMakeFiles/Makefile2 CMakeFiles/mojosetupgui_gtkplus2.dir/all + $(CMAKE_COMMAND) -E cmake_progress_start /home/softcoder/Code/mojosetup/build/CMakeFiles 0 +.PHONY : CMakeFiles/mojosetupgui_gtkplus2.dir/rule + +# Convenience name for target. +mojosetupgui_gtkplus2: CMakeFiles/mojosetupgui_gtkplus2.dir/rule +.PHONY : mojosetupgui_gtkplus2 + +# clean rule for target. +CMakeFiles/mojosetupgui_gtkplus2.dir/clean: + $(MAKE) -f CMakeFiles/mojosetupgui_gtkplus2.dir/build.make CMakeFiles/mojosetupgui_gtkplus2.dir/clean +.PHONY : CMakeFiles/mojosetupgui_gtkplus2.dir/clean + +# clean rule for target. +clean: CMakeFiles/mojosetupgui_gtkplus2.dir/clean +.PHONY : clean + +#============================================================================= +# Target rules for target CMakeFiles/skeleton.dir + +# All Build rule for target. +CMakeFiles/skeleton.dir/all: CMakeFiles/mojosetupgui_gtkplus2.dir/all +CMakeFiles/skeleton.dir/all: CMakeFiles/mojosetup.dir/all + $(MAKE) -f CMakeFiles/skeleton.dir/build.make CMakeFiles/skeleton.dir/depend + $(MAKE) -f CMakeFiles/skeleton.dir/build.make CMakeFiles/skeleton.dir/build + $(CMAKE_COMMAND) -E cmake_progress_report /home/softcoder/Code/mojosetup/build/CMakeFiles 81 + @echo "Built target skeleton" +.PHONY : CMakeFiles/skeleton.dir/all + +# Build rule for subdir invocation for target. +CMakeFiles/skeleton.dir/rule: cmake_check_build_system + $(CMAKE_COMMAND) -E cmake_progress_start /home/softcoder/Code/mojosetup/build/CMakeFiles 50 + $(MAKE) -f CMakeFiles/Makefile2 CMakeFiles/skeleton.dir/all + $(CMAKE_COMMAND) -E cmake_progress_start /home/softcoder/Code/mojosetup/build/CMakeFiles 0 +.PHONY : CMakeFiles/skeleton.dir/rule + +# Convenience name for target. +skeleton: CMakeFiles/skeleton.dir/rule +.PHONY : skeleton + +# clean rule for target. +CMakeFiles/skeleton.dir/clean: + $(MAKE) -f CMakeFiles/skeleton.dir/build.make CMakeFiles/skeleton.dir/clean +.PHONY : CMakeFiles/skeleton.dir/clean + +# clean rule for target. +clean: CMakeFiles/skeleton.dir/clean +.PHONY : clean + +#============================================================================= +# Special targets to cleanup operation of make. + +# Special rule to run CMake to check the build system integrity. +# No rule that depends on this can have commands that come from listfiles +# because they might be regenerated. +cmake_check_build_system: + $(CMAKE_COMMAND) -H$(CMAKE_SOURCE_DIR) -B$(CMAKE_BINARY_DIR) --check-build-system CMakeFiles/Makefile.cmake 0 +.PHONY : cmake_check_build_system + diff --git a/mk/linux/mojosetup/build/CMakeFiles/TargetDirectories.txt b/mk/linux/mojosetup/build/CMakeFiles/TargetDirectories.txt new file mode 100644 index 00000000..c35e7da6 --- /dev/null +++ b/mk/linux/mojosetup/build/CMakeFiles/TargetDirectories.txt @@ -0,0 +1,5 @@ +/home/softcoder/Code/mojosetup/build/CMakeFiles/lua.dir +/home/softcoder/Code/mojosetup/build/CMakeFiles/mojoluac.dir +/home/softcoder/Code/mojosetup/build/CMakeFiles/mojosetup.dir +/home/softcoder/Code/mojosetup/build/CMakeFiles/mojosetupgui_gtkplus2.dir +/home/softcoder/Code/mojosetup/build/CMakeFiles/skeleton.dir diff --git a/mk/linux/mojosetup/build/CMakeFiles/TestEndianess.bin b/mk/linux/mojosetup/build/CMakeFiles/TestEndianess.bin new file mode 100755 index 00000000..95396926 Binary files /dev/null and b/mk/linux/mojosetup/build/CMakeFiles/TestEndianess.bin differ diff --git a/mk/linux/mojosetup/build/CMakeFiles/cmake.check_cache b/mk/linux/mojosetup/build/CMakeFiles/cmake.check_cache new file mode 100644 index 00000000..3dccd731 --- /dev/null +++ b/mk/linux/mojosetup/build/CMakeFiles/cmake.check_cache @@ -0,0 +1 @@ +# This file is generated by cmake for dependency checking of the CMakeCache.txt file diff --git a/mk/linux/mojosetup/build/CMakeFiles/lua.dir/DependInfo.cmake b/mk/linux/mojosetup/build/CMakeFiles/lua.dir/DependInfo.cmake new file mode 100644 index 00000000..c6c259e1 --- /dev/null +++ b/mk/linux/mojosetup/build/CMakeFiles/lua.dir/DependInfo.cmake @@ -0,0 +1,42 @@ +# The set of languages for which implicit dependencies are needed: +SET(CMAKE_DEPENDS_LANGUAGES + ) +# The set of files for implicit dependencies of each language: + +# Preprocessor definitions for this target. +SET(CMAKE_TARGET_DEFINITIONS + "__MOJOSETUP__=1" + "APPID=mojosetup" + "_REENTRANT" + "_THREAD_SAFE" + "PLATFORM_UNIX=1" + "LUA_USE_MKSTEMP=1" + "LUA_USE_ULONGJMP=1" + "PLATFORM_LITTLEENDIAN=1" + "SUPPORT_LUALIB_IO=1" + "SUPPORT_LUALIB_OS=1" + "SUPPORT_LUALIB_MATH=1" + "SUPPORT_LUALIB_DB=1" + "SUPPORT_LUALIB_PACKAGE=1" + "SUPPORT_CRC32=1" + "SUPPORT_MD5=1" + "SUPPORT_SHA1=1" + "SUPPORT_GUI_STDIO=1" + "GUI_STATIC_LINK_STDIO=1" + "SUPPORT_GUI_GTKPLUS2=1" + "SUPPORT_ZIP=1" + "SUPPORT_TAR=1" + "SUPPORT_GZIP=1" + "SUPPORT_BZIP2=1" + "BZ_NO_STDIO=1" + "SUPPORT_JPG=1" + "SUPPORT_PNG=1" + "SUPPORT_STBIMAGE=1" + "SUPPORT_URL_HTTP=1" + "SUPPORT_URL_FTP=1" + "MOJOSETUP_HAVE_MNTENT_H=1" + ) + +# Targets to which this target links. +SET(CMAKE_TARGET_LINKED_INFO_FILES + ) diff --git a/mk/linux/mojosetup/build/CMakeFiles/lua.dir/build.make b/mk/linux/mojosetup/build/CMakeFiles/lua.dir/build.make new file mode 100644 index 00000000..bd17e746 --- /dev/null +++ b/mk/linux/mojosetup/build/CMakeFiles/lua.dir/build.make @@ -0,0 +1,60 @@ +# CMAKE generated file: DO NOT EDIT! +# Generated by "Unix Makefiles" Generator, CMake Version 2.8 + +#============================================================================= +# Special targets provided by cmake. + +# Disable implicit rules so canoncical targets will work. +.SUFFIXES: + +# Remove some rules from gmake that .SUFFIXES does not remove. +SUFFIXES = + +.SUFFIXES: .hpux_make_needs_suffix_list + +# Suppress display of executed commands. +$(VERBOSE).SILENT: + +# A target that is always out of date. +cmake_force: +.PHONY : cmake_force + +#============================================================================= +# Set environment variables for the build. + +# The shell in which to execute make rules. +SHELL = /bin/sh + +# The CMake executable. +CMAKE_COMMAND = /usr/bin/cmake + +# The command to remove a file. +RM = /usr/bin/cmake -E remove -f + +# The top-level source directory on which CMake was run. +CMAKE_SOURCE_DIR = /home/softcoder/Code/mojosetup + +# The top-level build directory on which CMake was run. +CMAKE_BINARY_DIR = /home/softcoder/Code/mojosetup/build + +# Utility rule file for lua. + +CMakeFiles/lua: + ./mojoluac -p /home/softcoder/Code/mojosetup/scripts/*.lua + +lua: CMakeFiles/lua +lua: CMakeFiles/lua.dir/build.make +.PHONY : lua + +# Rule to build all files generated by this target. +CMakeFiles/lua.dir/build: lua +.PHONY : CMakeFiles/lua.dir/build + +CMakeFiles/lua.dir/clean: + $(CMAKE_COMMAND) -P CMakeFiles/lua.dir/cmake_clean.cmake +.PHONY : CMakeFiles/lua.dir/clean + +CMakeFiles/lua.dir/depend: + cd /home/softcoder/Code/mojosetup/build && $(CMAKE_COMMAND) -E cmake_depends "Unix Makefiles" /home/softcoder/Code/mojosetup /home/softcoder/Code/mojosetup /home/softcoder/Code/mojosetup/build /home/softcoder/Code/mojosetup/build /home/softcoder/Code/mojosetup/build/CMakeFiles/lua.dir/DependInfo.cmake --color=$(COLOR) +.PHONY : CMakeFiles/lua.dir/depend + diff --git a/mk/linux/mojosetup/build/CMakeFiles/lua.dir/cmake_clean.cmake b/mk/linux/mojosetup/build/CMakeFiles/lua.dir/cmake_clean.cmake new file mode 100644 index 00000000..ce2367e3 --- /dev/null +++ b/mk/linux/mojosetup/build/CMakeFiles/lua.dir/cmake_clean.cmake @@ -0,0 +1,8 @@ +FILE(REMOVE_RECURSE + "CMakeFiles/lua" +) + +# Per-language clean rules from dependency scanning. +FOREACH(lang) + INCLUDE(CMakeFiles/lua.dir/cmake_clean_${lang}.cmake OPTIONAL) +ENDFOREACH(lang) diff --git a/mk/linux/mojosetup/build/CMakeFiles/lua.dir/progress.make b/mk/linux/mojosetup/build/CMakeFiles/lua.dir/progress.make new file mode 100644 index 00000000..8b137891 --- /dev/null +++ b/mk/linux/mojosetup/build/CMakeFiles/lua.dir/progress.make @@ -0,0 +1 @@ + diff --git a/mk/linux/mojosetup/build/CMakeFiles/mojoluac.dir/C.includecache b/mk/linux/mojosetup/build/CMakeFiles/mojoluac.dir/C.includecache new file mode 100644 index 00000000..acef3477 --- /dev/null +++ b/mk/linux/mojosetup/build/CMakeFiles/mojoluac.dir/C.includecache @@ -0,0 +1,804 @@ +#IncludeRegexLine: ^[ ]*#[ ]*(include|import)[ ]*[<"]([^">]+)([">]) + +#IncludeRegexScan: ^.*$ + +#IncludeRegexComplain: ^$ + +#IncludeRegexTransform: + +/home/softcoder/Code/mojosetup/lua/src/lapi.c +assert.h +- +math.h +- +stdarg.h +- +string.h +- +lua.h +/home/softcoder/Code/mojosetup/lua/src/lua.h +lapi.h +/home/softcoder/Code/mojosetup/lua/src/lapi.h +ldebug.h +/home/softcoder/Code/mojosetup/lua/src/ldebug.h +ldo.h +/home/softcoder/Code/mojosetup/lua/src/ldo.h +lfunc.h +/home/softcoder/Code/mojosetup/lua/src/lfunc.h +lgc.h +/home/softcoder/Code/mojosetup/lua/src/lgc.h +lmem.h +/home/softcoder/Code/mojosetup/lua/src/lmem.h +lobject.h +/home/softcoder/Code/mojosetup/lua/src/lobject.h +lstate.h +/home/softcoder/Code/mojosetup/lua/src/lstate.h +lstring.h +/home/softcoder/Code/mojosetup/lua/src/lstring.h +ltable.h +/home/softcoder/Code/mojosetup/lua/src/ltable.h +ltm.h +/home/softcoder/Code/mojosetup/lua/src/ltm.h +lundump.h +/home/softcoder/Code/mojosetup/lua/src/lundump.h +lvm.h +/home/softcoder/Code/mojosetup/lua/src/lvm.h + +/home/softcoder/Code/mojosetup/lua/src/lapi.h +lobject.h +/home/softcoder/Code/mojosetup/lua/src/lobject.h + +/home/softcoder/Code/mojosetup/lua/src/lauxlib.c +ctype.h +- +errno.h +- +stdarg.h +- +stdio.h +- +stdlib.h +- +string.h +- +lua.h +/home/softcoder/Code/mojosetup/lua/src/lua.h +lauxlib.h +/home/softcoder/Code/mojosetup/lua/src/lauxlib.h + +/home/softcoder/Code/mojosetup/lua/src/lauxlib.h +stddef.h +- +stdio.h +- +lua.h +/home/softcoder/Code/mojosetup/lua/src/lua.h + +/home/softcoder/Code/mojosetup/lua/src/lbaselib.c +ctype.h +- +stdio.h +- +stdlib.h +- +string.h +- +lua.h +/home/softcoder/Code/mojosetup/lua/src/lua.h +lauxlib.h +/home/softcoder/Code/mojosetup/lua/src/lauxlib.h +lualib.h +/home/softcoder/Code/mojosetup/lua/src/lualib.h + +/home/softcoder/Code/mojosetup/lua/src/lcode.c +stdlib.h +- +lua.h +/home/softcoder/Code/mojosetup/lua/src/lua.h +lcode.h +/home/softcoder/Code/mojosetup/lua/src/lcode.h +ldebug.h +/home/softcoder/Code/mojosetup/lua/src/ldebug.h +ldo.h +/home/softcoder/Code/mojosetup/lua/src/ldo.h +lgc.h +/home/softcoder/Code/mojosetup/lua/src/lgc.h +llex.h +/home/softcoder/Code/mojosetup/lua/src/llex.h +lmem.h +/home/softcoder/Code/mojosetup/lua/src/lmem.h +lobject.h +/home/softcoder/Code/mojosetup/lua/src/lobject.h +lopcodes.h +/home/softcoder/Code/mojosetup/lua/src/lopcodes.h +lparser.h +/home/softcoder/Code/mojosetup/lua/src/lparser.h +ltable.h +/home/softcoder/Code/mojosetup/lua/src/ltable.h + +/home/softcoder/Code/mojosetup/lua/src/lcode.h +llex.h +/home/softcoder/Code/mojosetup/lua/src/llex.h +lobject.h +/home/softcoder/Code/mojosetup/lua/src/lobject.h +lopcodes.h +/home/softcoder/Code/mojosetup/lua/src/lopcodes.h +lparser.h +/home/softcoder/Code/mojosetup/lua/src/lparser.h + +/home/softcoder/Code/mojosetup/lua/src/ldblib.c +stdio.h +- +stdlib.h +- +string.h +- +lua.h +/home/softcoder/Code/mojosetup/lua/src/lua.h +lauxlib.h +/home/softcoder/Code/mojosetup/lua/src/lauxlib.h +lualib.h +/home/softcoder/Code/mojosetup/lua/src/lualib.h + +/home/softcoder/Code/mojosetup/lua/src/ldebug.c +stdarg.h +- +stddef.h +- +string.h +- +lua.h +/home/softcoder/Code/mojosetup/lua/src/lua.h +lapi.h +/home/softcoder/Code/mojosetup/lua/src/lapi.h +lcode.h +/home/softcoder/Code/mojosetup/lua/src/lcode.h +ldebug.h +/home/softcoder/Code/mojosetup/lua/src/ldebug.h +ldo.h +/home/softcoder/Code/mojosetup/lua/src/ldo.h +lfunc.h +/home/softcoder/Code/mojosetup/lua/src/lfunc.h +lobject.h +/home/softcoder/Code/mojosetup/lua/src/lobject.h +lopcodes.h +/home/softcoder/Code/mojosetup/lua/src/lopcodes.h +lstate.h +/home/softcoder/Code/mojosetup/lua/src/lstate.h +lstring.h +/home/softcoder/Code/mojosetup/lua/src/lstring.h +ltable.h +/home/softcoder/Code/mojosetup/lua/src/ltable.h +ltm.h +/home/softcoder/Code/mojosetup/lua/src/ltm.h +lvm.h +/home/softcoder/Code/mojosetup/lua/src/lvm.h + +/home/softcoder/Code/mojosetup/lua/src/ldebug.h +lstate.h +/home/softcoder/Code/mojosetup/lua/src/lstate.h + +/home/softcoder/Code/mojosetup/lua/src/ldo.c +setjmp.h +- +stdlib.h +- +string.h +- +lua.h +/home/softcoder/Code/mojosetup/lua/src/lua.h +ldebug.h +/home/softcoder/Code/mojosetup/lua/src/ldebug.h +ldo.h +/home/softcoder/Code/mojosetup/lua/src/ldo.h +lfunc.h +/home/softcoder/Code/mojosetup/lua/src/lfunc.h +lgc.h +/home/softcoder/Code/mojosetup/lua/src/lgc.h +lmem.h +/home/softcoder/Code/mojosetup/lua/src/lmem.h +lobject.h +/home/softcoder/Code/mojosetup/lua/src/lobject.h +lopcodes.h +/home/softcoder/Code/mojosetup/lua/src/lopcodes.h +lparser.h +/home/softcoder/Code/mojosetup/lua/src/lparser.h +lstate.h +/home/softcoder/Code/mojosetup/lua/src/lstate.h +lstring.h +/home/softcoder/Code/mojosetup/lua/src/lstring.h +ltable.h +/home/softcoder/Code/mojosetup/lua/src/ltable.h +ltm.h +/home/softcoder/Code/mojosetup/lua/src/ltm.h +lundump.h +/home/softcoder/Code/mojosetup/lua/src/lundump.h +lvm.h +/home/softcoder/Code/mojosetup/lua/src/lvm.h +lzio.h +/home/softcoder/Code/mojosetup/lua/src/lzio.h + +/home/softcoder/Code/mojosetup/lua/src/ldo.h +lobject.h +/home/softcoder/Code/mojosetup/lua/src/lobject.h +lstate.h +/home/softcoder/Code/mojosetup/lua/src/lstate.h +lzio.h +/home/softcoder/Code/mojosetup/lua/src/lzio.h + +/home/softcoder/Code/mojosetup/lua/src/ldump.c +stddef.h +- +lua.h +/home/softcoder/Code/mojosetup/lua/src/lua.h +lobject.h +/home/softcoder/Code/mojosetup/lua/src/lobject.h +lstate.h +/home/softcoder/Code/mojosetup/lua/src/lstate.h +lundump.h +/home/softcoder/Code/mojosetup/lua/src/lundump.h + +/home/softcoder/Code/mojosetup/lua/src/lfunc.c +stddef.h +- +lua.h +/home/softcoder/Code/mojosetup/lua/src/lua.h +lfunc.h +/home/softcoder/Code/mojosetup/lua/src/lfunc.h +lgc.h +/home/softcoder/Code/mojosetup/lua/src/lgc.h +lmem.h +/home/softcoder/Code/mojosetup/lua/src/lmem.h +lobject.h +/home/softcoder/Code/mojosetup/lua/src/lobject.h +lstate.h +/home/softcoder/Code/mojosetup/lua/src/lstate.h + +/home/softcoder/Code/mojosetup/lua/src/lfunc.h +lobject.h +/home/softcoder/Code/mojosetup/lua/src/lobject.h + +/home/softcoder/Code/mojosetup/lua/src/lgc.c +string.h +- +lua.h +/home/softcoder/Code/mojosetup/lua/src/lua.h +ldebug.h +/home/softcoder/Code/mojosetup/lua/src/ldebug.h +ldo.h +/home/softcoder/Code/mojosetup/lua/src/ldo.h +lfunc.h +/home/softcoder/Code/mojosetup/lua/src/lfunc.h +lgc.h +/home/softcoder/Code/mojosetup/lua/src/lgc.h +lmem.h +/home/softcoder/Code/mojosetup/lua/src/lmem.h +lobject.h +/home/softcoder/Code/mojosetup/lua/src/lobject.h +lstate.h +/home/softcoder/Code/mojosetup/lua/src/lstate.h +lstring.h +/home/softcoder/Code/mojosetup/lua/src/lstring.h +ltable.h +/home/softcoder/Code/mojosetup/lua/src/ltable.h +ltm.h +/home/softcoder/Code/mojosetup/lua/src/ltm.h + +/home/softcoder/Code/mojosetup/lua/src/lgc.h +lobject.h +/home/softcoder/Code/mojosetup/lua/src/lobject.h + +/home/softcoder/Code/mojosetup/lua/src/linit.c +lua.h +/home/softcoder/Code/mojosetup/lua/src/lua.h +lualib.h +/home/softcoder/Code/mojosetup/lua/src/lualib.h +lauxlib.h +/home/softcoder/Code/mojosetup/lua/src/lauxlib.h + +/home/softcoder/Code/mojosetup/lua/src/liolib.c +errno.h +- +stdio.h +- +stdlib.h +- +string.h +- +lua.h +/home/softcoder/Code/mojosetup/lua/src/lua.h +lauxlib.h +/home/softcoder/Code/mojosetup/lua/src/lauxlib.h +lualib.h +/home/softcoder/Code/mojosetup/lua/src/lualib.h + +/home/softcoder/Code/mojosetup/lua/src/llex.c +ctype.h +- +locale.h +- +string.h +- +lua.h +/home/softcoder/Code/mojosetup/lua/src/lua.h +ldo.h +/home/softcoder/Code/mojosetup/lua/src/ldo.h +llex.h +/home/softcoder/Code/mojosetup/lua/src/llex.h +lobject.h +/home/softcoder/Code/mojosetup/lua/src/lobject.h +lparser.h +/home/softcoder/Code/mojosetup/lua/src/lparser.h +lstate.h +/home/softcoder/Code/mojosetup/lua/src/lstate.h +lstring.h +/home/softcoder/Code/mojosetup/lua/src/lstring.h +ltable.h +/home/softcoder/Code/mojosetup/lua/src/ltable.h +lzio.h +/home/softcoder/Code/mojosetup/lua/src/lzio.h + +/home/softcoder/Code/mojosetup/lua/src/llex.h +lobject.h +/home/softcoder/Code/mojosetup/lua/src/lobject.h +lzio.h +/home/softcoder/Code/mojosetup/lua/src/lzio.h + +/home/softcoder/Code/mojosetup/lua/src/llimits.h +limits.h +- +stddef.h +- +lua.h +/home/softcoder/Code/mojosetup/lua/src/lua.h + +/home/softcoder/Code/mojosetup/lua/src/lmathlib.c +stdlib.h +- +math.h +- +lua.h +/home/softcoder/Code/mojosetup/lua/src/lua.h +lauxlib.h +/home/softcoder/Code/mojosetup/lua/src/lauxlib.h +lualib.h +/home/softcoder/Code/mojosetup/lua/src/lualib.h + +/home/softcoder/Code/mojosetup/lua/src/lmem.c +stddef.h +- +lua.h +/home/softcoder/Code/mojosetup/lua/src/lua.h +ldebug.h +/home/softcoder/Code/mojosetup/lua/src/ldebug.h +ldo.h +/home/softcoder/Code/mojosetup/lua/src/ldo.h +lmem.h +/home/softcoder/Code/mojosetup/lua/src/lmem.h +lobject.h +/home/softcoder/Code/mojosetup/lua/src/lobject.h +lstate.h +/home/softcoder/Code/mojosetup/lua/src/lstate.h + +/home/softcoder/Code/mojosetup/lua/src/lmem.h +stddef.h +- +llimits.h +/home/softcoder/Code/mojosetup/lua/src/llimits.h +lua.h +/home/softcoder/Code/mojosetup/lua/src/lua.h + +/home/softcoder/Code/mojosetup/lua/src/loadlib.c +stdlib.h +- +string.h +- +lua.h +/home/softcoder/Code/mojosetup/lua/src/lua.h +lauxlib.h +/home/softcoder/Code/mojosetup/lua/src/lauxlib.h +lualib.h +/home/softcoder/Code/mojosetup/lua/src/lualib.h +dlfcn.h +- +windows.h +- +mach-o/dyld.h +- + +/home/softcoder/Code/mojosetup/lua/src/lobject.c +ctype.h +- +stdarg.h +- +stdio.h +- +stdlib.h +- +string.h +- +lua.h +/home/softcoder/Code/mojosetup/lua/src/lua.h +ldo.h +/home/softcoder/Code/mojosetup/lua/src/ldo.h +lmem.h +/home/softcoder/Code/mojosetup/lua/src/lmem.h +lobject.h +/home/softcoder/Code/mojosetup/lua/src/lobject.h +lstate.h +/home/softcoder/Code/mojosetup/lua/src/lstate.h +lstring.h +/home/softcoder/Code/mojosetup/lua/src/lstring.h +lvm.h +/home/softcoder/Code/mojosetup/lua/src/lvm.h + +/home/softcoder/Code/mojosetup/lua/src/lobject.h +stdarg.h +- +llimits.h +/home/softcoder/Code/mojosetup/lua/src/llimits.h +lua.h +/home/softcoder/Code/mojosetup/lua/src/lua.h + +/home/softcoder/Code/mojosetup/lua/src/lopcodes.c +lopcodes.h +/home/softcoder/Code/mojosetup/lua/src/lopcodes.h + +/home/softcoder/Code/mojosetup/lua/src/lopcodes.h +llimits.h +/home/softcoder/Code/mojosetup/lua/src/llimits.h + +/home/softcoder/Code/mojosetup/lua/src/loslib.c +errno.h +- +locale.h +- +stdlib.h +- +string.h +- +time.h +- +lua.h +/home/softcoder/Code/mojosetup/lua/src/lua.h +lauxlib.h +/home/softcoder/Code/mojosetup/lua/src/lauxlib.h +lualib.h +/home/softcoder/Code/mojosetup/lua/src/lualib.h + +/home/softcoder/Code/mojosetup/lua/src/lparser.c +string.h +- +lua.h +/home/softcoder/Code/mojosetup/lua/src/lua.h +lcode.h +/home/softcoder/Code/mojosetup/lua/src/lcode.h +ldebug.h +/home/softcoder/Code/mojosetup/lua/src/ldebug.h +ldo.h +/home/softcoder/Code/mojosetup/lua/src/ldo.h +lfunc.h +/home/softcoder/Code/mojosetup/lua/src/lfunc.h +llex.h +/home/softcoder/Code/mojosetup/lua/src/llex.h +lmem.h +/home/softcoder/Code/mojosetup/lua/src/lmem.h +lobject.h +/home/softcoder/Code/mojosetup/lua/src/lobject.h +lopcodes.h +/home/softcoder/Code/mojosetup/lua/src/lopcodes.h +lparser.h +/home/softcoder/Code/mojosetup/lua/src/lparser.h +lstate.h +/home/softcoder/Code/mojosetup/lua/src/lstate.h +lstring.h +/home/softcoder/Code/mojosetup/lua/src/lstring.h +ltable.h +/home/softcoder/Code/mojosetup/lua/src/ltable.h + +/home/softcoder/Code/mojosetup/lua/src/lparser.h +llimits.h +/home/softcoder/Code/mojosetup/lua/src/llimits.h +lobject.h +/home/softcoder/Code/mojosetup/lua/src/lobject.h +lzio.h +/home/softcoder/Code/mojosetup/lua/src/lzio.h + +/home/softcoder/Code/mojosetup/lua/src/lstate.c +stddef.h +- +lua.h +/home/softcoder/Code/mojosetup/lua/src/lua.h +ldebug.h +/home/softcoder/Code/mojosetup/lua/src/ldebug.h +ldo.h +/home/softcoder/Code/mojosetup/lua/src/ldo.h +lfunc.h +/home/softcoder/Code/mojosetup/lua/src/lfunc.h +lgc.h +/home/softcoder/Code/mojosetup/lua/src/lgc.h +llex.h +/home/softcoder/Code/mojosetup/lua/src/llex.h +lmem.h +/home/softcoder/Code/mojosetup/lua/src/lmem.h +lstate.h +/home/softcoder/Code/mojosetup/lua/src/lstate.h +lstring.h +/home/softcoder/Code/mojosetup/lua/src/lstring.h +ltable.h +/home/softcoder/Code/mojosetup/lua/src/ltable.h +ltm.h +/home/softcoder/Code/mojosetup/lua/src/ltm.h + +/home/softcoder/Code/mojosetup/lua/src/lstate.h +lua.h +/home/softcoder/Code/mojosetup/lua/src/lua.h +lobject.h +/home/softcoder/Code/mojosetup/lua/src/lobject.h +ltm.h +/home/softcoder/Code/mojosetup/lua/src/ltm.h +lzio.h +/home/softcoder/Code/mojosetup/lua/src/lzio.h + +/home/softcoder/Code/mojosetup/lua/src/lstring.c +string.h +- +lua.h +/home/softcoder/Code/mojosetup/lua/src/lua.h +lmem.h +/home/softcoder/Code/mojosetup/lua/src/lmem.h +lobject.h +/home/softcoder/Code/mojosetup/lua/src/lobject.h +lstate.h +/home/softcoder/Code/mojosetup/lua/src/lstate.h +lstring.h +/home/softcoder/Code/mojosetup/lua/src/lstring.h + +/home/softcoder/Code/mojosetup/lua/src/lstring.h +lgc.h +/home/softcoder/Code/mojosetup/lua/src/lgc.h +lobject.h +/home/softcoder/Code/mojosetup/lua/src/lobject.h +lstate.h +/home/softcoder/Code/mojosetup/lua/src/lstate.h + +/home/softcoder/Code/mojosetup/lua/src/lstrlib.c +ctype.h +- +stddef.h +- +stdio.h +- +stdlib.h +- +string.h +- +lua.h +/home/softcoder/Code/mojosetup/lua/src/lua.h +lauxlib.h +/home/softcoder/Code/mojosetup/lua/src/lauxlib.h +lualib.h +/home/softcoder/Code/mojosetup/lua/src/lualib.h + +/home/softcoder/Code/mojosetup/lua/src/ltable.c +math.h +- +string.h +- +lua.h +/home/softcoder/Code/mojosetup/lua/src/lua.h +ldebug.h +/home/softcoder/Code/mojosetup/lua/src/ldebug.h +ldo.h +/home/softcoder/Code/mojosetup/lua/src/ldo.h +lgc.h +/home/softcoder/Code/mojosetup/lua/src/lgc.h +lmem.h +/home/softcoder/Code/mojosetup/lua/src/lmem.h +lobject.h +/home/softcoder/Code/mojosetup/lua/src/lobject.h +lstate.h +/home/softcoder/Code/mojosetup/lua/src/lstate.h +ltable.h +/home/softcoder/Code/mojosetup/lua/src/ltable.h + +/home/softcoder/Code/mojosetup/lua/src/ltable.h +lobject.h +/home/softcoder/Code/mojosetup/lua/src/lobject.h + +/home/softcoder/Code/mojosetup/lua/src/ltablib.c +stddef.h +- +lua.h +/home/softcoder/Code/mojosetup/lua/src/lua.h +lauxlib.h +/home/softcoder/Code/mojosetup/lua/src/lauxlib.h +lualib.h +/home/softcoder/Code/mojosetup/lua/src/lualib.h + +/home/softcoder/Code/mojosetup/lua/src/ltm.c +string.h +- +lua.h +/home/softcoder/Code/mojosetup/lua/src/lua.h +lobject.h +/home/softcoder/Code/mojosetup/lua/src/lobject.h +lstate.h +/home/softcoder/Code/mojosetup/lua/src/lstate.h +lstring.h +/home/softcoder/Code/mojosetup/lua/src/lstring.h +ltable.h +/home/softcoder/Code/mojosetup/lua/src/ltable.h +ltm.h +/home/softcoder/Code/mojosetup/lua/src/ltm.h + +/home/softcoder/Code/mojosetup/lua/src/ltm.h +lobject.h +/home/softcoder/Code/mojosetup/lua/src/lobject.h + +/home/softcoder/Code/mojosetup/lua/src/lua.h +stdarg.h +- +stddef.h +- +luaconf.h +/home/softcoder/Code/mojosetup/lua/src/luaconf.h + +/home/softcoder/Code/mojosetup/lua/src/luac.c +errno.h +- +stdio.h +- +stdlib.h +- +string.h +- +lua.h +/home/softcoder/Code/mojosetup/lua/src/lua.h +lauxlib.h +/home/softcoder/Code/mojosetup/lua/src/lauxlib.h +ldo.h +/home/softcoder/Code/mojosetup/lua/src/ldo.h +lfunc.h +/home/softcoder/Code/mojosetup/lua/src/lfunc.h +lmem.h +/home/softcoder/Code/mojosetup/lua/src/lmem.h +lobject.h +/home/softcoder/Code/mojosetup/lua/src/lobject.h +lopcodes.h +/home/softcoder/Code/mojosetup/lua/src/lopcodes.h +lstring.h +/home/softcoder/Code/mojosetup/lua/src/lstring.h +lundump.h +/home/softcoder/Code/mojosetup/lua/src/lundump.h + +/home/softcoder/Code/mojosetup/lua/src/luaconf.h +limits.h +- +stddef.h +- +unistd.h +- +io.h +- +stdio.h +- +stdio.h +- +readline/readline.h +- +readline/history.h +- +assert.h +- +math.h +- +unistd.h +- + +/home/softcoder/Code/mojosetup/lua/src/lualib.h +lua.h +/home/softcoder/Code/mojosetup/lua/src/lua.h + +/home/softcoder/Code/mojosetup/lua/src/lundump.c +string.h +- +lua.h +/home/softcoder/Code/mojosetup/lua/src/lua.h +ldebug.h +/home/softcoder/Code/mojosetup/lua/src/ldebug.h +ldo.h +/home/softcoder/Code/mojosetup/lua/src/ldo.h +lfunc.h +/home/softcoder/Code/mojosetup/lua/src/lfunc.h +lmem.h +/home/softcoder/Code/mojosetup/lua/src/lmem.h +lobject.h +/home/softcoder/Code/mojosetup/lua/src/lobject.h +lstring.h +/home/softcoder/Code/mojosetup/lua/src/lstring.h +lundump.h +/home/softcoder/Code/mojosetup/lua/src/lundump.h +lzio.h +/home/softcoder/Code/mojosetup/lua/src/lzio.h + +/home/softcoder/Code/mojosetup/lua/src/lundump.h +lobject.h +/home/softcoder/Code/mojosetup/lua/src/lobject.h +lzio.h +/home/softcoder/Code/mojosetup/lua/src/lzio.h + +/home/softcoder/Code/mojosetup/lua/src/lvm.c +stdio.h +- +stdlib.h +- +string.h +- +lua.h +/home/softcoder/Code/mojosetup/lua/src/lua.h +ldebug.h +/home/softcoder/Code/mojosetup/lua/src/ldebug.h +ldo.h +/home/softcoder/Code/mojosetup/lua/src/ldo.h +lfunc.h +/home/softcoder/Code/mojosetup/lua/src/lfunc.h +lgc.h +/home/softcoder/Code/mojosetup/lua/src/lgc.h +lobject.h +/home/softcoder/Code/mojosetup/lua/src/lobject.h +lopcodes.h +/home/softcoder/Code/mojosetup/lua/src/lopcodes.h +lstate.h +/home/softcoder/Code/mojosetup/lua/src/lstate.h +lstring.h +/home/softcoder/Code/mojosetup/lua/src/lstring.h +ltable.h +/home/softcoder/Code/mojosetup/lua/src/ltable.h +ltm.h +/home/softcoder/Code/mojosetup/lua/src/ltm.h +lvm.h +/home/softcoder/Code/mojosetup/lua/src/lvm.h + +/home/softcoder/Code/mojosetup/lua/src/lvm.h +ldo.h +/home/softcoder/Code/mojosetup/lua/src/ldo.h +lobject.h +/home/softcoder/Code/mojosetup/lua/src/lobject.h +ltm.h +/home/softcoder/Code/mojosetup/lua/src/ltm.h + +/home/softcoder/Code/mojosetup/lua/src/lzio.c +string.h +- +lua.h +/home/softcoder/Code/mojosetup/lua/src/lua.h +llimits.h +/home/softcoder/Code/mojosetup/lua/src/llimits.h +lmem.h +/home/softcoder/Code/mojosetup/lua/src/lmem.h +lstate.h +/home/softcoder/Code/mojosetup/lua/src/lstate.h +lzio.h +/home/softcoder/Code/mojosetup/lua/src/lzio.h + +/home/softcoder/Code/mojosetup/lua/src/lzio.h +lua.h +/home/softcoder/Code/mojosetup/lua/src/lua.h +lmem.h +/home/softcoder/Code/mojosetup/lua/src/lmem.h + +/home/softcoder/Code/mojosetup/lua/src/print.c +ctype.h +- +stdio.h +- +ldebug.h +/home/softcoder/Code/mojosetup/lua/src/ldebug.h +lobject.h +/home/softcoder/Code/mojosetup/lua/src/lobject.h +lopcodes.h +/home/softcoder/Code/mojosetup/lua/src/lopcodes.h +lundump.h +/home/softcoder/Code/mojosetup/lua/src/lundump.h + diff --git a/mk/linux/mojosetup/build/CMakeFiles/mojoluac.dir/DependInfo.cmake b/mk/linux/mojosetup/build/CMakeFiles/mojoluac.dir/DependInfo.cmake new file mode 100644 index 00000000..5d651b10 --- /dev/null +++ b/mk/linux/mojosetup/build/CMakeFiles/mojoluac.dir/DependInfo.cmake @@ -0,0 +1,77 @@ +# The set of languages for which implicit dependencies are needed: +SET(CMAKE_DEPENDS_LANGUAGES + "C" + ) +# The set of files for implicit dependencies of each language: +SET(CMAKE_DEPENDS_CHECK_C + "/home/softcoder/Code/mojosetup/lua/src/lapi.c" "/home/softcoder/Code/mojosetup/build/CMakeFiles/mojoluac.dir/lua/src/lapi.o" + "/home/softcoder/Code/mojosetup/lua/src/lauxlib.c" "/home/softcoder/Code/mojosetup/build/CMakeFiles/mojoluac.dir/lua/src/lauxlib.o" + "/home/softcoder/Code/mojosetup/lua/src/lbaselib.c" "/home/softcoder/Code/mojosetup/build/CMakeFiles/mojoluac.dir/lua/src/lbaselib.o" + "/home/softcoder/Code/mojosetup/lua/src/lcode.c" "/home/softcoder/Code/mojosetup/build/CMakeFiles/mojoluac.dir/lua/src/lcode.o" + "/home/softcoder/Code/mojosetup/lua/src/ldblib.c" "/home/softcoder/Code/mojosetup/build/CMakeFiles/mojoluac.dir/lua/src/ldblib.o" + "/home/softcoder/Code/mojosetup/lua/src/ldebug.c" "/home/softcoder/Code/mojosetup/build/CMakeFiles/mojoluac.dir/lua/src/ldebug.o" + "/home/softcoder/Code/mojosetup/lua/src/ldo.c" "/home/softcoder/Code/mojosetup/build/CMakeFiles/mojoluac.dir/lua/src/ldo.o" + "/home/softcoder/Code/mojosetup/lua/src/ldump.c" "/home/softcoder/Code/mojosetup/build/CMakeFiles/mojoluac.dir/lua/src/ldump.o" + "/home/softcoder/Code/mojosetup/lua/src/lfunc.c" "/home/softcoder/Code/mojosetup/build/CMakeFiles/mojoluac.dir/lua/src/lfunc.o" + "/home/softcoder/Code/mojosetup/lua/src/lgc.c" "/home/softcoder/Code/mojosetup/build/CMakeFiles/mojoluac.dir/lua/src/lgc.o" + "/home/softcoder/Code/mojosetup/lua/src/linit.c" "/home/softcoder/Code/mojosetup/build/CMakeFiles/mojoluac.dir/lua/src/linit.o" + "/home/softcoder/Code/mojosetup/lua/src/liolib.c" "/home/softcoder/Code/mojosetup/build/CMakeFiles/mojoluac.dir/lua/src/liolib.o" + "/home/softcoder/Code/mojosetup/lua/src/llex.c" "/home/softcoder/Code/mojosetup/build/CMakeFiles/mojoluac.dir/lua/src/llex.o" + "/home/softcoder/Code/mojosetup/lua/src/lmathlib.c" "/home/softcoder/Code/mojosetup/build/CMakeFiles/mojoluac.dir/lua/src/lmathlib.o" + "/home/softcoder/Code/mojosetup/lua/src/lmem.c" "/home/softcoder/Code/mojosetup/build/CMakeFiles/mojoluac.dir/lua/src/lmem.o" + "/home/softcoder/Code/mojosetup/lua/src/loadlib.c" "/home/softcoder/Code/mojosetup/build/CMakeFiles/mojoluac.dir/lua/src/loadlib.o" + "/home/softcoder/Code/mojosetup/lua/src/lobject.c" "/home/softcoder/Code/mojosetup/build/CMakeFiles/mojoluac.dir/lua/src/lobject.o" + "/home/softcoder/Code/mojosetup/lua/src/lopcodes.c" "/home/softcoder/Code/mojosetup/build/CMakeFiles/mojoluac.dir/lua/src/lopcodes.o" + "/home/softcoder/Code/mojosetup/lua/src/loslib.c" "/home/softcoder/Code/mojosetup/build/CMakeFiles/mojoluac.dir/lua/src/loslib.o" + "/home/softcoder/Code/mojosetup/lua/src/lparser.c" "/home/softcoder/Code/mojosetup/build/CMakeFiles/mojoluac.dir/lua/src/lparser.o" + "/home/softcoder/Code/mojosetup/lua/src/lstate.c" "/home/softcoder/Code/mojosetup/build/CMakeFiles/mojoluac.dir/lua/src/lstate.o" + "/home/softcoder/Code/mojosetup/lua/src/lstring.c" "/home/softcoder/Code/mojosetup/build/CMakeFiles/mojoluac.dir/lua/src/lstring.o" + "/home/softcoder/Code/mojosetup/lua/src/lstrlib.c" "/home/softcoder/Code/mojosetup/build/CMakeFiles/mojoluac.dir/lua/src/lstrlib.o" + "/home/softcoder/Code/mojosetup/lua/src/ltable.c" "/home/softcoder/Code/mojosetup/build/CMakeFiles/mojoluac.dir/lua/src/ltable.o" + "/home/softcoder/Code/mojosetup/lua/src/ltablib.c" "/home/softcoder/Code/mojosetup/build/CMakeFiles/mojoluac.dir/lua/src/ltablib.o" + "/home/softcoder/Code/mojosetup/lua/src/ltm.c" "/home/softcoder/Code/mojosetup/build/CMakeFiles/mojoluac.dir/lua/src/ltm.o" + "/home/softcoder/Code/mojosetup/lua/src/luac.c" "/home/softcoder/Code/mojosetup/build/CMakeFiles/mojoluac.dir/lua/src/luac.o" + "/home/softcoder/Code/mojosetup/lua/src/lundump.c" "/home/softcoder/Code/mojosetup/build/CMakeFiles/mojoluac.dir/lua/src/lundump.o" + "/home/softcoder/Code/mojosetup/lua/src/lvm.c" "/home/softcoder/Code/mojosetup/build/CMakeFiles/mojoluac.dir/lua/src/lvm.o" + "/home/softcoder/Code/mojosetup/lua/src/lzio.c" "/home/softcoder/Code/mojosetup/build/CMakeFiles/mojoluac.dir/lua/src/lzio.o" + "/home/softcoder/Code/mojosetup/lua/src/print.c" "/home/softcoder/Code/mojosetup/build/CMakeFiles/mojoluac.dir/lua/src/print.o" + ) +SET(CMAKE_C_COMPILER_ID "GNU") + +# Preprocessor definitions for this target. +SET(CMAKE_TARGET_DEFINITIONS + "__MOJOSETUP__=1" + "APPID=mojosetup" + "_REENTRANT" + "_THREAD_SAFE" + "PLATFORM_UNIX=1" + "LUA_USE_MKSTEMP=1" + "LUA_USE_ULONGJMP=1" + "PLATFORM_LITTLEENDIAN=1" + "SUPPORT_LUALIB_IO=1" + "SUPPORT_LUALIB_OS=1" + "SUPPORT_LUALIB_MATH=1" + "SUPPORT_LUALIB_DB=1" + "SUPPORT_LUALIB_PACKAGE=1" + "SUPPORT_CRC32=1" + "SUPPORT_MD5=1" + "SUPPORT_SHA1=1" + "SUPPORT_GUI_STDIO=1" + "GUI_STATIC_LINK_STDIO=1" + "SUPPORT_GUI_GTKPLUS2=1" + "SUPPORT_ZIP=1" + "SUPPORT_TAR=1" + "SUPPORT_GZIP=1" + "SUPPORT_BZIP2=1" + "BZ_NO_STDIO=1" + "SUPPORT_JPG=1" + "SUPPORT_PNG=1" + "SUPPORT_STBIMAGE=1" + "SUPPORT_URL_HTTP=1" + "SUPPORT_URL_FTP=1" + "MOJOSETUP_HAVE_MNTENT_H=1" + ) + +# Targets to which this target links. +SET(CMAKE_TARGET_LINKED_INFO_FILES + ) diff --git a/mk/linux/mojosetup/build/CMakeFiles/mojoluac.dir/build.make b/mk/linux/mojosetup/build/CMakeFiles/mojoluac.dir/build.make new file mode 100644 index 00000000..591f1f66 --- /dev/null +++ b/mk/linux/mojosetup/build/CMakeFiles/mojoluac.dir/build.make @@ -0,0 +1,910 @@ +# CMAKE generated file: DO NOT EDIT! +# Generated by "Unix Makefiles" Generator, CMake Version 2.8 + +#============================================================================= +# Special targets provided by cmake. + +# Disable implicit rules so canoncical targets will work. +.SUFFIXES: + +# Remove some rules from gmake that .SUFFIXES does not remove. +SUFFIXES = + +.SUFFIXES: .hpux_make_needs_suffix_list + +# Suppress display of executed commands. +$(VERBOSE).SILENT: + +# A target that is always out of date. +cmake_force: +.PHONY : cmake_force + +#============================================================================= +# Set environment variables for the build. + +# The shell in which to execute make rules. +SHELL = /bin/sh + +# The CMake executable. +CMAKE_COMMAND = /usr/bin/cmake + +# The command to remove a file. +RM = /usr/bin/cmake -E remove -f + +# The top-level source directory on which CMake was run. +CMAKE_SOURCE_DIR = /home/softcoder/Code/mojosetup + +# The top-level build directory on which CMake was run. +CMAKE_BINARY_DIR = /home/softcoder/Code/mojosetup/build + +# Include any dependencies generated for this target. +include CMakeFiles/mojoluac.dir/depend.make + +# Include the progress variables for this target. +include CMakeFiles/mojoluac.dir/progress.make + +# Include the compile flags for this target's objects. +include CMakeFiles/mojoluac.dir/flags.make + +CMakeFiles/mojoluac.dir/lua/src/lapi.o: CMakeFiles/mojoluac.dir/flags.make +CMakeFiles/mojoluac.dir/lua/src/lapi.o: ../lua/src/lapi.c + $(CMAKE_COMMAND) -E cmake_progress_report /home/softcoder/Code/mojosetup/build/CMakeFiles $(CMAKE_PROGRESS_1) + @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green "Building C object CMakeFiles/mojoluac.dir/lua/src/lapi.o" + /usr/bin/gcc $(C_DEFINES) $(C_FLAGS) -o CMakeFiles/mojoluac.dir/lua/src/lapi.o -c /home/softcoder/Code/mojosetup/lua/src/lapi.c + +CMakeFiles/mojoluac.dir/lua/src/lapi.i: cmake_force + @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green "Preprocessing C source to CMakeFiles/mojoluac.dir/lua/src/lapi.i" + /usr/bin/gcc $(C_DEFINES) $(C_FLAGS) -E /home/softcoder/Code/mojosetup/lua/src/lapi.c > CMakeFiles/mojoluac.dir/lua/src/lapi.i + +CMakeFiles/mojoluac.dir/lua/src/lapi.s: cmake_force + @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green "Compiling C source to assembly CMakeFiles/mojoluac.dir/lua/src/lapi.s" + /usr/bin/gcc $(C_DEFINES) $(C_FLAGS) -S /home/softcoder/Code/mojosetup/lua/src/lapi.c -o CMakeFiles/mojoluac.dir/lua/src/lapi.s + +CMakeFiles/mojoluac.dir/lua/src/lapi.o.requires: +.PHONY : CMakeFiles/mojoluac.dir/lua/src/lapi.o.requires + +CMakeFiles/mojoluac.dir/lua/src/lapi.o.provides: CMakeFiles/mojoluac.dir/lua/src/lapi.o.requires + $(MAKE) -f CMakeFiles/mojoluac.dir/build.make CMakeFiles/mojoluac.dir/lua/src/lapi.o.provides.build +.PHONY : CMakeFiles/mojoluac.dir/lua/src/lapi.o.provides + +CMakeFiles/mojoluac.dir/lua/src/lapi.o.provides.build: CMakeFiles/mojoluac.dir/lua/src/lapi.o +.PHONY : CMakeFiles/mojoluac.dir/lua/src/lapi.o.provides.build + +CMakeFiles/mojoluac.dir/lua/src/ldebug.o: CMakeFiles/mojoluac.dir/flags.make +CMakeFiles/mojoluac.dir/lua/src/ldebug.o: ../lua/src/ldebug.c + $(CMAKE_COMMAND) -E cmake_progress_report /home/softcoder/Code/mojosetup/build/CMakeFiles $(CMAKE_PROGRESS_2) + @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green "Building C object CMakeFiles/mojoluac.dir/lua/src/ldebug.o" + /usr/bin/gcc $(C_DEFINES) $(C_FLAGS) -o CMakeFiles/mojoluac.dir/lua/src/ldebug.o -c /home/softcoder/Code/mojosetup/lua/src/ldebug.c + +CMakeFiles/mojoluac.dir/lua/src/ldebug.i: cmake_force + @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green "Preprocessing C source to CMakeFiles/mojoluac.dir/lua/src/ldebug.i" + /usr/bin/gcc $(C_DEFINES) $(C_FLAGS) -E /home/softcoder/Code/mojosetup/lua/src/ldebug.c > CMakeFiles/mojoluac.dir/lua/src/ldebug.i + +CMakeFiles/mojoluac.dir/lua/src/ldebug.s: cmake_force + @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green "Compiling C source to assembly CMakeFiles/mojoluac.dir/lua/src/ldebug.s" + /usr/bin/gcc $(C_DEFINES) $(C_FLAGS) -S /home/softcoder/Code/mojosetup/lua/src/ldebug.c -o CMakeFiles/mojoluac.dir/lua/src/ldebug.s + +CMakeFiles/mojoluac.dir/lua/src/ldebug.o.requires: +.PHONY : CMakeFiles/mojoluac.dir/lua/src/ldebug.o.requires + +CMakeFiles/mojoluac.dir/lua/src/ldebug.o.provides: CMakeFiles/mojoluac.dir/lua/src/ldebug.o.requires + $(MAKE) -f CMakeFiles/mojoluac.dir/build.make CMakeFiles/mojoluac.dir/lua/src/ldebug.o.provides.build +.PHONY : CMakeFiles/mojoluac.dir/lua/src/ldebug.o.provides + +CMakeFiles/mojoluac.dir/lua/src/ldebug.o.provides.build: CMakeFiles/mojoluac.dir/lua/src/ldebug.o +.PHONY : CMakeFiles/mojoluac.dir/lua/src/ldebug.o.provides.build + +CMakeFiles/mojoluac.dir/lua/src/ldo.o: CMakeFiles/mojoluac.dir/flags.make +CMakeFiles/mojoluac.dir/lua/src/ldo.o: ../lua/src/ldo.c + $(CMAKE_COMMAND) -E cmake_progress_report /home/softcoder/Code/mojosetup/build/CMakeFiles $(CMAKE_PROGRESS_3) + @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green "Building C object CMakeFiles/mojoluac.dir/lua/src/ldo.o" + /usr/bin/gcc $(C_DEFINES) $(C_FLAGS) -o CMakeFiles/mojoluac.dir/lua/src/ldo.o -c /home/softcoder/Code/mojosetup/lua/src/ldo.c + +CMakeFiles/mojoluac.dir/lua/src/ldo.i: cmake_force + @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green "Preprocessing C source to CMakeFiles/mojoluac.dir/lua/src/ldo.i" + /usr/bin/gcc $(C_DEFINES) $(C_FLAGS) -E /home/softcoder/Code/mojosetup/lua/src/ldo.c > CMakeFiles/mojoluac.dir/lua/src/ldo.i + +CMakeFiles/mojoluac.dir/lua/src/ldo.s: cmake_force + @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green "Compiling C source to assembly CMakeFiles/mojoluac.dir/lua/src/ldo.s" + /usr/bin/gcc $(C_DEFINES) $(C_FLAGS) -S /home/softcoder/Code/mojosetup/lua/src/ldo.c -o CMakeFiles/mojoluac.dir/lua/src/ldo.s + +CMakeFiles/mojoluac.dir/lua/src/ldo.o.requires: +.PHONY : CMakeFiles/mojoluac.dir/lua/src/ldo.o.requires + +CMakeFiles/mojoluac.dir/lua/src/ldo.o.provides: CMakeFiles/mojoluac.dir/lua/src/ldo.o.requires + $(MAKE) -f CMakeFiles/mojoluac.dir/build.make CMakeFiles/mojoluac.dir/lua/src/ldo.o.provides.build +.PHONY : CMakeFiles/mojoluac.dir/lua/src/ldo.o.provides + +CMakeFiles/mojoluac.dir/lua/src/ldo.o.provides.build: CMakeFiles/mojoluac.dir/lua/src/ldo.o +.PHONY : CMakeFiles/mojoluac.dir/lua/src/ldo.o.provides.build + +CMakeFiles/mojoluac.dir/lua/src/ldump.o: CMakeFiles/mojoluac.dir/flags.make +CMakeFiles/mojoluac.dir/lua/src/ldump.o: ../lua/src/ldump.c + $(CMAKE_COMMAND) -E cmake_progress_report /home/softcoder/Code/mojosetup/build/CMakeFiles $(CMAKE_PROGRESS_4) + @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green "Building C object CMakeFiles/mojoluac.dir/lua/src/ldump.o" + /usr/bin/gcc $(C_DEFINES) $(C_FLAGS) -o CMakeFiles/mojoluac.dir/lua/src/ldump.o -c /home/softcoder/Code/mojosetup/lua/src/ldump.c + +CMakeFiles/mojoluac.dir/lua/src/ldump.i: cmake_force + @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green "Preprocessing C source to CMakeFiles/mojoluac.dir/lua/src/ldump.i" + /usr/bin/gcc $(C_DEFINES) $(C_FLAGS) -E /home/softcoder/Code/mojosetup/lua/src/ldump.c > CMakeFiles/mojoluac.dir/lua/src/ldump.i + +CMakeFiles/mojoluac.dir/lua/src/ldump.s: cmake_force + @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green "Compiling C source to assembly CMakeFiles/mojoluac.dir/lua/src/ldump.s" + /usr/bin/gcc $(C_DEFINES) $(C_FLAGS) -S /home/softcoder/Code/mojosetup/lua/src/ldump.c -o CMakeFiles/mojoluac.dir/lua/src/ldump.s + +CMakeFiles/mojoluac.dir/lua/src/ldump.o.requires: +.PHONY : CMakeFiles/mojoluac.dir/lua/src/ldump.o.requires + +CMakeFiles/mojoluac.dir/lua/src/ldump.o.provides: CMakeFiles/mojoluac.dir/lua/src/ldump.o.requires + $(MAKE) -f CMakeFiles/mojoluac.dir/build.make CMakeFiles/mojoluac.dir/lua/src/ldump.o.provides.build +.PHONY : CMakeFiles/mojoluac.dir/lua/src/ldump.o.provides + +CMakeFiles/mojoluac.dir/lua/src/ldump.o.provides.build: CMakeFiles/mojoluac.dir/lua/src/ldump.o +.PHONY : CMakeFiles/mojoluac.dir/lua/src/ldump.o.provides.build + +CMakeFiles/mojoluac.dir/lua/src/lfunc.o: CMakeFiles/mojoluac.dir/flags.make +CMakeFiles/mojoluac.dir/lua/src/lfunc.o: ../lua/src/lfunc.c + $(CMAKE_COMMAND) -E cmake_progress_report /home/softcoder/Code/mojosetup/build/CMakeFiles $(CMAKE_PROGRESS_5) + @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green "Building C object CMakeFiles/mojoluac.dir/lua/src/lfunc.o" + /usr/bin/gcc $(C_DEFINES) $(C_FLAGS) -o CMakeFiles/mojoluac.dir/lua/src/lfunc.o -c /home/softcoder/Code/mojosetup/lua/src/lfunc.c + +CMakeFiles/mojoluac.dir/lua/src/lfunc.i: cmake_force + @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green "Preprocessing C source to CMakeFiles/mojoluac.dir/lua/src/lfunc.i" + /usr/bin/gcc $(C_DEFINES) $(C_FLAGS) -E /home/softcoder/Code/mojosetup/lua/src/lfunc.c > CMakeFiles/mojoluac.dir/lua/src/lfunc.i + +CMakeFiles/mojoluac.dir/lua/src/lfunc.s: cmake_force + @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green "Compiling C source to assembly CMakeFiles/mojoluac.dir/lua/src/lfunc.s" + /usr/bin/gcc $(C_DEFINES) $(C_FLAGS) -S /home/softcoder/Code/mojosetup/lua/src/lfunc.c -o CMakeFiles/mojoluac.dir/lua/src/lfunc.s + +CMakeFiles/mojoluac.dir/lua/src/lfunc.o.requires: +.PHONY : CMakeFiles/mojoluac.dir/lua/src/lfunc.o.requires + +CMakeFiles/mojoluac.dir/lua/src/lfunc.o.provides: CMakeFiles/mojoluac.dir/lua/src/lfunc.o.requires + $(MAKE) -f CMakeFiles/mojoluac.dir/build.make CMakeFiles/mojoluac.dir/lua/src/lfunc.o.provides.build +.PHONY : CMakeFiles/mojoluac.dir/lua/src/lfunc.o.provides + +CMakeFiles/mojoluac.dir/lua/src/lfunc.o.provides.build: CMakeFiles/mojoluac.dir/lua/src/lfunc.o +.PHONY : CMakeFiles/mojoluac.dir/lua/src/lfunc.o.provides.build + +CMakeFiles/mojoluac.dir/lua/src/lgc.o: CMakeFiles/mojoluac.dir/flags.make +CMakeFiles/mojoluac.dir/lua/src/lgc.o: ../lua/src/lgc.c + $(CMAKE_COMMAND) -E cmake_progress_report /home/softcoder/Code/mojosetup/build/CMakeFiles $(CMAKE_PROGRESS_6) + @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green "Building C object CMakeFiles/mojoluac.dir/lua/src/lgc.o" + /usr/bin/gcc $(C_DEFINES) $(C_FLAGS) -o CMakeFiles/mojoluac.dir/lua/src/lgc.o -c /home/softcoder/Code/mojosetup/lua/src/lgc.c + +CMakeFiles/mojoluac.dir/lua/src/lgc.i: cmake_force + @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green "Preprocessing C source to CMakeFiles/mojoluac.dir/lua/src/lgc.i" + /usr/bin/gcc $(C_DEFINES) $(C_FLAGS) -E /home/softcoder/Code/mojosetup/lua/src/lgc.c > CMakeFiles/mojoluac.dir/lua/src/lgc.i + +CMakeFiles/mojoluac.dir/lua/src/lgc.s: cmake_force + @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green "Compiling C source to assembly CMakeFiles/mojoluac.dir/lua/src/lgc.s" + /usr/bin/gcc $(C_DEFINES) $(C_FLAGS) -S /home/softcoder/Code/mojosetup/lua/src/lgc.c -o CMakeFiles/mojoluac.dir/lua/src/lgc.s + +CMakeFiles/mojoluac.dir/lua/src/lgc.o.requires: +.PHONY : CMakeFiles/mojoluac.dir/lua/src/lgc.o.requires + +CMakeFiles/mojoluac.dir/lua/src/lgc.o.provides: CMakeFiles/mojoluac.dir/lua/src/lgc.o.requires + $(MAKE) -f CMakeFiles/mojoluac.dir/build.make CMakeFiles/mojoluac.dir/lua/src/lgc.o.provides.build +.PHONY : CMakeFiles/mojoluac.dir/lua/src/lgc.o.provides + +CMakeFiles/mojoluac.dir/lua/src/lgc.o.provides.build: CMakeFiles/mojoluac.dir/lua/src/lgc.o +.PHONY : CMakeFiles/mojoluac.dir/lua/src/lgc.o.provides.build + +CMakeFiles/mojoluac.dir/lua/src/lmem.o: CMakeFiles/mojoluac.dir/flags.make +CMakeFiles/mojoluac.dir/lua/src/lmem.o: ../lua/src/lmem.c + $(CMAKE_COMMAND) -E cmake_progress_report /home/softcoder/Code/mojosetup/build/CMakeFiles $(CMAKE_PROGRESS_7) + @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green "Building C object CMakeFiles/mojoluac.dir/lua/src/lmem.o" + /usr/bin/gcc $(C_DEFINES) $(C_FLAGS) -o CMakeFiles/mojoluac.dir/lua/src/lmem.o -c /home/softcoder/Code/mojosetup/lua/src/lmem.c + +CMakeFiles/mojoluac.dir/lua/src/lmem.i: cmake_force + @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green "Preprocessing C source to CMakeFiles/mojoluac.dir/lua/src/lmem.i" + /usr/bin/gcc $(C_DEFINES) $(C_FLAGS) -E /home/softcoder/Code/mojosetup/lua/src/lmem.c > CMakeFiles/mojoluac.dir/lua/src/lmem.i + +CMakeFiles/mojoluac.dir/lua/src/lmem.s: cmake_force + @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green "Compiling C source to assembly CMakeFiles/mojoluac.dir/lua/src/lmem.s" + /usr/bin/gcc $(C_DEFINES) $(C_FLAGS) -S /home/softcoder/Code/mojosetup/lua/src/lmem.c -o CMakeFiles/mojoluac.dir/lua/src/lmem.s + +CMakeFiles/mojoluac.dir/lua/src/lmem.o.requires: +.PHONY : CMakeFiles/mojoluac.dir/lua/src/lmem.o.requires + +CMakeFiles/mojoluac.dir/lua/src/lmem.o.provides: CMakeFiles/mojoluac.dir/lua/src/lmem.o.requires + $(MAKE) -f CMakeFiles/mojoluac.dir/build.make CMakeFiles/mojoluac.dir/lua/src/lmem.o.provides.build +.PHONY : CMakeFiles/mojoluac.dir/lua/src/lmem.o.provides + +CMakeFiles/mojoluac.dir/lua/src/lmem.o.provides.build: CMakeFiles/mojoluac.dir/lua/src/lmem.o +.PHONY : CMakeFiles/mojoluac.dir/lua/src/lmem.o.provides.build + +CMakeFiles/mojoluac.dir/lua/src/lobject.o: CMakeFiles/mojoluac.dir/flags.make +CMakeFiles/mojoluac.dir/lua/src/lobject.o: ../lua/src/lobject.c + $(CMAKE_COMMAND) -E cmake_progress_report /home/softcoder/Code/mojosetup/build/CMakeFiles $(CMAKE_PROGRESS_8) + @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green "Building C object CMakeFiles/mojoluac.dir/lua/src/lobject.o" + /usr/bin/gcc $(C_DEFINES) $(C_FLAGS) -o CMakeFiles/mojoluac.dir/lua/src/lobject.o -c /home/softcoder/Code/mojosetup/lua/src/lobject.c + +CMakeFiles/mojoluac.dir/lua/src/lobject.i: cmake_force + @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green "Preprocessing C source to CMakeFiles/mojoluac.dir/lua/src/lobject.i" + /usr/bin/gcc $(C_DEFINES) $(C_FLAGS) -E /home/softcoder/Code/mojosetup/lua/src/lobject.c > CMakeFiles/mojoluac.dir/lua/src/lobject.i + +CMakeFiles/mojoluac.dir/lua/src/lobject.s: cmake_force + @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green "Compiling C source to assembly CMakeFiles/mojoluac.dir/lua/src/lobject.s" + /usr/bin/gcc $(C_DEFINES) $(C_FLAGS) -S /home/softcoder/Code/mojosetup/lua/src/lobject.c -o CMakeFiles/mojoluac.dir/lua/src/lobject.s + +CMakeFiles/mojoluac.dir/lua/src/lobject.o.requires: +.PHONY : CMakeFiles/mojoluac.dir/lua/src/lobject.o.requires + +CMakeFiles/mojoluac.dir/lua/src/lobject.o.provides: CMakeFiles/mojoluac.dir/lua/src/lobject.o.requires + $(MAKE) -f CMakeFiles/mojoluac.dir/build.make CMakeFiles/mojoluac.dir/lua/src/lobject.o.provides.build +.PHONY : CMakeFiles/mojoluac.dir/lua/src/lobject.o.provides + +CMakeFiles/mojoluac.dir/lua/src/lobject.o.provides.build: CMakeFiles/mojoluac.dir/lua/src/lobject.o +.PHONY : CMakeFiles/mojoluac.dir/lua/src/lobject.o.provides.build + +CMakeFiles/mojoluac.dir/lua/src/lopcodes.o: CMakeFiles/mojoluac.dir/flags.make +CMakeFiles/mojoluac.dir/lua/src/lopcodes.o: ../lua/src/lopcodes.c + $(CMAKE_COMMAND) -E cmake_progress_report /home/softcoder/Code/mojosetup/build/CMakeFiles $(CMAKE_PROGRESS_9) + @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green "Building C object CMakeFiles/mojoluac.dir/lua/src/lopcodes.o" + /usr/bin/gcc $(C_DEFINES) $(C_FLAGS) -o CMakeFiles/mojoluac.dir/lua/src/lopcodes.o -c /home/softcoder/Code/mojosetup/lua/src/lopcodes.c + +CMakeFiles/mojoluac.dir/lua/src/lopcodes.i: cmake_force + @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green "Preprocessing C source to CMakeFiles/mojoluac.dir/lua/src/lopcodes.i" + /usr/bin/gcc $(C_DEFINES) $(C_FLAGS) -E /home/softcoder/Code/mojosetup/lua/src/lopcodes.c > CMakeFiles/mojoluac.dir/lua/src/lopcodes.i + +CMakeFiles/mojoluac.dir/lua/src/lopcodes.s: cmake_force + @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green "Compiling C source to assembly CMakeFiles/mojoluac.dir/lua/src/lopcodes.s" + /usr/bin/gcc $(C_DEFINES) $(C_FLAGS) -S /home/softcoder/Code/mojosetup/lua/src/lopcodes.c -o CMakeFiles/mojoluac.dir/lua/src/lopcodes.s + +CMakeFiles/mojoluac.dir/lua/src/lopcodes.o.requires: +.PHONY : CMakeFiles/mojoluac.dir/lua/src/lopcodes.o.requires + +CMakeFiles/mojoluac.dir/lua/src/lopcodes.o.provides: CMakeFiles/mojoluac.dir/lua/src/lopcodes.o.requires + $(MAKE) -f CMakeFiles/mojoluac.dir/build.make CMakeFiles/mojoluac.dir/lua/src/lopcodes.o.provides.build +.PHONY : CMakeFiles/mojoluac.dir/lua/src/lopcodes.o.provides + +CMakeFiles/mojoluac.dir/lua/src/lopcodes.o.provides.build: CMakeFiles/mojoluac.dir/lua/src/lopcodes.o +.PHONY : CMakeFiles/mojoluac.dir/lua/src/lopcodes.o.provides.build + +CMakeFiles/mojoluac.dir/lua/src/lstate.o: CMakeFiles/mojoluac.dir/flags.make +CMakeFiles/mojoluac.dir/lua/src/lstate.o: ../lua/src/lstate.c + $(CMAKE_COMMAND) -E cmake_progress_report /home/softcoder/Code/mojosetup/build/CMakeFiles $(CMAKE_PROGRESS_10) + @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green "Building C object CMakeFiles/mojoluac.dir/lua/src/lstate.o" + /usr/bin/gcc $(C_DEFINES) $(C_FLAGS) -o CMakeFiles/mojoluac.dir/lua/src/lstate.o -c /home/softcoder/Code/mojosetup/lua/src/lstate.c + +CMakeFiles/mojoluac.dir/lua/src/lstate.i: cmake_force + @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green "Preprocessing C source to CMakeFiles/mojoluac.dir/lua/src/lstate.i" + /usr/bin/gcc $(C_DEFINES) $(C_FLAGS) -E /home/softcoder/Code/mojosetup/lua/src/lstate.c > CMakeFiles/mojoluac.dir/lua/src/lstate.i + +CMakeFiles/mojoluac.dir/lua/src/lstate.s: cmake_force + @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green "Compiling C source to assembly CMakeFiles/mojoluac.dir/lua/src/lstate.s" + /usr/bin/gcc $(C_DEFINES) $(C_FLAGS) -S /home/softcoder/Code/mojosetup/lua/src/lstate.c -o CMakeFiles/mojoluac.dir/lua/src/lstate.s + +CMakeFiles/mojoluac.dir/lua/src/lstate.o.requires: +.PHONY : CMakeFiles/mojoluac.dir/lua/src/lstate.o.requires + +CMakeFiles/mojoluac.dir/lua/src/lstate.o.provides: CMakeFiles/mojoluac.dir/lua/src/lstate.o.requires + $(MAKE) -f CMakeFiles/mojoluac.dir/build.make CMakeFiles/mojoluac.dir/lua/src/lstate.o.provides.build +.PHONY : CMakeFiles/mojoluac.dir/lua/src/lstate.o.provides + +CMakeFiles/mojoluac.dir/lua/src/lstate.o.provides.build: CMakeFiles/mojoluac.dir/lua/src/lstate.o +.PHONY : CMakeFiles/mojoluac.dir/lua/src/lstate.o.provides.build + +CMakeFiles/mojoluac.dir/lua/src/lstring.o: CMakeFiles/mojoluac.dir/flags.make +CMakeFiles/mojoluac.dir/lua/src/lstring.o: ../lua/src/lstring.c + $(CMAKE_COMMAND) -E cmake_progress_report /home/softcoder/Code/mojosetup/build/CMakeFiles $(CMAKE_PROGRESS_11) + @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green "Building C object CMakeFiles/mojoluac.dir/lua/src/lstring.o" + /usr/bin/gcc $(C_DEFINES) $(C_FLAGS) -o CMakeFiles/mojoluac.dir/lua/src/lstring.o -c /home/softcoder/Code/mojosetup/lua/src/lstring.c + +CMakeFiles/mojoluac.dir/lua/src/lstring.i: cmake_force + @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green "Preprocessing C source to CMakeFiles/mojoluac.dir/lua/src/lstring.i" + /usr/bin/gcc $(C_DEFINES) $(C_FLAGS) -E /home/softcoder/Code/mojosetup/lua/src/lstring.c > CMakeFiles/mojoluac.dir/lua/src/lstring.i + +CMakeFiles/mojoluac.dir/lua/src/lstring.s: cmake_force + @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green "Compiling C source to assembly CMakeFiles/mojoluac.dir/lua/src/lstring.s" + /usr/bin/gcc $(C_DEFINES) $(C_FLAGS) -S /home/softcoder/Code/mojosetup/lua/src/lstring.c -o CMakeFiles/mojoluac.dir/lua/src/lstring.s + +CMakeFiles/mojoluac.dir/lua/src/lstring.o.requires: +.PHONY : CMakeFiles/mojoluac.dir/lua/src/lstring.o.requires + +CMakeFiles/mojoluac.dir/lua/src/lstring.o.provides: CMakeFiles/mojoluac.dir/lua/src/lstring.o.requires + $(MAKE) -f CMakeFiles/mojoluac.dir/build.make CMakeFiles/mojoluac.dir/lua/src/lstring.o.provides.build +.PHONY : CMakeFiles/mojoluac.dir/lua/src/lstring.o.provides + +CMakeFiles/mojoluac.dir/lua/src/lstring.o.provides.build: CMakeFiles/mojoluac.dir/lua/src/lstring.o +.PHONY : CMakeFiles/mojoluac.dir/lua/src/lstring.o.provides.build + +CMakeFiles/mojoluac.dir/lua/src/ltable.o: CMakeFiles/mojoluac.dir/flags.make +CMakeFiles/mojoluac.dir/lua/src/ltable.o: ../lua/src/ltable.c + $(CMAKE_COMMAND) -E cmake_progress_report /home/softcoder/Code/mojosetup/build/CMakeFiles $(CMAKE_PROGRESS_12) + @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green "Building C object CMakeFiles/mojoluac.dir/lua/src/ltable.o" + /usr/bin/gcc $(C_DEFINES) $(C_FLAGS) -o CMakeFiles/mojoluac.dir/lua/src/ltable.o -c /home/softcoder/Code/mojosetup/lua/src/ltable.c + +CMakeFiles/mojoluac.dir/lua/src/ltable.i: cmake_force + @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green "Preprocessing C source to CMakeFiles/mojoluac.dir/lua/src/ltable.i" + /usr/bin/gcc $(C_DEFINES) $(C_FLAGS) -E /home/softcoder/Code/mojosetup/lua/src/ltable.c > CMakeFiles/mojoluac.dir/lua/src/ltable.i + +CMakeFiles/mojoluac.dir/lua/src/ltable.s: cmake_force + @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green "Compiling C source to assembly CMakeFiles/mojoluac.dir/lua/src/ltable.s" + /usr/bin/gcc $(C_DEFINES) $(C_FLAGS) -S /home/softcoder/Code/mojosetup/lua/src/ltable.c -o CMakeFiles/mojoluac.dir/lua/src/ltable.s + +CMakeFiles/mojoluac.dir/lua/src/ltable.o.requires: +.PHONY : CMakeFiles/mojoluac.dir/lua/src/ltable.o.requires + +CMakeFiles/mojoluac.dir/lua/src/ltable.o.provides: CMakeFiles/mojoluac.dir/lua/src/ltable.o.requires + $(MAKE) -f CMakeFiles/mojoluac.dir/build.make CMakeFiles/mojoluac.dir/lua/src/ltable.o.provides.build +.PHONY : CMakeFiles/mojoluac.dir/lua/src/ltable.o.provides + +CMakeFiles/mojoluac.dir/lua/src/ltable.o.provides.build: CMakeFiles/mojoluac.dir/lua/src/ltable.o +.PHONY : CMakeFiles/mojoluac.dir/lua/src/ltable.o.provides.build + +CMakeFiles/mojoluac.dir/lua/src/ltm.o: CMakeFiles/mojoluac.dir/flags.make +CMakeFiles/mojoluac.dir/lua/src/ltm.o: ../lua/src/ltm.c + $(CMAKE_COMMAND) -E cmake_progress_report /home/softcoder/Code/mojosetup/build/CMakeFiles $(CMAKE_PROGRESS_13) + @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green "Building C object CMakeFiles/mojoluac.dir/lua/src/ltm.o" + /usr/bin/gcc $(C_DEFINES) $(C_FLAGS) -o CMakeFiles/mojoluac.dir/lua/src/ltm.o -c /home/softcoder/Code/mojosetup/lua/src/ltm.c + +CMakeFiles/mojoluac.dir/lua/src/ltm.i: cmake_force + @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green "Preprocessing C source to CMakeFiles/mojoluac.dir/lua/src/ltm.i" + /usr/bin/gcc $(C_DEFINES) $(C_FLAGS) -E /home/softcoder/Code/mojosetup/lua/src/ltm.c > CMakeFiles/mojoluac.dir/lua/src/ltm.i + +CMakeFiles/mojoluac.dir/lua/src/ltm.s: cmake_force + @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green "Compiling C source to assembly CMakeFiles/mojoluac.dir/lua/src/ltm.s" + /usr/bin/gcc $(C_DEFINES) $(C_FLAGS) -S /home/softcoder/Code/mojosetup/lua/src/ltm.c -o CMakeFiles/mojoluac.dir/lua/src/ltm.s + +CMakeFiles/mojoluac.dir/lua/src/ltm.o.requires: +.PHONY : CMakeFiles/mojoluac.dir/lua/src/ltm.o.requires + +CMakeFiles/mojoluac.dir/lua/src/ltm.o.provides: CMakeFiles/mojoluac.dir/lua/src/ltm.o.requires + $(MAKE) -f CMakeFiles/mojoluac.dir/build.make CMakeFiles/mojoluac.dir/lua/src/ltm.o.provides.build +.PHONY : CMakeFiles/mojoluac.dir/lua/src/ltm.o.provides + +CMakeFiles/mojoluac.dir/lua/src/ltm.o.provides.build: CMakeFiles/mojoluac.dir/lua/src/ltm.o +.PHONY : CMakeFiles/mojoluac.dir/lua/src/ltm.o.provides.build + +CMakeFiles/mojoluac.dir/lua/src/lundump.o: CMakeFiles/mojoluac.dir/flags.make +CMakeFiles/mojoluac.dir/lua/src/lundump.o: ../lua/src/lundump.c + $(CMAKE_COMMAND) -E cmake_progress_report /home/softcoder/Code/mojosetup/build/CMakeFiles $(CMAKE_PROGRESS_14) + @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green "Building C object CMakeFiles/mojoluac.dir/lua/src/lundump.o" + /usr/bin/gcc $(C_DEFINES) $(C_FLAGS) -o CMakeFiles/mojoluac.dir/lua/src/lundump.o -c /home/softcoder/Code/mojosetup/lua/src/lundump.c + +CMakeFiles/mojoluac.dir/lua/src/lundump.i: cmake_force + @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green "Preprocessing C source to CMakeFiles/mojoluac.dir/lua/src/lundump.i" + /usr/bin/gcc $(C_DEFINES) $(C_FLAGS) -E /home/softcoder/Code/mojosetup/lua/src/lundump.c > CMakeFiles/mojoluac.dir/lua/src/lundump.i + +CMakeFiles/mojoluac.dir/lua/src/lundump.s: cmake_force + @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green "Compiling C source to assembly CMakeFiles/mojoluac.dir/lua/src/lundump.s" + /usr/bin/gcc $(C_DEFINES) $(C_FLAGS) -S /home/softcoder/Code/mojosetup/lua/src/lundump.c -o CMakeFiles/mojoluac.dir/lua/src/lundump.s + +CMakeFiles/mojoluac.dir/lua/src/lundump.o.requires: +.PHONY : CMakeFiles/mojoluac.dir/lua/src/lundump.o.requires + +CMakeFiles/mojoluac.dir/lua/src/lundump.o.provides: CMakeFiles/mojoluac.dir/lua/src/lundump.o.requires + $(MAKE) -f CMakeFiles/mojoluac.dir/build.make CMakeFiles/mojoluac.dir/lua/src/lundump.o.provides.build +.PHONY : CMakeFiles/mojoluac.dir/lua/src/lundump.o.provides + +CMakeFiles/mojoluac.dir/lua/src/lundump.o.provides.build: CMakeFiles/mojoluac.dir/lua/src/lundump.o +.PHONY : CMakeFiles/mojoluac.dir/lua/src/lundump.o.provides.build + +CMakeFiles/mojoluac.dir/lua/src/lvm.o: CMakeFiles/mojoluac.dir/flags.make +CMakeFiles/mojoluac.dir/lua/src/lvm.o: ../lua/src/lvm.c + $(CMAKE_COMMAND) -E cmake_progress_report /home/softcoder/Code/mojosetup/build/CMakeFiles $(CMAKE_PROGRESS_15) + @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green "Building C object CMakeFiles/mojoluac.dir/lua/src/lvm.o" + /usr/bin/gcc $(C_DEFINES) $(C_FLAGS) -o CMakeFiles/mojoluac.dir/lua/src/lvm.o -c /home/softcoder/Code/mojosetup/lua/src/lvm.c + +CMakeFiles/mojoluac.dir/lua/src/lvm.i: cmake_force + @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green "Preprocessing C source to CMakeFiles/mojoluac.dir/lua/src/lvm.i" + /usr/bin/gcc $(C_DEFINES) $(C_FLAGS) -E /home/softcoder/Code/mojosetup/lua/src/lvm.c > CMakeFiles/mojoluac.dir/lua/src/lvm.i + +CMakeFiles/mojoluac.dir/lua/src/lvm.s: cmake_force + @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green "Compiling C source to assembly CMakeFiles/mojoluac.dir/lua/src/lvm.s" + /usr/bin/gcc $(C_DEFINES) $(C_FLAGS) -S /home/softcoder/Code/mojosetup/lua/src/lvm.c -o CMakeFiles/mojoluac.dir/lua/src/lvm.s + +CMakeFiles/mojoluac.dir/lua/src/lvm.o.requires: +.PHONY : CMakeFiles/mojoluac.dir/lua/src/lvm.o.requires + +CMakeFiles/mojoluac.dir/lua/src/lvm.o.provides: CMakeFiles/mojoluac.dir/lua/src/lvm.o.requires + $(MAKE) -f CMakeFiles/mojoluac.dir/build.make CMakeFiles/mojoluac.dir/lua/src/lvm.o.provides.build +.PHONY : CMakeFiles/mojoluac.dir/lua/src/lvm.o.provides + +CMakeFiles/mojoluac.dir/lua/src/lvm.o.provides.build: CMakeFiles/mojoluac.dir/lua/src/lvm.o +.PHONY : CMakeFiles/mojoluac.dir/lua/src/lvm.o.provides.build + +CMakeFiles/mojoluac.dir/lua/src/lzio.o: CMakeFiles/mojoluac.dir/flags.make +CMakeFiles/mojoluac.dir/lua/src/lzio.o: ../lua/src/lzio.c + $(CMAKE_COMMAND) -E cmake_progress_report /home/softcoder/Code/mojosetup/build/CMakeFiles $(CMAKE_PROGRESS_16) + @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green "Building C object CMakeFiles/mojoluac.dir/lua/src/lzio.o" + /usr/bin/gcc $(C_DEFINES) $(C_FLAGS) -o CMakeFiles/mojoluac.dir/lua/src/lzio.o -c /home/softcoder/Code/mojosetup/lua/src/lzio.c + +CMakeFiles/mojoluac.dir/lua/src/lzio.i: cmake_force + @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green "Preprocessing C source to CMakeFiles/mojoluac.dir/lua/src/lzio.i" + /usr/bin/gcc $(C_DEFINES) $(C_FLAGS) -E /home/softcoder/Code/mojosetup/lua/src/lzio.c > CMakeFiles/mojoluac.dir/lua/src/lzio.i + +CMakeFiles/mojoluac.dir/lua/src/lzio.s: cmake_force + @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green "Compiling C source to assembly CMakeFiles/mojoluac.dir/lua/src/lzio.s" + /usr/bin/gcc $(C_DEFINES) $(C_FLAGS) -S /home/softcoder/Code/mojosetup/lua/src/lzio.c -o CMakeFiles/mojoluac.dir/lua/src/lzio.s + +CMakeFiles/mojoluac.dir/lua/src/lzio.o.requires: +.PHONY : CMakeFiles/mojoluac.dir/lua/src/lzio.o.requires + +CMakeFiles/mojoluac.dir/lua/src/lzio.o.provides: CMakeFiles/mojoluac.dir/lua/src/lzio.o.requires + $(MAKE) -f CMakeFiles/mojoluac.dir/build.make CMakeFiles/mojoluac.dir/lua/src/lzio.o.provides.build +.PHONY : CMakeFiles/mojoluac.dir/lua/src/lzio.o.provides + +CMakeFiles/mojoluac.dir/lua/src/lzio.o.provides.build: CMakeFiles/mojoluac.dir/lua/src/lzio.o +.PHONY : CMakeFiles/mojoluac.dir/lua/src/lzio.o.provides.build + +CMakeFiles/mojoluac.dir/lua/src/lauxlib.o: CMakeFiles/mojoluac.dir/flags.make +CMakeFiles/mojoluac.dir/lua/src/lauxlib.o: ../lua/src/lauxlib.c + $(CMAKE_COMMAND) -E cmake_progress_report /home/softcoder/Code/mojosetup/build/CMakeFiles $(CMAKE_PROGRESS_17) + @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green "Building C object CMakeFiles/mojoluac.dir/lua/src/lauxlib.o" + /usr/bin/gcc $(C_DEFINES) $(C_FLAGS) -o CMakeFiles/mojoluac.dir/lua/src/lauxlib.o -c /home/softcoder/Code/mojosetup/lua/src/lauxlib.c + +CMakeFiles/mojoluac.dir/lua/src/lauxlib.i: cmake_force + @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green "Preprocessing C source to CMakeFiles/mojoluac.dir/lua/src/lauxlib.i" + /usr/bin/gcc $(C_DEFINES) $(C_FLAGS) -E /home/softcoder/Code/mojosetup/lua/src/lauxlib.c > CMakeFiles/mojoluac.dir/lua/src/lauxlib.i + +CMakeFiles/mojoluac.dir/lua/src/lauxlib.s: cmake_force + @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green "Compiling C source to assembly CMakeFiles/mojoluac.dir/lua/src/lauxlib.s" + /usr/bin/gcc $(C_DEFINES) $(C_FLAGS) -S /home/softcoder/Code/mojosetup/lua/src/lauxlib.c -o CMakeFiles/mojoluac.dir/lua/src/lauxlib.s + +CMakeFiles/mojoluac.dir/lua/src/lauxlib.o.requires: +.PHONY : CMakeFiles/mojoluac.dir/lua/src/lauxlib.o.requires + +CMakeFiles/mojoluac.dir/lua/src/lauxlib.o.provides: CMakeFiles/mojoluac.dir/lua/src/lauxlib.o.requires + $(MAKE) -f CMakeFiles/mojoluac.dir/build.make CMakeFiles/mojoluac.dir/lua/src/lauxlib.o.provides.build +.PHONY : CMakeFiles/mojoluac.dir/lua/src/lauxlib.o.provides + +CMakeFiles/mojoluac.dir/lua/src/lauxlib.o.provides.build: CMakeFiles/mojoluac.dir/lua/src/lauxlib.o +.PHONY : CMakeFiles/mojoluac.dir/lua/src/lauxlib.o.provides.build + +CMakeFiles/mojoluac.dir/lua/src/lbaselib.o: CMakeFiles/mojoluac.dir/flags.make +CMakeFiles/mojoluac.dir/lua/src/lbaselib.o: ../lua/src/lbaselib.c + $(CMAKE_COMMAND) -E cmake_progress_report /home/softcoder/Code/mojosetup/build/CMakeFiles $(CMAKE_PROGRESS_18) + @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green "Building C object CMakeFiles/mojoluac.dir/lua/src/lbaselib.o" + /usr/bin/gcc $(C_DEFINES) $(C_FLAGS) -o CMakeFiles/mojoluac.dir/lua/src/lbaselib.o -c /home/softcoder/Code/mojosetup/lua/src/lbaselib.c + +CMakeFiles/mojoluac.dir/lua/src/lbaselib.i: cmake_force + @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green "Preprocessing C source to CMakeFiles/mojoluac.dir/lua/src/lbaselib.i" + /usr/bin/gcc $(C_DEFINES) $(C_FLAGS) -E /home/softcoder/Code/mojosetup/lua/src/lbaselib.c > CMakeFiles/mojoluac.dir/lua/src/lbaselib.i + +CMakeFiles/mojoluac.dir/lua/src/lbaselib.s: cmake_force + @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green "Compiling C source to assembly CMakeFiles/mojoluac.dir/lua/src/lbaselib.s" + /usr/bin/gcc $(C_DEFINES) $(C_FLAGS) -S /home/softcoder/Code/mojosetup/lua/src/lbaselib.c -o CMakeFiles/mojoluac.dir/lua/src/lbaselib.s + +CMakeFiles/mojoluac.dir/lua/src/lbaselib.o.requires: +.PHONY : CMakeFiles/mojoluac.dir/lua/src/lbaselib.o.requires + +CMakeFiles/mojoluac.dir/lua/src/lbaselib.o.provides: CMakeFiles/mojoluac.dir/lua/src/lbaselib.o.requires + $(MAKE) -f CMakeFiles/mojoluac.dir/build.make CMakeFiles/mojoluac.dir/lua/src/lbaselib.o.provides.build +.PHONY : CMakeFiles/mojoluac.dir/lua/src/lbaselib.o.provides + +CMakeFiles/mojoluac.dir/lua/src/lbaselib.o.provides.build: CMakeFiles/mojoluac.dir/lua/src/lbaselib.o +.PHONY : CMakeFiles/mojoluac.dir/lua/src/lbaselib.o.provides.build + +CMakeFiles/mojoluac.dir/lua/src/lstrlib.o: CMakeFiles/mojoluac.dir/flags.make +CMakeFiles/mojoluac.dir/lua/src/lstrlib.o: ../lua/src/lstrlib.c + $(CMAKE_COMMAND) -E cmake_progress_report /home/softcoder/Code/mojosetup/build/CMakeFiles $(CMAKE_PROGRESS_19) + @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green "Building C object CMakeFiles/mojoluac.dir/lua/src/lstrlib.o" + /usr/bin/gcc $(C_DEFINES) $(C_FLAGS) -o CMakeFiles/mojoluac.dir/lua/src/lstrlib.o -c /home/softcoder/Code/mojosetup/lua/src/lstrlib.c + +CMakeFiles/mojoluac.dir/lua/src/lstrlib.i: cmake_force + @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green "Preprocessing C source to CMakeFiles/mojoluac.dir/lua/src/lstrlib.i" + /usr/bin/gcc $(C_DEFINES) $(C_FLAGS) -E /home/softcoder/Code/mojosetup/lua/src/lstrlib.c > CMakeFiles/mojoluac.dir/lua/src/lstrlib.i + +CMakeFiles/mojoluac.dir/lua/src/lstrlib.s: cmake_force + @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green "Compiling C source to assembly CMakeFiles/mojoluac.dir/lua/src/lstrlib.s" + /usr/bin/gcc $(C_DEFINES) $(C_FLAGS) -S /home/softcoder/Code/mojosetup/lua/src/lstrlib.c -o CMakeFiles/mojoluac.dir/lua/src/lstrlib.s + +CMakeFiles/mojoluac.dir/lua/src/lstrlib.o.requires: +.PHONY : CMakeFiles/mojoluac.dir/lua/src/lstrlib.o.requires + +CMakeFiles/mojoluac.dir/lua/src/lstrlib.o.provides: CMakeFiles/mojoluac.dir/lua/src/lstrlib.o.requires + $(MAKE) -f CMakeFiles/mojoluac.dir/build.make CMakeFiles/mojoluac.dir/lua/src/lstrlib.o.provides.build +.PHONY : CMakeFiles/mojoluac.dir/lua/src/lstrlib.o.provides + +CMakeFiles/mojoluac.dir/lua/src/lstrlib.o.provides.build: CMakeFiles/mojoluac.dir/lua/src/lstrlib.o +.PHONY : CMakeFiles/mojoluac.dir/lua/src/lstrlib.o.provides.build + +CMakeFiles/mojoluac.dir/lua/src/ltablib.o: CMakeFiles/mojoluac.dir/flags.make +CMakeFiles/mojoluac.dir/lua/src/ltablib.o: ../lua/src/ltablib.c + $(CMAKE_COMMAND) -E cmake_progress_report /home/softcoder/Code/mojosetup/build/CMakeFiles $(CMAKE_PROGRESS_20) + @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green "Building C object CMakeFiles/mojoluac.dir/lua/src/ltablib.o" + /usr/bin/gcc $(C_DEFINES) $(C_FLAGS) -o CMakeFiles/mojoluac.dir/lua/src/ltablib.o -c /home/softcoder/Code/mojosetup/lua/src/ltablib.c + +CMakeFiles/mojoluac.dir/lua/src/ltablib.i: cmake_force + @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green "Preprocessing C source to CMakeFiles/mojoluac.dir/lua/src/ltablib.i" + /usr/bin/gcc $(C_DEFINES) $(C_FLAGS) -E /home/softcoder/Code/mojosetup/lua/src/ltablib.c > CMakeFiles/mojoluac.dir/lua/src/ltablib.i + +CMakeFiles/mojoluac.dir/lua/src/ltablib.s: cmake_force + @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green "Compiling C source to assembly CMakeFiles/mojoluac.dir/lua/src/ltablib.s" + /usr/bin/gcc $(C_DEFINES) $(C_FLAGS) -S /home/softcoder/Code/mojosetup/lua/src/ltablib.c -o CMakeFiles/mojoluac.dir/lua/src/ltablib.s + +CMakeFiles/mojoluac.dir/lua/src/ltablib.o.requires: +.PHONY : CMakeFiles/mojoluac.dir/lua/src/ltablib.o.requires + +CMakeFiles/mojoluac.dir/lua/src/ltablib.o.provides: CMakeFiles/mojoluac.dir/lua/src/ltablib.o.requires + $(MAKE) -f CMakeFiles/mojoluac.dir/build.make CMakeFiles/mojoluac.dir/lua/src/ltablib.o.provides.build +.PHONY : CMakeFiles/mojoluac.dir/lua/src/ltablib.o.provides + +CMakeFiles/mojoluac.dir/lua/src/ltablib.o.provides.build: CMakeFiles/mojoluac.dir/lua/src/ltablib.o +.PHONY : CMakeFiles/mojoluac.dir/lua/src/ltablib.o.provides.build + +CMakeFiles/mojoluac.dir/lua/src/lparser.o: CMakeFiles/mojoluac.dir/flags.make +CMakeFiles/mojoluac.dir/lua/src/lparser.o: ../lua/src/lparser.c + $(CMAKE_COMMAND) -E cmake_progress_report /home/softcoder/Code/mojosetup/build/CMakeFiles $(CMAKE_PROGRESS_21) + @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green "Building C object CMakeFiles/mojoluac.dir/lua/src/lparser.o" + /usr/bin/gcc $(C_DEFINES) $(C_FLAGS) -o CMakeFiles/mojoluac.dir/lua/src/lparser.o -c /home/softcoder/Code/mojosetup/lua/src/lparser.c + +CMakeFiles/mojoluac.dir/lua/src/lparser.i: cmake_force + @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green "Preprocessing C source to CMakeFiles/mojoluac.dir/lua/src/lparser.i" + /usr/bin/gcc $(C_DEFINES) $(C_FLAGS) -E /home/softcoder/Code/mojosetup/lua/src/lparser.c > CMakeFiles/mojoluac.dir/lua/src/lparser.i + +CMakeFiles/mojoluac.dir/lua/src/lparser.s: cmake_force + @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green "Compiling C source to assembly CMakeFiles/mojoluac.dir/lua/src/lparser.s" + /usr/bin/gcc $(C_DEFINES) $(C_FLAGS) -S /home/softcoder/Code/mojosetup/lua/src/lparser.c -o CMakeFiles/mojoluac.dir/lua/src/lparser.s + +CMakeFiles/mojoluac.dir/lua/src/lparser.o.requires: +.PHONY : CMakeFiles/mojoluac.dir/lua/src/lparser.o.requires + +CMakeFiles/mojoluac.dir/lua/src/lparser.o.provides: CMakeFiles/mojoluac.dir/lua/src/lparser.o.requires + $(MAKE) -f CMakeFiles/mojoluac.dir/build.make CMakeFiles/mojoluac.dir/lua/src/lparser.o.provides.build +.PHONY : CMakeFiles/mojoluac.dir/lua/src/lparser.o.provides + +CMakeFiles/mojoluac.dir/lua/src/lparser.o.provides.build: CMakeFiles/mojoluac.dir/lua/src/lparser.o +.PHONY : CMakeFiles/mojoluac.dir/lua/src/lparser.o.provides.build + +CMakeFiles/mojoluac.dir/lua/src/llex.o: CMakeFiles/mojoluac.dir/flags.make +CMakeFiles/mojoluac.dir/lua/src/llex.o: ../lua/src/llex.c + $(CMAKE_COMMAND) -E cmake_progress_report /home/softcoder/Code/mojosetup/build/CMakeFiles $(CMAKE_PROGRESS_22) + @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green "Building C object CMakeFiles/mojoluac.dir/lua/src/llex.o" + /usr/bin/gcc $(C_DEFINES) $(C_FLAGS) -o CMakeFiles/mojoluac.dir/lua/src/llex.o -c /home/softcoder/Code/mojosetup/lua/src/llex.c + +CMakeFiles/mojoluac.dir/lua/src/llex.i: cmake_force + @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green "Preprocessing C source to CMakeFiles/mojoluac.dir/lua/src/llex.i" + /usr/bin/gcc $(C_DEFINES) $(C_FLAGS) -E /home/softcoder/Code/mojosetup/lua/src/llex.c > CMakeFiles/mojoluac.dir/lua/src/llex.i + +CMakeFiles/mojoluac.dir/lua/src/llex.s: cmake_force + @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green "Compiling C source to assembly CMakeFiles/mojoluac.dir/lua/src/llex.s" + /usr/bin/gcc $(C_DEFINES) $(C_FLAGS) -S /home/softcoder/Code/mojosetup/lua/src/llex.c -o CMakeFiles/mojoluac.dir/lua/src/llex.s + +CMakeFiles/mojoluac.dir/lua/src/llex.o.requires: +.PHONY : CMakeFiles/mojoluac.dir/lua/src/llex.o.requires + +CMakeFiles/mojoluac.dir/lua/src/llex.o.provides: CMakeFiles/mojoluac.dir/lua/src/llex.o.requires + $(MAKE) -f CMakeFiles/mojoluac.dir/build.make CMakeFiles/mojoluac.dir/lua/src/llex.o.provides.build +.PHONY : CMakeFiles/mojoluac.dir/lua/src/llex.o.provides + +CMakeFiles/mojoluac.dir/lua/src/llex.o.provides.build: CMakeFiles/mojoluac.dir/lua/src/llex.o +.PHONY : CMakeFiles/mojoluac.dir/lua/src/llex.o.provides.build + +CMakeFiles/mojoluac.dir/lua/src/lcode.o: CMakeFiles/mojoluac.dir/flags.make +CMakeFiles/mojoluac.dir/lua/src/lcode.o: ../lua/src/lcode.c + $(CMAKE_COMMAND) -E cmake_progress_report /home/softcoder/Code/mojosetup/build/CMakeFiles $(CMAKE_PROGRESS_23) + @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green "Building C object CMakeFiles/mojoluac.dir/lua/src/lcode.o" + /usr/bin/gcc $(C_DEFINES) $(C_FLAGS) -o CMakeFiles/mojoluac.dir/lua/src/lcode.o -c /home/softcoder/Code/mojosetup/lua/src/lcode.c + +CMakeFiles/mojoluac.dir/lua/src/lcode.i: cmake_force + @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green "Preprocessing C source to CMakeFiles/mojoluac.dir/lua/src/lcode.i" + /usr/bin/gcc $(C_DEFINES) $(C_FLAGS) -E /home/softcoder/Code/mojosetup/lua/src/lcode.c > CMakeFiles/mojoluac.dir/lua/src/lcode.i + +CMakeFiles/mojoluac.dir/lua/src/lcode.s: cmake_force + @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green "Compiling C source to assembly CMakeFiles/mojoluac.dir/lua/src/lcode.s" + /usr/bin/gcc $(C_DEFINES) $(C_FLAGS) -S /home/softcoder/Code/mojosetup/lua/src/lcode.c -o CMakeFiles/mojoluac.dir/lua/src/lcode.s + +CMakeFiles/mojoluac.dir/lua/src/lcode.o.requires: +.PHONY : CMakeFiles/mojoluac.dir/lua/src/lcode.o.requires + +CMakeFiles/mojoluac.dir/lua/src/lcode.o.provides: CMakeFiles/mojoluac.dir/lua/src/lcode.o.requires + $(MAKE) -f CMakeFiles/mojoluac.dir/build.make CMakeFiles/mojoluac.dir/lua/src/lcode.o.provides.build +.PHONY : CMakeFiles/mojoluac.dir/lua/src/lcode.o.provides + +CMakeFiles/mojoluac.dir/lua/src/lcode.o.provides.build: CMakeFiles/mojoluac.dir/lua/src/lcode.o +.PHONY : CMakeFiles/mojoluac.dir/lua/src/lcode.o.provides.build + +CMakeFiles/mojoluac.dir/lua/src/luac.o: CMakeFiles/mojoluac.dir/flags.make +CMakeFiles/mojoluac.dir/lua/src/luac.o: ../lua/src/luac.c + $(CMAKE_COMMAND) -E cmake_progress_report /home/softcoder/Code/mojosetup/build/CMakeFiles $(CMAKE_PROGRESS_24) + @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green "Building C object CMakeFiles/mojoluac.dir/lua/src/luac.o" + /usr/bin/gcc $(C_DEFINES) $(C_FLAGS) -o CMakeFiles/mojoluac.dir/lua/src/luac.o -c /home/softcoder/Code/mojosetup/lua/src/luac.c + +CMakeFiles/mojoluac.dir/lua/src/luac.i: cmake_force + @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green "Preprocessing C source to CMakeFiles/mojoluac.dir/lua/src/luac.i" + /usr/bin/gcc $(C_DEFINES) $(C_FLAGS) -E /home/softcoder/Code/mojosetup/lua/src/luac.c > CMakeFiles/mojoluac.dir/lua/src/luac.i + +CMakeFiles/mojoluac.dir/lua/src/luac.s: cmake_force + @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green "Compiling C source to assembly CMakeFiles/mojoluac.dir/lua/src/luac.s" + /usr/bin/gcc $(C_DEFINES) $(C_FLAGS) -S /home/softcoder/Code/mojosetup/lua/src/luac.c -o CMakeFiles/mojoluac.dir/lua/src/luac.s + +CMakeFiles/mojoluac.dir/lua/src/luac.o.requires: +.PHONY : CMakeFiles/mojoluac.dir/lua/src/luac.o.requires + +CMakeFiles/mojoluac.dir/lua/src/luac.o.provides: CMakeFiles/mojoluac.dir/lua/src/luac.o.requires + $(MAKE) -f CMakeFiles/mojoluac.dir/build.make CMakeFiles/mojoluac.dir/lua/src/luac.o.provides.build +.PHONY : CMakeFiles/mojoluac.dir/lua/src/luac.o.provides + +CMakeFiles/mojoluac.dir/lua/src/luac.o.provides.build: CMakeFiles/mojoluac.dir/lua/src/luac.o +.PHONY : CMakeFiles/mojoluac.dir/lua/src/luac.o.provides.build + +CMakeFiles/mojoluac.dir/lua/src/print.o: CMakeFiles/mojoluac.dir/flags.make +CMakeFiles/mojoluac.dir/lua/src/print.o: ../lua/src/print.c + $(CMAKE_COMMAND) -E cmake_progress_report /home/softcoder/Code/mojosetup/build/CMakeFiles $(CMAKE_PROGRESS_25) + @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green "Building C object CMakeFiles/mojoluac.dir/lua/src/print.o" + /usr/bin/gcc $(C_DEFINES) $(C_FLAGS) -o CMakeFiles/mojoluac.dir/lua/src/print.o -c /home/softcoder/Code/mojosetup/lua/src/print.c + +CMakeFiles/mojoluac.dir/lua/src/print.i: cmake_force + @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green "Preprocessing C source to CMakeFiles/mojoluac.dir/lua/src/print.i" + /usr/bin/gcc $(C_DEFINES) $(C_FLAGS) -E /home/softcoder/Code/mojosetup/lua/src/print.c > CMakeFiles/mojoluac.dir/lua/src/print.i + +CMakeFiles/mojoluac.dir/lua/src/print.s: cmake_force + @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green "Compiling C source to assembly CMakeFiles/mojoluac.dir/lua/src/print.s" + /usr/bin/gcc $(C_DEFINES) $(C_FLAGS) -S /home/softcoder/Code/mojosetup/lua/src/print.c -o CMakeFiles/mojoluac.dir/lua/src/print.s + +CMakeFiles/mojoluac.dir/lua/src/print.o.requires: +.PHONY : CMakeFiles/mojoluac.dir/lua/src/print.o.requires + +CMakeFiles/mojoluac.dir/lua/src/print.o.provides: CMakeFiles/mojoluac.dir/lua/src/print.o.requires + $(MAKE) -f CMakeFiles/mojoluac.dir/build.make CMakeFiles/mojoluac.dir/lua/src/print.o.provides.build +.PHONY : CMakeFiles/mojoluac.dir/lua/src/print.o.provides + +CMakeFiles/mojoluac.dir/lua/src/print.o.provides.build: CMakeFiles/mojoluac.dir/lua/src/print.o +.PHONY : CMakeFiles/mojoluac.dir/lua/src/print.o.provides.build + +CMakeFiles/mojoluac.dir/lua/src/linit.o: CMakeFiles/mojoluac.dir/flags.make +CMakeFiles/mojoluac.dir/lua/src/linit.o: ../lua/src/linit.c + $(CMAKE_COMMAND) -E cmake_progress_report /home/softcoder/Code/mojosetup/build/CMakeFiles $(CMAKE_PROGRESS_26) + @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green "Building C object CMakeFiles/mojoluac.dir/lua/src/linit.o" + /usr/bin/gcc $(C_DEFINES) $(C_FLAGS) -o CMakeFiles/mojoluac.dir/lua/src/linit.o -c /home/softcoder/Code/mojosetup/lua/src/linit.c + +CMakeFiles/mojoluac.dir/lua/src/linit.i: cmake_force + @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green "Preprocessing C source to CMakeFiles/mojoluac.dir/lua/src/linit.i" + /usr/bin/gcc $(C_DEFINES) $(C_FLAGS) -E /home/softcoder/Code/mojosetup/lua/src/linit.c > CMakeFiles/mojoluac.dir/lua/src/linit.i + +CMakeFiles/mojoluac.dir/lua/src/linit.s: cmake_force + @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green "Compiling C source to assembly CMakeFiles/mojoluac.dir/lua/src/linit.s" + /usr/bin/gcc $(C_DEFINES) $(C_FLAGS) -S /home/softcoder/Code/mojosetup/lua/src/linit.c -o CMakeFiles/mojoluac.dir/lua/src/linit.s + +CMakeFiles/mojoluac.dir/lua/src/linit.o.requires: +.PHONY : CMakeFiles/mojoluac.dir/lua/src/linit.o.requires + +CMakeFiles/mojoluac.dir/lua/src/linit.o.provides: CMakeFiles/mojoluac.dir/lua/src/linit.o.requires + $(MAKE) -f CMakeFiles/mojoluac.dir/build.make CMakeFiles/mojoluac.dir/lua/src/linit.o.provides.build +.PHONY : CMakeFiles/mojoluac.dir/lua/src/linit.o.provides + +CMakeFiles/mojoluac.dir/lua/src/linit.o.provides.build: CMakeFiles/mojoluac.dir/lua/src/linit.o +.PHONY : CMakeFiles/mojoluac.dir/lua/src/linit.o.provides.build + +CMakeFiles/mojoluac.dir/lua/src/ldblib.o: CMakeFiles/mojoluac.dir/flags.make +CMakeFiles/mojoluac.dir/lua/src/ldblib.o: ../lua/src/ldblib.c + $(CMAKE_COMMAND) -E cmake_progress_report /home/softcoder/Code/mojosetup/build/CMakeFiles $(CMAKE_PROGRESS_27) + @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green "Building C object CMakeFiles/mojoluac.dir/lua/src/ldblib.o" + /usr/bin/gcc $(C_DEFINES) $(C_FLAGS) -o CMakeFiles/mojoluac.dir/lua/src/ldblib.o -c /home/softcoder/Code/mojosetup/lua/src/ldblib.c + +CMakeFiles/mojoluac.dir/lua/src/ldblib.i: cmake_force + @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green "Preprocessing C source to CMakeFiles/mojoluac.dir/lua/src/ldblib.i" + /usr/bin/gcc $(C_DEFINES) $(C_FLAGS) -E /home/softcoder/Code/mojosetup/lua/src/ldblib.c > CMakeFiles/mojoluac.dir/lua/src/ldblib.i + +CMakeFiles/mojoluac.dir/lua/src/ldblib.s: cmake_force + @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green "Compiling C source to assembly CMakeFiles/mojoluac.dir/lua/src/ldblib.s" + /usr/bin/gcc $(C_DEFINES) $(C_FLAGS) -S /home/softcoder/Code/mojosetup/lua/src/ldblib.c -o CMakeFiles/mojoluac.dir/lua/src/ldblib.s + +CMakeFiles/mojoluac.dir/lua/src/ldblib.o.requires: +.PHONY : CMakeFiles/mojoluac.dir/lua/src/ldblib.o.requires + +CMakeFiles/mojoluac.dir/lua/src/ldblib.o.provides: CMakeFiles/mojoluac.dir/lua/src/ldblib.o.requires + $(MAKE) -f CMakeFiles/mojoluac.dir/build.make CMakeFiles/mojoluac.dir/lua/src/ldblib.o.provides.build +.PHONY : CMakeFiles/mojoluac.dir/lua/src/ldblib.o.provides + +CMakeFiles/mojoluac.dir/lua/src/ldblib.o.provides.build: CMakeFiles/mojoluac.dir/lua/src/ldblib.o +.PHONY : CMakeFiles/mojoluac.dir/lua/src/ldblib.o.provides.build + +CMakeFiles/mojoluac.dir/lua/src/liolib.o: CMakeFiles/mojoluac.dir/flags.make +CMakeFiles/mojoluac.dir/lua/src/liolib.o: ../lua/src/liolib.c + $(CMAKE_COMMAND) -E cmake_progress_report /home/softcoder/Code/mojosetup/build/CMakeFiles $(CMAKE_PROGRESS_28) + @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green "Building C object CMakeFiles/mojoluac.dir/lua/src/liolib.o" + /usr/bin/gcc $(C_DEFINES) $(C_FLAGS) -o CMakeFiles/mojoluac.dir/lua/src/liolib.o -c /home/softcoder/Code/mojosetup/lua/src/liolib.c + +CMakeFiles/mojoluac.dir/lua/src/liolib.i: cmake_force + @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green "Preprocessing C source to CMakeFiles/mojoluac.dir/lua/src/liolib.i" + /usr/bin/gcc $(C_DEFINES) $(C_FLAGS) -E /home/softcoder/Code/mojosetup/lua/src/liolib.c > CMakeFiles/mojoluac.dir/lua/src/liolib.i + +CMakeFiles/mojoluac.dir/lua/src/liolib.s: cmake_force + @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green "Compiling C source to assembly CMakeFiles/mojoluac.dir/lua/src/liolib.s" + /usr/bin/gcc $(C_DEFINES) $(C_FLAGS) -S /home/softcoder/Code/mojosetup/lua/src/liolib.c -o CMakeFiles/mojoluac.dir/lua/src/liolib.s + +CMakeFiles/mojoluac.dir/lua/src/liolib.o.requires: +.PHONY : CMakeFiles/mojoluac.dir/lua/src/liolib.o.requires + +CMakeFiles/mojoluac.dir/lua/src/liolib.o.provides: CMakeFiles/mojoluac.dir/lua/src/liolib.o.requires + $(MAKE) -f CMakeFiles/mojoluac.dir/build.make CMakeFiles/mojoluac.dir/lua/src/liolib.o.provides.build +.PHONY : CMakeFiles/mojoluac.dir/lua/src/liolib.o.provides + +CMakeFiles/mojoluac.dir/lua/src/liolib.o.provides.build: CMakeFiles/mojoluac.dir/lua/src/liolib.o +.PHONY : CMakeFiles/mojoluac.dir/lua/src/liolib.o.provides.build + +CMakeFiles/mojoluac.dir/lua/src/lmathlib.o: CMakeFiles/mojoluac.dir/flags.make +CMakeFiles/mojoluac.dir/lua/src/lmathlib.o: ../lua/src/lmathlib.c + $(CMAKE_COMMAND) -E cmake_progress_report /home/softcoder/Code/mojosetup/build/CMakeFiles $(CMAKE_PROGRESS_29) + @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green "Building C object CMakeFiles/mojoluac.dir/lua/src/lmathlib.o" + /usr/bin/gcc $(C_DEFINES) $(C_FLAGS) -o CMakeFiles/mojoluac.dir/lua/src/lmathlib.o -c /home/softcoder/Code/mojosetup/lua/src/lmathlib.c + +CMakeFiles/mojoluac.dir/lua/src/lmathlib.i: cmake_force + @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green "Preprocessing C source to CMakeFiles/mojoluac.dir/lua/src/lmathlib.i" + /usr/bin/gcc $(C_DEFINES) $(C_FLAGS) -E /home/softcoder/Code/mojosetup/lua/src/lmathlib.c > CMakeFiles/mojoluac.dir/lua/src/lmathlib.i + +CMakeFiles/mojoluac.dir/lua/src/lmathlib.s: cmake_force + @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green "Compiling C source to assembly CMakeFiles/mojoluac.dir/lua/src/lmathlib.s" + /usr/bin/gcc $(C_DEFINES) $(C_FLAGS) -S /home/softcoder/Code/mojosetup/lua/src/lmathlib.c -o CMakeFiles/mojoluac.dir/lua/src/lmathlib.s + +CMakeFiles/mojoluac.dir/lua/src/lmathlib.o.requires: +.PHONY : CMakeFiles/mojoluac.dir/lua/src/lmathlib.o.requires + +CMakeFiles/mojoluac.dir/lua/src/lmathlib.o.provides: CMakeFiles/mojoluac.dir/lua/src/lmathlib.o.requires + $(MAKE) -f CMakeFiles/mojoluac.dir/build.make CMakeFiles/mojoluac.dir/lua/src/lmathlib.o.provides.build +.PHONY : CMakeFiles/mojoluac.dir/lua/src/lmathlib.o.provides + +CMakeFiles/mojoluac.dir/lua/src/lmathlib.o.provides.build: CMakeFiles/mojoluac.dir/lua/src/lmathlib.o +.PHONY : CMakeFiles/mojoluac.dir/lua/src/lmathlib.o.provides.build + +CMakeFiles/mojoluac.dir/lua/src/loslib.o: CMakeFiles/mojoluac.dir/flags.make +CMakeFiles/mojoluac.dir/lua/src/loslib.o: ../lua/src/loslib.c + $(CMAKE_COMMAND) -E cmake_progress_report /home/softcoder/Code/mojosetup/build/CMakeFiles $(CMAKE_PROGRESS_30) + @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green "Building C object CMakeFiles/mojoluac.dir/lua/src/loslib.o" + /usr/bin/gcc $(C_DEFINES) $(C_FLAGS) -o CMakeFiles/mojoluac.dir/lua/src/loslib.o -c /home/softcoder/Code/mojosetup/lua/src/loslib.c + +CMakeFiles/mojoluac.dir/lua/src/loslib.i: cmake_force + @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green "Preprocessing C source to CMakeFiles/mojoluac.dir/lua/src/loslib.i" + /usr/bin/gcc $(C_DEFINES) $(C_FLAGS) -E /home/softcoder/Code/mojosetup/lua/src/loslib.c > CMakeFiles/mojoluac.dir/lua/src/loslib.i + +CMakeFiles/mojoluac.dir/lua/src/loslib.s: cmake_force + @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green "Compiling C source to assembly CMakeFiles/mojoluac.dir/lua/src/loslib.s" + /usr/bin/gcc $(C_DEFINES) $(C_FLAGS) -S /home/softcoder/Code/mojosetup/lua/src/loslib.c -o CMakeFiles/mojoluac.dir/lua/src/loslib.s + +CMakeFiles/mojoluac.dir/lua/src/loslib.o.requires: +.PHONY : CMakeFiles/mojoluac.dir/lua/src/loslib.o.requires + +CMakeFiles/mojoluac.dir/lua/src/loslib.o.provides: CMakeFiles/mojoluac.dir/lua/src/loslib.o.requires + $(MAKE) -f CMakeFiles/mojoluac.dir/build.make CMakeFiles/mojoluac.dir/lua/src/loslib.o.provides.build +.PHONY : CMakeFiles/mojoluac.dir/lua/src/loslib.o.provides + +CMakeFiles/mojoluac.dir/lua/src/loslib.o.provides.build: CMakeFiles/mojoluac.dir/lua/src/loslib.o +.PHONY : CMakeFiles/mojoluac.dir/lua/src/loslib.o.provides.build + +CMakeFiles/mojoluac.dir/lua/src/loadlib.o: CMakeFiles/mojoluac.dir/flags.make +CMakeFiles/mojoluac.dir/lua/src/loadlib.o: ../lua/src/loadlib.c + $(CMAKE_COMMAND) -E cmake_progress_report /home/softcoder/Code/mojosetup/build/CMakeFiles $(CMAKE_PROGRESS_31) + @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green "Building C object CMakeFiles/mojoluac.dir/lua/src/loadlib.o" + /usr/bin/gcc $(C_DEFINES) $(C_FLAGS) -o CMakeFiles/mojoluac.dir/lua/src/loadlib.o -c /home/softcoder/Code/mojosetup/lua/src/loadlib.c + +CMakeFiles/mojoluac.dir/lua/src/loadlib.i: cmake_force + @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green "Preprocessing C source to CMakeFiles/mojoluac.dir/lua/src/loadlib.i" + /usr/bin/gcc $(C_DEFINES) $(C_FLAGS) -E /home/softcoder/Code/mojosetup/lua/src/loadlib.c > CMakeFiles/mojoluac.dir/lua/src/loadlib.i + +CMakeFiles/mojoluac.dir/lua/src/loadlib.s: cmake_force + @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green "Compiling C source to assembly CMakeFiles/mojoluac.dir/lua/src/loadlib.s" + /usr/bin/gcc $(C_DEFINES) $(C_FLAGS) -S /home/softcoder/Code/mojosetup/lua/src/loadlib.c -o CMakeFiles/mojoluac.dir/lua/src/loadlib.s + +CMakeFiles/mojoluac.dir/lua/src/loadlib.o.requires: +.PHONY : CMakeFiles/mojoluac.dir/lua/src/loadlib.o.requires + +CMakeFiles/mojoluac.dir/lua/src/loadlib.o.provides: CMakeFiles/mojoluac.dir/lua/src/loadlib.o.requires + $(MAKE) -f CMakeFiles/mojoluac.dir/build.make CMakeFiles/mojoluac.dir/lua/src/loadlib.o.provides.build +.PHONY : CMakeFiles/mojoluac.dir/lua/src/loadlib.o.provides + +CMakeFiles/mojoluac.dir/lua/src/loadlib.o.provides.build: CMakeFiles/mojoluac.dir/lua/src/loadlib.o +.PHONY : CMakeFiles/mojoluac.dir/lua/src/loadlib.o.provides.build + +# Object files for target mojoluac +mojoluac_OBJECTS = \ +"CMakeFiles/mojoluac.dir/lua/src/lapi.o" \ +"CMakeFiles/mojoluac.dir/lua/src/ldebug.o" \ +"CMakeFiles/mojoluac.dir/lua/src/ldo.o" \ +"CMakeFiles/mojoluac.dir/lua/src/ldump.o" \ +"CMakeFiles/mojoluac.dir/lua/src/lfunc.o" \ +"CMakeFiles/mojoluac.dir/lua/src/lgc.o" \ +"CMakeFiles/mojoluac.dir/lua/src/lmem.o" \ +"CMakeFiles/mojoluac.dir/lua/src/lobject.o" \ +"CMakeFiles/mojoluac.dir/lua/src/lopcodes.o" \ +"CMakeFiles/mojoluac.dir/lua/src/lstate.o" \ +"CMakeFiles/mojoluac.dir/lua/src/lstring.o" \ +"CMakeFiles/mojoluac.dir/lua/src/ltable.o" \ +"CMakeFiles/mojoluac.dir/lua/src/ltm.o" \ +"CMakeFiles/mojoluac.dir/lua/src/lundump.o" \ +"CMakeFiles/mojoluac.dir/lua/src/lvm.o" \ +"CMakeFiles/mojoluac.dir/lua/src/lzio.o" \ +"CMakeFiles/mojoluac.dir/lua/src/lauxlib.o" \ +"CMakeFiles/mojoluac.dir/lua/src/lbaselib.o" \ +"CMakeFiles/mojoluac.dir/lua/src/lstrlib.o" \ +"CMakeFiles/mojoluac.dir/lua/src/ltablib.o" \ +"CMakeFiles/mojoluac.dir/lua/src/lparser.o" \ +"CMakeFiles/mojoluac.dir/lua/src/llex.o" \ +"CMakeFiles/mojoluac.dir/lua/src/lcode.o" \ +"CMakeFiles/mojoluac.dir/lua/src/luac.o" \ +"CMakeFiles/mojoluac.dir/lua/src/print.o" \ +"CMakeFiles/mojoluac.dir/lua/src/linit.o" \ +"CMakeFiles/mojoluac.dir/lua/src/ldblib.o" \ +"CMakeFiles/mojoluac.dir/lua/src/liolib.o" \ +"CMakeFiles/mojoluac.dir/lua/src/lmathlib.o" \ +"CMakeFiles/mojoluac.dir/lua/src/loslib.o" \ +"CMakeFiles/mojoluac.dir/lua/src/loadlib.o" + +# External object files for target mojoluac +mojoluac_EXTERNAL_OBJECTS = + +mojoluac: CMakeFiles/mojoluac.dir/lua/src/lapi.o +mojoluac: CMakeFiles/mojoluac.dir/lua/src/ldebug.o +mojoluac: CMakeFiles/mojoluac.dir/lua/src/ldo.o +mojoluac: CMakeFiles/mojoluac.dir/lua/src/ldump.o +mojoluac: CMakeFiles/mojoluac.dir/lua/src/lfunc.o +mojoluac: CMakeFiles/mojoluac.dir/lua/src/lgc.o +mojoluac: CMakeFiles/mojoluac.dir/lua/src/lmem.o +mojoluac: CMakeFiles/mojoluac.dir/lua/src/lobject.o +mojoluac: CMakeFiles/mojoluac.dir/lua/src/lopcodes.o +mojoluac: CMakeFiles/mojoluac.dir/lua/src/lstate.o +mojoluac: CMakeFiles/mojoluac.dir/lua/src/lstring.o +mojoluac: CMakeFiles/mojoluac.dir/lua/src/ltable.o +mojoluac: CMakeFiles/mojoluac.dir/lua/src/ltm.o +mojoluac: CMakeFiles/mojoluac.dir/lua/src/lundump.o +mojoluac: CMakeFiles/mojoluac.dir/lua/src/lvm.o +mojoluac: CMakeFiles/mojoluac.dir/lua/src/lzio.o +mojoluac: CMakeFiles/mojoluac.dir/lua/src/lauxlib.o +mojoluac: CMakeFiles/mojoluac.dir/lua/src/lbaselib.o +mojoluac: CMakeFiles/mojoluac.dir/lua/src/lstrlib.o +mojoluac: CMakeFiles/mojoluac.dir/lua/src/ltablib.o +mojoluac: CMakeFiles/mojoluac.dir/lua/src/lparser.o +mojoluac: CMakeFiles/mojoluac.dir/lua/src/llex.o +mojoluac: CMakeFiles/mojoluac.dir/lua/src/lcode.o +mojoluac: CMakeFiles/mojoluac.dir/lua/src/luac.o +mojoluac: CMakeFiles/mojoluac.dir/lua/src/print.o +mojoluac: CMakeFiles/mojoluac.dir/lua/src/linit.o +mojoluac: CMakeFiles/mojoluac.dir/lua/src/ldblib.o +mojoluac: CMakeFiles/mojoluac.dir/lua/src/liolib.o +mojoluac: CMakeFiles/mojoluac.dir/lua/src/lmathlib.o +mojoluac: CMakeFiles/mojoluac.dir/lua/src/loslib.o +mojoluac: CMakeFiles/mojoluac.dir/lua/src/loadlib.o +mojoluac: CMakeFiles/mojoluac.dir/build.make +mojoluac: CMakeFiles/mojoluac.dir/link.txt + @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --red --bold "Linking C executable mojoluac" + $(CMAKE_COMMAND) -E cmake_link_script CMakeFiles/mojoluac.dir/link.txt --verbose=$(VERBOSE) + +# Rule to build all files generated by this target. +CMakeFiles/mojoluac.dir/build: mojoluac +.PHONY : CMakeFiles/mojoluac.dir/build + +CMakeFiles/mojoluac.dir/requires: CMakeFiles/mojoluac.dir/lua/src/lapi.o.requires +CMakeFiles/mojoluac.dir/requires: CMakeFiles/mojoluac.dir/lua/src/ldebug.o.requires +CMakeFiles/mojoluac.dir/requires: CMakeFiles/mojoluac.dir/lua/src/ldo.o.requires +CMakeFiles/mojoluac.dir/requires: CMakeFiles/mojoluac.dir/lua/src/ldump.o.requires +CMakeFiles/mojoluac.dir/requires: CMakeFiles/mojoluac.dir/lua/src/lfunc.o.requires +CMakeFiles/mojoluac.dir/requires: CMakeFiles/mojoluac.dir/lua/src/lgc.o.requires +CMakeFiles/mojoluac.dir/requires: CMakeFiles/mojoluac.dir/lua/src/lmem.o.requires +CMakeFiles/mojoluac.dir/requires: CMakeFiles/mojoluac.dir/lua/src/lobject.o.requires +CMakeFiles/mojoluac.dir/requires: CMakeFiles/mojoluac.dir/lua/src/lopcodes.o.requires +CMakeFiles/mojoluac.dir/requires: CMakeFiles/mojoluac.dir/lua/src/lstate.o.requires +CMakeFiles/mojoluac.dir/requires: CMakeFiles/mojoluac.dir/lua/src/lstring.o.requires +CMakeFiles/mojoluac.dir/requires: CMakeFiles/mojoluac.dir/lua/src/ltable.o.requires +CMakeFiles/mojoluac.dir/requires: CMakeFiles/mojoluac.dir/lua/src/ltm.o.requires +CMakeFiles/mojoluac.dir/requires: CMakeFiles/mojoluac.dir/lua/src/lundump.o.requires +CMakeFiles/mojoluac.dir/requires: CMakeFiles/mojoluac.dir/lua/src/lvm.o.requires +CMakeFiles/mojoluac.dir/requires: CMakeFiles/mojoluac.dir/lua/src/lzio.o.requires +CMakeFiles/mojoluac.dir/requires: CMakeFiles/mojoluac.dir/lua/src/lauxlib.o.requires +CMakeFiles/mojoluac.dir/requires: CMakeFiles/mojoluac.dir/lua/src/lbaselib.o.requires +CMakeFiles/mojoluac.dir/requires: CMakeFiles/mojoluac.dir/lua/src/lstrlib.o.requires +CMakeFiles/mojoluac.dir/requires: CMakeFiles/mojoluac.dir/lua/src/ltablib.o.requires +CMakeFiles/mojoluac.dir/requires: CMakeFiles/mojoluac.dir/lua/src/lparser.o.requires +CMakeFiles/mojoluac.dir/requires: CMakeFiles/mojoluac.dir/lua/src/llex.o.requires +CMakeFiles/mojoluac.dir/requires: CMakeFiles/mojoluac.dir/lua/src/lcode.o.requires +CMakeFiles/mojoluac.dir/requires: CMakeFiles/mojoluac.dir/lua/src/luac.o.requires +CMakeFiles/mojoluac.dir/requires: CMakeFiles/mojoluac.dir/lua/src/print.o.requires +CMakeFiles/mojoluac.dir/requires: CMakeFiles/mojoluac.dir/lua/src/linit.o.requires +CMakeFiles/mojoluac.dir/requires: CMakeFiles/mojoluac.dir/lua/src/ldblib.o.requires +CMakeFiles/mojoluac.dir/requires: CMakeFiles/mojoluac.dir/lua/src/liolib.o.requires +CMakeFiles/mojoluac.dir/requires: CMakeFiles/mojoluac.dir/lua/src/lmathlib.o.requires +CMakeFiles/mojoluac.dir/requires: CMakeFiles/mojoluac.dir/lua/src/loslib.o.requires +CMakeFiles/mojoluac.dir/requires: CMakeFiles/mojoluac.dir/lua/src/loadlib.o.requires +.PHONY : CMakeFiles/mojoluac.dir/requires + +CMakeFiles/mojoluac.dir/clean: + $(CMAKE_COMMAND) -P CMakeFiles/mojoluac.dir/cmake_clean.cmake +.PHONY : CMakeFiles/mojoluac.dir/clean + +CMakeFiles/mojoluac.dir/depend: + cd /home/softcoder/Code/mojosetup/build && $(CMAKE_COMMAND) -E cmake_depends "Unix Makefiles" /home/softcoder/Code/mojosetup /home/softcoder/Code/mojosetup /home/softcoder/Code/mojosetup/build /home/softcoder/Code/mojosetup/build /home/softcoder/Code/mojosetup/build/CMakeFiles/mojoluac.dir/DependInfo.cmake --color=$(COLOR) +.PHONY : CMakeFiles/mojoluac.dir/depend + diff --git a/mk/linux/mojosetup/build/CMakeFiles/mojoluac.dir/cmake_clean.cmake b/mk/linux/mojosetup/build/CMakeFiles/mojoluac.dir/cmake_clean.cmake new file mode 100644 index 00000000..88a32f07 --- /dev/null +++ b/mk/linux/mojosetup/build/CMakeFiles/mojoluac.dir/cmake_clean.cmake @@ -0,0 +1,40 @@ +FILE(REMOVE_RECURSE + "CMakeFiles/mojoluac.dir/lua/src/lapi.o" + "CMakeFiles/mojoluac.dir/lua/src/ldebug.o" + "CMakeFiles/mojoluac.dir/lua/src/ldo.o" + "CMakeFiles/mojoluac.dir/lua/src/ldump.o" + "CMakeFiles/mojoluac.dir/lua/src/lfunc.o" + "CMakeFiles/mojoluac.dir/lua/src/lgc.o" + "CMakeFiles/mojoluac.dir/lua/src/lmem.o" + "CMakeFiles/mojoluac.dir/lua/src/lobject.o" + "CMakeFiles/mojoluac.dir/lua/src/lopcodes.o" + "CMakeFiles/mojoluac.dir/lua/src/lstate.o" + "CMakeFiles/mojoluac.dir/lua/src/lstring.o" + "CMakeFiles/mojoluac.dir/lua/src/ltable.o" + "CMakeFiles/mojoluac.dir/lua/src/ltm.o" + "CMakeFiles/mojoluac.dir/lua/src/lundump.o" + "CMakeFiles/mojoluac.dir/lua/src/lvm.o" + "CMakeFiles/mojoluac.dir/lua/src/lzio.o" + "CMakeFiles/mojoluac.dir/lua/src/lauxlib.o" + "CMakeFiles/mojoluac.dir/lua/src/lbaselib.o" + "CMakeFiles/mojoluac.dir/lua/src/lstrlib.o" + "CMakeFiles/mojoluac.dir/lua/src/ltablib.o" + "CMakeFiles/mojoluac.dir/lua/src/lparser.o" + "CMakeFiles/mojoluac.dir/lua/src/llex.o" + "CMakeFiles/mojoluac.dir/lua/src/lcode.o" + "CMakeFiles/mojoluac.dir/lua/src/luac.o" + "CMakeFiles/mojoluac.dir/lua/src/print.o" + "CMakeFiles/mojoluac.dir/lua/src/linit.o" + "CMakeFiles/mojoluac.dir/lua/src/ldblib.o" + "CMakeFiles/mojoluac.dir/lua/src/liolib.o" + "CMakeFiles/mojoluac.dir/lua/src/lmathlib.o" + "CMakeFiles/mojoluac.dir/lua/src/loslib.o" + "CMakeFiles/mojoluac.dir/lua/src/loadlib.o" + "mojoluac.pdb" + "mojoluac" +) + +# Per-language clean rules from dependency scanning. +FOREACH(lang C) + INCLUDE(CMakeFiles/mojoluac.dir/cmake_clean_${lang}.cmake OPTIONAL) +ENDFOREACH(lang) diff --git a/mk/linux/mojosetup/build/CMakeFiles/mojoluac.dir/depend.internal b/mk/linux/mojosetup/build/CMakeFiles/mojoluac.dir/depend.internal new file mode 100644 index 00000000..a5465dc8 --- /dev/null +++ b/mk/linux/mojosetup/build/CMakeFiles/mojoluac.dir/depend.internal @@ -0,0 +1,378 @@ +# CMAKE generated file: DO NOT EDIT! +# Generated by "Unix Makefiles" Generator, CMake Version 2.8 + +CMakeFiles/mojoluac.dir/lua/src/lapi.o + /home/softcoder/Code/mojosetup/lua/src/lapi.c + /home/softcoder/Code/mojosetup/lua/src/lapi.h + /home/softcoder/Code/mojosetup/lua/src/ldebug.h + /home/softcoder/Code/mojosetup/lua/src/ldo.h + /home/softcoder/Code/mojosetup/lua/src/lfunc.h + /home/softcoder/Code/mojosetup/lua/src/lgc.h + /home/softcoder/Code/mojosetup/lua/src/llimits.h + /home/softcoder/Code/mojosetup/lua/src/lmem.h + /home/softcoder/Code/mojosetup/lua/src/lobject.h + /home/softcoder/Code/mojosetup/lua/src/lstate.h + /home/softcoder/Code/mojosetup/lua/src/lstring.h + /home/softcoder/Code/mojosetup/lua/src/ltable.h + /home/softcoder/Code/mojosetup/lua/src/ltm.h + /home/softcoder/Code/mojosetup/lua/src/lua.h + /home/softcoder/Code/mojosetup/lua/src/luaconf.h + /home/softcoder/Code/mojosetup/lua/src/lundump.h + /home/softcoder/Code/mojosetup/lua/src/lvm.h + /home/softcoder/Code/mojosetup/lua/src/lzio.h +CMakeFiles/mojoluac.dir/lua/src/lauxlib.o + /home/softcoder/Code/mojosetup/lua/src/lauxlib.c + /home/softcoder/Code/mojosetup/lua/src/lauxlib.h + /home/softcoder/Code/mojosetup/lua/src/lua.h + /home/softcoder/Code/mojosetup/lua/src/luaconf.h +CMakeFiles/mojoluac.dir/lua/src/lbaselib.o + /home/softcoder/Code/mojosetup/lua/src/lauxlib.h + /home/softcoder/Code/mojosetup/lua/src/lbaselib.c + /home/softcoder/Code/mojosetup/lua/src/lua.h + /home/softcoder/Code/mojosetup/lua/src/luaconf.h + /home/softcoder/Code/mojosetup/lua/src/lualib.h +CMakeFiles/mojoluac.dir/lua/src/lcode.o + /home/softcoder/Code/mojosetup/lua/src/lcode.c + /home/softcoder/Code/mojosetup/lua/src/lcode.h + /home/softcoder/Code/mojosetup/lua/src/ldebug.h + /home/softcoder/Code/mojosetup/lua/src/ldo.h + /home/softcoder/Code/mojosetup/lua/src/lgc.h + /home/softcoder/Code/mojosetup/lua/src/llex.h + /home/softcoder/Code/mojosetup/lua/src/llimits.h + /home/softcoder/Code/mojosetup/lua/src/lmem.h + /home/softcoder/Code/mojosetup/lua/src/lobject.h + /home/softcoder/Code/mojosetup/lua/src/lopcodes.h + /home/softcoder/Code/mojosetup/lua/src/lparser.h + /home/softcoder/Code/mojosetup/lua/src/lstate.h + /home/softcoder/Code/mojosetup/lua/src/ltable.h + /home/softcoder/Code/mojosetup/lua/src/ltm.h + /home/softcoder/Code/mojosetup/lua/src/lua.h + /home/softcoder/Code/mojosetup/lua/src/luaconf.h + /home/softcoder/Code/mojosetup/lua/src/lzio.h +CMakeFiles/mojoluac.dir/lua/src/ldblib.o + /home/softcoder/Code/mojosetup/lua/src/lauxlib.h + /home/softcoder/Code/mojosetup/lua/src/ldblib.c + /home/softcoder/Code/mojosetup/lua/src/lua.h + /home/softcoder/Code/mojosetup/lua/src/luaconf.h + /home/softcoder/Code/mojosetup/lua/src/lualib.h +CMakeFiles/mojoluac.dir/lua/src/ldebug.o + /home/softcoder/Code/mojosetup/lua/src/lapi.h + /home/softcoder/Code/mojosetup/lua/src/lcode.h + /home/softcoder/Code/mojosetup/lua/src/ldebug.c + /home/softcoder/Code/mojosetup/lua/src/ldebug.h + /home/softcoder/Code/mojosetup/lua/src/ldo.h + /home/softcoder/Code/mojosetup/lua/src/lfunc.h + /home/softcoder/Code/mojosetup/lua/src/lgc.h + /home/softcoder/Code/mojosetup/lua/src/llex.h + /home/softcoder/Code/mojosetup/lua/src/llimits.h + /home/softcoder/Code/mojosetup/lua/src/lmem.h + /home/softcoder/Code/mojosetup/lua/src/lobject.h + /home/softcoder/Code/mojosetup/lua/src/lopcodes.h + /home/softcoder/Code/mojosetup/lua/src/lparser.h + /home/softcoder/Code/mojosetup/lua/src/lstate.h + /home/softcoder/Code/mojosetup/lua/src/lstring.h + /home/softcoder/Code/mojosetup/lua/src/ltable.h + /home/softcoder/Code/mojosetup/lua/src/ltm.h + /home/softcoder/Code/mojosetup/lua/src/lua.h + /home/softcoder/Code/mojosetup/lua/src/luaconf.h + /home/softcoder/Code/mojosetup/lua/src/lvm.h + /home/softcoder/Code/mojosetup/lua/src/lzio.h +CMakeFiles/mojoluac.dir/lua/src/ldo.o + /home/softcoder/Code/mojosetup/lua/src/ldebug.h + /home/softcoder/Code/mojosetup/lua/src/ldo.c + /home/softcoder/Code/mojosetup/lua/src/ldo.h + /home/softcoder/Code/mojosetup/lua/src/lfunc.h + /home/softcoder/Code/mojosetup/lua/src/lgc.h + /home/softcoder/Code/mojosetup/lua/src/llimits.h + /home/softcoder/Code/mojosetup/lua/src/lmem.h + /home/softcoder/Code/mojosetup/lua/src/lobject.h + /home/softcoder/Code/mojosetup/lua/src/lopcodes.h + /home/softcoder/Code/mojosetup/lua/src/lparser.h + /home/softcoder/Code/mojosetup/lua/src/lstate.h + /home/softcoder/Code/mojosetup/lua/src/lstring.h + /home/softcoder/Code/mojosetup/lua/src/ltable.h + /home/softcoder/Code/mojosetup/lua/src/ltm.h + /home/softcoder/Code/mojosetup/lua/src/lua.h + /home/softcoder/Code/mojosetup/lua/src/luaconf.h + /home/softcoder/Code/mojosetup/lua/src/lundump.h + /home/softcoder/Code/mojosetup/lua/src/lvm.h + /home/softcoder/Code/mojosetup/lua/src/lzio.h +CMakeFiles/mojoluac.dir/lua/src/ldump.o + /home/softcoder/Code/mojosetup/lua/src/ldump.c + /home/softcoder/Code/mojosetup/lua/src/llimits.h + /home/softcoder/Code/mojosetup/lua/src/lmem.h + /home/softcoder/Code/mojosetup/lua/src/lobject.h + /home/softcoder/Code/mojosetup/lua/src/lstate.h + /home/softcoder/Code/mojosetup/lua/src/ltm.h + /home/softcoder/Code/mojosetup/lua/src/lua.h + /home/softcoder/Code/mojosetup/lua/src/luaconf.h + /home/softcoder/Code/mojosetup/lua/src/lundump.h + /home/softcoder/Code/mojosetup/lua/src/lzio.h +CMakeFiles/mojoluac.dir/lua/src/lfunc.o + /home/softcoder/Code/mojosetup/lua/src/lfunc.c + /home/softcoder/Code/mojosetup/lua/src/lfunc.h + /home/softcoder/Code/mojosetup/lua/src/lgc.h + /home/softcoder/Code/mojosetup/lua/src/llimits.h + /home/softcoder/Code/mojosetup/lua/src/lmem.h + /home/softcoder/Code/mojosetup/lua/src/lobject.h + /home/softcoder/Code/mojosetup/lua/src/lstate.h + /home/softcoder/Code/mojosetup/lua/src/ltm.h + /home/softcoder/Code/mojosetup/lua/src/lua.h + /home/softcoder/Code/mojosetup/lua/src/luaconf.h + /home/softcoder/Code/mojosetup/lua/src/lzio.h +CMakeFiles/mojoluac.dir/lua/src/lgc.o + /home/softcoder/Code/mojosetup/lua/src/ldebug.h + /home/softcoder/Code/mojosetup/lua/src/ldo.h + /home/softcoder/Code/mojosetup/lua/src/lfunc.h + /home/softcoder/Code/mojosetup/lua/src/lgc.c + /home/softcoder/Code/mojosetup/lua/src/lgc.h + /home/softcoder/Code/mojosetup/lua/src/llimits.h + /home/softcoder/Code/mojosetup/lua/src/lmem.h + /home/softcoder/Code/mojosetup/lua/src/lobject.h + /home/softcoder/Code/mojosetup/lua/src/lstate.h + /home/softcoder/Code/mojosetup/lua/src/lstring.h + /home/softcoder/Code/mojosetup/lua/src/ltable.h + /home/softcoder/Code/mojosetup/lua/src/ltm.h + /home/softcoder/Code/mojosetup/lua/src/lua.h + /home/softcoder/Code/mojosetup/lua/src/luaconf.h + /home/softcoder/Code/mojosetup/lua/src/lzio.h +CMakeFiles/mojoluac.dir/lua/src/linit.o + /home/softcoder/Code/mojosetup/lua/src/lauxlib.h + /home/softcoder/Code/mojosetup/lua/src/linit.c + /home/softcoder/Code/mojosetup/lua/src/lua.h + /home/softcoder/Code/mojosetup/lua/src/luaconf.h + /home/softcoder/Code/mojosetup/lua/src/lualib.h +CMakeFiles/mojoluac.dir/lua/src/liolib.o + /home/softcoder/Code/mojosetup/lua/src/lauxlib.h + /home/softcoder/Code/mojosetup/lua/src/liolib.c + /home/softcoder/Code/mojosetup/lua/src/lua.h + /home/softcoder/Code/mojosetup/lua/src/luaconf.h + /home/softcoder/Code/mojosetup/lua/src/lualib.h +CMakeFiles/mojoluac.dir/lua/src/llex.o + /home/softcoder/Code/mojosetup/lua/src/ldo.h + /home/softcoder/Code/mojosetup/lua/src/lgc.h + /home/softcoder/Code/mojosetup/lua/src/llex.c + /home/softcoder/Code/mojosetup/lua/src/llex.h + /home/softcoder/Code/mojosetup/lua/src/llimits.h + /home/softcoder/Code/mojosetup/lua/src/lmem.h + /home/softcoder/Code/mojosetup/lua/src/lobject.h + /home/softcoder/Code/mojosetup/lua/src/lparser.h + /home/softcoder/Code/mojosetup/lua/src/lstate.h + /home/softcoder/Code/mojosetup/lua/src/lstring.h + /home/softcoder/Code/mojosetup/lua/src/ltable.h + /home/softcoder/Code/mojosetup/lua/src/ltm.h + /home/softcoder/Code/mojosetup/lua/src/lua.h + /home/softcoder/Code/mojosetup/lua/src/luaconf.h + /home/softcoder/Code/mojosetup/lua/src/lzio.h +CMakeFiles/mojoluac.dir/lua/src/lmathlib.o + /home/softcoder/Code/mojosetup/lua/src/lauxlib.h + /home/softcoder/Code/mojosetup/lua/src/lmathlib.c + /home/softcoder/Code/mojosetup/lua/src/lua.h + /home/softcoder/Code/mojosetup/lua/src/luaconf.h + /home/softcoder/Code/mojosetup/lua/src/lualib.h +CMakeFiles/mojoluac.dir/lua/src/lmem.o + /home/softcoder/Code/mojosetup/lua/src/ldebug.h + /home/softcoder/Code/mojosetup/lua/src/ldo.h + /home/softcoder/Code/mojosetup/lua/src/llimits.h + /home/softcoder/Code/mojosetup/lua/src/lmem.c + /home/softcoder/Code/mojosetup/lua/src/lmem.h + /home/softcoder/Code/mojosetup/lua/src/lobject.h + /home/softcoder/Code/mojosetup/lua/src/lstate.h + /home/softcoder/Code/mojosetup/lua/src/ltm.h + /home/softcoder/Code/mojosetup/lua/src/lua.h + /home/softcoder/Code/mojosetup/lua/src/luaconf.h + /home/softcoder/Code/mojosetup/lua/src/lzio.h +CMakeFiles/mojoluac.dir/lua/src/loadlib.o + /home/softcoder/Code/mojosetup/lua/src/lauxlib.h + /home/softcoder/Code/mojosetup/lua/src/loadlib.c + /home/softcoder/Code/mojosetup/lua/src/lua.h + /home/softcoder/Code/mojosetup/lua/src/luaconf.h + /home/softcoder/Code/mojosetup/lua/src/lualib.h +CMakeFiles/mojoluac.dir/lua/src/lobject.o + /home/softcoder/Code/mojosetup/lua/src/ldo.h + /home/softcoder/Code/mojosetup/lua/src/lgc.h + /home/softcoder/Code/mojosetup/lua/src/llimits.h + /home/softcoder/Code/mojosetup/lua/src/lmem.h + /home/softcoder/Code/mojosetup/lua/src/lobject.c + /home/softcoder/Code/mojosetup/lua/src/lobject.h + /home/softcoder/Code/mojosetup/lua/src/lstate.h + /home/softcoder/Code/mojosetup/lua/src/lstring.h + /home/softcoder/Code/mojosetup/lua/src/ltm.h + /home/softcoder/Code/mojosetup/lua/src/lua.h + /home/softcoder/Code/mojosetup/lua/src/luaconf.h + /home/softcoder/Code/mojosetup/lua/src/lvm.h + /home/softcoder/Code/mojosetup/lua/src/lzio.h +CMakeFiles/mojoluac.dir/lua/src/lopcodes.o + /home/softcoder/Code/mojosetup/lua/src/llimits.h + /home/softcoder/Code/mojosetup/lua/src/lopcodes.c + /home/softcoder/Code/mojosetup/lua/src/lopcodes.h + /home/softcoder/Code/mojosetup/lua/src/lua.h + /home/softcoder/Code/mojosetup/lua/src/luaconf.h +CMakeFiles/mojoluac.dir/lua/src/loslib.o + /home/softcoder/Code/mojosetup/lua/src/lauxlib.h + /home/softcoder/Code/mojosetup/lua/src/loslib.c + /home/softcoder/Code/mojosetup/lua/src/lua.h + /home/softcoder/Code/mojosetup/lua/src/luaconf.h + /home/softcoder/Code/mojosetup/lua/src/lualib.h +CMakeFiles/mojoluac.dir/lua/src/lparser.o + /home/softcoder/Code/mojosetup/lua/src/lcode.h + /home/softcoder/Code/mojosetup/lua/src/ldebug.h + /home/softcoder/Code/mojosetup/lua/src/ldo.h + /home/softcoder/Code/mojosetup/lua/src/lfunc.h + /home/softcoder/Code/mojosetup/lua/src/lgc.h + /home/softcoder/Code/mojosetup/lua/src/llex.h + /home/softcoder/Code/mojosetup/lua/src/llimits.h + /home/softcoder/Code/mojosetup/lua/src/lmem.h + /home/softcoder/Code/mojosetup/lua/src/lobject.h + /home/softcoder/Code/mojosetup/lua/src/lopcodes.h + /home/softcoder/Code/mojosetup/lua/src/lparser.c + /home/softcoder/Code/mojosetup/lua/src/lparser.h + /home/softcoder/Code/mojosetup/lua/src/lstate.h + /home/softcoder/Code/mojosetup/lua/src/lstring.h + /home/softcoder/Code/mojosetup/lua/src/ltable.h + /home/softcoder/Code/mojosetup/lua/src/ltm.h + /home/softcoder/Code/mojosetup/lua/src/lua.h + /home/softcoder/Code/mojosetup/lua/src/luaconf.h + /home/softcoder/Code/mojosetup/lua/src/lzio.h +CMakeFiles/mojoluac.dir/lua/src/lstate.o + /home/softcoder/Code/mojosetup/lua/src/ldebug.h + /home/softcoder/Code/mojosetup/lua/src/ldo.h + /home/softcoder/Code/mojosetup/lua/src/lfunc.h + /home/softcoder/Code/mojosetup/lua/src/lgc.h + /home/softcoder/Code/mojosetup/lua/src/llex.h + /home/softcoder/Code/mojosetup/lua/src/llimits.h + /home/softcoder/Code/mojosetup/lua/src/lmem.h + /home/softcoder/Code/mojosetup/lua/src/lobject.h + /home/softcoder/Code/mojosetup/lua/src/lstate.c + /home/softcoder/Code/mojosetup/lua/src/lstate.h + /home/softcoder/Code/mojosetup/lua/src/lstring.h + /home/softcoder/Code/mojosetup/lua/src/ltable.h + /home/softcoder/Code/mojosetup/lua/src/ltm.h + /home/softcoder/Code/mojosetup/lua/src/lua.h + /home/softcoder/Code/mojosetup/lua/src/luaconf.h + /home/softcoder/Code/mojosetup/lua/src/lzio.h +CMakeFiles/mojoluac.dir/lua/src/lstring.o + /home/softcoder/Code/mojosetup/lua/src/lgc.h + /home/softcoder/Code/mojosetup/lua/src/llimits.h + /home/softcoder/Code/mojosetup/lua/src/lmem.h + /home/softcoder/Code/mojosetup/lua/src/lobject.h + /home/softcoder/Code/mojosetup/lua/src/lstate.h + /home/softcoder/Code/mojosetup/lua/src/lstring.c + /home/softcoder/Code/mojosetup/lua/src/lstring.h + /home/softcoder/Code/mojosetup/lua/src/ltm.h + /home/softcoder/Code/mojosetup/lua/src/lua.h + /home/softcoder/Code/mojosetup/lua/src/luaconf.h + /home/softcoder/Code/mojosetup/lua/src/lzio.h +CMakeFiles/mojoluac.dir/lua/src/lstrlib.o + /home/softcoder/Code/mojosetup/lua/src/lauxlib.h + /home/softcoder/Code/mojosetup/lua/src/lstrlib.c + /home/softcoder/Code/mojosetup/lua/src/lua.h + /home/softcoder/Code/mojosetup/lua/src/luaconf.h + /home/softcoder/Code/mojosetup/lua/src/lualib.h +CMakeFiles/mojoluac.dir/lua/src/ltable.o + /home/softcoder/Code/mojosetup/lua/src/ldebug.h + /home/softcoder/Code/mojosetup/lua/src/ldo.h + /home/softcoder/Code/mojosetup/lua/src/lgc.h + /home/softcoder/Code/mojosetup/lua/src/llimits.h + /home/softcoder/Code/mojosetup/lua/src/lmem.h + /home/softcoder/Code/mojosetup/lua/src/lobject.h + /home/softcoder/Code/mojosetup/lua/src/lstate.h + /home/softcoder/Code/mojosetup/lua/src/ltable.c + /home/softcoder/Code/mojosetup/lua/src/ltable.h + /home/softcoder/Code/mojosetup/lua/src/ltm.h + /home/softcoder/Code/mojosetup/lua/src/lua.h + /home/softcoder/Code/mojosetup/lua/src/luaconf.h + /home/softcoder/Code/mojosetup/lua/src/lzio.h +CMakeFiles/mojoluac.dir/lua/src/ltablib.o + /home/softcoder/Code/mojosetup/lua/src/lauxlib.h + /home/softcoder/Code/mojosetup/lua/src/ltablib.c + /home/softcoder/Code/mojosetup/lua/src/lua.h + /home/softcoder/Code/mojosetup/lua/src/luaconf.h + /home/softcoder/Code/mojosetup/lua/src/lualib.h +CMakeFiles/mojoluac.dir/lua/src/ltm.o + /home/softcoder/Code/mojosetup/lua/src/lgc.h + /home/softcoder/Code/mojosetup/lua/src/llimits.h + /home/softcoder/Code/mojosetup/lua/src/lmem.h + /home/softcoder/Code/mojosetup/lua/src/lobject.h + /home/softcoder/Code/mojosetup/lua/src/lstate.h + /home/softcoder/Code/mojosetup/lua/src/lstring.h + /home/softcoder/Code/mojosetup/lua/src/ltable.h + /home/softcoder/Code/mojosetup/lua/src/ltm.c + /home/softcoder/Code/mojosetup/lua/src/ltm.h + /home/softcoder/Code/mojosetup/lua/src/lua.h + /home/softcoder/Code/mojosetup/lua/src/luaconf.h + /home/softcoder/Code/mojosetup/lua/src/lzio.h +CMakeFiles/mojoluac.dir/lua/src/luac.o + /home/softcoder/Code/mojosetup/lua/src/lauxlib.h + /home/softcoder/Code/mojosetup/lua/src/ldo.h + /home/softcoder/Code/mojosetup/lua/src/lfunc.h + /home/softcoder/Code/mojosetup/lua/src/lgc.h + /home/softcoder/Code/mojosetup/lua/src/llimits.h + /home/softcoder/Code/mojosetup/lua/src/lmem.h + /home/softcoder/Code/mojosetup/lua/src/lobject.h + /home/softcoder/Code/mojosetup/lua/src/lopcodes.h + /home/softcoder/Code/mojosetup/lua/src/lstate.h + /home/softcoder/Code/mojosetup/lua/src/lstring.h + /home/softcoder/Code/mojosetup/lua/src/ltm.h + /home/softcoder/Code/mojosetup/lua/src/lua.h + /home/softcoder/Code/mojosetup/lua/src/luac.c + /home/softcoder/Code/mojosetup/lua/src/luaconf.h + /home/softcoder/Code/mojosetup/lua/src/lundump.h + /home/softcoder/Code/mojosetup/lua/src/lzio.h +CMakeFiles/mojoluac.dir/lua/src/lundump.o + /home/softcoder/Code/mojosetup/lua/src/ldebug.h + /home/softcoder/Code/mojosetup/lua/src/ldo.h + /home/softcoder/Code/mojosetup/lua/src/lfunc.h + /home/softcoder/Code/mojosetup/lua/src/lgc.h + /home/softcoder/Code/mojosetup/lua/src/llimits.h + /home/softcoder/Code/mojosetup/lua/src/lmem.h + /home/softcoder/Code/mojosetup/lua/src/lobject.h + /home/softcoder/Code/mojosetup/lua/src/lstate.h + /home/softcoder/Code/mojosetup/lua/src/lstring.h + /home/softcoder/Code/mojosetup/lua/src/ltm.h + /home/softcoder/Code/mojosetup/lua/src/lua.h + /home/softcoder/Code/mojosetup/lua/src/luaconf.h + /home/softcoder/Code/mojosetup/lua/src/lundump.c + /home/softcoder/Code/mojosetup/lua/src/lundump.h + /home/softcoder/Code/mojosetup/lua/src/lzio.h +CMakeFiles/mojoluac.dir/lua/src/lvm.o + /home/softcoder/Code/mojosetup/lua/src/ldebug.h + /home/softcoder/Code/mojosetup/lua/src/ldo.h + /home/softcoder/Code/mojosetup/lua/src/lfunc.h + /home/softcoder/Code/mojosetup/lua/src/lgc.h + /home/softcoder/Code/mojosetup/lua/src/llimits.h + /home/softcoder/Code/mojosetup/lua/src/lmem.h + /home/softcoder/Code/mojosetup/lua/src/lobject.h + /home/softcoder/Code/mojosetup/lua/src/lopcodes.h + /home/softcoder/Code/mojosetup/lua/src/lstate.h + /home/softcoder/Code/mojosetup/lua/src/lstring.h + /home/softcoder/Code/mojosetup/lua/src/ltable.h + /home/softcoder/Code/mojosetup/lua/src/ltm.h + /home/softcoder/Code/mojosetup/lua/src/lua.h + /home/softcoder/Code/mojosetup/lua/src/luaconf.h + /home/softcoder/Code/mojosetup/lua/src/lvm.c + /home/softcoder/Code/mojosetup/lua/src/lvm.h + /home/softcoder/Code/mojosetup/lua/src/lzio.h +CMakeFiles/mojoluac.dir/lua/src/lzio.o + /home/softcoder/Code/mojosetup/lua/src/llimits.h + /home/softcoder/Code/mojosetup/lua/src/lmem.h + /home/softcoder/Code/mojosetup/lua/src/lobject.h + /home/softcoder/Code/mojosetup/lua/src/lstate.h + /home/softcoder/Code/mojosetup/lua/src/ltm.h + /home/softcoder/Code/mojosetup/lua/src/lua.h + /home/softcoder/Code/mojosetup/lua/src/luaconf.h + /home/softcoder/Code/mojosetup/lua/src/lzio.c + /home/softcoder/Code/mojosetup/lua/src/lzio.h +CMakeFiles/mojoluac.dir/lua/src/print.o + /home/softcoder/Code/mojosetup/lua/src/ldebug.h + /home/softcoder/Code/mojosetup/lua/src/llimits.h + /home/softcoder/Code/mojosetup/lua/src/lmem.h + /home/softcoder/Code/mojosetup/lua/src/lobject.h + /home/softcoder/Code/mojosetup/lua/src/lopcodes.h + /home/softcoder/Code/mojosetup/lua/src/lstate.h + /home/softcoder/Code/mojosetup/lua/src/ltm.h + /home/softcoder/Code/mojosetup/lua/src/lua.h + /home/softcoder/Code/mojosetup/lua/src/luaconf.h + /home/softcoder/Code/mojosetup/lua/src/lundump.h + /home/softcoder/Code/mojosetup/lua/src/lzio.h + /home/softcoder/Code/mojosetup/lua/src/print.c diff --git a/mk/linux/mojosetup/build/CMakeFiles/mojoluac.dir/depend.make b/mk/linux/mojosetup/build/CMakeFiles/mojoluac.dir/depend.make new file mode 100644 index 00000000..7f6468f9 --- /dev/null +++ b/mk/linux/mojosetup/build/CMakeFiles/mojoluac.dir/depend.make @@ -0,0 +1,378 @@ +# CMAKE generated file: DO NOT EDIT! +# Generated by "Unix Makefiles" Generator, CMake Version 2.8 + +CMakeFiles/mojoluac.dir/lua/src/lapi.o: ../lua/src/lapi.c +CMakeFiles/mojoluac.dir/lua/src/lapi.o: ../lua/src/lapi.h +CMakeFiles/mojoluac.dir/lua/src/lapi.o: ../lua/src/ldebug.h +CMakeFiles/mojoluac.dir/lua/src/lapi.o: ../lua/src/ldo.h +CMakeFiles/mojoluac.dir/lua/src/lapi.o: ../lua/src/lfunc.h +CMakeFiles/mojoluac.dir/lua/src/lapi.o: ../lua/src/lgc.h +CMakeFiles/mojoluac.dir/lua/src/lapi.o: ../lua/src/llimits.h +CMakeFiles/mojoluac.dir/lua/src/lapi.o: ../lua/src/lmem.h +CMakeFiles/mojoluac.dir/lua/src/lapi.o: ../lua/src/lobject.h +CMakeFiles/mojoluac.dir/lua/src/lapi.o: ../lua/src/lstate.h +CMakeFiles/mojoluac.dir/lua/src/lapi.o: ../lua/src/lstring.h +CMakeFiles/mojoluac.dir/lua/src/lapi.o: ../lua/src/ltable.h +CMakeFiles/mojoluac.dir/lua/src/lapi.o: ../lua/src/ltm.h +CMakeFiles/mojoluac.dir/lua/src/lapi.o: ../lua/src/lua.h +CMakeFiles/mojoluac.dir/lua/src/lapi.o: ../lua/src/luaconf.h +CMakeFiles/mojoluac.dir/lua/src/lapi.o: ../lua/src/lundump.h +CMakeFiles/mojoluac.dir/lua/src/lapi.o: ../lua/src/lvm.h +CMakeFiles/mojoluac.dir/lua/src/lapi.o: ../lua/src/lzio.h + +CMakeFiles/mojoluac.dir/lua/src/lauxlib.o: ../lua/src/lauxlib.c +CMakeFiles/mojoluac.dir/lua/src/lauxlib.o: ../lua/src/lauxlib.h +CMakeFiles/mojoluac.dir/lua/src/lauxlib.o: ../lua/src/lua.h +CMakeFiles/mojoluac.dir/lua/src/lauxlib.o: ../lua/src/luaconf.h + +CMakeFiles/mojoluac.dir/lua/src/lbaselib.o: ../lua/src/lauxlib.h +CMakeFiles/mojoluac.dir/lua/src/lbaselib.o: ../lua/src/lbaselib.c +CMakeFiles/mojoluac.dir/lua/src/lbaselib.o: ../lua/src/lua.h +CMakeFiles/mojoluac.dir/lua/src/lbaselib.o: ../lua/src/luaconf.h +CMakeFiles/mojoluac.dir/lua/src/lbaselib.o: ../lua/src/lualib.h + +CMakeFiles/mojoluac.dir/lua/src/lcode.o: ../lua/src/lcode.c +CMakeFiles/mojoluac.dir/lua/src/lcode.o: ../lua/src/lcode.h +CMakeFiles/mojoluac.dir/lua/src/lcode.o: ../lua/src/ldebug.h +CMakeFiles/mojoluac.dir/lua/src/lcode.o: ../lua/src/ldo.h +CMakeFiles/mojoluac.dir/lua/src/lcode.o: ../lua/src/lgc.h +CMakeFiles/mojoluac.dir/lua/src/lcode.o: ../lua/src/llex.h +CMakeFiles/mojoluac.dir/lua/src/lcode.o: ../lua/src/llimits.h +CMakeFiles/mojoluac.dir/lua/src/lcode.o: ../lua/src/lmem.h +CMakeFiles/mojoluac.dir/lua/src/lcode.o: ../lua/src/lobject.h +CMakeFiles/mojoluac.dir/lua/src/lcode.o: ../lua/src/lopcodes.h +CMakeFiles/mojoluac.dir/lua/src/lcode.o: ../lua/src/lparser.h +CMakeFiles/mojoluac.dir/lua/src/lcode.o: ../lua/src/lstate.h +CMakeFiles/mojoluac.dir/lua/src/lcode.o: ../lua/src/ltable.h +CMakeFiles/mojoluac.dir/lua/src/lcode.o: ../lua/src/ltm.h +CMakeFiles/mojoluac.dir/lua/src/lcode.o: ../lua/src/lua.h +CMakeFiles/mojoluac.dir/lua/src/lcode.o: ../lua/src/luaconf.h +CMakeFiles/mojoluac.dir/lua/src/lcode.o: ../lua/src/lzio.h + +CMakeFiles/mojoluac.dir/lua/src/ldblib.o: ../lua/src/lauxlib.h +CMakeFiles/mojoluac.dir/lua/src/ldblib.o: ../lua/src/ldblib.c +CMakeFiles/mojoluac.dir/lua/src/ldblib.o: ../lua/src/lua.h +CMakeFiles/mojoluac.dir/lua/src/ldblib.o: ../lua/src/luaconf.h +CMakeFiles/mojoluac.dir/lua/src/ldblib.o: ../lua/src/lualib.h + +CMakeFiles/mojoluac.dir/lua/src/ldebug.o: ../lua/src/lapi.h +CMakeFiles/mojoluac.dir/lua/src/ldebug.o: ../lua/src/lcode.h +CMakeFiles/mojoluac.dir/lua/src/ldebug.o: ../lua/src/ldebug.c +CMakeFiles/mojoluac.dir/lua/src/ldebug.o: ../lua/src/ldebug.h +CMakeFiles/mojoluac.dir/lua/src/ldebug.o: ../lua/src/ldo.h +CMakeFiles/mojoluac.dir/lua/src/ldebug.o: ../lua/src/lfunc.h +CMakeFiles/mojoluac.dir/lua/src/ldebug.o: ../lua/src/lgc.h +CMakeFiles/mojoluac.dir/lua/src/ldebug.o: ../lua/src/llex.h +CMakeFiles/mojoluac.dir/lua/src/ldebug.o: ../lua/src/llimits.h +CMakeFiles/mojoluac.dir/lua/src/ldebug.o: ../lua/src/lmem.h +CMakeFiles/mojoluac.dir/lua/src/ldebug.o: ../lua/src/lobject.h +CMakeFiles/mojoluac.dir/lua/src/ldebug.o: ../lua/src/lopcodes.h +CMakeFiles/mojoluac.dir/lua/src/ldebug.o: ../lua/src/lparser.h +CMakeFiles/mojoluac.dir/lua/src/ldebug.o: ../lua/src/lstate.h +CMakeFiles/mojoluac.dir/lua/src/ldebug.o: ../lua/src/lstring.h +CMakeFiles/mojoluac.dir/lua/src/ldebug.o: ../lua/src/ltable.h +CMakeFiles/mojoluac.dir/lua/src/ldebug.o: ../lua/src/ltm.h +CMakeFiles/mojoluac.dir/lua/src/ldebug.o: ../lua/src/lua.h +CMakeFiles/mojoluac.dir/lua/src/ldebug.o: ../lua/src/luaconf.h +CMakeFiles/mojoluac.dir/lua/src/ldebug.o: ../lua/src/lvm.h +CMakeFiles/mojoluac.dir/lua/src/ldebug.o: ../lua/src/lzio.h + +CMakeFiles/mojoluac.dir/lua/src/ldo.o: ../lua/src/ldebug.h +CMakeFiles/mojoluac.dir/lua/src/ldo.o: ../lua/src/ldo.c +CMakeFiles/mojoluac.dir/lua/src/ldo.o: ../lua/src/ldo.h +CMakeFiles/mojoluac.dir/lua/src/ldo.o: ../lua/src/lfunc.h +CMakeFiles/mojoluac.dir/lua/src/ldo.o: ../lua/src/lgc.h +CMakeFiles/mojoluac.dir/lua/src/ldo.o: ../lua/src/llimits.h +CMakeFiles/mojoluac.dir/lua/src/ldo.o: ../lua/src/lmem.h +CMakeFiles/mojoluac.dir/lua/src/ldo.o: ../lua/src/lobject.h +CMakeFiles/mojoluac.dir/lua/src/ldo.o: ../lua/src/lopcodes.h +CMakeFiles/mojoluac.dir/lua/src/ldo.o: ../lua/src/lparser.h +CMakeFiles/mojoluac.dir/lua/src/ldo.o: ../lua/src/lstate.h +CMakeFiles/mojoluac.dir/lua/src/ldo.o: ../lua/src/lstring.h +CMakeFiles/mojoluac.dir/lua/src/ldo.o: ../lua/src/ltable.h +CMakeFiles/mojoluac.dir/lua/src/ldo.o: ../lua/src/ltm.h +CMakeFiles/mojoluac.dir/lua/src/ldo.o: ../lua/src/lua.h +CMakeFiles/mojoluac.dir/lua/src/ldo.o: ../lua/src/luaconf.h +CMakeFiles/mojoluac.dir/lua/src/ldo.o: ../lua/src/lundump.h +CMakeFiles/mojoluac.dir/lua/src/ldo.o: ../lua/src/lvm.h +CMakeFiles/mojoluac.dir/lua/src/ldo.o: ../lua/src/lzio.h + +CMakeFiles/mojoluac.dir/lua/src/ldump.o: ../lua/src/ldump.c +CMakeFiles/mojoluac.dir/lua/src/ldump.o: ../lua/src/llimits.h +CMakeFiles/mojoluac.dir/lua/src/ldump.o: ../lua/src/lmem.h +CMakeFiles/mojoluac.dir/lua/src/ldump.o: ../lua/src/lobject.h +CMakeFiles/mojoluac.dir/lua/src/ldump.o: ../lua/src/lstate.h +CMakeFiles/mojoluac.dir/lua/src/ldump.o: ../lua/src/ltm.h +CMakeFiles/mojoluac.dir/lua/src/ldump.o: ../lua/src/lua.h +CMakeFiles/mojoluac.dir/lua/src/ldump.o: ../lua/src/luaconf.h +CMakeFiles/mojoluac.dir/lua/src/ldump.o: ../lua/src/lundump.h +CMakeFiles/mojoluac.dir/lua/src/ldump.o: ../lua/src/lzio.h + +CMakeFiles/mojoluac.dir/lua/src/lfunc.o: ../lua/src/lfunc.c +CMakeFiles/mojoluac.dir/lua/src/lfunc.o: ../lua/src/lfunc.h +CMakeFiles/mojoluac.dir/lua/src/lfunc.o: ../lua/src/lgc.h +CMakeFiles/mojoluac.dir/lua/src/lfunc.o: ../lua/src/llimits.h +CMakeFiles/mojoluac.dir/lua/src/lfunc.o: ../lua/src/lmem.h +CMakeFiles/mojoluac.dir/lua/src/lfunc.o: ../lua/src/lobject.h +CMakeFiles/mojoluac.dir/lua/src/lfunc.o: ../lua/src/lstate.h +CMakeFiles/mojoluac.dir/lua/src/lfunc.o: ../lua/src/ltm.h +CMakeFiles/mojoluac.dir/lua/src/lfunc.o: ../lua/src/lua.h +CMakeFiles/mojoluac.dir/lua/src/lfunc.o: ../lua/src/luaconf.h +CMakeFiles/mojoluac.dir/lua/src/lfunc.o: ../lua/src/lzio.h + +CMakeFiles/mojoluac.dir/lua/src/lgc.o: ../lua/src/ldebug.h +CMakeFiles/mojoluac.dir/lua/src/lgc.o: ../lua/src/ldo.h +CMakeFiles/mojoluac.dir/lua/src/lgc.o: ../lua/src/lfunc.h +CMakeFiles/mojoluac.dir/lua/src/lgc.o: ../lua/src/lgc.c +CMakeFiles/mojoluac.dir/lua/src/lgc.o: ../lua/src/lgc.h +CMakeFiles/mojoluac.dir/lua/src/lgc.o: ../lua/src/llimits.h +CMakeFiles/mojoluac.dir/lua/src/lgc.o: ../lua/src/lmem.h +CMakeFiles/mojoluac.dir/lua/src/lgc.o: ../lua/src/lobject.h +CMakeFiles/mojoluac.dir/lua/src/lgc.o: ../lua/src/lstate.h +CMakeFiles/mojoluac.dir/lua/src/lgc.o: ../lua/src/lstring.h +CMakeFiles/mojoluac.dir/lua/src/lgc.o: ../lua/src/ltable.h +CMakeFiles/mojoluac.dir/lua/src/lgc.o: ../lua/src/ltm.h +CMakeFiles/mojoluac.dir/lua/src/lgc.o: ../lua/src/lua.h +CMakeFiles/mojoluac.dir/lua/src/lgc.o: ../lua/src/luaconf.h +CMakeFiles/mojoluac.dir/lua/src/lgc.o: ../lua/src/lzio.h + +CMakeFiles/mojoluac.dir/lua/src/linit.o: ../lua/src/lauxlib.h +CMakeFiles/mojoluac.dir/lua/src/linit.o: ../lua/src/linit.c +CMakeFiles/mojoluac.dir/lua/src/linit.o: ../lua/src/lua.h +CMakeFiles/mojoluac.dir/lua/src/linit.o: ../lua/src/luaconf.h +CMakeFiles/mojoluac.dir/lua/src/linit.o: ../lua/src/lualib.h + +CMakeFiles/mojoluac.dir/lua/src/liolib.o: ../lua/src/lauxlib.h +CMakeFiles/mojoluac.dir/lua/src/liolib.o: ../lua/src/liolib.c +CMakeFiles/mojoluac.dir/lua/src/liolib.o: ../lua/src/lua.h +CMakeFiles/mojoluac.dir/lua/src/liolib.o: ../lua/src/luaconf.h +CMakeFiles/mojoluac.dir/lua/src/liolib.o: ../lua/src/lualib.h + +CMakeFiles/mojoluac.dir/lua/src/llex.o: ../lua/src/ldo.h +CMakeFiles/mojoluac.dir/lua/src/llex.o: ../lua/src/lgc.h +CMakeFiles/mojoluac.dir/lua/src/llex.o: ../lua/src/llex.c +CMakeFiles/mojoluac.dir/lua/src/llex.o: ../lua/src/llex.h +CMakeFiles/mojoluac.dir/lua/src/llex.o: ../lua/src/llimits.h +CMakeFiles/mojoluac.dir/lua/src/llex.o: ../lua/src/lmem.h +CMakeFiles/mojoluac.dir/lua/src/llex.o: ../lua/src/lobject.h +CMakeFiles/mojoluac.dir/lua/src/llex.o: ../lua/src/lparser.h +CMakeFiles/mojoluac.dir/lua/src/llex.o: ../lua/src/lstate.h +CMakeFiles/mojoluac.dir/lua/src/llex.o: ../lua/src/lstring.h +CMakeFiles/mojoluac.dir/lua/src/llex.o: ../lua/src/ltable.h +CMakeFiles/mojoluac.dir/lua/src/llex.o: ../lua/src/ltm.h +CMakeFiles/mojoluac.dir/lua/src/llex.o: ../lua/src/lua.h +CMakeFiles/mojoluac.dir/lua/src/llex.o: ../lua/src/luaconf.h +CMakeFiles/mojoluac.dir/lua/src/llex.o: ../lua/src/lzio.h + +CMakeFiles/mojoluac.dir/lua/src/lmathlib.o: ../lua/src/lauxlib.h +CMakeFiles/mojoluac.dir/lua/src/lmathlib.o: ../lua/src/lmathlib.c +CMakeFiles/mojoluac.dir/lua/src/lmathlib.o: ../lua/src/lua.h +CMakeFiles/mojoluac.dir/lua/src/lmathlib.o: ../lua/src/luaconf.h +CMakeFiles/mojoluac.dir/lua/src/lmathlib.o: ../lua/src/lualib.h + +CMakeFiles/mojoluac.dir/lua/src/lmem.o: ../lua/src/ldebug.h +CMakeFiles/mojoluac.dir/lua/src/lmem.o: ../lua/src/ldo.h +CMakeFiles/mojoluac.dir/lua/src/lmem.o: ../lua/src/llimits.h +CMakeFiles/mojoluac.dir/lua/src/lmem.o: ../lua/src/lmem.c +CMakeFiles/mojoluac.dir/lua/src/lmem.o: ../lua/src/lmem.h +CMakeFiles/mojoluac.dir/lua/src/lmem.o: ../lua/src/lobject.h +CMakeFiles/mojoluac.dir/lua/src/lmem.o: ../lua/src/lstate.h +CMakeFiles/mojoluac.dir/lua/src/lmem.o: ../lua/src/ltm.h +CMakeFiles/mojoluac.dir/lua/src/lmem.o: ../lua/src/lua.h +CMakeFiles/mojoluac.dir/lua/src/lmem.o: ../lua/src/luaconf.h +CMakeFiles/mojoluac.dir/lua/src/lmem.o: ../lua/src/lzio.h + +CMakeFiles/mojoluac.dir/lua/src/loadlib.o: ../lua/src/lauxlib.h +CMakeFiles/mojoluac.dir/lua/src/loadlib.o: ../lua/src/loadlib.c +CMakeFiles/mojoluac.dir/lua/src/loadlib.o: ../lua/src/lua.h +CMakeFiles/mojoluac.dir/lua/src/loadlib.o: ../lua/src/luaconf.h +CMakeFiles/mojoluac.dir/lua/src/loadlib.o: ../lua/src/lualib.h + +CMakeFiles/mojoluac.dir/lua/src/lobject.o: ../lua/src/ldo.h +CMakeFiles/mojoluac.dir/lua/src/lobject.o: ../lua/src/lgc.h +CMakeFiles/mojoluac.dir/lua/src/lobject.o: ../lua/src/llimits.h +CMakeFiles/mojoluac.dir/lua/src/lobject.o: ../lua/src/lmem.h +CMakeFiles/mojoluac.dir/lua/src/lobject.o: ../lua/src/lobject.c +CMakeFiles/mojoluac.dir/lua/src/lobject.o: ../lua/src/lobject.h +CMakeFiles/mojoluac.dir/lua/src/lobject.o: ../lua/src/lstate.h +CMakeFiles/mojoluac.dir/lua/src/lobject.o: ../lua/src/lstring.h +CMakeFiles/mojoluac.dir/lua/src/lobject.o: ../lua/src/ltm.h +CMakeFiles/mojoluac.dir/lua/src/lobject.o: ../lua/src/lua.h +CMakeFiles/mojoluac.dir/lua/src/lobject.o: ../lua/src/luaconf.h +CMakeFiles/mojoluac.dir/lua/src/lobject.o: ../lua/src/lvm.h +CMakeFiles/mojoluac.dir/lua/src/lobject.o: ../lua/src/lzio.h + +CMakeFiles/mojoluac.dir/lua/src/lopcodes.o: ../lua/src/llimits.h +CMakeFiles/mojoluac.dir/lua/src/lopcodes.o: ../lua/src/lopcodes.c +CMakeFiles/mojoluac.dir/lua/src/lopcodes.o: ../lua/src/lopcodes.h +CMakeFiles/mojoluac.dir/lua/src/lopcodes.o: ../lua/src/lua.h +CMakeFiles/mojoluac.dir/lua/src/lopcodes.o: ../lua/src/luaconf.h + +CMakeFiles/mojoluac.dir/lua/src/loslib.o: ../lua/src/lauxlib.h +CMakeFiles/mojoluac.dir/lua/src/loslib.o: ../lua/src/loslib.c +CMakeFiles/mojoluac.dir/lua/src/loslib.o: ../lua/src/lua.h +CMakeFiles/mojoluac.dir/lua/src/loslib.o: ../lua/src/luaconf.h +CMakeFiles/mojoluac.dir/lua/src/loslib.o: ../lua/src/lualib.h + +CMakeFiles/mojoluac.dir/lua/src/lparser.o: ../lua/src/lcode.h +CMakeFiles/mojoluac.dir/lua/src/lparser.o: ../lua/src/ldebug.h +CMakeFiles/mojoluac.dir/lua/src/lparser.o: ../lua/src/ldo.h +CMakeFiles/mojoluac.dir/lua/src/lparser.o: ../lua/src/lfunc.h +CMakeFiles/mojoluac.dir/lua/src/lparser.o: ../lua/src/lgc.h +CMakeFiles/mojoluac.dir/lua/src/lparser.o: ../lua/src/llex.h +CMakeFiles/mojoluac.dir/lua/src/lparser.o: ../lua/src/llimits.h +CMakeFiles/mojoluac.dir/lua/src/lparser.o: ../lua/src/lmem.h +CMakeFiles/mojoluac.dir/lua/src/lparser.o: ../lua/src/lobject.h +CMakeFiles/mojoluac.dir/lua/src/lparser.o: ../lua/src/lopcodes.h +CMakeFiles/mojoluac.dir/lua/src/lparser.o: ../lua/src/lparser.c +CMakeFiles/mojoluac.dir/lua/src/lparser.o: ../lua/src/lparser.h +CMakeFiles/mojoluac.dir/lua/src/lparser.o: ../lua/src/lstate.h +CMakeFiles/mojoluac.dir/lua/src/lparser.o: ../lua/src/lstring.h +CMakeFiles/mojoluac.dir/lua/src/lparser.o: ../lua/src/ltable.h +CMakeFiles/mojoluac.dir/lua/src/lparser.o: ../lua/src/ltm.h +CMakeFiles/mojoluac.dir/lua/src/lparser.o: ../lua/src/lua.h +CMakeFiles/mojoluac.dir/lua/src/lparser.o: ../lua/src/luaconf.h +CMakeFiles/mojoluac.dir/lua/src/lparser.o: ../lua/src/lzio.h + +CMakeFiles/mojoluac.dir/lua/src/lstate.o: ../lua/src/ldebug.h +CMakeFiles/mojoluac.dir/lua/src/lstate.o: ../lua/src/ldo.h +CMakeFiles/mojoluac.dir/lua/src/lstate.o: ../lua/src/lfunc.h +CMakeFiles/mojoluac.dir/lua/src/lstate.o: ../lua/src/lgc.h +CMakeFiles/mojoluac.dir/lua/src/lstate.o: ../lua/src/llex.h +CMakeFiles/mojoluac.dir/lua/src/lstate.o: ../lua/src/llimits.h +CMakeFiles/mojoluac.dir/lua/src/lstate.o: ../lua/src/lmem.h +CMakeFiles/mojoluac.dir/lua/src/lstate.o: ../lua/src/lobject.h +CMakeFiles/mojoluac.dir/lua/src/lstate.o: ../lua/src/lstate.c +CMakeFiles/mojoluac.dir/lua/src/lstate.o: ../lua/src/lstate.h +CMakeFiles/mojoluac.dir/lua/src/lstate.o: ../lua/src/lstring.h +CMakeFiles/mojoluac.dir/lua/src/lstate.o: ../lua/src/ltable.h +CMakeFiles/mojoluac.dir/lua/src/lstate.o: ../lua/src/ltm.h +CMakeFiles/mojoluac.dir/lua/src/lstate.o: ../lua/src/lua.h +CMakeFiles/mojoluac.dir/lua/src/lstate.o: ../lua/src/luaconf.h +CMakeFiles/mojoluac.dir/lua/src/lstate.o: ../lua/src/lzio.h + +CMakeFiles/mojoluac.dir/lua/src/lstring.o: ../lua/src/lgc.h +CMakeFiles/mojoluac.dir/lua/src/lstring.o: ../lua/src/llimits.h +CMakeFiles/mojoluac.dir/lua/src/lstring.o: ../lua/src/lmem.h +CMakeFiles/mojoluac.dir/lua/src/lstring.o: ../lua/src/lobject.h +CMakeFiles/mojoluac.dir/lua/src/lstring.o: ../lua/src/lstate.h +CMakeFiles/mojoluac.dir/lua/src/lstring.o: ../lua/src/lstring.c +CMakeFiles/mojoluac.dir/lua/src/lstring.o: ../lua/src/lstring.h +CMakeFiles/mojoluac.dir/lua/src/lstring.o: ../lua/src/ltm.h +CMakeFiles/mojoluac.dir/lua/src/lstring.o: ../lua/src/lua.h +CMakeFiles/mojoluac.dir/lua/src/lstring.o: ../lua/src/luaconf.h +CMakeFiles/mojoluac.dir/lua/src/lstring.o: ../lua/src/lzio.h + +CMakeFiles/mojoluac.dir/lua/src/lstrlib.o: ../lua/src/lauxlib.h +CMakeFiles/mojoluac.dir/lua/src/lstrlib.o: ../lua/src/lstrlib.c +CMakeFiles/mojoluac.dir/lua/src/lstrlib.o: ../lua/src/lua.h +CMakeFiles/mojoluac.dir/lua/src/lstrlib.o: ../lua/src/luaconf.h +CMakeFiles/mojoluac.dir/lua/src/lstrlib.o: ../lua/src/lualib.h + +CMakeFiles/mojoluac.dir/lua/src/ltable.o: ../lua/src/ldebug.h +CMakeFiles/mojoluac.dir/lua/src/ltable.o: ../lua/src/ldo.h +CMakeFiles/mojoluac.dir/lua/src/ltable.o: ../lua/src/lgc.h +CMakeFiles/mojoluac.dir/lua/src/ltable.o: ../lua/src/llimits.h +CMakeFiles/mojoluac.dir/lua/src/ltable.o: ../lua/src/lmem.h +CMakeFiles/mojoluac.dir/lua/src/ltable.o: ../lua/src/lobject.h +CMakeFiles/mojoluac.dir/lua/src/ltable.o: ../lua/src/lstate.h +CMakeFiles/mojoluac.dir/lua/src/ltable.o: ../lua/src/ltable.c +CMakeFiles/mojoluac.dir/lua/src/ltable.o: ../lua/src/ltable.h +CMakeFiles/mojoluac.dir/lua/src/ltable.o: ../lua/src/ltm.h +CMakeFiles/mojoluac.dir/lua/src/ltable.o: ../lua/src/lua.h +CMakeFiles/mojoluac.dir/lua/src/ltable.o: ../lua/src/luaconf.h +CMakeFiles/mojoluac.dir/lua/src/ltable.o: ../lua/src/lzio.h + +CMakeFiles/mojoluac.dir/lua/src/ltablib.o: ../lua/src/lauxlib.h +CMakeFiles/mojoluac.dir/lua/src/ltablib.o: ../lua/src/ltablib.c +CMakeFiles/mojoluac.dir/lua/src/ltablib.o: ../lua/src/lua.h +CMakeFiles/mojoluac.dir/lua/src/ltablib.o: ../lua/src/luaconf.h +CMakeFiles/mojoluac.dir/lua/src/ltablib.o: ../lua/src/lualib.h + +CMakeFiles/mojoluac.dir/lua/src/ltm.o: ../lua/src/lgc.h +CMakeFiles/mojoluac.dir/lua/src/ltm.o: ../lua/src/llimits.h +CMakeFiles/mojoluac.dir/lua/src/ltm.o: ../lua/src/lmem.h +CMakeFiles/mojoluac.dir/lua/src/ltm.o: ../lua/src/lobject.h +CMakeFiles/mojoluac.dir/lua/src/ltm.o: ../lua/src/lstate.h +CMakeFiles/mojoluac.dir/lua/src/ltm.o: ../lua/src/lstring.h +CMakeFiles/mojoluac.dir/lua/src/ltm.o: ../lua/src/ltable.h +CMakeFiles/mojoluac.dir/lua/src/ltm.o: ../lua/src/ltm.c +CMakeFiles/mojoluac.dir/lua/src/ltm.o: ../lua/src/ltm.h +CMakeFiles/mojoluac.dir/lua/src/ltm.o: ../lua/src/lua.h +CMakeFiles/mojoluac.dir/lua/src/ltm.o: ../lua/src/luaconf.h +CMakeFiles/mojoluac.dir/lua/src/ltm.o: ../lua/src/lzio.h + +CMakeFiles/mojoluac.dir/lua/src/luac.o: ../lua/src/lauxlib.h +CMakeFiles/mojoluac.dir/lua/src/luac.o: ../lua/src/ldo.h +CMakeFiles/mojoluac.dir/lua/src/luac.o: ../lua/src/lfunc.h +CMakeFiles/mojoluac.dir/lua/src/luac.o: ../lua/src/lgc.h +CMakeFiles/mojoluac.dir/lua/src/luac.o: ../lua/src/llimits.h +CMakeFiles/mojoluac.dir/lua/src/luac.o: ../lua/src/lmem.h +CMakeFiles/mojoluac.dir/lua/src/luac.o: ../lua/src/lobject.h +CMakeFiles/mojoluac.dir/lua/src/luac.o: ../lua/src/lopcodes.h +CMakeFiles/mojoluac.dir/lua/src/luac.o: ../lua/src/lstate.h +CMakeFiles/mojoluac.dir/lua/src/luac.o: ../lua/src/lstring.h +CMakeFiles/mojoluac.dir/lua/src/luac.o: ../lua/src/ltm.h +CMakeFiles/mojoluac.dir/lua/src/luac.o: ../lua/src/lua.h +CMakeFiles/mojoluac.dir/lua/src/luac.o: ../lua/src/luac.c +CMakeFiles/mojoluac.dir/lua/src/luac.o: ../lua/src/luaconf.h +CMakeFiles/mojoluac.dir/lua/src/luac.o: ../lua/src/lundump.h +CMakeFiles/mojoluac.dir/lua/src/luac.o: ../lua/src/lzio.h + +CMakeFiles/mojoluac.dir/lua/src/lundump.o: ../lua/src/ldebug.h +CMakeFiles/mojoluac.dir/lua/src/lundump.o: ../lua/src/ldo.h +CMakeFiles/mojoluac.dir/lua/src/lundump.o: ../lua/src/lfunc.h +CMakeFiles/mojoluac.dir/lua/src/lundump.o: ../lua/src/lgc.h +CMakeFiles/mojoluac.dir/lua/src/lundump.o: ../lua/src/llimits.h +CMakeFiles/mojoluac.dir/lua/src/lundump.o: ../lua/src/lmem.h +CMakeFiles/mojoluac.dir/lua/src/lundump.o: ../lua/src/lobject.h +CMakeFiles/mojoluac.dir/lua/src/lundump.o: ../lua/src/lstate.h +CMakeFiles/mojoluac.dir/lua/src/lundump.o: ../lua/src/lstring.h +CMakeFiles/mojoluac.dir/lua/src/lundump.o: ../lua/src/ltm.h +CMakeFiles/mojoluac.dir/lua/src/lundump.o: ../lua/src/lua.h +CMakeFiles/mojoluac.dir/lua/src/lundump.o: ../lua/src/luaconf.h +CMakeFiles/mojoluac.dir/lua/src/lundump.o: ../lua/src/lundump.c +CMakeFiles/mojoluac.dir/lua/src/lundump.o: ../lua/src/lundump.h +CMakeFiles/mojoluac.dir/lua/src/lundump.o: ../lua/src/lzio.h + +CMakeFiles/mojoluac.dir/lua/src/lvm.o: ../lua/src/ldebug.h +CMakeFiles/mojoluac.dir/lua/src/lvm.o: ../lua/src/ldo.h +CMakeFiles/mojoluac.dir/lua/src/lvm.o: ../lua/src/lfunc.h +CMakeFiles/mojoluac.dir/lua/src/lvm.o: ../lua/src/lgc.h +CMakeFiles/mojoluac.dir/lua/src/lvm.o: ../lua/src/llimits.h +CMakeFiles/mojoluac.dir/lua/src/lvm.o: ../lua/src/lmem.h +CMakeFiles/mojoluac.dir/lua/src/lvm.o: ../lua/src/lobject.h +CMakeFiles/mojoluac.dir/lua/src/lvm.o: ../lua/src/lopcodes.h +CMakeFiles/mojoluac.dir/lua/src/lvm.o: ../lua/src/lstate.h +CMakeFiles/mojoluac.dir/lua/src/lvm.o: ../lua/src/lstring.h +CMakeFiles/mojoluac.dir/lua/src/lvm.o: ../lua/src/ltable.h +CMakeFiles/mojoluac.dir/lua/src/lvm.o: ../lua/src/ltm.h +CMakeFiles/mojoluac.dir/lua/src/lvm.o: ../lua/src/lua.h +CMakeFiles/mojoluac.dir/lua/src/lvm.o: ../lua/src/luaconf.h +CMakeFiles/mojoluac.dir/lua/src/lvm.o: ../lua/src/lvm.c +CMakeFiles/mojoluac.dir/lua/src/lvm.o: ../lua/src/lvm.h +CMakeFiles/mojoluac.dir/lua/src/lvm.o: ../lua/src/lzio.h + +CMakeFiles/mojoluac.dir/lua/src/lzio.o: ../lua/src/llimits.h +CMakeFiles/mojoluac.dir/lua/src/lzio.o: ../lua/src/lmem.h +CMakeFiles/mojoluac.dir/lua/src/lzio.o: ../lua/src/lobject.h +CMakeFiles/mojoluac.dir/lua/src/lzio.o: ../lua/src/lstate.h +CMakeFiles/mojoluac.dir/lua/src/lzio.o: ../lua/src/ltm.h +CMakeFiles/mojoluac.dir/lua/src/lzio.o: ../lua/src/lua.h +CMakeFiles/mojoluac.dir/lua/src/lzio.o: ../lua/src/luaconf.h +CMakeFiles/mojoluac.dir/lua/src/lzio.o: ../lua/src/lzio.c +CMakeFiles/mojoluac.dir/lua/src/lzio.o: ../lua/src/lzio.h + +CMakeFiles/mojoluac.dir/lua/src/print.o: ../lua/src/ldebug.h +CMakeFiles/mojoluac.dir/lua/src/print.o: ../lua/src/llimits.h +CMakeFiles/mojoluac.dir/lua/src/print.o: ../lua/src/lmem.h +CMakeFiles/mojoluac.dir/lua/src/print.o: ../lua/src/lobject.h +CMakeFiles/mojoluac.dir/lua/src/print.o: ../lua/src/lopcodes.h +CMakeFiles/mojoluac.dir/lua/src/print.o: ../lua/src/lstate.h +CMakeFiles/mojoluac.dir/lua/src/print.o: ../lua/src/ltm.h +CMakeFiles/mojoluac.dir/lua/src/print.o: ../lua/src/lua.h +CMakeFiles/mojoluac.dir/lua/src/print.o: ../lua/src/luaconf.h +CMakeFiles/mojoluac.dir/lua/src/print.o: ../lua/src/lundump.h +CMakeFiles/mojoluac.dir/lua/src/print.o: ../lua/src/lzio.h +CMakeFiles/mojoluac.dir/lua/src/print.o: ../lua/src/print.c + diff --git a/mk/linux/mojosetup/build/CMakeFiles/mojoluac.dir/flags.make b/mk/linux/mojosetup/build/CMakeFiles/mojoluac.dir/flags.make new file mode 100644 index 00000000..af60b456 --- /dev/null +++ b/mk/linux/mojosetup/build/CMakeFiles/mojoluac.dir/flags.make @@ -0,0 +1,8 @@ +# CMAKE generated file: DO NOT EDIT! +# Generated by "Unix Makefiles" Generator, CMake Version 2.8 + +# compile C with /usr/bin/gcc +C_FLAGS = -I/home/softcoder/Code/mojosetup/. -I/home/softcoder/Code/mojosetup/lua/src -DAPPREV="hg-767:48f7a9461c37" -pipe -Wall -Werror -fsigned-char -fvisibility=hidden -fno-stack-protector -DPNG_NO_MMX_CODE -I/usr/include/gtk-2.0 -I/usr/lib/gtk-2.0/include -I/usr/include/atk-1.0 -I/usr/include/cairo -I/usr/include/pango-1.0 -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include -I/usr/include/freetype2 -I/usr/include/libpng12 + +C_DEFINES = -D__MOJOSETUP__=1 -DAPPID=mojosetup -D_REENTRANT -D_THREAD_SAFE -DPLATFORM_UNIX=1 -DLUA_USE_MKSTEMP=1 -DLUA_USE_ULONGJMP=1 -DPLATFORM_LITTLEENDIAN=1 -DSUPPORT_LUALIB_IO=1 -DSUPPORT_LUALIB_OS=1 -DSUPPORT_LUALIB_MATH=1 -DSUPPORT_LUALIB_DB=1 -DSUPPORT_LUALIB_PACKAGE=1 -DSUPPORT_CRC32=1 -DSUPPORT_MD5=1 -DSUPPORT_SHA1=1 -DSUPPORT_GUI_STDIO=1 -DGUI_STATIC_LINK_STDIO=1 -DSUPPORT_GUI_GTKPLUS2=1 -DSUPPORT_ZIP=1 -DSUPPORT_TAR=1 -DSUPPORT_GZIP=1 -DSUPPORT_BZIP2=1 -DBZ_NO_STDIO=1 -DSUPPORT_JPG=1 -DSUPPORT_PNG=1 -DSUPPORT_STBIMAGE=1 -DSUPPORT_URL_HTTP=1 -DSUPPORT_URL_FTP=1 -DMOJOSETUP_HAVE_MNTENT_H=1 + diff --git a/mk/linux/mojosetup/build/CMakeFiles/mojoluac.dir/link.txt b/mk/linux/mojosetup/build/CMakeFiles/mojoluac.dir/link.txt new file mode 100644 index 00000000..724565fb --- /dev/null +++ b/mk/linux/mojosetup/build/CMakeFiles/mojoluac.dir/link.txt @@ -0,0 +1 @@ +/usr/bin/gcc CMakeFiles/mojoluac.dir/lua/src/lapi.o CMakeFiles/mojoluac.dir/lua/src/ldebug.o CMakeFiles/mojoluac.dir/lua/src/ldo.o CMakeFiles/mojoluac.dir/lua/src/ldump.o CMakeFiles/mojoluac.dir/lua/src/lfunc.o CMakeFiles/mojoluac.dir/lua/src/lgc.o CMakeFiles/mojoluac.dir/lua/src/lmem.o CMakeFiles/mojoluac.dir/lua/src/lobject.o CMakeFiles/mojoluac.dir/lua/src/lopcodes.o CMakeFiles/mojoluac.dir/lua/src/lstate.o CMakeFiles/mojoluac.dir/lua/src/lstring.o CMakeFiles/mojoluac.dir/lua/src/ltable.o CMakeFiles/mojoluac.dir/lua/src/ltm.o CMakeFiles/mojoluac.dir/lua/src/lundump.o CMakeFiles/mojoluac.dir/lua/src/lvm.o CMakeFiles/mojoluac.dir/lua/src/lzio.o CMakeFiles/mojoluac.dir/lua/src/lauxlib.o CMakeFiles/mojoluac.dir/lua/src/lbaselib.o CMakeFiles/mojoluac.dir/lua/src/lstrlib.o CMakeFiles/mojoluac.dir/lua/src/ltablib.o CMakeFiles/mojoluac.dir/lua/src/lparser.o CMakeFiles/mojoluac.dir/lua/src/llex.o CMakeFiles/mojoluac.dir/lua/src/lcode.o CMakeFiles/mojoluac.dir/lua/src/luac.o CMakeFiles/mojoluac.dir/lua/src/print.o CMakeFiles/mojoluac.dir/lua/src/linit.o CMakeFiles/mojoluac.dir/lua/src/ldblib.o CMakeFiles/mojoluac.dir/lua/src/liolib.o CMakeFiles/mojoluac.dir/lua/src/lmathlib.o CMakeFiles/mojoluac.dir/lua/src/loslib.o CMakeFiles/mojoluac.dir/lua/src/loadlib.o -o mojoluac -lpthread -lz -lbz2 -ldl -lm diff --git a/mk/linux/mojosetup/build/CMakeFiles/mojoluac.dir/progress.make b/mk/linux/mojosetup/build/CMakeFiles/mojoluac.dir/progress.make new file mode 100644 index 00000000..117b06c8 --- /dev/null +++ b/mk/linux/mojosetup/build/CMakeFiles/mojoluac.dir/progress.make @@ -0,0 +1,32 @@ +CMAKE_PROGRESS_1 = 1 +CMAKE_PROGRESS_2 = 2 +CMAKE_PROGRESS_3 = 3 +CMAKE_PROGRESS_4 = 4 +CMAKE_PROGRESS_5 = 5 +CMAKE_PROGRESS_6 = 6 +CMAKE_PROGRESS_7 = 7 +CMAKE_PROGRESS_8 = 8 +CMAKE_PROGRESS_9 = 9 +CMAKE_PROGRESS_10 = 10 +CMAKE_PROGRESS_11 = 11 +CMAKE_PROGRESS_12 = 12 +CMAKE_PROGRESS_13 = 13 +CMAKE_PROGRESS_14 = 14 +CMAKE_PROGRESS_15 = 15 +CMAKE_PROGRESS_16 = 16 +CMAKE_PROGRESS_17 = 17 +CMAKE_PROGRESS_18 = 18 +CMAKE_PROGRESS_19 = 19 +CMAKE_PROGRESS_20 = 20 +CMAKE_PROGRESS_21 = 21 +CMAKE_PROGRESS_22 = 22 +CMAKE_PROGRESS_23 = 23 +CMAKE_PROGRESS_24 = 24 +CMAKE_PROGRESS_25 = 25 +CMAKE_PROGRESS_26 = 26 +CMAKE_PROGRESS_27 = 27 +CMAKE_PROGRESS_28 = 28 +CMAKE_PROGRESS_29 = 29 +CMAKE_PROGRESS_30 = 30 +CMAKE_PROGRESS_31 = 31 + diff --git a/mk/linux/mojosetup/build/CMakeFiles/mojosetup.dir/C.includecache b/mk/linux/mojosetup/build/CMakeFiles/mojosetup.dir/C.includecache new file mode 100644 index 00000000..354065ae --- /dev/null +++ b/mk/linux/mojosetup/build/CMakeFiles/mojosetup.dir/C.includecache @@ -0,0 +1,1230 @@ +#IncludeRegexLine: ^[ ]*#[ ]*(include|import)[ ]*[<"]([^">]+)([">]) + +#IncludeRegexScan: ^.*$ + +#IncludeRegexComplain: ^$ + +#IncludeRegexTransform: + +../lua/src/lauxlib.h +stddef.h +- +stdio.h +- +lua.h +../lua/src/lua.h + +../lua/src/lua.h +stdarg.h +- +stddef.h +- +luaconf.h +../lua/src/luaconf.h + +../lua/src/luaconf.h +limits.h +- +stddef.h +- +unistd.h +- +io.h +- +stdio.h +- +stdio.h +- +readline/readline.h +- +readline/history.h +- +assert.h +- +math.h +- +unistd.h +- + +../lua/src/lualib.h +lua.h +../lua/src/lua.h + +/home/softcoder/Code/mojosetup/archive_pck.c +fileio.h +/home/softcoder/Code/mojosetup/fileio.h +platform.h +/home/softcoder/Code/mojosetup/platform.h + +/home/softcoder/Code/mojosetup/archive_tar.c +fileio.h +/home/softcoder/Code/mojosetup/fileio.h + +/home/softcoder/Code/mojosetup/archive_uz2.c +fileio.h +/home/softcoder/Code/mojosetup/fileio.h +platform.h +/home/softcoder/Code/mojosetup/platform.h +zlib/zlib.h +/home/softcoder/Code/mojosetup/zlib/zlib.h + +/home/softcoder/Code/mojosetup/archive_zip.c +fileio.h +/home/softcoder/Code/mojosetup/fileio.h +time.h +- +errno.h +- +zlib/zlib.h +/home/softcoder/Code/mojosetup/zlib/zlib.h + +/home/softcoder/Code/mojosetup/buildver.c + +/home/softcoder/Code/mojosetup/bzip2/bzlib.h +stdio.h +- +windows.h +- + +/home/softcoder/Code/mojosetup/checksum_crc32.c +universal.h +/home/softcoder/Code/mojosetup/universal.h + +/home/softcoder/Code/mojosetup/checksum_md5.c +universal.h +/home/softcoder/Code/mojosetup/universal.h + +/home/softcoder/Code/mojosetup/checksum_sha1.c +universal.h +/home/softcoder/Code/mojosetup/universal.h + +/home/softcoder/Code/mojosetup/fileio.c +fileio.h +/home/softcoder/Code/mojosetup/fileio.h +platform.h +/home/softcoder/Code/mojosetup/platform.h +zlib/zlib.h +/home/softcoder/Code/mojosetup/zlib/zlib.h +bzip2/bzlib.h +/home/softcoder/Code/mojosetup/bzip2/bzlib.h + +/home/softcoder/Code/mojosetup/fileio.h +universal.h +/home/softcoder/Code/mojosetup/universal.h + +/home/softcoder/Code/mojosetup/gui.c +gui.h +/home/softcoder/Code/mojosetup/gui.h +platform.h +/home/softcoder/Code/mojosetup/platform.h +fileio.h +/home/softcoder/Code/mojosetup/fileio.h + +/home/softcoder/Code/mojosetup/gui.h +universal.h +/home/softcoder/Code/mojosetup/universal.h + +/home/softcoder/Code/mojosetup/gui_stdio.c +gui.h +/home/softcoder/Code/mojosetup/gui.h +ctype.h +- + +/home/softcoder/Code/mojosetup/libfetch/../fileio.h +universal.h +/home/softcoder/Code/mojosetup/libfetch/../universal.h + +/home/softcoder/Code/mojosetup/libfetch/../platform.h +universal.h +/home/softcoder/Code/mojosetup/libfetch/../universal.h + +/home/softcoder/Code/mojosetup/libfetch/../universal.h +stdio.h +- +stdlib.h +- +string.h +- +assert.h +- +time.h +- +malloc.h +- + +/home/softcoder/Code/mojosetup/libfetch/common.c +mojosetup_libfetch.h +/home/softcoder/Code/mojosetup/libfetch/mojosetup_libfetch.h +pthread.h +- +sys/cdefs.h +- +sys/param.h +- +sys/socket.h +- +sys/time.h +- +sys/uio.h +- +netinet/in.h +- +errno.h +- +netdb.h +- +pwd.h +- +stdarg.h +- +stdlib.h +- +stdio.h +- +string.h +- +unistd.h +- +fetch.h +/home/softcoder/Code/mojosetup/libfetch/fetch.h +common.h +/home/softcoder/Code/mojosetup/libfetch/common.h + +/home/softcoder/Code/mojosetup/libfetch/common.h +openssl/crypto.h +- +openssl/x509.h +- +openssl/pem.h +- +openssl/ssl.h +- +openssl/err.h +- + +/home/softcoder/Code/mojosetup/libfetch/fetch.c +mojosetup_libfetch.h +/home/softcoder/Code/mojosetup/libfetch/mojosetup_libfetch.h +sys/cdefs.h +- +sys/param.h +- +sys/errno.h +- +ctype.h +- +stdio.h +- +stdlib.h +- +string.h +- +fetch.h +/home/softcoder/Code/mojosetup/libfetch/fetch.h +common.h +/home/softcoder/Code/mojosetup/libfetch/common.h + +/home/softcoder/Code/mojosetup/libfetch/fetch.h + +/home/softcoder/Code/mojosetup/libfetch/ftp.c +mojosetup_libfetch.h +/home/softcoder/Code/mojosetup/libfetch/mojosetup_libfetch.h +sys/cdefs.h +- +sys/param.h +- +sys/socket.h +- +netinet/in.h +- +ctype.h +- +err.h +- +errno.h +- +fcntl.h +- +netdb.h +- +stdarg.h +- +stdint.h +- +stdio.h +- +stdlib.h +- +string.h +- +time.h +- +unistd.h +- +fetch.h +/home/softcoder/Code/mojosetup/libfetch/fetch.h +common.h +/home/softcoder/Code/mojosetup/libfetch/common.h +ftperr.h +/home/softcoder/Code/mojosetup/libfetch/ftperr.h + +/home/softcoder/Code/mojosetup/libfetch/ftperr.h + +/home/softcoder/Code/mojosetup/libfetch/http.c +mojosetup_libfetch.h +/home/softcoder/Code/mojosetup/libfetch/mojosetup_libfetch.h +sys/cdefs.h +- +sys/param.h +- +sys/socket.h +- +ctype.h +- +err.h +- +errno.h +- +locale.h +- +netdb.h +- +stdarg.h +- +stdio.h +- +stdlib.h +- +string.h +- +time.h +- +unistd.h +- +netinet/in.h +- +netinet/tcp.h +- +fetch.h +/home/softcoder/Code/mojosetup/libfetch/fetch.h +common.h +/home/softcoder/Code/mojosetup/libfetch/common.h +httperr.h +/home/softcoder/Code/mojosetup/libfetch/httperr.h + +/home/softcoder/Code/mojosetup/libfetch/httperr.h + +/home/softcoder/Code/mojosetup/libfetch/mojosetup_libfetch.h +../universal.h +/home/softcoder/Code/mojosetup/libfetch/../universal.h +../platform.h +/home/softcoder/Code/mojosetup/libfetch/../platform.h +../fileio.h +/home/softcoder/Code/mojosetup/libfetch/../fileio.h +stdarg.h +- +stdint.h +- +time.h +- +limits.h +- + +/home/softcoder/Code/mojosetup/lua/src/lapi.c +assert.h +- +math.h +- +stdarg.h +- +string.h +- +lua.h +/home/softcoder/Code/mojosetup/lua/src/lua.h +lapi.h +/home/softcoder/Code/mojosetup/lua/src/lapi.h +ldebug.h +/home/softcoder/Code/mojosetup/lua/src/ldebug.h +ldo.h +/home/softcoder/Code/mojosetup/lua/src/ldo.h +lfunc.h +/home/softcoder/Code/mojosetup/lua/src/lfunc.h +lgc.h +/home/softcoder/Code/mojosetup/lua/src/lgc.h +lmem.h +/home/softcoder/Code/mojosetup/lua/src/lmem.h +lobject.h +/home/softcoder/Code/mojosetup/lua/src/lobject.h +lstate.h +/home/softcoder/Code/mojosetup/lua/src/lstate.h +lstring.h +/home/softcoder/Code/mojosetup/lua/src/lstring.h +ltable.h +/home/softcoder/Code/mojosetup/lua/src/ltable.h +ltm.h +/home/softcoder/Code/mojosetup/lua/src/ltm.h +lundump.h +/home/softcoder/Code/mojosetup/lua/src/lundump.h +lvm.h +/home/softcoder/Code/mojosetup/lua/src/lvm.h + +/home/softcoder/Code/mojosetup/lua/src/lapi.h +lobject.h +/home/softcoder/Code/mojosetup/lua/src/lobject.h + +/home/softcoder/Code/mojosetup/lua/src/lauxlib.c +ctype.h +- +errno.h +- +stdarg.h +- +stdio.h +- +stdlib.h +- +string.h +- +lua.h +/home/softcoder/Code/mojosetup/lua/src/lua.h +lauxlib.h +/home/softcoder/Code/mojosetup/lua/src/lauxlib.h + +/home/softcoder/Code/mojosetup/lua/src/lauxlib.h +stddef.h +- +stdio.h +- +lua.h +/home/softcoder/Code/mojosetup/lua/src/lua.h + +/home/softcoder/Code/mojosetup/lua/src/lbaselib.c +ctype.h +- +stdio.h +- +stdlib.h +- +string.h +- +lua.h +/home/softcoder/Code/mojosetup/lua/src/lua.h +lauxlib.h +/home/softcoder/Code/mojosetup/lua/src/lauxlib.h +lualib.h +/home/softcoder/Code/mojosetup/lua/src/lualib.h + +/home/softcoder/Code/mojosetup/lua/src/lcode.c +stdlib.h +- +lua.h +/home/softcoder/Code/mojosetup/lua/src/lua.h +lcode.h +/home/softcoder/Code/mojosetup/lua/src/lcode.h +ldebug.h +/home/softcoder/Code/mojosetup/lua/src/ldebug.h +ldo.h +/home/softcoder/Code/mojosetup/lua/src/ldo.h +lgc.h +/home/softcoder/Code/mojosetup/lua/src/lgc.h +llex.h +/home/softcoder/Code/mojosetup/lua/src/llex.h +lmem.h +/home/softcoder/Code/mojosetup/lua/src/lmem.h +lobject.h +/home/softcoder/Code/mojosetup/lua/src/lobject.h +lopcodes.h +/home/softcoder/Code/mojosetup/lua/src/lopcodes.h +lparser.h +/home/softcoder/Code/mojosetup/lua/src/lparser.h +ltable.h +/home/softcoder/Code/mojosetup/lua/src/ltable.h + +/home/softcoder/Code/mojosetup/lua/src/lcode.h +llex.h +/home/softcoder/Code/mojosetup/lua/src/llex.h +lobject.h +/home/softcoder/Code/mojosetup/lua/src/lobject.h +lopcodes.h +/home/softcoder/Code/mojosetup/lua/src/lopcodes.h +lparser.h +/home/softcoder/Code/mojosetup/lua/src/lparser.h + +/home/softcoder/Code/mojosetup/lua/src/ldblib.c +stdio.h +- +stdlib.h +- +string.h +- +lua.h +/home/softcoder/Code/mojosetup/lua/src/lua.h +lauxlib.h +/home/softcoder/Code/mojosetup/lua/src/lauxlib.h +lualib.h +/home/softcoder/Code/mojosetup/lua/src/lualib.h + +/home/softcoder/Code/mojosetup/lua/src/ldebug.c +stdarg.h +- +stddef.h +- +string.h +- +lua.h +/home/softcoder/Code/mojosetup/lua/src/lua.h +lapi.h +/home/softcoder/Code/mojosetup/lua/src/lapi.h +lcode.h +/home/softcoder/Code/mojosetup/lua/src/lcode.h +ldebug.h +/home/softcoder/Code/mojosetup/lua/src/ldebug.h +ldo.h +/home/softcoder/Code/mojosetup/lua/src/ldo.h +lfunc.h +/home/softcoder/Code/mojosetup/lua/src/lfunc.h +lobject.h +/home/softcoder/Code/mojosetup/lua/src/lobject.h +lopcodes.h +/home/softcoder/Code/mojosetup/lua/src/lopcodes.h +lstate.h +/home/softcoder/Code/mojosetup/lua/src/lstate.h +lstring.h +/home/softcoder/Code/mojosetup/lua/src/lstring.h +ltable.h +/home/softcoder/Code/mojosetup/lua/src/ltable.h +ltm.h +/home/softcoder/Code/mojosetup/lua/src/ltm.h +lvm.h +/home/softcoder/Code/mojosetup/lua/src/lvm.h + +/home/softcoder/Code/mojosetup/lua/src/ldebug.h +lstate.h +/home/softcoder/Code/mojosetup/lua/src/lstate.h + +/home/softcoder/Code/mojosetup/lua/src/ldo.c +setjmp.h +- +stdlib.h +- +string.h +- +lua.h +/home/softcoder/Code/mojosetup/lua/src/lua.h +ldebug.h +/home/softcoder/Code/mojosetup/lua/src/ldebug.h +ldo.h +/home/softcoder/Code/mojosetup/lua/src/ldo.h +lfunc.h +/home/softcoder/Code/mojosetup/lua/src/lfunc.h +lgc.h +/home/softcoder/Code/mojosetup/lua/src/lgc.h +lmem.h +/home/softcoder/Code/mojosetup/lua/src/lmem.h +lobject.h +/home/softcoder/Code/mojosetup/lua/src/lobject.h +lopcodes.h +/home/softcoder/Code/mojosetup/lua/src/lopcodes.h +lparser.h +/home/softcoder/Code/mojosetup/lua/src/lparser.h +lstate.h +/home/softcoder/Code/mojosetup/lua/src/lstate.h +lstring.h +/home/softcoder/Code/mojosetup/lua/src/lstring.h +ltable.h +/home/softcoder/Code/mojosetup/lua/src/ltable.h +ltm.h +/home/softcoder/Code/mojosetup/lua/src/ltm.h +lundump.h +/home/softcoder/Code/mojosetup/lua/src/lundump.h +lvm.h +/home/softcoder/Code/mojosetup/lua/src/lvm.h +lzio.h +/home/softcoder/Code/mojosetup/lua/src/lzio.h + +/home/softcoder/Code/mojosetup/lua/src/ldo.h +lobject.h +/home/softcoder/Code/mojosetup/lua/src/lobject.h +lstate.h +/home/softcoder/Code/mojosetup/lua/src/lstate.h +lzio.h +/home/softcoder/Code/mojosetup/lua/src/lzio.h + +/home/softcoder/Code/mojosetup/lua/src/ldump.c +stddef.h +- +lua.h +/home/softcoder/Code/mojosetup/lua/src/lua.h +lobject.h +/home/softcoder/Code/mojosetup/lua/src/lobject.h +lstate.h +/home/softcoder/Code/mojosetup/lua/src/lstate.h +lundump.h +/home/softcoder/Code/mojosetup/lua/src/lundump.h + +/home/softcoder/Code/mojosetup/lua/src/lfunc.c +stddef.h +- +lua.h +/home/softcoder/Code/mojosetup/lua/src/lua.h +lfunc.h +/home/softcoder/Code/mojosetup/lua/src/lfunc.h +lgc.h +/home/softcoder/Code/mojosetup/lua/src/lgc.h +lmem.h +/home/softcoder/Code/mojosetup/lua/src/lmem.h +lobject.h +/home/softcoder/Code/mojosetup/lua/src/lobject.h +lstate.h +/home/softcoder/Code/mojosetup/lua/src/lstate.h + +/home/softcoder/Code/mojosetup/lua/src/lfunc.h +lobject.h +/home/softcoder/Code/mojosetup/lua/src/lobject.h + +/home/softcoder/Code/mojosetup/lua/src/lgc.c +string.h +- +lua.h +/home/softcoder/Code/mojosetup/lua/src/lua.h +ldebug.h +/home/softcoder/Code/mojosetup/lua/src/ldebug.h +ldo.h +/home/softcoder/Code/mojosetup/lua/src/ldo.h +lfunc.h +/home/softcoder/Code/mojosetup/lua/src/lfunc.h +lgc.h +/home/softcoder/Code/mojosetup/lua/src/lgc.h +lmem.h +/home/softcoder/Code/mojosetup/lua/src/lmem.h +lobject.h +/home/softcoder/Code/mojosetup/lua/src/lobject.h +lstate.h +/home/softcoder/Code/mojosetup/lua/src/lstate.h +lstring.h +/home/softcoder/Code/mojosetup/lua/src/lstring.h +ltable.h +/home/softcoder/Code/mojosetup/lua/src/ltable.h +ltm.h +/home/softcoder/Code/mojosetup/lua/src/ltm.h + +/home/softcoder/Code/mojosetup/lua/src/lgc.h +lobject.h +/home/softcoder/Code/mojosetup/lua/src/lobject.h + +/home/softcoder/Code/mojosetup/lua/src/liolib.c +errno.h +- +stdio.h +- +stdlib.h +- +string.h +- +lua.h +/home/softcoder/Code/mojosetup/lua/src/lua.h +lauxlib.h +/home/softcoder/Code/mojosetup/lua/src/lauxlib.h +lualib.h +/home/softcoder/Code/mojosetup/lua/src/lualib.h + +/home/softcoder/Code/mojosetup/lua/src/llex.c +ctype.h +- +locale.h +- +string.h +- +lua.h +/home/softcoder/Code/mojosetup/lua/src/lua.h +ldo.h +/home/softcoder/Code/mojosetup/lua/src/ldo.h +llex.h +/home/softcoder/Code/mojosetup/lua/src/llex.h +lobject.h +/home/softcoder/Code/mojosetup/lua/src/lobject.h +lparser.h +/home/softcoder/Code/mojosetup/lua/src/lparser.h +lstate.h +/home/softcoder/Code/mojosetup/lua/src/lstate.h +lstring.h +/home/softcoder/Code/mojosetup/lua/src/lstring.h +ltable.h +/home/softcoder/Code/mojosetup/lua/src/ltable.h +lzio.h +/home/softcoder/Code/mojosetup/lua/src/lzio.h + +/home/softcoder/Code/mojosetup/lua/src/llex.h +lobject.h +/home/softcoder/Code/mojosetup/lua/src/lobject.h +lzio.h +/home/softcoder/Code/mojosetup/lua/src/lzio.h + +/home/softcoder/Code/mojosetup/lua/src/llimits.h +limits.h +- +stddef.h +- +lua.h +/home/softcoder/Code/mojosetup/lua/src/lua.h + +/home/softcoder/Code/mojosetup/lua/src/lmathlib.c +stdlib.h +- +math.h +- +lua.h +/home/softcoder/Code/mojosetup/lua/src/lua.h +lauxlib.h +/home/softcoder/Code/mojosetup/lua/src/lauxlib.h +lualib.h +/home/softcoder/Code/mojosetup/lua/src/lualib.h + +/home/softcoder/Code/mojosetup/lua/src/lmem.c +stddef.h +- +lua.h +/home/softcoder/Code/mojosetup/lua/src/lua.h +ldebug.h +/home/softcoder/Code/mojosetup/lua/src/ldebug.h +ldo.h +/home/softcoder/Code/mojosetup/lua/src/ldo.h +lmem.h +/home/softcoder/Code/mojosetup/lua/src/lmem.h +lobject.h +/home/softcoder/Code/mojosetup/lua/src/lobject.h +lstate.h +/home/softcoder/Code/mojosetup/lua/src/lstate.h + +/home/softcoder/Code/mojosetup/lua/src/lmem.h +stddef.h +- +llimits.h +/home/softcoder/Code/mojosetup/lua/src/llimits.h +lua.h +/home/softcoder/Code/mojosetup/lua/src/lua.h + +/home/softcoder/Code/mojosetup/lua/src/loadlib.c +stdlib.h +- +string.h +- +lua.h +/home/softcoder/Code/mojosetup/lua/src/lua.h +lauxlib.h +/home/softcoder/Code/mojosetup/lua/src/lauxlib.h +lualib.h +/home/softcoder/Code/mojosetup/lua/src/lualib.h +dlfcn.h +- +windows.h +- +mach-o/dyld.h +- + +/home/softcoder/Code/mojosetup/lua/src/lobject.c +ctype.h +- +stdarg.h +- +stdio.h +- +stdlib.h +- +string.h +- +lua.h +/home/softcoder/Code/mojosetup/lua/src/lua.h +ldo.h +/home/softcoder/Code/mojosetup/lua/src/ldo.h +lmem.h +/home/softcoder/Code/mojosetup/lua/src/lmem.h +lobject.h +/home/softcoder/Code/mojosetup/lua/src/lobject.h +lstate.h +/home/softcoder/Code/mojosetup/lua/src/lstate.h +lstring.h +/home/softcoder/Code/mojosetup/lua/src/lstring.h +lvm.h +/home/softcoder/Code/mojosetup/lua/src/lvm.h + +/home/softcoder/Code/mojosetup/lua/src/lobject.h +stdarg.h +- +llimits.h +/home/softcoder/Code/mojosetup/lua/src/llimits.h +lua.h +/home/softcoder/Code/mojosetup/lua/src/lua.h + +/home/softcoder/Code/mojosetup/lua/src/lopcodes.c +lopcodes.h +/home/softcoder/Code/mojosetup/lua/src/lopcodes.h + +/home/softcoder/Code/mojosetup/lua/src/lopcodes.h +llimits.h +/home/softcoder/Code/mojosetup/lua/src/llimits.h + +/home/softcoder/Code/mojosetup/lua/src/loslib.c +errno.h +- +locale.h +- +stdlib.h +- +string.h +- +time.h +- +lua.h +/home/softcoder/Code/mojosetup/lua/src/lua.h +lauxlib.h +/home/softcoder/Code/mojosetup/lua/src/lauxlib.h +lualib.h +/home/softcoder/Code/mojosetup/lua/src/lualib.h + +/home/softcoder/Code/mojosetup/lua/src/lparser.c +string.h +- +lua.h +/home/softcoder/Code/mojosetup/lua/src/lua.h +lcode.h +/home/softcoder/Code/mojosetup/lua/src/lcode.h +ldebug.h +/home/softcoder/Code/mojosetup/lua/src/ldebug.h +ldo.h +/home/softcoder/Code/mojosetup/lua/src/ldo.h +lfunc.h +/home/softcoder/Code/mojosetup/lua/src/lfunc.h +llex.h +/home/softcoder/Code/mojosetup/lua/src/llex.h +lmem.h +/home/softcoder/Code/mojosetup/lua/src/lmem.h +lobject.h +/home/softcoder/Code/mojosetup/lua/src/lobject.h +lopcodes.h +/home/softcoder/Code/mojosetup/lua/src/lopcodes.h +lparser.h +/home/softcoder/Code/mojosetup/lua/src/lparser.h +lstate.h +/home/softcoder/Code/mojosetup/lua/src/lstate.h +lstring.h +/home/softcoder/Code/mojosetup/lua/src/lstring.h +ltable.h +/home/softcoder/Code/mojosetup/lua/src/ltable.h + +/home/softcoder/Code/mojosetup/lua/src/lparser.h +llimits.h +/home/softcoder/Code/mojosetup/lua/src/llimits.h +lobject.h +/home/softcoder/Code/mojosetup/lua/src/lobject.h +lzio.h +/home/softcoder/Code/mojosetup/lua/src/lzio.h + +/home/softcoder/Code/mojosetup/lua/src/lstate.c +stddef.h +- +lua.h +/home/softcoder/Code/mojosetup/lua/src/lua.h +ldebug.h +/home/softcoder/Code/mojosetup/lua/src/ldebug.h +ldo.h +/home/softcoder/Code/mojosetup/lua/src/ldo.h +lfunc.h +/home/softcoder/Code/mojosetup/lua/src/lfunc.h +lgc.h +/home/softcoder/Code/mojosetup/lua/src/lgc.h +llex.h +/home/softcoder/Code/mojosetup/lua/src/llex.h +lmem.h +/home/softcoder/Code/mojosetup/lua/src/lmem.h +lstate.h +/home/softcoder/Code/mojosetup/lua/src/lstate.h +lstring.h +/home/softcoder/Code/mojosetup/lua/src/lstring.h +ltable.h +/home/softcoder/Code/mojosetup/lua/src/ltable.h +ltm.h +/home/softcoder/Code/mojosetup/lua/src/ltm.h + +/home/softcoder/Code/mojosetup/lua/src/lstate.h +lua.h +/home/softcoder/Code/mojosetup/lua/src/lua.h +lobject.h +/home/softcoder/Code/mojosetup/lua/src/lobject.h +ltm.h +/home/softcoder/Code/mojosetup/lua/src/ltm.h +lzio.h +/home/softcoder/Code/mojosetup/lua/src/lzio.h + +/home/softcoder/Code/mojosetup/lua/src/lstring.c +string.h +- +lua.h +/home/softcoder/Code/mojosetup/lua/src/lua.h +lmem.h +/home/softcoder/Code/mojosetup/lua/src/lmem.h +lobject.h +/home/softcoder/Code/mojosetup/lua/src/lobject.h +lstate.h +/home/softcoder/Code/mojosetup/lua/src/lstate.h +lstring.h +/home/softcoder/Code/mojosetup/lua/src/lstring.h + +/home/softcoder/Code/mojosetup/lua/src/lstring.h +lgc.h +/home/softcoder/Code/mojosetup/lua/src/lgc.h +lobject.h +/home/softcoder/Code/mojosetup/lua/src/lobject.h +lstate.h +/home/softcoder/Code/mojosetup/lua/src/lstate.h + +/home/softcoder/Code/mojosetup/lua/src/lstrlib.c +ctype.h +- +stddef.h +- +stdio.h +- +stdlib.h +- +string.h +- +lua.h +/home/softcoder/Code/mojosetup/lua/src/lua.h +lauxlib.h +/home/softcoder/Code/mojosetup/lua/src/lauxlib.h +lualib.h +/home/softcoder/Code/mojosetup/lua/src/lualib.h + +/home/softcoder/Code/mojosetup/lua/src/ltable.c +math.h +- +string.h +- +lua.h +/home/softcoder/Code/mojosetup/lua/src/lua.h +ldebug.h +/home/softcoder/Code/mojosetup/lua/src/ldebug.h +ldo.h +/home/softcoder/Code/mojosetup/lua/src/ldo.h +lgc.h +/home/softcoder/Code/mojosetup/lua/src/lgc.h +lmem.h +/home/softcoder/Code/mojosetup/lua/src/lmem.h +lobject.h +/home/softcoder/Code/mojosetup/lua/src/lobject.h +lstate.h +/home/softcoder/Code/mojosetup/lua/src/lstate.h +ltable.h +/home/softcoder/Code/mojosetup/lua/src/ltable.h + +/home/softcoder/Code/mojosetup/lua/src/ltable.h +lobject.h +/home/softcoder/Code/mojosetup/lua/src/lobject.h + +/home/softcoder/Code/mojosetup/lua/src/ltablib.c +stddef.h +- +lua.h +/home/softcoder/Code/mojosetup/lua/src/lua.h +lauxlib.h +/home/softcoder/Code/mojosetup/lua/src/lauxlib.h +lualib.h +/home/softcoder/Code/mojosetup/lua/src/lualib.h + +/home/softcoder/Code/mojosetup/lua/src/ltm.c +string.h +- +lua.h +/home/softcoder/Code/mojosetup/lua/src/lua.h +lobject.h +/home/softcoder/Code/mojosetup/lua/src/lobject.h +lstate.h +/home/softcoder/Code/mojosetup/lua/src/lstate.h +lstring.h +/home/softcoder/Code/mojosetup/lua/src/lstring.h +ltable.h +/home/softcoder/Code/mojosetup/lua/src/ltable.h +ltm.h +/home/softcoder/Code/mojosetup/lua/src/ltm.h + +/home/softcoder/Code/mojosetup/lua/src/ltm.h +lobject.h +/home/softcoder/Code/mojosetup/lua/src/lobject.h + +/home/softcoder/Code/mojosetup/lua/src/lua.h +stdarg.h +- +stddef.h +- +luaconf.h +/home/softcoder/Code/mojosetup/lua/src/luaconf.h + +/home/softcoder/Code/mojosetup/lua/src/luaconf.h +limits.h +- +stddef.h +- +unistd.h +- +io.h +- +stdio.h +- +stdio.h +- +readline/readline.h +- +readline/history.h +- +assert.h +- +math.h +- +unistd.h +- + +/home/softcoder/Code/mojosetup/lua/src/lualib.h +lua.h +/home/softcoder/Code/mojosetup/lua/src/lua.h + +/home/softcoder/Code/mojosetup/lua/src/lundump.c +string.h +- +lua.h +/home/softcoder/Code/mojosetup/lua/src/lua.h +ldebug.h +/home/softcoder/Code/mojosetup/lua/src/ldebug.h +ldo.h +/home/softcoder/Code/mojosetup/lua/src/ldo.h +lfunc.h +/home/softcoder/Code/mojosetup/lua/src/lfunc.h +lmem.h +/home/softcoder/Code/mojosetup/lua/src/lmem.h +lobject.h +/home/softcoder/Code/mojosetup/lua/src/lobject.h +lstring.h +/home/softcoder/Code/mojosetup/lua/src/lstring.h +lundump.h +/home/softcoder/Code/mojosetup/lua/src/lundump.h +lzio.h +/home/softcoder/Code/mojosetup/lua/src/lzio.h + +/home/softcoder/Code/mojosetup/lua/src/lundump.h +lobject.h +/home/softcoder/Code/mojosetup/lua/src/lobject.h +lzio.h +/home/softcoder/Code/mojosetup/lua/src/lzio.h + +/home/softcoder/Code/mojosetup/lua/src/lvm.c +stdio.h +- +stdlib.h +- +string.h +- +lua.h +/home/softcoder/Code/mojosetup/lua/src/lua.h +ldebug.h +/home/softcoder/Code/mojosetup/lua/src/ldebug.h +ldo.h +/home/softcoder/Code/mojosetup/lua/src/ldo.h +lfunc.h +/home/softcoder/Code/mojosetup/lua/src/lfunc.h +lgc.h +/home/softcoder/Code/mojosetup/lua/src/lgc.h +lobject.h +/home/softcoder/Code/mojosetup/lua/src/lobject.h +lopcodes.h +/home/softcoder/Code/mojosetup/lua/src/lopcodes.h +lstate.h +/home/softcoder/Code/mojosetup/lua/src/lstate.h +lstring.h +/home/softcoder/Code/mojosetup/lua/src/lstring.h +ltable.h +/home/softcoder/Code/mojosetup/lua/src/ltable.h +ltm.h +/home/softcoder/Code/mojosetup/lua/src/ltm.h +lvm.h +/home/softcoder/Code/mojosetup/lua/src/lvm.h + +/home/softcoder/Code/mojosetup/lua/src/lvm.h +ldo.h +/home/softcoder/Code/mojosetup/lua/src/ldo.h +lobject.h +/home/softcoder/Code/mojosetup/lua/src/lobject.h +ltm.h +/home/softcoder/Code/mojosetup/lua/src/ltm.h + +/home/softcoder/Code/mojosetup/lua/src/lzio.c +string.h +- +lua.h +/home/softcoder/Code/mojosetup/lua/src/lua.h +llimits.h +/home/softcoder/Code/mojosetup/lua/src/llimits.h +lmem.h +/home/softcoder/Code/mojosetup/lua/src/lmem.h +lstate.h +/home/softcoder/Code/mojosetup/lua/src/lstate.h +lzio.h +/home/softcoder/Code/mojosetup/lua/src/lzio.h + +/home/softcoder/Code/mojosetup/lua/src/lzio.h +lua.h +/home/softcoder/Code/mojosetup/lua/src/lua.h +lmem.h +/home/softcoder/Code/mojosetup/lua/src/lmem.h + +/home/softcoder/Code/mojosetup/lua_glue.c +universal.h +/home/softcoder/Code/mojosetup/universal.h +lua_glue.h +/home/softcoder/Code/mojosetup/lua_glue.h +platform.h +/home/softcoder/Code/mojosetup/platform.h +fileio.h +/home/softcoder/Code/mojosetup/fileio.h +lua.h +/home/softcoder/Code/mojosetup/lua.h +lauxlib.h +/home/softcoder/Code/mojosetup/lauxlib.h +lualib.h +/home/softcoder/Code/mojosetup/lualib.h +gui.h +/home/softcoder/Code/mojosetup/gui.h + +/home/softcoder/Code/mojosetup/lua_glue.h +universal.h +/home/softcoder/Code/mojosetup/universal.h + +/home/softcoder/Code/mojosetup/mojosetup.c +stdarg.h +- +universal.h +/home/softcoder/Code/mojosetup/universal.h +platform.h +/home/softcoder/Code/mojosetup/platform.h +gui.h +/home/softcoder/Code/mojosetup/gui.h +lua_glue.h +/home/softcoder/Code/mojosetup/lua_glue.h +fileio.h +/home/softcoder/Code/mojosetup/fileio.h + +/home/softcoder/Code/mojosetup/platform.h +universal.h +/home/softcoder/Code/mojosetup/universal.h + +/home/softcoder/Code/mojosetup/platform_unix.c +Carbon/Carbon.h +- +sys/time.h +- +sys/types.h +- +sys/stat.h +- +sys/param.h +- +sys/utsname.h +- +sys/mount.h +- +stdio.h +- +time.h +- +unistd.h +- +signal.h +- +syslog.h +- +dirent.h +- +fcntl.h +- +sys/wait.h +- +limits.h +- +sys/ucred.h +- +mntent.h +- +sys/mnttab.h +- +dlfcn.h +- +platform.h +/home/softcoder/Code/mojosetup/platform.h +gui.h +/home/softcoder/Code/mojosetup/gui.h +fileio.h +/home/softcoder/Code/mojosetup/fileio.h + +/home/softcoder/Code/mojosetup/platform_windows.c +platform.h +/home/softcoder/Code/mojosetup/platform.h +gui.h +/home/softcoder/Code/mojosetup/gui.h +windows.h +- +shellapi.h +- +io.h +- +fcntl.h +- + +/home/softcoder/Code/mojosetup/stb_image.c +universal.h +/home/softcoder/Code/mojosetup/universal.h +stdio.h +- +math.h +- +string.h +- +stdio.h +- +stdlib.h +- +memory.h +- +assert.h +- +stdarg.h +- + +/home/softcoder/Code/mojosetup/universal.h +stdio.h +- +stdlib.h +- +string.h +- +assert.h +- +time.h +- +malloc.h +- + +/home/softcoder/Code/mojosetup/zlib/zconf.h +windows.h +- +sys/types.h +- +unistd.h +- +unixio.h +- +sys/types.h +- + +/home/softcoder/Code/mojosetup/zlib/zlib.h +zconf.h +/home/softcoder/Code/mojosetup/zlib/zconf.h + diff --git a/mk/linux/mojosetup/build/CMakeFiles/mojosetup.dir/DependInfo.cmake b/mk/linux/mojosetup/build/CMakeFiles/mojosetup.dir/DependInfo.cmake new file mode 100644 index 00000000..bab91290 --- /dev/null +++ b/mk/linux/mojosetup/build/CMakeFiles/mojosetup.dir/DependInfo.cmake @@ -0,0 +1,94 @@ +# The set of languages for which implicit dependencies are needed: +SET(CMAKE_DEPENDS_LANGUAGES + "C" + ) +# The set of files for implicit dependencies of each language: +SET(CMAKE_DEPENDS_CHECK_C + "/home/softcoder/Code/mojosetup/archive_pck.c" "/home/softcoder/Code/mojosetup/build/CMakeFiles/mojosetup.dir/archive_pck.o" + "/home/softcoder/Code/mojosetup/archive_tar.c" "/home/softcoder/Code/mojosetup/build/CMakeFiles/mojosetup.dir/archive_tar.o" + "/home/softcoder/Code/mojosetup/archive_uz2.c" "/home/softcoder/Code/mojosetup/build/CMakeFiles/mojosetup.dir/archive_uz2.o" + "/home/softcoder/Code/mojosetup/archive_zip.c" "/home/softcoder/Code/mojosetup/build/CMakeFiles/mojosetup.dir/archive_zip.o" + "/home/softcoder/Code/mojosetup/buildver.c" "/home/softcoder/Code/mojosetup/build/CMakeFiles/mojosetup.dir/buildver.o" + "/home/softcoder/Code/mojosetup/checksum_crc32.c" "/home/softcoder/Code/mojosetup/build/CMakeFiles/mojosetup.dir/checksum_crc32.o" + "/home/softcoder/Code/mojosetup/checksum_md5.c" "/home/softcoder/Code/mojosetup/build/CMakeFiles/mojosetup.dir/checksum_md5.o" + "/home/softcoder/Code/mojosetup/checksum_sha1.c" "/home/softcoder/Code/mojosetup/build/CMakeFiles/mojosetup.dir/checksum_sha1.o" + "/home/softcoder/Code/mojosetup/fileio.c" "/home/softcoder/Code/mojosetup/build/CMakeFiles/mojosetup.dir/fileio.o" + "/home/softcoder/Code/mojosetup/gui.c" "/home/softcoder/Code/mojosetup/build/CMakeFiles/mojosetup.dir/gui.o" + "/home/softcoder/Code/mojosetup/gui_stdio.c" "/home/softcoder/Code/mojosetup/build/CMakeFiles/mojosetup.dir/gui_stdio.o" + "/home/softcoder/Code/mojosetup/libfetch/common.c" "/home/softcoder/Code/mojosetup/build/CMakeFiles/mojosetup.dir/libfetch/common.o" + "/home/softcoder/Code/mojosetup/libfetch/fetch.c" "/home/softcoder/Code/mojosetup/build/CMakeFiles/mojosetup.dir/libfetch/fetch.o" + "/home/softcoder/Code/mojosetup/libfetch/ftp.c" "/home/softcoder/Code/mojosetup/build/CMakeFiles/mojosetup.dir/libfetch/ftp.o" + "/home/softcoder/Code/mojosetup/libfetch/http.c" "/home/softcoder/Code/mojosetup/build/CMakeFiles/mojosetup.dir/libfetch/http.o" + "/home/softcoder/Code/mojosetup/lua/src/lapi.c" "/home/softcoder/Code/mojosetup/build/CMakeFiles/mojosetup.dir/lua/src/lapi.o" + "/home/softcoder/Code/mojosetup/lua/src/lauxlib.c" "/home/softcoder/Code/mojosetup/build/CMakeFiles/mojosetup.dir/lua/src/lauxlib.o" + "/home/softcoder/Code/mojosetup/lua/src/lbaselib.c" "/home/softcoder/Code/mojosetup/build/CMakeFiles/mojosetup.dir/lua/src/lbaselib.o" + "/home/softcoder/Code/mojosetup/lua/src/lcode.c" "/home/softcoder/Code/mojosetup/build/CMakeFiles/mojosetup.dir/lua/src/lcode.o" + "/home/softcoder/Code/mojosetup/lua/src/ldblib.c" "/home/softcoder/Code/mojosetup/build/CMakeFiles/mojosetup.dir/lua/src/ldblib.o" + "/home/softcoder/Code/mojosetup/lua/src/ldebug.c" "/home/softcoder/Code/mojosetup/build/CMakeFiles/mojosetup.dir/lua/src/ldebug.o" + "/home/softcoder/Code/mojosetup/lua/src/ldo.c" "/home/softcoder/Code/mojosetup/build/CMakeFiles/mojosetup.dir/lua/src/ldo.o" + "/home/softcoder/Code/mojosetup/lua/src/ldump.c" "/home/softcoder/Code/mojosetup/build/CMakeFiles/mojosetup.dir/lua/src/ldump.o" + "/home/softcoder/Code/mojosetup/lua/src/lfunc.c" "/home/softcoder/Code/mojosetup/build/CMakeFiles/mojosetup.dir/lua/src/lfunc.o" + "/home/softcoder/Code/mojosetup/lua/src/lgc.c" "/home/softcoder/Code/mojosetup/build/CMakeFiles/mojosetup.dir/lua/src/lgc.o" + "/home/softcoder/Code/mojosetup/lua/src/liolib.c" "/home/softcoder/Code/mojosetup/build/CMakeFiles/mojosetup.dir/lua/src/liolib.o" + "/home/softcoder/Code/mojosetup/lua/src/llex.c" "/home/softcoder/Code/mojosetup/build/CMakeFiles/mojosetup.dir/lua/src/llex.o" + "/home/softcoder/Code/mojosetup/lua/src/lmathlib.c" "/home/softcoder/Code/mojosetup/build/CMakeFiles/mojosetup.dir/lua/src/lmathlib.o" + "/home/softcoder/Code/mojosetup/lua/src/lmem.c" "/home/softcoder/Code/mojosetup/build/CMakeFiles/mojosetup.dir/lua/src/lmem.o" + "/home/softcoder/Code/mojosetup/lua/src/loadlib.c" "/home/softcoder/Code/mojosetup/build/CMakeFiles/mojosetup.dir/lua/src/loadlib.o" + "/home/softcoder/Code/mojosetup/lua/src/lobject.c" "/home/softcoder/Code/mojosetup/build/CMakeFiles/mojosetup.dir/lua/src/lobject.o" + "/home/softcoder/Code/mojosetup/lua/src/lopcodes.c" "/home/softcoder/Code/mojosetup/build/CMakeFiles/mojosetup.dir/lua/src/lopcodes.o" + "/home/softcoder/Code/mojosetup/lua/src/loslib.c" "/home/softcoder/Code/mojosetup/build/CMakeFiles/mojosetup.dir/lua/src/loslib.o" + "/home/softcoder/Code/mojosetup/lua/src/lparser.c" "/home/softcoder/Code/mojosetup/build/CMakeFiles/mojosetup.dir/lua/src/lparser.o" + "/home/softcoder/Code/mojosetup/lua/src/lstate.c" "/home/softcoder/Code/mojosetup/build/CMakeFiles/mojosetup.dir/lua/src/lstate.o" + "/home/softcoder/Code/mojosetup/lua/src/lstring.c" "/home/softcoder/Code/mojosetup/build/CMakeFiles/mojosetup.dir/lua/src/lstring.o" + "/home/softcoder/Code/mojosetup/lua/src/lstrlib.c" "/home/softcoder/Code/mojosetup/build/CMakeFiles/mojosetup.dir/lua/src/lstrlib.o" + "/home/softcoder/Code/mojosetup/lua/src/ltable.c" "/home/softcoder/Code/mojosetup/build/CMakeFiles/mojosetup.dir/lua/src/ltable.o" + "/home/softcoder/Code/mojosetup/lua/src/ltablib.c" "/home/softcoder/Code/mojosetup/build/CMakeFiles/mojosetup.dir/lua/src/ltablib.o" + "/home/softcoder/Code/mojosetup/lua/src/ltm.c" "/home/softcoder/Code/mojosetup/build/CMakeFiles/mojosetup.dir/lua/src/ltm.o" + "/home/softcoder/Code/mojosetup/lua/src/lundump.c" "/home/softcoder/Code/mojosetup/build/CMakeFiles/mojosetup.dir/lua/src/lundump.o" + "/home/softcoder/Code/mojosetup/lua/src/lvm.c" "/home/softcoder/Code/mojosetup/build/CMakeFiles/mojosetup.dir/lua/src/lvm.o" + "/home/softcoder/Code/mojosetup/lua/src/lzio.c" "/home/softcoder/Code/mojosetup/build/CMakeFiles/mojosetup.dir/lua/src/lzio.o" + "/home/softcoder/Code/mojosetup/lua_glue.c" "/home/softcoder/Code/mojosetup/build/CMakeFiles/mojosetup.dir/lua_glue.o" + "/home/softcoder/Code/mojosetup/mojosetup.c" "/home/softcoder/Code/mojosetup/build/CMakeFiles/mojosetup.dir/mojosetup.o" + "/home/softcoder/Code/mojosetup/platform_unix.c" "/home/softcoder/Code/mojosetup/build/CMakeFiles/mojosetup.dir/platform_unix.o" + "/home/softcoder/Code/mojosetup/platform_windows.c" "/home/softcoder/Code/mojosetup/build/CMakeFiles/mojosetup.dir/platform_windows.o" + "/home/softcoder/Code/mojosetup/stb_image.c" "/home/softcoder/Code/mojosetup/build/CMakeFiles/mojosetup.dir/stb_image.o" + ) +SET(CMAKE_C_COMPILER_ID "GNU") + +# Preprocessor definitions for this target. +SET(CMAKE_TARGET_DEFINITIONS + "__MOJOSETUP__=1" + "APPID=mojosetup" + "_REENTRANT" + "_THREAD_SAFE" + "PLATFORM_UNIX=1" + "LUA_USE_MKSTEMP=1" + "LUA_USE_ULONGJMP=1" + "PLATFORM_LITTLEENDIAN=1" + "SUPPORT_LUALIB_IO=1" + "SUPPORT_LUALIB_OS=1" + "SUPPORT_LUALIB_MATH=1" + "SUPPORT_LUALIB_DB=1" + "SUPPORT_LUALIB_PACKAGE=1" + "SUPPORT_CRC32=1" + "SUPPORT_MD5=1" + "SUPPORT_SHA1=1" + "SUPPORT_GUI_STDIO=1" + "GUI_STATIC_LINK_STDIO=1" + "SUPPORT_GUI_GTKPLUS2=1" + "SUPPORT_ZIP=1" + "SUPPORT_TAR=1" + "SUPPORT_GZIP=1" + "SUPPORT_BZIP2=1" + "BZ_NO_STDIO=1" + "SUPPORT_JPG=1" + "SUPPORT_PNG=1" + "SUPPORT_STBIMAGE=1" + "SUPPORT_URL_HTTP=1" + "SUPPORT_URL_FTP=1" + "MOJOSETUP_HAVE_MNTENT_H=1" + ) + +# Targets to which this target links. +SET(CMAKE_TARGET_LINKED_INFO_FILES + ) diff --git a/mk/linux/mojosetup/build/CMakeFiles/mojosetup.dir/build.make b/mk/linux/mojosetup/build/CMakeFiles/mojosetup.dir/build.make new file mode 100644 index 00000000..6559a1f0 --- /dev/null +++ b/mk/linux/mojosetup/build/CMakeFiles/mojosetup.dir/build.make @@ -0,0 +1,1369 @@ +# CMAKE generated file: DO NOT EDIT! +# Generated by "Unix Makefiles" Generator, CMake Version 2.8 + +#============================================================================= +# Special targets provided by cmake. + +# Disable implicit rules so canoncical targets will work. +.SUFFIXES: + +# Remove some rules from gmake that .SUFFIXES does not remove. +SUFFIXES = + +.SUFFIXES: .hpux_make_needs_suffix_list + +# Suppress display of executed commands. +$(VERBOSE).SILENT: + +# A target that is always out of date. +cmake_force: +.PHONY : cmake_force + +#============================================================================= +# Set environment variables for the build. + +# The shell in which to execute make rules. +SHELL = /bin/sh + +# The CMake executable. +CMAKE_COMMAND = /usr/bin/cmake + +# The command to remove a file. +RM = /usr/bin/cmake -E remove -f + +# The top-level source directory on which CMake was run. +CMAKE_SOURCE_DIR = /home/softcoder/Code/mojosetup + +# The top-level build directory on which CMake was run. +CMAKE_BINARY_DIR = /home/softcoder/Code/mojosetup/build + +# Include any dependencies generated for this target. +include CMakeFiles/mojosetup.dir/depend.make + +# Include the progress variables for this target. +include CMakeFiles/mojosetup.dir/progress.make + +# Include the compile flags for this target's objects. +include CMakeFiles/mojosetup.dir/flags.make + +CMakeFiles/mojosetup.dir/buildver.o: CMakeFiles/mojosetup.dir/flags.make +CMakeFiles/mojosetup.dir/buildver.o: ../buildver.c + $(CMAKE_COMMAND) -E cmake_progress_report /home/softcoder/Code/mojosetup/build/CMakeFiles $(CMAKE_PROGRESS_1) + @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green "Building C object CMakeFiles/mojosetup.dir/buildver.o" + /usr/bin/gcc $(C_DEFINES) $(C_FLAGS) -o CMakeFiles/mojosetup.dir/buildver.o -c /home/softcoder/Code/mojosetup/buildver.c + +CMakeFiles/mojosetup.dir/buildver.i: cmake_force + @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green "Preprocessing C source to CMakeFiles/mojosetup.dir/buildver.i" + /usr/bin/gcc $(C_DEFINES) $(C_FLAGS) -E /home/softcoder/Code/mojosetup/buildver.c > CMakeFiles/mojosetup.dir/buildver.i + +CMakeFiles/mojosetup.dir/buildver.s: cmake_force + @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green "Compiling C source to assembly CMakeFiles/mojosetup.dir/buildver.s" + /usr/bin/gcc $(C_DEFINES) $(C_FLAGS) -S /home/softcoder/Code/mojosetup/buildver.c -o CMakeFiles/mojosetup.dir/buildver.s + +CMakeFiles/mojosetup.dir/buildver.o.requires: +.PHONY : CMakeFiles/mojosetup.dir/buildver.o.requires + +CMakeFiles/mojosetup.dir/buildver.o.provides: CMakeFiles/mojosetup.dir/buildver.o.requires + $(MAKE) -f CMakeFiles/mojosetup.dir/build.make CMakeFiles/mojosetup.dir/buildver.o.provides.build +.PHONY : CMakeFiles/mojosetup.dir/buildver.o.provides + +CMakeFiles/mojosetup.dir/buildver.o.provides.build: CMakeFiles/mojosetup.dir/buildver.o +.PHONY : CMakeFiles/mojosetup.dir/buildver.o.provides.build + +CMakeFiles/mojosetup.dir/mojosetup.o: CMakeFiles/mojosetup.dir/flags.make +CMakeFiles/mojosetup.dir/mojosetup.o: ../mojosetup.c + $(CMAKE_COMMAND) -E cmake_progress_report /home/softcoder/Code/mojosetup/build/CMakeFiles $(CMAKE_PROGRESS_2) + @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green "Building C object CMakeFiles/mojosetup.dir/mojosetup.o" + /usr/bin/gcc $(C_DEFINES) $(C_FLAGS) -o CMakeFiles/mojosetup.dir/mojosetup.o -c /home/softcoder/Code/mojosetup/mojosetup.c + +CMakeFiles/mojosetup.dir/mojosetup.i: cmake_force + @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green "Preprocessing C source to CMakeFiles/mojosetup.dir/mojosetup.i" + /usr/bin/gcc $(C_DEFINES) $(C_FLAGS) -E /home/softcoder/Code/mojosetup/mojosetup.c > CMakeFiles/mojosetup.dir/mojosetup.i + +CMakeFiles/mojosetup.dir/mojosetup.s: cmake_force + @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green "Compiling C source to assembly CMakeFiles/mojosetup.dir/mojosetup.s" + /usr/bin/gcc $(C_DEFINES) $(C_FLAGS) -S /home/softcoder/Code/mojosetup/mojosetup.c -o CMakeFiles/mojosetup.dir/mojosetup.s + +CMakeFiles/mojosetup.dir/mojosetup.o.requires: +.PHONY : CMakeFiles/mojosetup.dir/mojosetup.o.requires + +CMakeFiles/mojosetup.dir/mojosetup.o.provides: CMakeFiles/mojosetup.dir/mojosetup.o.requires + $(MAKE) -f CMakeFiles/mojosetup.dir/build.make CMakeFiles/mojosetup.dir/mojosetup.o.provides.build +.PHONY : CMakeFiles/mojosetup.dir/mojosetup.o.provides + +CMakeFiles/mojosetup.dir/mojosetup.o.provides.build: CMakeFiles/mojosetup.dir/mojosetup.o +.PHONY : CMakeFiles/mojosetup.dir/mojosetup.o.provides.build + +CMakeFiles/mojosetup.dir/gui.o: CMakeFiles/mojosetup.dir/flags.make +CMakeFiles/mojosetup.dir/gui.o: ../gui.c + $(CMAKE_COMMAND) -E cmake_progress_report /home/softcoder/Code/mojosetup/build/CMakeFiles $(CMAKE_PROGRESS_3) + @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green "Building C object CMakeFiles/mojosetup.dir/gui.o" + /usr/bin/gcc $(C_DEFINES) $(C_FLAGS) -o CMakeFiles/mojosetup.dir/gui.o -c /home/softcoder/Code/mojosetup/gui.c + +CMakeFiles/mojosetup.dir/gui.i: cmake_force + @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green "Preprocessing C source to CMakeFiles/mojosetup.dir/gui.i" + /usr/bin/gcc $(C_DEFINES) $(C_FLAGS) -E /home/softcoder/Code/mojosetup/gui.c > CMakeFiles/mojosetup.dir/gui.i + +CMakeFiles/mojosetup.dir/gui.s: cmake_force + @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green "Compiling C source to assembly CMakeFiles/mojosetup.dir/gui.s" + /usr/bin/gcc $(C_DEFINES) $(C_FLAGS) -S /home/softcoder/Code/mojosetup/gui.c -o CMakeFiles/mojosetup.dir/gui.s + +CMakeFiles/mojosetup.dir/gui.o.requires: +.PHONY : CMakeFiles/mojosetup.dir/gui.o.requires + +CMakeFiles/mojosetup.dir/gui.o.provides: CMakeFiles/mojosetup.dir/gui.o.requires + $(MAKE) -f CMakeFiles/mojosetup.dir/build.make CMakeFiles/mojosetup.dir/gui.o.provides.build +.PHONY : CMakeFiles/mojosetup.dir/gui.o.provides + +CMakeFiles/mojosetup.dir/gui.o.provides.build: CMakeFiles/mojosetup.dir/gui.o +.PHONY : CMakeFiles/mojosetup.dir/gui.o.provides.build + +CMakeFiles/mojosetup.dir/fileio.o: CMakeFiles/mojosetup.dir/flags.make +CMakeFiles/mojosetup.dir/fileio.o: ../fileio.c + $(CMAKE_COMMAND) -E cmake_progress_report /home/softcoder/Code/mojosetup/build/CMakeFiles $(CMAKE_PROGRESS_4) + @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green "Building C object CMakeFiles/mojosetup.dir/fileio.o" + /usr/bin/gcc $(C_DEFINES) $(C_FLAGS) -o CMakeFiles/mojosetup.dir/fileio.o -c /home/softcoder/Code/mojosetup/fileio.c + +CMakeFiles/mojosetup.dir/fileio.i: cmake_force + @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green "Preprocessing C source to CMakeFiles/mojosetup.dir/fileio.i" + /usr/bin/gcc $(C_DEFINES) $(C_FLAGS) -E /home/softcoder/Code/mojosetup/fileio.c > CMakeFiles/mojosetup.dir/fileio.i + +CMakeFiles/mojosetup.dir/fileio.s: cmake_force + @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green "Compiling C source to assembly CMakeFiles/mojosetup.dir/fileio.s" + /usr/bin/gcc $(C_DEFINES) $(C_FLAGS) -S /home/softcoder/Code/mojosetup/fileio.c -o CMakeFiles/mojosetup.dir/fileio.s + +CMakeFiles/mojosetup.dir/fileio.o.requires: +.PHONY : CMakeFiles/mojosetup.dir/fileio.o.requires + +CMakeFiles/mojosetup.dir/fileio.o.provides: CMakeFiles/mojosetup.dir/fileio.o.requires + $(MAKE) -f CMakeFiles/mojosetup.dir/build.make CMakeFiles/mojosetup.dir/fileio.o.provides.build +.PHONY : CMakeFiles/mojosetup.dir/fileio.o.provides + +CMakeFiles/mojosetup.dir/fileio.o.provides.build: CMakeFiles/mojosetup.dir/fileio.o +.PHONY : CMakeFiles/mojosetup.dir/fileio.o.provides.build + +CMakeFiles/mojosetup.dir/archive_zip.o: CMakeFiles/mojosetup.dir/flags.make +CMakeFiles/mojosetup.dir/archive_zip.o: ../archive_zip.c + $(CMAKE_COMMAND) -E cmake_progress_report /home/softcoder/Code/mojosetup/build/CMakeFiles $(CMAKE_PROGRESS_5) + @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green "Building C object CMakeFiles/mojosetup.dir/archive_zip.o" + /usr/bin/gcc $(C_DEFINES) $(C_FLAGS) -o CMakeFiles/mojosetup.dir/archive_zip.o -c /home/softcoder/Code/mojosetup/archive_zip.c + +CMakeFiles/mojosetup.dir/archive_zip.i: cmake_force + @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green "Preprocessing C source to CMakeFiles/mojosetup.dir/archive_zip.i" + /usr/bin/gcc $(C_DEFINES) $(C_FLAGS) -E /home/softcoder/Code/mojosetup/archive_zip.c > CMakeFiles/mojosetup.dir/archive_zip.i + +CMakeFiles/mojosetup.dir/archive_zip.s: cmake_force + @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green "Compiling C source to assembly CMakeFiles/mojosetup.dir/archive_zip.s" + /usr/bin/gcc $(C_DEFINES) $(C_FLAGS) -S /home/softcoder/Code/mojosetup/archive_zip.c -o CMakeFiles/mojosetup.dir/archive_zip.s + +CMakeFiles/mojosetup.dir/archive_zip.o.requires: +.PHONY : CMakeFiles/mojosetup.dir/archive_zip.o.requires + +CMakeFiles/mojosetup.dir/archive_zip.o.provides: CMakeFiles/mojosetup.dir/archive_zip.o.requires + $(MAKE) -f CMakeFiles/mojosetup.dir/build.make CMakeFiles/mojosetup.dir/archive_zip.o.provides.build +.PHONY : CMakeFiles/mojosetup.dir/archive_zip.o.provides + +CMakeFiles/mojosetup.dir/archive_zip.o.provides.build: CMakeFiles/mojosetup.dir/archive_zip.o +.PHONY : CMakeFiles/mojosetup.dir/archive_zip.o.provides.build + +CMakeFiles/mojosetup.dir/archive_tar.o: CMakeFiles/mojosetup.dir/flags.make +CMakeFiles/mojosetup.dir/archive_tar.o: ../archive_tar.c + $(CMAKE_COMMAND) -E cmake_progress_report /home/softcoder/Code/mojosetup/build/CMakeFiles $(CMAKE_PROGRESS_6) + @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green "Building C object CMakeFiles/mojosetup.dir/archive_tar.o" + /usr/bin/gcc $(C_DEFINES) $(C_FLAGS) -o CMakeFiles/mojosetup.dir/archive_tar.o -c /home/softcoder/Code/mojosetup/archive_tar.c + +CMakeFiles/mojosetup.dir/archive_tar.i: cmake_force + @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green "Preprocessing C source to CMakeFiles/mojosetup.dir/archive_tar.i" + /usr/bin/gcc $(C_DEFINES) $(C_FLAGS) -E /home/softcoder/Code/mojosetup/archive_tar.c > CMakeFiles/mojosetup.dir/archive_tar.i + +CMakeFiles/mojosetup.dir/archive_tar.s: cmake_force + @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green "Compiling C source to assembly CMakeFiles/mojosetup.dir/archive_tar.s" + /usr/bin/gcc $(C_DEFINES) $(C_FLAGS) -S /home/softcoder/Code/mojosetup/archive_tar.c -o CMakeFiles/mojosetup.dir/archive_tar.s + +CMakeFiles/mojosetup.dir/archive_tar.o.requires: +.PHONY : CMakeFiles/mojosetup.dir/archive_tar.o.requires + +CMakeFiles/mojosetup.dir/archive_tar.o.provides: CMakeFiles/mojosetup.dir/archive_tar.o.requires + $(MAKE) -f CMakeFiles/mojosetup.dir/build.make CMakeFiles/mojosetup.dir/archive_tar.o.provides.build +.PHONY : CMakeFiles/mojosetup.dir/archive_tar.o.provides + +CMakeFiles/mojosetup.dir/archive_tar.o.provides.build: CMakeFiles/mojosetup.dir/archive_tar.o +.PHONY : CMakeFiles/mojosetup.dir/archive_tar.o.provides.build + +CMakeFiles/mojosetup.dir/archive_uz2.o: CMakeFiles/mojosetup.dir/flags.make +CMakeFiles/mojosetup.dir/archive_uz2.o: ../archive_uz2.c + $(CMAKE_COMMAND) -E cmake_progress_report /home/softcoder/Code/mojosetup/build/CMakeFiles $(CMAKE_PROGRESS_7) + @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green "Building C object CMakeFiles/mojosetup.dir/archive_uz2.o" + /usr/bin/gcc $(C_DEFINES) $(C_FLAGS) -o CMakeFiles/mojosetup.dir/archive_uz2.o -c /home/softcoder/Code/mojosetup/archive_uz2.c + +CMakeFiles/mojosetup.dir/archive_uz2.i: cmake_force + @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green "Preprocessing C source to CMakeFiles/mojosetup.dir/archive_uz2.i" + /usr/bin/gcc $(C_DEFINES) $(C_FLAGS) -E /home/softcoder/Code/mojosetup/archive_uz2.c > CMakeFiles/mojosetup.dir/archive_uz2.i + +CMakeFiles/mojosetup.dir/archive_uz2.s: cmake_force + @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green "Compiling C source to assembly CMakeFiles/mojosetup.dir/archive_uz2.s" + /usr/bin/gcc $(C_DEFINES) $(C_FLAGS) -S /home/softcoder/Code/mojosetup/archive_uz2.c -o CMakeFiles/mojosetup.dir/archive_uz2.s + +CMakeFiles/mojosetup.dir/archive_uz2.o.requires: +.PHONY : CMakeFiles/mojosetup.dir/archive_uz2.o.requires + +CMakeFiles/mojosetup.dir/archive_uz2.o.provides: CMakeFiles/mojosetup.dir/archive_uz2.o.requires + $(MAKE) -f CMakeFiles/mojosetup.dir/build.make CMakeFiles/mojosetup.dir/archive_uz2.o.provides.build +.PHONY : CMakeFiles/mojosetup.dir/archive_uz2.o.provides + +CMakeFiles/mojosetup.dir/archive_uz2.o.provides.build: CMakeFiles/mojosetup.dir/archive_uz2.o +.PHONY : CMakeFiles/mojosetup.dir/archive_uz2.o.provides.build + +CMakeFiles/mojosetup.dir/archive_pck.o: CMakeFiles/mojosetup.dir/flags.make +CMakeFiles/mojosetup.dir/archive_pck.o: ../archive_pck.c + $(CMAKE_COMMAND) -E cmake_progress_report /home/softcoder/Code/mojosetup/build/CMakeFiles $(CMAKE_PROGRESS_8) + @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green "Building C object CMakeFiles/mojosetup.dir/archive_pck.o" + /usr/bin/gcc $(C_DEFINES) $(C_FLAGS) -o CMakeFiles/mojosetup.dir/archive_pck.o -c /home/softcoder/Code/mojosetup/archive_pck.c + +CMakeFiles/mojosetup.dir/archive_pck.i: cmake_force + @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green "Preprocessing C source to CMakeFiles/mojosetup.dir/archive_pck.i" + /usr/bin/gcc $(C_DEFINES) $(C_FLAGS) -E /home/softcoder/Code/mojosetup/archive_pck.c > CMakeFiles/mojosetup.dir/archive_pck.i + +CMakeFiles/mojosetup.dir/archive_pck.s: cmake_force + @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green "Compiling C source to assembly CMakeFiles/mojosetup.dir/archive_pck.s" + /usr/bin/gcc $(C_DEFINES) $(C_FLAGS) -S /home/softcoder/Code/mojosetup/archive_pck.c -o CMakeFiles/mojosetup.dir/archive_pck.s + +CMakeFiles/mojosetup.dir/archive_pck.o.requires: +.PHONY : CMakeFiles/mojosetup.dir/archive_pck.o.requires + +CMakeFiles/mojosetup.dir/archive_pck.o.provides: CMakeFiles/mojosetup.dir/archive_pck.o.requires + $(MAKE) -f CMakeFiles/mojosetup.dir/build.make CMakeFiles/mojosetup.dir/archive_pck.o.provides.build +.PHONY : CMakeFiles/mojosetup.dir/archive_pck.o.provides + +CMakeFiles/mojosetup.dir/archive_pck.o.provides.build: CMakeFiles/mojosetup.dir/archive_pck.o +.PHONY : CMakeFiles/mojosetup.dir/archive_pck.o.provides.build + +CMakeFiles/mojosetup.dir/checksum_crc32.o: CMakeFiles/mojosetup.dir/flags.make +CMakeFiles/mojosetup.dir/checksum_crc32.o: ../checksum_crc32.c + $(CMAKE_COMMAND) -E cmake_progress_report /home/softcoder/Code/mojosetup/build/CMakeFiles $(CMAKE_PROGRESS_9) + @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green "Building C object CMakeFiles/mojosetup.dir/checksum_crc32.o" + /usr/bin/gcc $(C_DEFINES) $(C_FLAGS) -o CMakeFiles/mojosetup.dir/checksum_crc32.o -c /home/softcoder/Code/mojosetup/checksum_crc32.c + +CMakeFiles/mojosetup.dir/checksum_crc32.i: cmake_force + @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green "Preprocessing C source to CMakeFiles/mojosetup.dir/checksum_crc32.i" + /usr/bin/gcc $(C_DEFINES) $(C_FLAGS) -E /home/softcoder/Code/mojosetup/checksum_crc32.c > CMakeFiles/mojosetup.dir/checksum_crc32.i + +CMakeFiles/mojosetup.dir/checksum_crc32.s: cmake_force + @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green "Compiling C source to assembly CMakeFiles/mojosetup.dir/checksum_crc32.s" + /usr/bin/gcc $(C_DEFINES) $(C_FLAGS) -S /home/softcoder/Code/mojosetup/checksum_crc32.c -o CMakeFiles/mojosetup.dir/checksum_crc32.s + +CMakeFiles/mojosetup.dir/checksum_crc32.o.requires: +.PHONY : CMakeFiles/mojosetup.dir/checksum_crc32.o.requires + +CMakeFiles/mojosetup.dir/checksum_crc32.o.provides: CMakeFiles/mojosetup.dir/checksum_crc32.o.requires + $(MAKE) -f CMakeFiles/mojosetup.dir/build.make CMakeFiles/mojosetup.dir/checksum_crc32.o.provides.build +.PHONY : CMakeFiles/mojosetup.dir/checksum_crc32.o.provides + +CMakeFiles/mojosetup.dir/checksum_crc32.o.provides.build: CMakeFiles/mojosetup.dir/checksum_crc32.o +.PHONY : CMakeFiles/mojosetup.dir/checksum_crc32.o.provides.build + +CMakeFiles/mojosetup.dir/checksum_md5.o: CMakeFiles/mojosetup.dir/flags.make +CMakeFiles/mojosetup.dir/checksum_md5.o: ../checksum_md5.c + $(CMAKE_COMMAND) -E cmake_progress_report /home/softcoder/Code/mojosetup/build/CMakeFiles $(CMAKE_PROGRESS_10) + @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green "Building C object CMakeFiles/mojosetup.dir/checksum_md5.o" + /usr/bin/gcc $(C_DEFINES) $(C_FLAGS) -o CMakeFiles/mojosetup.dir/checksum_md5.o -c /home/softcoder/Code/mojosetup/checksum_md5.c + +CMakeFiles/mojosetup.dir/checksum_md5.i: cmake_force + @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green "Preprocessing C source to CMakeFiles/mojosetup.dir/checksum_md5.i" + /usr/bin/gcc $(C_DEFINES) $(C_FLAGS) -E /home/softcoder/Code/mojosetup/checksum_md5.c > CMakeFiles/mojosetup.dir/checksum_md5.i + +CMakeFiles/mojosetup.dir/checksum_md5.s: cmake_force + @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green "Compiling C source to assembly CMakeFiles/mojosetup.dir/checksum_md5.s" + /usr/bin/gcc $(C_DEFINES) $(C_FLAGS) -S /home/softcoder/Code/mojosetup/checksum_md5.c -o CMakeFiles/mojosetup.dir/checksum_md5.s + +CMakeFiles/mojosetup.dir/checksum_md5.o.requires: +.PHONY : CMakeFiles/mojosetup.dir/checksum_md5.o.requires + +CMakeFiles/mojosetup.dir/checksum_md5.o.provides: CMakeFiles/mojosetup.dir/checksum_md5.o.requires + $(MAKE) -f CMakeFiles/mojosetup.dir/build.make CMakeFiles/mojosetup.dir/checksum_md5.o.provides.build +.PHONY : CMakeFiles/mojosetup.dir/checksum_md5.o.provides + +CMakeFiles/mojosetup.dir/checksum_md5.o.provides.build: CMakeFiles/mojosetup.dir/checksum_md5.o +.PHONY : CMakeFiles/mojosetup.dir/checksum_md5.o.provides.build + +CMakeFiles/mojosetup.dir/checksum_sha1.o: CMakeFiles/mojosetup.dir/flags.make +CMakeFiles/mojosetup.dir/checksum_sha1.o: ../checksum_sha1.c + $(CMAKE_COMMAND) -E cmake_progress_report /home/softcoder/Code/mojosetup/build/CMakeFiles $(CMAKE_PROGRESS_11) + @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green "Building C object CMakeFiles/mojosetup.dir/checksum_sha1.o" + /usr/bin/gcc $(C_DEFINES) $(C_FLAGS) -o CMakeFiles/mojosetup.dir/checksum_sha1.o -c /home/softcoder/Code/mojosetup/checksum_sha1.c + +CMakeFiles/mojosetup.dir/checksum_sha1.i: cmake_force + @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green "Preprocessing C source to CMakeFiles/mojosetup.dir/checksum_sha1.i" + /usr/bin/gcc $(C_DEFINES) $(C_FLAGS) -E /home/softcoder/Code/mojosetup/checksum_sha1.c > CMakeFiles/mojosetup.dir/checksum_sha1.i + +CMakeFiles/mojosetup.dir/checksum_sha1.s: cmake_force + @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green "Compiling C source to assembly CMakeFiles/mojosetup.dir/checksum_sha1.s" + /usr/bin/gcc $(C_DEFINES) $(C_FLAGS) -S /home/softcoder/Code/mojosetup/checksum_sha1.c -o CMakeFiles/mojosetup.dir/checksum_sha1.s + +CMakeFiles/mojosetup.dir/checksum_sha1.o.requires: +.PHONY : CMakeFiles/mojosetup.dir/checksum_sha1.o.requires + +CMakeFiles/mojosetup.dir/checksum_sha1.o.provides: CMakeFiles/mojosetup.dir/checksum_sha1.o.requires + $(MAKE) -f CMakeFiles/mojosetup.dir/build.make CMakeFiles/mojosetup.dir/checksum_sha1.o.provides.build +.PHONY : CMakeFiles/mojosetup.dir/checksum_sha1.o.provides + +CMakeFiles/mojosetup.dir/checksum_sha1.o.provides.build: CMakeFiles/mojosetup.dir/checksum_sha1.o +.PHONY : CMakeFiles/mojosetup.dir/checksum_sha1.o.provides.build + +CMakeFiles/mojosetup.dir/platform_unix.o: CMakeFiles/mojosetup.dir/flags.make +CMakeFiles/mojosetup.dir/platform_unix.o: ../platform_unix.c + $(CMAKE_COMMAND) -E cmake_progress_report /home/softcoder/Code/mojosetup/build/CMakeFiles $(CMAKE_PROGRESS_12) + @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green "Building C object CMakeFiles/mojosetup.dir/platform_unix.o" + /usr/bin/gcc $(C_DEFINES) $(C_FLAGS) -o CMakeFiles/mojosetup.dir/platform_unix.o -c /home/softcoder/Code/mojosetup/platform_unix.c + +CMakeFiles/mojosetup.dir/platform_unix.i: cmake_force + @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green "Preprocessing C source to CMakeFiles/mojosetup.dir/platform_unix.i" + /usr/bin/gcc $(C_DEFINES) $(C_FLAGS) -E /home/softcoder/Code/mojosetup/platform_unix.c > CMakeFiles/mojosetup.dir/platform_unix.i + +CMakeFiles/mojosetup.dir/platform_unix.s: cmake_force + @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green "Compiling C source to assembly CMakeFiles/mojosetup.dir/platform_unix.s" + /usr/bin/gcc $(C_DEFINES) $(C_FLAGS) -S /home/softcoder/Code/mojosetup/platform_unix.c -o CMakeFiles/mojosetup.dir/platform_unix.s + +CMakeFiles/mojosetup.dir/platform_unix.o.requires: +.PHONY : CMakeFiles/mojosetup.dir/platform_unix.o.requires + +CMakeFiles/mojosetup.dir/platform_unix.o.provides: CMakeFiles/mojosetup.dir/platform_unix.o.requires + $(MAKE) -f CMakeFiles/mojosetup.dir/build.make CMakeFiles/mojosetup.dir/platform_unix.o.provides.build +.PHONY : CMakeFiles/mojosetup.dir/platform_unix.o.provides + +CMakeFiles/mojosetup.dir/platform_unix.o.provides.build: CMakeFiles/mojosetup.dir/platform_unix.o +.PHONY : CMakeFiles/mojosetup.dir/platform_unix.o.provides.build + +CMakeFiles/mojosetup.dir/platform_windows.o: CMakeFiles/mojosetup.dir/flags.make +CMakeFiles/mojosetup.dir/platform_windows.o: ../platform_windows.c + $(CMAKE_COMMAND) -E cmake_progress_report /home/softcoder/Code/mojosetup/build/CMakeFiles $(CMAKE_PROGRESS_13) + @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green "Building C object CMakeFiles/mojosetup.dir/platform_windows.o" + /usr/bin/gcc $(C_DEFINES) $(C_FLAGS) -o CMakeFiles/mojosetup.dir/platform_windows.o -c /home/softcoder/Code/mojosetup/platform_windows.c + +CMakeFiles/mojosetup.dir/platform_windows.i: cmake_force + @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green "Preprocessing C source to CMakeFiles/mojosetup.dir/platform_windows.i" + /usr/bin/gcc $(C_DEFINES) $(C_FLAGS) -E /home/softcoder/Code/mojosetup/platform_windows.c > CMakeFiles/mojosetup.dir/platform_windows.i + +CMakeFiles/mojosetup.dir/platform_windows.s: cmake_force + @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green "Compiling C source to assembly CMakeFiles/mojosetup.dir/platform_windows.s" + /usr/bin/gcc $(C_DEFINES) $(C_FLAGS) -S /home/softcoder/Code/mojosetup/platform_windows.c -o CMakeFiles/mojosetup.dir/platform_windows.s + +CMakeFiles/mojosetup.dir/platform_windows.o.requires: +.PHONY : CMakeFiles/mojosetup.dir/platform_windows.o.requires + +CMakeFiles/mojosetup.dir/platform_windows.o.provides: CMakeFiles/mojosetup.dir/platform_windows.o.requires + $(MAKE) -f CMakeFiles/mojosetup.dir/build.make CMakeFiles/mojosetup.dir/platform_windows.o.provides.build +.PHONY : CMakeFiles/mojosetup.dir/platform_windows.o.provides + +CMakeFiles/mojosetup.dir/platform_windows.o.provides.build: CMakeFiles/mojosetup.dir/platform_windows.o +.PHONY : CMakeFiles/mojosetup.dir/platform_windows.o.provides.build + +CMakeFiles/mojosetup.dir/lua_glue.o: CMakeFiles/mojosetup.dir/flags.make +CMakeFiles/mojosetup.dir/lua_glue.o: ../lua_glue.c + $(CMAKE_COMMAND) -E cmake_progress_report /home/softcoder/Code/mojosetup/build/CMakeFiles $(CMAKE_PROGRESS_14) + @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green "Building C object CMakeFiles/mojosetup.dir/lua_glue.o" + /usr/bin/gcc $(C_DEFINES) $(C_FLAGS) -o CMakeFiles/mojosetup.dir/lua_glue.o -c /home/softcoder/Code/mojosetup/lua_glue.c + +CMakeFiles/mojosetup.dir/lua_glue.i: cmake_force + @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green "Preprocessing C source to CMakeFiles/mojosetup.dir/lua_glue.i" + /usr/bin/gcc $(C_DEFINES) $(C_FLAGS) -E /home/softcoder/Code/mojosetup/lua_glue.c > CMakeFiles/mojosetup.dir/lua_glue.i + +CMakeFiles/mojosetup.dir/lua_glue.s: cmake_force + @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green "Compiling C source to assembly CMakeFiles/mojosetup.dir/lua_glue.s" + /usr/bin/gcc $(C_DEFINES) $(C_FLAGS) -S /home/softcoder/Code/mojosetup/lua_glue.c -o CMakeFiles/mojosetup.dir/lua_glue.s + +CMakeFiles/mojosetup.dir/lua_glue.o.requires: +.PHONY : CMakeFiles/mojosetup.dir/lua_glue.o.requires + +CMakeFiles/mojosetup.dir/lua_glue.o.provides: CMakeFiles/mojosetup.dir/lua_glue.o.requires + $(MAKE) -f CMakeFiles/mojosetup.dir/build.make CMakeFiles/mojosetup.dir/lua_glue.o.provides.build +.PHONY : CMakeFiles/mojosetup.dir/lua_glue.o.provides + +CMakeFiles/mojosetup.dir/lua_glue.o.provides.build: CMakeFiles/mojosetup.dir/lua_glue.o +.PHONY : CMakeFiles/mojosetup.dir/lua_glue.o.provides.build + +CMakeFiles/mojosetup.dir/lua/src/lapi.o: CMakeFiles/mojosetup.dir/flags.make +CMakeFiles/mojosetup.dir/lua/src/lapi.o: ../lua/src/lapi.c + $(CMAKE_COMMAND) -E cmake_progress_report /home/softcoder/Code/mojosetup/build/CMakeFiles $(CMAKE_PROGRESS_15) + @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green "Building C object CMakeFiles/mojosetup.dir/lua/src/lapi.o" + /usr/bin/gcc $(C_DEFINES) $(C_FLAGS) -o CMakeFiles/mojosetup.dir/lua/src/lapi.o -c /home/softcoder/Code/mojosetup/lua/src/lapi.c + +CMakeFiles/mojosetup.dir/lua/src/lapi.i: cmake_force + @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green "Preprocessing C source to CMakeFiles/mojosetup.dir/lua/src/lapi.i" + /usr/bin/gcc $(C_DEFINES) $(C_FLAGS) -E /home/softcoder/Code/mojosetup/lua/src/lapi.c > CMakeFiles/mojosetup.dir/lua/src/lapi.i + +CMakeFiles/mojosetup.dir/lua/src/lapi.s: cmake_force + @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green "Compiling C source to assembly CMakeFiles/mojosetup.dir/lua/src/lapi.s" + /usr/bin/gcc $(C_DEFINES) $(C_FLAGS) -S /home/softcoder/Code/mojosetup/lua/src/lapi.c -o CMakeFiles/mojosetup.dir/lua/src/lapi.s + +CMakeFiles/mojosetup.dir/lua/src/lapi.o.requires: +.PHONY : CMakeFiles/mojosetup.dir/lua/src/lapi.o.requires + +CMakeFiles/mojosetup.dir/lua/src/lapi.o.provides: CMakeFiles/mojosetup.dir/lua/src/lapi.o.requires + $(MAKE) -f CMakeFiles/mojosetup.dir/build.make CMakeFiles/mojosetup.dir/lua/src/lapi.o.provides.build +.PHONY : CMakeFiles/mojosetup.dir/lua/src/lapi.o.provides + +CMakeFiles/mojosetup.dir/lua/src/lapi.o.provides.build: CMakeFiles/mojosetup.dir/lua/src/lapi.o +.PHONY : CMakeFiles/mojosetup.dir/lua/src/lapi.o.provides.build + +CMakeFiles/mojosetup.dir/lua/src/ldebug.o: CMakeFiles/mojosetup.dir/flags.make +CMakeFiles/mojosetup.dir/lua/src/ldebug.o: ../lua/src/ldebug.c + $(CMAKE_COMMAND) -E cmake_progress_report /home/softcoder/Code/mojosetup/build/CMakeFiles $(CMAKE_PROGRESS_16) + @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green "Building C object CMakeFiles/mojosetup.dir/lua/src/ldebug.o" + /usr/bin/gcc $(C_DEFINES) $(C_FLAGS) -o CMakeFiles/mojosetup.dir/lua/src/ldebug.o -c /home/softcoder/Code/mojosetup/lua/src/ldebug.c + +CMakeFiles/mojosetup.dir/lua/src/ldebug.i: cmake_force + @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green "Preprocessing C source to CMakeFiles/mojosetup.dir/lua/src/ldebug.i" + /usr/bin/gcc $(C_DEFINES) $(C_FLAGS) -E /home/softcoder/Code/mojosetup/lua/src/ldebug.c > CMakeFiles/mojosetup.dir/lua/src/ldebug.i + +CMakeFiles/mojosetup.dir/lua/src/ldebug.s: cmake_force + @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green "Compiling C source to assembly CMakeFiles/mojosetup.dir/lua/src/ldebug.s" + /usr/bin/gcc $(C_DEFINES) $(C_FLAGS) -S /home/softcoder/Code/mojosetup/lua/src/ldebug.c -o CMakeFiles/mojosetup.dir/lua/src/ldebug.s + +CMakeFiles/mojosetup.dir/lua/src/ldebug.o.requires: +.PHONY : CMakeFiles/mojosetup.dir/lua/src/ldebug.o.requires + +CMakeFiles/mojosetup.dir/lua/src/ldebug.o.provides: CMakeFiles/mojosetup.dir/lua/src/ldebug.o.requires + $(MAKE) -f CMakeFiles/mojosetup.dir/build.make CMakeFiles/mojosetup.dir/lua/src/ldebug.o.provides.build +.PHONY : CMakeFiles/mojosetup.dir/lua/src/ldebug.o.provides + +CMakeFiles/mojosetup.dir/lua/src/ldebug.o.provides.build: CMakeFiles/mojosetup.dir/lua/src/ldebug.o +.PHONY : CMakeFiles/mojosetup.dir/lua/src/ldebug.o.provides.build + +CMakeFiles/mojosetup.dir/lua/src/ldo.o: CMakeFiles/mojosetup.dir/flags.make +CMakeFiles/mojosetup.dir/lua/src/ldo.o: ../lua/src/ldo.c + $(CMAKE_COMMAND) -E cmake_progress_report /home/softcoder/Code/mojosetup/build/CMakeFiles $(CMAKE_PROGRESS_17) + @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green "Building C object CMakeFiles/mojosetup.dir/lua/src/ldo.o" + /usr/bin/gcc $(C_DEFINES) $(C_FLAGS) -o CMakeFiles/mojosetup.dir/lua/src/ldo.o -c /home/softcoder/Code/mojosetup/lua/src/ldo.c + +CMakeFiles/mojosetup.dir/lua/src/ldo.i: cmake_force + @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green "Preprocessing C source to CMakeFiles/mojosetup.dir/lua/src/ldo.i" + /usr/bin/gcc $(C_DEFINES) $(C_FLAGS) -E /home/softcoder/Code/mojosetup/lua/src/ldo.c > CMakeFiles/mojosetup.dir/lua/src/ldo.i + +CMakeFiles/mojosetup.dir/lua/src/ldo.s: cmake_force + @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green "Compiling C source to assembly CMakeFiles/mojosetup.dir/lua/src/ldo.s" + /usr/bin/gcc $(C_DEFINES) $(C_FLAGS) -S /home/softcoder/Code/mojosetup/lua/src/ldo.c -o CMakeFiles/mojosetup.dir/lua/src/ldo.s + +CMakeFiles/mojosetup.dir/lua/src/ldo.o.requires: +.PHONY : CMakeFiles/mojosetup.dir/lua/src/ldo.o.requires + +CMakeFiles/mojosetup.dir/lua/src/ldo.o.provides: CMakeFiles/mojosetup.dir/lua/src/ldo.o.requires + $(MAKE) -f CMakeFiles/mojosetup.dir/build.make CMakeFiles/mojosetup.dir/lua/src/ldo.o.provides.build +.PHONY : CMakeFiles/mojosetup.dir/lua/src/ldo.o.provides + +CMakeFiles/mojosetup.dir/lua/src/ldo.o.provides.build: CMakeFiles/mojosetup.dir/lua/src/ldo.o +.PHONY : CMakeFiles/mojosetup.dir/lua/src/ldo.o.provides.build + +CMakeFiles/mojosetup.dir/lua/src/ldump.o: CMakeFiles/mojosetup.dir/flags.make +CMakeFiles/mojosetup.dir/lua/src/ldump.o: ../lua/src/ldump.c + $(CMAKE_COMMAND) -E cmake_progress_report /home/softcoder/Code/mojosetup/build/CMakeFiles $(CMAKE_PROGRESS_18) + @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green "Building C object CMakeFiles/mojosetup.dir/lua/src/ldump.o" + /usr/bin/gcc $(C_DEFINES) $(C_FLAGS) -o CMakeFiles/mojosetup.dir/lua/src/ldump.o -c /home/softcoder/Code/mojosetup/lua/src/ldump.c + +CMakeFiles/mojosetup.dir/lua/src/ldump.i: cmake_force + @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green "Preprocessing C source to CMakeFiles/mojosetup.dir/lua/src/ldump.i" + /usr/bin/gcc $(C_DEFINES) $(C_FLAGS) -E /home/softcoder/Code/mojosetup/lua/src/ldump.c > CMakeFiles/mojosetup.dir/lua/src/ldump.i + +CMakeFiles/mojosetup.dir/lua/src/ldump.s: cmake_force + @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green "Compiling C source to assembly CMakeFiles/mojosetup.dir/lua/src/ldump.s" + /usr/bin/gcc $(C_DEFINES) $(C_FLAGS) -S /home/softcoder/Code/mojosetup/lua/src/ldump.c -o CMakeFiles/mojosetup.dir/lua/src/ldump.s + +CMakeFiles/mojosetup.dir/lua/src/ldump.o.requires: +.PHONY : CMakeFiles/mojosetup.dir/lua/src/ldump.o.requires + +CMakeFiles/mojosetup.dir/lua/src/ldump.o.provides: CMakeFiles/mojosetup.dir/lua/src/ldump.o.requires + $(MAKE) -f CMakeFiles/mojosetup.dir/build.make CMakeFiles/mojosetup.dir/lua/src/ldump.o.provides.build +.PHONY : CMakeFiles/mojosetup.dir/lua/src/ldump.o.provides + +CMakeFiles/mojosetup.dir/lua/src/ldump.o.provides.build: CMakeFiles/mojosetup.dir/lua/src/ldump.o +.PHONY : CMakeFiles/mojosetup.dir/lua/src/ldump.o.provides.build + +CMakeFiles/mojosetup.dir/lua/src/lfunc.o: CMakeFiles/mojosetup.dir/flags.make +CMakeFiles/mojosetup.dir/lua/src/lfunc.o: ../lua/src/lfunc.c + $(CMAKE_COMMAND) -E cmake_progress_report /home/softcoder/Code/mojosetup/build/CMakeFiles $(CMAKE_PROGRESS_19) + @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green "Building C object CMakeFiles/mojosetup.dir/lua/src/lfunc.o" + /usr/bin/gcc $(C_DEFINES) $(C_FLAGS) -o CMakeFiles/mojosetup.dir/lua/src/lfunc.o -c /home/softcoder/Code/mojosetup/lua/src/lfunc.c + +CMakeFiles/mojosetup.dir/lua/src/lfunc.i: cmake_force + @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green "Preprocessing C source to CMakeFiles/mojosetup.dir/lua/src/lfunc.i" + /usr/bin/gcc $(C_DEFINES) $(C_FLAGS) -E /home/softcoder/Code/mojosetup/lua/src/lfunc.c > CMakeFiles/mojosetup.dir/lua/src/lfunc.i + +CMakeFiles/mojosetup.dir/lua/src/lfunc.s: cmake_force + @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green "Compiling C source to assembly CMakeFiles/mojosetup.dir/lua/src/lfunc.s" + /usr/bin/gcc $(C_DEFINES) $(C_FLAGS) -S /home/softcoder/Code/mojosetup/lua/src/lfunc.c -o CMakeFiles/mojosetup.dir/lua/src/lfunc.s + +CMakeFiles/mojosetup.dir/lua/src/lfunc.o.requires: +.PHONY : CMakeFiles/mojosetup.dir/lua/src/lfunc.o.requires + +CMakeFiles/mojosetup.dir/lua/src/lfunc.o.provides: CMakeFiles/mojosetup.dir/lua/src/lfunc.o.requires + $(MAKE) -f CMakeFiles/mojosetup.dir/build.make CMakeFiles/mojosetup.dir/lua/src/lfunc.o.provides.build +.PHONY : CMakeFiles/mojosetup.dir/lua/src/lfunc.o.provides + +CMakeFiles/mojosetup.dir/lua/src/lfunc.o.provides.build: CMakeFiles/mojosetup.dir/lua/src/lfunc.o +.PHONY : CMakeFiles/mojosetup.dir/lua/src/lfunc.o.provides.build + +CMakeFiles/mojosetup.dir/lua/src/lgc.o: CMakeFiles/mojosetup.dir/flags.make +CMakeFiles/mojosetup.dir/lua/src/lgc.o: ../lua/src/lgc.c + $(CMAKE_COMMAND) -E cmake_progress_report /home/softcoder/Code/mojosetup/build/CMakeFiles $(CMAKE_PROGRESS_20) + @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green "Building C object CMakeFiles/mojosetup.dir/lua/src/lgc.o" + /usr/bin/gcc $(C_DEFINES) $(C_FLAGS) -o CMakeFiles/mojosetup.dir/lua/src/lgc.o -c /home/softcoder/Code/mojosetup/lua/src/lgc.c + +CMakeFiles/mojosetup.dir/lua/src/lgc.i: cmake_force + @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green "Preprocessing C source to CMakeFiles/mojosetup.dir/lua/src/lgc.i" + /usr/bin/gcc $(C_DEFINES) $(C_FLAGS) -E /home/softcoder/Code/mojosetup/lua/src/lgc.c > CMakeFiles/mojosetup.dir/lua/src/lgc.i + +CMakeFiles/mojosetup.dir/lua/src/lgc.s: cmake_force + @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green "Compiling C source to assembly CMakeFiles/mojosetup.dir/lua/src/lgc.s" + /usr/bin/gcc $(C_DEFINES) $(C_FLAGS) -S /home/softcoder/Code/mojosetup/lua/src/lgc.c -o CMakeFiles/mojosetup.dir/lua/src/lgc.s + +CMakeFiles/mojosetup.dir/lua/src/lgc.o.requires: +.PHONY : CMakeFiles/mojosetup.dir/lua/src/lgc.o.requires + +CMakeFiles/mojosetup.dir/lua/src/lgc.o.provides: CMakeFiles/mojosetup.dir/lua/src/lgc.o.requires + $(MAKE) -f CMakeFiles/mojosetup.dir/build.make CMakeFiles/mojosetup.dir/lua/src/lgc.o.provides.build +.PHONY : CMakeFiles/mojosetup.dir/lua/src/lgc.o.provides + +CMakeFiles/mojosetup.dir/lua/src/lgc.o.provides.build: CMakeFiles/mojosetup.dir/lua/src/lgc.o +.PHONY : CMakeFiles/mojosetup.dir/lua/src/lgc.o.provides.build + +CMakeFiles/mojosetup.dir/lua/src/lmem.o: CMakeFiles/mojosetup.dir/flags.make +CMakeFiles/mojosetup.dir/lua/src/lmem.o: ../lua/src/lmem.c + $(CMAKE_COMMAND) -E cmake_progress_report /home/softcoder/Code/mojosetup/build/CMakeFiles $(CMAKE_PROGRESS_21) + @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green "Building C object CMakeFiles/mojosetup.dir/lua/src/lmem.o" + /usr/bin/gcc $(C_DEFINES) $(C_FLAGS) -o CMakeFiles/mojosetup.dir/lua/src/lmem.o -c /home/softcoder/Code/mojosetup/lua/src/lmem.c + +CMakeFiles/mojosetup.dir/lua/src/lmem.i: cmake_force + @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green "Preprocessing C source to CMakeFiles/mojosetup.dir/lua/src/lmem.i" + /usr/bin/gcc $(C_DEFINES) $(C_FLAGS) -E /home/softcoder/Code/mojosetup/lua/src/lmem.c > CMakeFiles/mojosetup.dir/lua/src/lmem.i + +CMakeFiles/mojosetup.dir/lua/src/lmem.s: cmake_force + @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green "Compiling C source to assembly CMakeFiles/mojosetup.dir/lua/src/lmem.s" + /usr/bin/gcc $(C_DEFINES) $(C_FLAGS) -S /home/softcoder/Code/mojosetup/lua/src/lmem.c -o CMakeFiles/mojosetup.dir/lua/src/lmem.s + +CMakeFiles/mojosetup.dir/lua/src/lmem.o.requires: +.PHONY : CMakeFiles/mojosetup.dir/lua/src/lmem.o.requires + +CMakeFiles/mojosetup.dir/lua/src/lmem.o.provides: CMakeFiles/mojosetup.dir/lua/src/lmem.o.requires + $(MAKE) -f CMakeFiles/mojosetup.dir/build.make CMakeFiles/mojosetup.dir/lua/src/lmem.o.provides.build +.PHONY : CMakeFiles/mojosetup.dir/lua/src/lmem.o.provides + +CMakeFiles/mojosetup.dir/lua/src/lmem.o.provides.build: CMakeFiles/mojosetup.dir/lua/src/lmem.o +.PHONY : CMakeFiles/mojosetup.dir/lua/src/lmem.o.provides.build + +CMakeFiles/mojosetup.dir/lua/src/lobject.o: CMakeFiles/mojosetup.dir/flags.make +CMakeFiles/mojosetup.dir/lua/src/lobject.o: ../lua/src/lobject.c + $(CMAKE_COMMAND) -E cmake_progress_report /home/softcoder/Code/mojosetup/build/CMakeFiles $(CMAKE_PROGRESS_22) + @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green "Building C object CMakeFiles/mojosetup.dir/lua/src/lobject.o" + /usr/bin/gcc $(C_DEFINES) $(C_FLAGS) -o CMakeFiles/mojosetup.dir/lua/src/lobject.o -c /home/softcoder/Code/mojosetup/lua/src/lobject.c + +CMakeFiles/mojosetup.dir/lua/src/lobject.i: cmake_force + @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green "Preprocessing C source to CMakeFiles/mojosetup.dir/lua/src/lobject.i" + /usr/bin/gcc $(C_DEFINES) $(C_FLAGS) -E /home/softcoder/Code/mojosetup/lua/src/lobject.c > CMakeFiles/mojosetup.dir/lua/src/lobject.i + +CMakeFiles/mojosetup.dir/lua/src/lobject.s: cmake_force + @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green "Compiling C source to assembly CMakeFiles/mojosetup.dir/lua/src/lobject.s" + /usr/bin/gcc $(C_DEFINES) $(C_FLAGS) -S /home/softcoder/Code/mojosetup/lua/src/lobject.c -o CMakeFiles/mojosetup.dir/lua/src/lobject.s + +CMakeFiles/mojosetup.dir/lua/src/lobject.o.requires: +.PHONY : CMakeFiles/mojosetup.dir/lua/src/lobject.o.requires + +CMakeFiles/mojosetup.dir/lua/src/lobject.o.provides: CMakeFiles/mojosetup.dir/lua/src/lobject.o.requires + $(MAKE) -f CMakeFiles/mojosetup.dir/build.make CMakeFiles/mojosetup.dir/lua/src/lobject.o.provides.build +.PHONY : CMakeFiles/mojosetup.dir/lua/src/lobject.o.provides + +CMakeFiles/mojosetup.dir/lua/src/lobject.o.provides.build: CMakeFiles/mojosetup.dir/lua/src/lobject.o +.PHONY : CMakeFiles/mojosetup.dir/lua/src/lobject.o.provides.build + +CMakeFiles/mojosetup.dir/lua/src/lopcodes.o: CMakeFiles/mojosetup.dir/flags.make +CMakeFiles/mojosetup.dir/lua/src/lopcodes.o: ../lua/src/lopcodes.c + $(CMAKE_COMMAND) -E cmake_progress_report /home/softcoder/Code/mojosetup/build/CMakeFiles $(CMAKE_PROGRESS_23) + @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green "Building C object CMakeFiles/mojosetup.dir/lua/src/lopcodes.o" + /usr/bin/gcc $(C_DEFINES) $(C_FLAGS) -o CMakeFiles/mojosetup.dir/lua/src/lopcodes.o -c /home/softcoder/Code/mojosetup/lua/src/lopcodes.c + +CMakeFiles/mojosetup.dir/lua/src/lopcodes.i: cmake_force + @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green "Preprocessing C source to CMakeFiles/mojosetup.dir/lua/src/lopcodes.i" + /usr/bin/gcc $(C_DEFINES) $(C_FLAGS) -E /home/softcoder/Code/mojosetup/lua/src/lopcodes.c > CMakeFiles/mojosetup.dir/lua/src/lopcodes.i + +CMakeFiles/mojosetup.dir/lua/src/lopcodes.s: cmake_force + @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green "Compiling C source to assembly CMakeFiles/mojosetup.dir/lua/src/lopcodes.s" + /usr/bin/gcc $(C_DEFINES) $(C_FLAGS) -S /home/softcoder/Code/mojosetup/lua/src/lopcodes.c -o CMakeFiles/mojosetup.dir/lua/src/lopcodes.s + +CMakeFiles/mojosetup.dir/lua/src/lopcodes.o.requires: +.PHONY : CMakeFiles/mojosetup.dir/lua/src/lopcodes.o.requires + +CMakeFiles/mojosetup.dir/lua/src/lopcodes.o.provides: CMakeFiles/mojosetup.dir/lua/src/lopcodes.o.requires + $(MAKE) -f CMakeFiles/mojosetup.dir/build.make CMakeFiles/mojosetup.dir/lua/src/lopcodes.o.provides.build +.PHONY : CMakeFiles/mojosetup.dir/lua/src/lopcodes.o.provides + +CMakeFiles/mojosetup.dir/lua/src/lopcodes.o.provides.build: CMakeFiles/mojosetup.dir/lua/src/lopcodes.o +.PHONY : CMakeFiles/mojosetup.dir/lua/src/lopcodes.o.provides.build + +CMakeFiles/mojosetup.dir/lua/src/lstate.o: CMakeFiles/mojosetup.dir/flags.make +CMakeFiles/mojosetup.dir/lua/src/lstate.o: ../lua/src/lstate.c + $(CMAKE_COMMAND) -E cmake_progress_report /home/softcoder/Code/mojosetup/build/CMakeFiles $(CMAKE_PROGRESS_24) + @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green "Building C object CMakeFiles/mojosetup.dir/lua/src/lstate.o" + /usr/bin/gcc $(C_DEFINES) $(C_FLAGS) -o CMakeFiles/mojosetup.dir/lua/src/lstate.o -c /home/softcoder/Code/mojosetup/lua/src/lstate.c + +CMakeFiles/mojosetup.dir/lua/src/lstate.i: cmake_force + @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green "Preprocessing C source to CMakeFiles/mojosetup.dir/lua/src/lstate.i" + /usr/bin/gcc $(C_DEFINES) $(C_FLAGS) -E /home/softcoder/Code/mojosetup/lua/src/lstate.c > CMakeFiles/mojosetup.dir/lua/src/lstate.i + +CMakeFiles/mojosetup.dir/lua/src/lstate.s: cmake_force + @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green "Compiling C source to assembly CMakeFiles/mojosetup.dir/lua/src/lstate.s" + /usr/bin/gcc $(C_DEFINES) $(C_FLAGS) -S /home/softcoder/Code/mojosetup/lua/src/lstate.c -o CMakeFiles/mojosetup.dir/lua/src/lstate.s + +CMakeFiles/mojosetup.dir/lua/src/lstate.o.requires: +.PHONY : CMakeFiles/mojosetup.dir/lua/src/lstate.o.requires + +CMakeFiles/mojosetup.dir/lua/src/lstate.o.provides: CMakeFiles/mojosetup.dir/lua/src/lstate.o.requires + $(MAKE) -f CMakeFiles/mojosetup.dir/build.make CMakeFiles/mojosetup.dir/lua/src/lstate.o.provides.build +.PHONY : CMakeFiles/mojosetup.dir/lua/src/lstate.o.provides + +CMakeFiles/mojosetup.dir/lua/src/lstate.o.provides.build: CMakeFiles/mojosetup.dir/lua/src/lstate.o +.PHONY : CMakeFiles/mojosetup.dir/lua/src/lstate.o.provides.build + +CMakeFiles/mojosetup.dir/lua/src/lstring.o: CMakeFiles/mojosetup.dir/flags.make +CMakeFiles/mojosetup.dir/lua/src/lstring.o: ../lua/src/lstring.c + $(CMAKE_COMMAND) -E cmake_progress_report /home/softcoder/Code/mojosetup/build/CMakeFiles $(CMAKE_PROGRESS_25) + @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green "Building C object CMakeFiles/mojosetup.dir/lua/src/lstring.o" + /usr/bin/gcc $(C_DEFINES) $(C_FLAGS) -o CMakeFiles/mojosetup.dir/lua/src/lstring.o -c /home/softcoder/Code/mojosetup/lua/src/lstring.c + +CMakeFiles/mojosetup.dir/lua/src/lstring.i: cmake_force + @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green "Preprocessing C source to CMakeFiles/mojosetup.dir/lua/src/lstring.i" + /usr/bin/gcc $(C_DEFINES) $(C_FLAGS) -E /home/softcoder/Code/mojosetup/lua/src/lstring.c > CMakeFiles/mojosetup.dir/lua/src/lstring.i + +CMakeFiles/mojosetup.dir/lua/src/lstring.s: cmake_force + @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green "Compiling C source to assembly CMakeFiles/mojosetup.dir/lua/src/lstring.s" + /usr/bin/gcc $(C_DEFINES) $(C_FLAGS) -S /home/softcoder/Code/mojosetup/lua/src/lstring.c -o CMakeFiles/mojosetup.dir/lua/src/lstring.s + +CMakeFiles/mojosetup.dir/lua/src/lstring.o.requires: +.PHONY : CMakeFiles/mojosetup.dir/lua/src/lstring.o.requires + +CMakeFiles/mojosetup.dir/lua/src/lstring.o.provides: CMakeFiles/mojosetup.dir/lua/src/lstring.o.requires + $(MAKE) -f CMakeFiles/mojosetup.dir/build.make CMakeFiles/mojosetup.dir/lua/src/lstring.o.provides.build +.PHONY : CMakeFiles/mojosetup.dir/lua/src/lstring.o.provides + +CMakeFiles/mojosetup.dir/lua/src/lstring.o.provides.build: CMakeFiles/mojosetup.dir/lua/src/lstring.o +.PHONY : CMakeFiles/mojosetup.dir/lua/src/lstring.o.provides.build + +CMakeFiles/mojosetup.dir/lua/src/ltable.o: CMakeFiles/mojosetup.dir/flags.make +CMakeFiles/mojosetup.dir/lua/src/ltable.o: ../lua/src/ltable.c + $(CMAKE_COMMAND) -E cmake_progress_report /home/softcoder/Code/mojosetup/build/CMakeFiles $(CMAKE_PROGRESS_26) + @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green "Building C object CMakeFiles/mojosetup.dir/lua/src/ltable.o" + /usr/bin/gcc $(C_DEFINES) $(C_FLAGS) -o CMakeFiles/mojosetup.dir/lua/src/ltable.o -c /home/softcoder/Code/mojosetup/lua/src/ltable.c + +CMakeFiles/mojosetup.dir/lua/src/ltable.i: cmake_force + @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green "Preprocessing C source to CMakeFiles/mojosetup.dir/lua/src/ltable.i" + /usr/bin/gcc $(C_DEFINES) $(C_FLAGS) -E /home/softcoder/Code/mojosetup/lua/src/ltable.c > CMakeFiles/mojosetup.dir/lua/src/ltable.i + +CMakeFiles/mojosetup.dir/lua/src/ltable.s: cmake_force + @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green "Compiling C source to assembly CMakeFiles/mojosetup.dir/lua/src/ltable.s" + /usr/bin/gcc $(C_DEFINES) $(C_FLAGS) -S /home/softcoder/Code/mojosetup/lua/src/ltable.c -o CMakeFiles/mojosetup.dir/lua/src/ltable.s + +CMakeFiles/mojosetup.dir/lua/src/ltable.o.requires: +.PHONY : CMakeFiles/mojosetup.dir/lua/src/ltable.o.requires + +CMakeFiles/mojosetup.dir/lua/src/ltable.o.provides: CMakeFiles/mojosetup.dir/lua/src/ltable.o.requires + $(MAKE) -f CMakeFiles/mojosetup.dir/build.make CMakeFiles/mojosetup.dir/lua/src/ltable.o.provides.build +.PHONY : CMakeFiles/mojosetup.dir/lua/src/ltable.o.provides + +CMakeFiles/mojosetup.dir/lua/src/ltable.o.provides.build: CMakeFiles/mojosetup.dir/lua/src/ltable.o +.PHONY : CMakeFiles/mojosetup.dir/lua/src/ltable.o.provides.build + +CMakeFiles/mojosetup.dir/lua/src/ltm.o: CMakeFiles/mojosetup.dir/flags.make +CMakeFiles/mojosetup.dir/lua/src/ltm.o: ../lua/src/ltm.c + $(CMAKE_COMMAND) -E cmake_progress_report /home/softcoder/Code/mojosetup/build/CMakeFiles $(CMAKE_PROGRESS_27) + @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green "Building C object CMakeFiles/mojosetup.dir/lua/src/ltm.o" + /usr/bin/gcc $(C_DEFINES) $(C_FLAGS) -o CMakeFiles/mojosetup.dir/lua/src/ltm.o -c /home/softcoder/Code/mojosetup/lua/src/ltm.c + +CMakeFiles/mojosetup.dir/lua/src/ltm.i: cmake_force + @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green "Preprocessing C source to CMakeFiles/mojosetup.dir/lua/src/ltm.i" + /usr/bin/gcc $(C_DEFINES) $(C_FLAGS) -E /home/softcoder/Code/mojosetup/lua/src/ltm.c > CMakeFiles/mojosetup.dir/lua/src/ltm.i + +CMakeFiles/mojosetup.dir/lua/src/ltm.s: cmake_force + @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green "Compiling C source to assembly CMakeFiles/mojosetup.dir/lua/src/ltm.s" + /usr/bin/gcc $(C_DEFINES) $(C_FLAGS) -S /home/softcoder/Code/mojosetup/lua/src/ltm.c -o CMakeFiles/mojosetup.dir/lua/src/ltm.s + +CMakeFiles/mojosetup.dir/lua/src/ltm.o.requires: +.PHONY : CMakeFiles/mojosetup.dir/lua/src/ltm.o.requires + +CMakeFiles/mojosetup.dir/lua/src/ltm.o.provides: CMakeFiles/mojosetup.dir/lua/src/ltm.o.requires + $(MAKE) -f CMakeFiles/mojosetup.dir/build.make CMakeFiles/mojosetup.dir/lua/src/ltm.o.provides.build +.PHONY : CMakeFiles/mojosetup.dir/lua/src/ltm.o.provides + +CMakeFiles/mojosetup.dir/lua/src/ltm.o.provides.build: CMakeFiles/mojosetup.dir/lua/src/ltm.o +.PHONY : CMakeFiles/mojosetup.dir/lua/src/ltm.o.provides.build + +CMakeFiles/mojosetup.dir/lua/src/lundump.o: CMakeFiles/mojosetup.dir/flags.make +CMakeFiles/mojosetup.dir/lua/src/lundump.o: ../lua/src/lundump.c + $(CMAKE_COMMAND) -E cmake_progress_report /home/softcoder/Code/mojosetup/build/CMakeFiles $(CMAKE_PROGRESS_28) + @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green "Building C object CMakeFiles/mojosetup.dir/lua/src/lundump.o" + /usr/bin/gcc $(C_DEFINES) $(C_FLAGS) -o CMakeFiles/mojosetup.dir/lua/src/lundump.o -c /home/softcoder/Code/mojosetup/lua/src/lundump.c + +CMakeFiles/mojosetup.dir/lua/src/lundump.i: cmake_force + @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green "Preprocessing C source to CMakeFiles/mojosetup.dir/lua/src/lundump.i" + /usr/bin/gcc $(C_DEFINES) $(C_FLAGS) -E /home/softcoder/Code/mojosetup/lua/src/lundump.c > CMakeFiles/mojosetup.dir/lua/src/lundump.i + +CMakeFiles/mojosetup.dir/lua/src/lundump.s: cmake_force + @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green "Compiling C source to assembly CMakeFiles/mojosetup.dir/lua/src/lundump.s" + /usr/bin/gcc $(C_DEFINES) $(C_FLAGS) -S /home/softcoder/Code/mojosetup/lua/src/lundump.c -o CMakeFiles/mojosetup.dir/lua/src/lundump.s + +CMakeFiles/mojosetup.dir/lua/src/lundump.o.requires: +.PHONY : CMakeFiles/mojosetup.dir/lua/src/lundump.o.requires + +CMakeFiles/mojosetup.dir/lua/src/lundump.o.provides: CMakeFiles/mojosetup.dir/lua/src/lundump.o.requires + $(MAKE) -f CMakeFiles/mojosetup.dir/build.make CMakeFiles/mojosetup.dir/lua/src/lundump.o.provides.build +.PHONY : CMakeFiles/mojosetup.dir/lua/src/lundump.o.provides + +CMakeFiles/mojosetup.dir/lua/src/lundump.o.provides.build: CMakeFiles/mojosetup.dir/lua/src/lundump.o +.PHONY : CMakeFiles/mojosetup.dir/lua/src/lundump.o.provides.build + +CMakeFiles/mojosetup.dir/lua/src/lvm.o: CMakeFiles/mojosetup.dir/flags.make +CMakeFiles/mojosetup.dir/lua/src/lvm.o: ../lua/src/lvm.c + $(CMAKE_COMMAND) -E cmake_progress_report /home/softcoder/Code/mojosetup/build/CMakeFiles $(CMAKE_PROGRESS_29) + @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green "Building C object CMakeFiles/mojosetup.dir/lua/src/lvm.o" + /usr/bin/gcc $(C_DEFINES) $(C_FLAGS) -o CMakeFiles/mojosetup.dir/lua/src/lvm.o -c /home/softcoder/Code/mojosetup/lua/src/lvm.c + +CMakeFiles/mojosetup.dir/lua/src/lvm.i: cmake_force + @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green "Preprocessing C source to CMakeFiles/mojosetup.dir/lua/src/lvm.i" + /usr/bin/gcc $(C_DEFINES) $(C_FLAGS) -E /home/softcoder/Code/mojosetup/lua/src/lvm.c > CMakeFiles/mojosetup.dir/lua/src/lvm.i + +CMakeFiles/mojosetup.dir/lua/src/lvm.s: cmake_force + @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green "Compiling C source to assembly CMakeFiles/mojosetup.dir/lua/src/lvm.s" + /usr/bin/gcc $(C_DEFINES) $(C_FLAGS) -S /home/softcoder/Code/mojosetup/lua/src/lvm.c -o CMakeFiles/mojosetup.dir/lua/src/lvm.s + +CMakeFiles/mojosetup.dir/lua/src/lvm.o.requires: +.PHONY : CMakeFiles/mojosetup.dir/lua/src/lvm.o.requires + +CMakeFiles/mojosetup.dir/lua/src/lvm.o.provides: CMakeFiles/mojosetup.dir/lua/src/lvm.o.requires + $(MAKE) -f CMakeFiles/mojosetup.dir/build.make CMakeFiles/mojosetup.dir/lua/src/lvm.o.provides.build +.PHONY : CMakeFiles/mojosetup.dir/lua/src/lvm.o.provides + +CMakeFiles/mojosetup.dir/lua/src/lvm.o.provides.build: CMakeFiles/mojosetup.dir/lua/src/lvm.o +.PHONY : CMakeFiles/mojosetup.dir/lua/src/lvm.o.provides.build + +CMakeFiles/mojosetup.dir/lua/src/lzio.o: CMakeFiles/mojosetup.dir/flags.make +CMakeFiles/mojosetup.dir/lua/src/lzio.o: ../lua/src/lzio.c + $(CMAKE_COMMAND) -E cmake_progress_report /home/softcoder/Code/mojosetup/build/CMakeFiles $(CMAKE_PROGRESS_30) + @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green "Building C object CMakeFiles/mojosetup.dir/lua/src/lzio.o" + /usr/bin/gcc $(C_DEFINES) $(C_FLAGS) -o CMakeFiles/mojosetup.dir/lua/src/lzio.o -c /home/softcoder/Code/mojosetup/lua/src/lzio.c + +CMakeFiles/mojosetup.dir/lua/src/lzio.i: cmake_force + @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green "Preprocessing C source to CMakeFiles/mojosetup.dir/lua/src/lzio.i" + /usr/bin/gcc $(C_DEFINES) $(C_FLAGS) -E /home/softcoder/Code/mojosetup/lua/src/lzio.c > CMakeFiles/mojosetup.dir/lua/src/lzio.i + +CMakeFiles/mojosetup.dir/lua/src/lzio.s: cmake_force + @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green "Compiling C source to assembly CMakeFiles/mojosetup.dir/lua/src/lzio.s" + /usr/bin/gcc $(C_DEFINES) $(C_FLAGS) -S /home/softcoder/Code/mojosetup/lua/src/lzio.c -o CMakeFiles/mojosetup.dir/lua/src/lzio.s + +CMakeFiles/mojosetup.dir/lua/src/lzio.o.requires: +.PHONY : CMakeFiles/mojosetup.dir/lua/src/lzio.o.requires + +CMakeFiles/mojosetup.dir/lua/src/lzio.o.provides: CMakeFiles/mojosetup.dir/lua/src/lzio.o.requires + $(MAKE) -f CMakeFiles/mojosetup.dir/build.make CMakeFiles/mojosetup.dir/lua/src/lzio.o.provides.build +.PHONY : CMakeFiles/mojosetup.dir/lua/src/lzio.o.provides + +CMakeFiles/mojosetup.dir/lua/src/lzio.o.provides.build: CMakeFiles/mojosetup.dir/lua/src/lzio.o +.PHONY : CMakeFiles/mojosetup.dir/lua/src/lzio.o.provides.build + +CMakeFiles/mojosetup.dir/lua/src/lauxlib.o: CMakeFiles/mojosetup.dir/flags.make +CMakeFiles/mojosetup.dir/lua/src/lauxlib.o: ../lua/src/lauxlib.c + $(CMAKE_COMMAND) -E cmake_progress_report /home/softcoder/Code/mojosetup/build/CMakeFiles $(CMAKE_PROGRESS_31) + @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green "Building C object CMakeFiles/mojosetup.dir/lua/src/lauxlib.o" + /usr/bin/gcc $(C_DEFINES) $(C_FLAGS) -o CMakeFiles/mojosetup.dir/lua/src/lauxlib.o -c /home/softcoder/Code/mojosetup/lua/src/lauxlib.c + +CMakeFiles/mojosetup.dir/lua/src/lauxlib.i: cmake_force + @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green "Preprocessing C source to CMakeFiles/mojosetup.dir/lua/src/lauxlib.i" + /usr/bin/gcc $(C_DEFINES) $(C_FLAGS) -E /home/softcoder/Code/mojosetup/lua/src/lauxlib.c > CMakeFiles/mojosetup.dir/lua/src/lauxlib.i + +CMakeFiles/mojosetup.dir/lua/src/lauxlib.s: cmake_force + @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green "Compiling C source to assembly CMakeFiles/mojosetup.dir/lua/src/lauxlib.s" + /usr/bin/gcc $(C_DEFINES) $(C_FLAGS) -S /home/softcoder/Code/mojosetup/lua/src/lauxlib.c -o CMakeFiles/mojosetup.dir/lua/src/lauxlib.s + +CMakeFiles/mojosetup.dir/lua/src/lauxlib.o.requires: +.PHONY : CMakeFiles/mojosetup.dir/lua/src/lauxlib.o.requires + +CMakeFiles/mojosetup.dir/lua/src/lauxlib.o.provides: CMakeFiles/mojosetup.dir/lua/src/lauxlib.o.requires + $(MAKE) -f CMakeFiles/mojosetup.dir/build.make CMakeFiles/mojosetup.dir/lua/src/lauxlib.o.provides.build +.PHONY : CMakeFiles/mojosetup.dir/lua/src/lauxlib.o.provides + +CMakeFiles/mojosetup.dir/lua/src/lauxlib.o.provides.build: CMakeFiles/mojosetup.dir/lua/src/lauxlib.o +.PHONY : CMakeFiles/mojosetup.dir/lua/src/lauxlib.o.provides.build + +CMakeFiles/mojosetup.dir/lua/src/lbaselib.o: CMakeFiles/mojosetup.dir/flags.make +CMakeFiles/mojosetup.dir/lua/src/lbaselib.o: ../lua/src/lbaselib.c + $(CMAKE_COMMAND) -E cmake_progress_report /home/softcoder/Code/mojosetup/build/CMakeFiles $(CMAKE_PROGRESS_32) + @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green "Building C object CMakeFiles/mojosetup.dir/lua/src/lbaselib.o" + /usr/bin/gcc $(C_DEFINES) $(C_FLAGS) -o CMakeFiles/mojosetup.dir/lua/src/lbaselib.o -c /home/softcoder/Code/mojosetup/lua/src/lbaselib.c + +CMakeFiles/mojosetup.dir/lua/src/lbaselib.i: cmake_force + @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green "Preprocessing C source to CMakeFiles/mojosetup.dir/lua/src/lbaselib.i" + /usr/bin/gcc $(C_DEFINES) $(C_FLAGS) -E /home/softcoder/Code/mojosetup/lua/src/lbaselib.c > CMakeFiles/mojosetup.dir/lua/src/lbaselib.i + +CMakeFiles/mojosetup.dir/lua/src/lbaselib.s: cmake_force + @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green "Compiling C source to assembly CMakeFiles/mojosetup.dir/lua/src/lbaselib.s" + /usr/bin/gcc $(C_DEFINES) $(C_FLAGS) -S /home/softcoder/Code/mojosetup/lua/src/lbaselib.c -o CMakeFiles/mojosetup.dir/lua/src/lbaselib.s + +CMakeFiles/mojosetup.dir/lua/src/lbaselib.o.requires: +.PHONY : CMakeFiles/mojosetup.dir/lua/src/lbaselib.o.requires + +CMakeFiles/mojosetup.dir/lua/src/lbaselib.o.provides: CMakeFiles/mojosetup.dir/lua/src/lbaselib.o.requires + $(MAKE) -f CMakeFiles/mojosetup.dir/build.make CMakeFiles/mojosetup.dir/lua/src/lbaselib.o.provides.build +.PHONY : CMakeFiles/mojosetup.dir/lua/src/lbaselib.o.provides + +CMakeFiles/mojosetup.dir/lua/src/lbaselib.o.provides.build: CMakeFiles/mojosetup.dir/lua/src/lbaselib.o +.PHONY : CMakeFiles/mojosetup.dir/lua/src/lbaselib.o.provides.build + +CMakeFiles/mojosetup.dir/lua/src/lstrlib.o: CMakeFiles/mojosetup.dir/flags.make +CMakeFiles/mojosetup.dir/lua/src/lstrlib.o: ../lua/src/lstrlib.c + $(CMAKE_COMMAND) -E cmake_progress_report /home/softcoder/Code/mojosetup/build/CMakeFiles $(CMAKE_PROGRESS_33) + @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green "Building C object CMakeFiles/mojosetup.dir/lua/src/lstrlib.o" + /usr/bin/gcc $(C_DEFINES) $(C_FLAGS) -o CMakeFiles/mojosetup.dir/lua/src/lstrlib.o -c /home/softcoder/Code/mojosetup/lua/src/lstrlib.c + +CMakeFiles/mojosetup.dir/lua/src/lstrlib.i: cmake_force + @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green "Preprocessing C source to CMakeFiles/mojosetup.dir/lua/src/lstrlib.i" + /usr/bin/gcc $(C_DEFINES) $(C_FLAGS) -E /home/softcoder/Code/mojosetup/lua/src/lstrlib.c > CMakeFiles/mojosetup.dir/lua/src/lstrlib.i + +CMakeFiles/mojosetup.dir/lua/src/lstrlib.s: cmake_force + @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green "Compiling C source to assembly CMakeFiles/mojosetup.dir/lua/src/lstrlib.s" + /usr/bin/gcc $(C_DEFINES) $(C_FLAGS) -S /home/softcoder/Code/mojosetup/lua/src/lstrlib.c -o CMakeFiles/mojosetup.dir/lua/src/lstrlib.s + +CMakeFiles/mojosetup.dir/lua/src/lstrlib.o.requires: +.PHONY : CMakeFiles/mojosetup.dir/lua/src/lstrlib.o.requires + +CMakeFiles/mojosetup.dir/lua/src/lstrlib.o.provides: CMakeFiles/mojosetup.dir/lua/src/lstrlib.o.requires + $(MAKE) -f CMakeFiles/mojosetup.dir/build.make CMakeFiles/mojosetup.dir/lua/src/lstrlib.o.provides.build +.PHONY : CMakeFiles/mojosetup.dir/lua/src/lstrlib.o.provides + +CMakeFiles/mojosetup.dir/lua/src/lstrlib.o.provides.build: CMakeFiles/mojosetup.dir/lua/src/lstrlib.o +.PHONY : CMakeFiles/mojosetup.dir/lua/src/lstrlib.o.provides.build + +CMakeFiles/mojosetup.dir/lua/src/ltablib.o: CMakeFiles/mojosetup.dir/flags.make +CMakeFiles/mojosetup.dir/lua/src/ltablib.o: ../lua/src/ltablib.c + $(CMAKE_COMMAND) -E cmake_progress_report /home/softcoder/Code/mojosetup/build/CMakeFiles $(CMAKE_PROGRESS_34) + @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green "Building C object CMakeFiles/mojosetup.dir/lua/src/ltablib.o" + /usr/bin/gcc $(C_DEFINES) $(C_FLAGS) -o CMakeFiles/mojosetup.dir/lua/src/ltablib.o -c /home/softcoder/Code/mojosetup/lua/src/ltablib.c + +CMakeFiles/mojosetup.dir/lua/src/ltablib.i: cmake_force + @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green "Preprocessing C source to CMakeFiles/mojosetup.dir/lua/src/ltablib.i" + /usr/bin/gcc $(C_DEFINES) $(C_FLAGS) -E /home/softcoder/Code/mojosetup/lua/src/ltablib.c > CMakeFiles/mojosetup.dir/lua/src/ltablib.i + +CMakeFiles/mojosetup.dir/lua/src/ltablib.s: cmake_force + @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green "Compiling C source to assembly CMakeFiles/mojosetup.dir/lua/src/ltablib.s" + /usr/bin/gcc $(C_DEFINES) $(C_FLAGS) -S /home/softcoder/Code/mojosetup/lua/src/ltablib.c -o CMakeFiles/mojosetup.dir/lua/src/ltablib.s + +CMakeFiles/mojosetup.dir/lua/src/ltablib.o.requires: +.PHONY : CMakeFiles/mojosetup.dir/lua/src/ltablib.o.requires + +CMakeFiles/mojosetup.dir/lua/src/ltablib.o.provides: CMakeFiles/mojosetup.dir/lua/src/ltablib.o.requires + $(MAKE) -f CMakeFiles/mojosetup.dir/build.make CMakeFiles/mojosetup.dir/lua/src/ltablib.o.provides.build +.PHONY : CMakeFiles/mojosetup.dir/lua/src/ltablib.o.provides + +CMakeFiles/mojosetup.dir/lua/src/ltablib.o.provides.build: CMakeFiles/mojosetup.dir/lua/src/ltablib.o +.PHONY : CMakeFiles/mojosetup.dir/lua/src/ltablib.o.provides.build + +CMakeFiles/mojosetup.dir/lua/src/lparser.o: CMakeFiles/mojosetup.dir/flags.make +CMakeFiles/mojosetup.dir/lua/src/lparser.o: ../lua/src/lparser.c + $(CMAKE_COMMAND) -E cmake_progress_report /home/softcoder/Code/mojosetup/build/CMakeFiles $(CMAKE_PROGRESS_35) + @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green "Building C object CMakeFiles/mojosetup.dir/lua/src/lparser.o" + /usr/bin/gcc $(C_DEFINES) $(C_FLAGS) -o CMakeFiles/mojosetup.dir/lua/src/lparser.o -c /home/softcoder/Code/mojosetup/lua/src/lparser.c + +CMakeFiles/mojosetup.dir/lua/src/lparser.i: cmake_force + @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green "Preprocessing C source to CMakeFiles/mojosetup.dir/lua/src/lparser.i" + /usr/bin/gcc $(C_DEFINES) $(C_FLAGS) -E /home/softcoder/Code/mojosetup/lua/src/lparser.c > CMakeFiles/mojosetup.dir/lua/src/lparser.i + +CMakeFiles/mojosetup.dir/lua/src/lparser.s: cmake_force + @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green "Compiling C source to assembly CMakeFiles/mojosetup.dir/lua/src/lparser.s" + /usr/bin/gcc $(C_DEFINES) $(C_FLAGS) -S /home/softcoder/Code/mojosetup/lua/src/lparser.c -o CMakeFiles/mojosetup.dir/lua/src/lparser.s + +CMakeFiles/mojosetup.dir/lua/src/lparser.o.requires: +.PHONY : CMakeFiles/mojosetup.dir/lua/src/lparser.o.requires + +CMakeFiles/mojosetup.dir/lua/src/lparser.o.provides: CMakeFiles/mojosetup.dir/lua/src/lparser.o.requires + $(MAKE) -f CMakeFiles/mojosetup.dir/build.make CMakeFiles/mojosetup.dir/lua/src/lparser.o.provides.build +.PHONY : CMakeFiles/mojosetup.dir/lua/src/lparser.o.provides + +CMakeFiles/mojosetup.dir/lua/src/lparser.o.provides.build: CMakeFiles/mojosetup.dir/lua/src/lparser.o +.PHONY : CMakeFiles/mojosetup.dir/lua/src/lparser.o.provides.build + +CMakeFiles/mojosetup.dir/lua/src/llex.o: CMakeFiles/mojosetup.dir/flags.make +CMakeFiles/mojosetup.dir/lua/src/llex.o: ../lua/src/llex.c + $(CMAKE_COMMAND) -E cmake_progress_report /home/softcoder/Code/mojosetup/build/CMakeFiles $(CMAKE_PROGRESS_36) + @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green "Building C object CMakeFiles/mojosetup.dir/lua/src/llex.o" + /usr/bin/gcc $(C_DEFINES) $(C_FLAGS) -o CMakeFiles/mojosetup.dir/lua/src/llex.o -c /home/softcoder/Code/mojosetup/lua/src/llex.c + +CMakeFiles/mojosetup.dir/lua/src/llex.i: cmake_force + @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green "Preprocessing C source to CMakeFiles/mojosetup.dir/lua/src/llex.i" + /usr/bin/gcc $(C_DEFINES) $(C_FLAGS) -E /home/softcoder/Code/mojosetup/lua/src/llex.c > CMakeFiles/mojosetup.dir/lua/src/llex.i + +CMakeFiles/mojosetup.dir/lua/src/llex.s: cmake_force + @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green "Compiling C source to assembly CMakeFiles/mojosetup.dir/lua/src/llex.s" + /usr/bin/gcc $(C_DEFINES) $(C_FLAGS) -S /home/softcoder/Code/mojosetup/lua/src/llex.c -o CMakeFiles/mojosetup.dir/lua/src/llex.s + +CMakeFiles/mojosetup.dir/lua/src/llex.o.requires: +.PHONY : CMakeFiles/mojosetup.dir/lua/src/llex.o.requires + +CMakeFiles/mojosetup.dir/lua/src/llex.o.provides: CMakeFiles/mojosetup.dir/lua/src/llex.o.requires + $(MAKE) -f CMakeFiles/mojosetup.dir/build.make CMakeFiles/mojosetup.dir/lua/src/llex.o.provides.build +.PHONY : CMakeFiles/mojosetup.dir/lua/src/llex.o.provides + +CMakeFiles/mojosetup.dir/lua/src/llex.o.provides.build: CMakeFiles/mojosetup.dir/lua/src/llex.o +.PHONY : CMakeFiles/mojosetup.dir/lua/src/llex.o.provides.build + +CMakeFiles/mojosetup.dir/lua/src/lcode.o: CMakeFiles/mojosetup.dir/flags.make +CMakeFiles/mojosetup.dir/lua/src/lcode.o: ../lua/src/lcode.c + $(CMAKE_COMMAND) -E cmake_progress_report /home/softcoder/Code/mojosetup/build/CMakeFiles $(CMAKE_PROGRESS_37) + @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green "Building C object CMakeFiles/mojosetup.dir/lua/src/lcode.o" + /usr/bin/gcc $(C_DEFINES) $(C_FLAGS) -o CMakeFiles/mojosetup.dir/lua/src/lcode.o -c /home/softcoder/Code/mojosetup/lua/src/lcode.c + +CMakeFiles/mojosetup.dir/lua/src/lcode.i: cmake_force + @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green "Preprocessing C source to CMakeFiles/mojosetup.dir/lua/src/lcode.i" + /usr/bin/gcc $(C_DEFINES) $(C_FLAGS) -E /home/softcoder/Code/mojosetup/lua/src/lcode.c > CMakeFiles/mojosetup.dir/lua/src/lcode.i + +CMakeFiles/mojosetup.dir/lua/src/lcode.s: cmake_force + @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green "Compiling C source to assembly CMakeFiles/mojosetup.dir/lua/src/lcode.s" + /usr/bin/gcc $(C_DEFINES) $(C_FLAGS) -S /home/softcoder/Code/mojosetup/lua/src/lcode.c -o CMakeFiles/mojosetup.dir/lua/src/lcode.s + +CMakeFiles/mojosetup.dir/lua/src/lcode.o.requires: +.PHONY : CMakeFiles/mojosetup.dir/lua/src/lcode.o.requires + +CMakeFiles/mojosetup.dir/lua/src/lcode.o.provides: CMakeFiles/mojosetup.dir/lua/src/lcode.o.requires + $(MAKE) -f CMakeFiles/mojosetup.dir/build.make CMakeFiles/mojosetup.dir/lua/src/lcode.o.provides.build +.PHONY : CMakeFiles/mojosetup.dir/lua/src/lcode.o.provides + +CMakeFiles/mojosetup.dir/lua/src/lcode.o.provides.build: CMakeFiles/mojosetup.dir/lua/src/lcode.o +.PHONY : CMakeFiles/mojosetup.dir/lua/src/lcode.o.provides.build + +CMakeFiles/mojosetup.dir/lua/src/liolib.o: CMakeFiles/mojosetup.dir/flags.make +CMakeFiles/mojosetup.dir/lua/src/liolib.o: ../lua/src/liolib.c + $(CMAKE_COMMAND) -E cmake_progress_report /home/softcoder/Code/mojosetup/build/CMakeFiles $(CMAKE_PROGRESS_38) + @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green "Building C object CMakeFiles/mojosetup.dir/lua/src/liolib.o" + /usr/bin/gcc $(C_DEFINES) $(C_FLAGS) -o CMakeFiles/mojosetup.dir/lua/src/liolib.o -c /home/softcoder/Code/mojosetup/lua/src/liolib.c + +CMakeFiles/mojosetup.dir/lua/src/liolib.i: cmake_force + @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green "Preprocessing C source to CMakeFiles/mojosetup.dir/lua/src/liolib.i" + /usr/bin/gcc $(C_DEFINES) $(C_FLAGS) -E /home/softcoder/Code/mojosetup/lua/src/liolib.c > CMakeFiles/mojosetup.dir/lua/src/liolib.i + +CMakeFiles/mojosetup.dir/lua/src/liolib.s: cmake_force + @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green "Compiling C source to assembly CMakeFiles/mojosetup.dir/lua/src/liolib.s" + /usr/bin/gcc $(C_DEFINES) $(C_FLAGS) -S /home/softcoder/Code/mojosetup/lua/src/liolib.c -o CMakeFiles/mojosetup.dir/lua/src/liolib.s + +CMakeFiles/mojosetup.dir/lua/src/liolib.o.requires: +.PHONY : CMakeFiles/mojosetup.dir/lua/src/liolib.o.requires + +CMakeFiles/mojosetup.dir/lua/src/liolib.o.provides: CMakeFiles/mojosetup.dir/lua/src/liolib.o.requires + $(MAKE) -f CMakeFiles/mojosetup.dir/build.make CMakeFiles/mojosetup.dir/lua/src/liolib.o.provides.build +.PHONY : CMakeFiles/mojosetup.dir/lua/src/liolib.o.provides + +CMakeFiles/mojosetup.dir/lua/src/liolib.o.provides.build: CMakeFiles/mojosetup.dir/lua/src/liolib.o +.PHONY : CMakeFiles/mojosetup.dir/lua/src/liolib.o.provides.build + +CMakeFiles/mojosetup.dir/lua/src/loslib.o: CMakeFiles/mojosetup.dir/flags.make +CMakeFiles/mojosetup.dir/lua/src/loslib.o: ../lua/src/loslib.c + $(CMAKE_COMMAND) -E cmake_progress_report /home/softcoder/Code/mojosetup/build/CMakeFiles $(CMAKE_PROGRESS_39) + @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green "Building C object CMakeFiles/mojosetup.dir/lua/src/loslib.o" + /usr/bin/gcc $(C_DEFINES) $(C_FLAGS) -o CMakeFiles/mojosetup.dir/lua/src/loslib.o -c /home/softcoder/Code/mojosetup/lua/src/loslib.c + +CMakeFiles/mojosetup.dir/lua/src/loslib.i: cmake_force + @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green "Preprocessing C source to CMakeFiles/mojosetup.dir/lua/src/loslib.i" + /usr/bin/gcc $(C_DEFINES) $(C_FLAGS) -E /home/softcoder/Code/mojosetup/lua/src/loslib.c > CMakeFiles/mojosetup.dir/lua/src/loslib.i + +CMakeFiles/mojosetup.dir/lua/src/loslib.s: cmake_force + @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green "Compiling C source to assembly CMakeFiles/mojosetup.dir/lua/src/loslib.s" + /usr/bin/gcc $(C_DEFINES) $(C_FLAGS) -S /home/softcoder/Code/mojosetup/lua/src/loslib.c -o CMakeFiles/mojosetup.dir/lua/src/loslib.s + +CMakeFiles/mojosetup.dir/lua/src/loslib.o.requires: +.PHONY : CMakeFiles/mojosetup.dir/lua/src/loslib.o.requires + +CMakeFiles/mojosetup.dir/lua/src/loslib.o.provides: CMakeFiles/mojosetup.dir/lua/src/loslib.o.requires + $(MAKE) -f CMakeFiles/mojosetup.dir/build.make CMakeFiles/mojosetup.dir/lua/src/loslib.o.provides.build +.PHONY : CMakeFiles/mojosetup.dir/lua/src/loslib.o.provides + +CMakeFiles/mojosetup.dir/lua/src/loslib.o.provides.build: CMakeFiles/mojosetup.dir/lua/src/loslib.o +.PHONY : CMakeFiles/mojosetup.dir/lua/src/loslib.o.provides.build + +CMakeFiles/mojosetup.dir/lua/src/lmathlib.o: CMakeFiles/mojosetup.dir/flags.make +CMakeFiles/mojosetup.dir/lua/src/lmathlib.o: ../lua/src/lmathlib.c + $(CMAKE_COMMAND) -E cmake_progress_report /home/softcoder/Code/mojosetup/build/CMakeFiles $(CMAKE_PROGRESS_40) + @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green "Building C object CMakeFiles/mojosetup.dir/lua/src/lmathlib.o" + /usr/bin/gcc $(C_DEFINES) $(C_FLAGS) -o CMakeFiles/mojosetup.dir/lua/src/lmathlib.o -c /home/softcoder/Code/mojosetup/lua/src/lmathlib.c + +CMakeFiles/mojosetup.dir/lua/src/lmathlib.i: cmake_force + @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green "Preprocessing C source to CMakeFiles/mojosetup.dir/lua/src/lmathlib.i" + /usr/bin/gcc $(C_DEFINES) $(C_FLAGS) -E /home/softcoder/Code/mojosetup/lua/src/lmathlib.c > CMakeFiles/mojosetup.dir/lua/src/lmathlib.i + +CMakeFiles/mojosetup.dir/lua/src/lmathlib.s: cmake_force + @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green "Compiling C source to assembly CMakeFiles/mojosetup.dir/lua/src/lmathlib.s" + /usr/bin/gcc $(C_DEFINES) $(C_FLAGS) -S /home/softcoder/Code/mojosetup/lua/src/lmathlib.c -o CMakeFiles/mojosetup.dir/lua/src/lmathlib.s + +CMakeFiles/mojosetup.dir/lua/src/lmathlib.o.requires: +.PHONY : CMakeFiles/mojosetup.dir/lua/src/lmathlib.o.requires + +CMakeFiles/mojosetup.dir/lua/src/lmathlib.o.provides: CMakeFiles/mojosetup.dir/lua/src/lmathlib.o.requires + $(MAKE) -f CMakeFiles/mojosetup.dir/build.make CMakeFiles/mojosetup.dir/lua/src/lmathlib.o.provides.build +.PHONY : CMakeFiles/mojosetup.dir/lua/src/lmathlib.o.provides + +CMakeFiles/mojosetup.dir/lua/src/lmathlib.o.provides.build: CMakeFiles/mojosetup.dir/lua/src/lmathlib.o +.PHONY : CMakeFiles/mojosetup.dir/lua/src/lmathlib.o.provides.build + +CMakeFiles/mojosetup.dir/lua/src/ldblib.o: CMakeFiles/mojosetup.dir/flags.make +CMakeFiles/mojosetup.dir/lua/src/ldblib.o: ../lua/src/ldblib.c + $(CMAKE_COMMAND) -E cmake_progress_report /home/softcoder/Code/mojosetup/build/CMakeFiles $(CMAKE_PROGRESS_41) + @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green "Building C object CMakeFiles/mojosetup.dir/lua/src/ldblib.o" + /usr/bin/gcc $(C_DEFINES) $(C_FLAGS) -o CMakeFiles/mojosetup.dir/lua/src/ldblib.o -c /home/softcoder/Code/mojosetup/lua/src/ldblib.c + +CMakeFiles/mojosetup.dir/lua/src/ldblib.i: cmake_force + @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green "Preprocessing C source to CMakeFiles/mojosetup.dir/lua/src/ldblib.i" + /usr/bin/gcc $(C_DEFINES) $(C_FLAGS) -E /home/softcoder/Code/mojosetup/lua/src/ldblib.c > CMakeFiles/mojosetup.dir/lua/src/ldblib.i + +CMakeFiles/mojosetup.dir/lua/src/ldblib.s: cmake_force + @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green "Compiling C source to assembly CMakeFiles/mojosetup.dir/lua/src/ldblib.s" + /usr/bin/gcc $(C_DEFINES) $(C_FLAGS) -S /home/softcoder/Code/mojosetup/lua/src/ldblib.c -o CMakeFiles/mojosetup.dir/lua/src/ldblib.s + +CMakeFiles/mojosetup.dir/lua/src/ldblib.o.requires: +.PHONY : CMakeFiles/mojosetup.dir/lua/src/ldblib.o.requires + +CMakeFiles/mojosetup.dir/lua/src/ldblib.o.provides: CMakeFiles/mojosetup.dir/lua/src/ldblib.o.requires + $(MAKE) -f CMakeFiles/mojosetup.dir/build.make CMakeFiles/mojosetup.dir/lua/src/ldblib.o.provides.build +.PHONY : CMakeFiles/mojosetup.dir/lua/src/ldblib.o.provides + +CMakeFiles/mojosetup.dir/lua/src/ldblib.o.provides.build: CMakeFiles/mojosetup.dir/lua/src/ldblib.o +.PHONY : CMakeFiles/mojosetup.dir/lua/src/ldblib.o.provides.build + +CMakeFiles/mojosetup.dir/lua/src/loadlib.o: CMakeFiles/mojosetup.dir/flags.make +CMakeFiles/mojosetup.dir/lua/src/loadlib.o: ../lua/src/loadlib.c + $(CMAKE_COMMAND) -E cmake_progress_report /home/softcoder/Code/mojosetup/build/CMakeFiles $(CMAKE_PROGRESS_42) + @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green "Building C object CMakeFiles/mojosetup.dir/lua/src/loadlib.o" + /usr/bin/gcc $(C_DEFINES) $(C_FLAGS) -o CMakeFiles/mojosetup.dir/lua/src/loadlib.o -c /home/softcoder/Code/mojosetup/lua/src/loadlib.c + +CMakeFiles/mojosetup.dir/lua/src/loadlib.i: cmake_force + @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green "Preprocessing C source to CMakeFiles/mojosetup.dir/lua/src/loadlib.i" + /usr/bin/gcc $(C_DEFINES) $(C_FLAGS) -E /home/softcoder/Code/mojosetup/lua/src/loadlib.c > CMakeFiles/mojosetup.dir/lua/src/loadlib.i + +CMakeFiles/mojosetup.dir/lua/src/loadlib.s: cmake_force + @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green "Compiling C source to assembly CMakeFiles/mojosetup.dir/lua/src/loadlib.s" + /usr/bin/gcc $(C_DEFINES) $(C_FLAGS) -S /home/softcoder/Code/mojosetup/lua/src/loadlib.c -o CMakeFiles/mojosetup.dir/lua/src/loadlib.s + +CMakeFiles/mojosetup.dir/lua/src/loadlib.o.requires: +.PHONY : CMakeFiles/mojosetup.dir/lua/src/loadlib.o.requires + +CMakeFiles/mojosetup.dir/lua/src/loadlib.o.provides: CMakeFiles/mojosetup.dir/lua/src/loadlib.o.requires + $(MAKE) -f CMakeFiles/mojosetup.dir/build.make CMakeFiles/mojosetup.dir/lua/src/loadlib.o.provides.build +.PHONY : CMakeFiles/mojosetup.dir/lua/src/loadlib.o.provides + +CMakeFiles/mojosetup.dir/lua/src/loadlib.o.provides.build: CMakeFiles/mojosetup.dir/lua/src/loadlib.o +.PHONY : CMakeFiles/mojosetup.dir/lua/src/loadlib.o.provides.build + +CMakeFiles/mojosetup.dir/gui_stdio.o: CMakeFiles/mojosetup.dir/flags.make +CMakeFiles/mojosetup.dir/gui_stdio.o: ../gui_stdio.c + $(CMAKE_COMMAND) -E cmake_progress_report /home/softcoder/Code/mojosetup/build/CMakeFiles $(CMAKE_PROGRESS_43) + @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green "Building C object CMakeFiles/mojosetup.dir/gui_stdio.o" + /usr/bin/gcc $(C_DEFINES) $(C_FLAGS) -o CMakeFiles/mojosetup.dir/gui_stdio.o -c /home/softcoder/Code/mojosetup/gui_stdio.c + +CMakeFiles/mojosetup.dir/gui_stdio.i: cmake_force + @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green "Preprocessing C source to CMakeFiles/mojosetup.dir/gui_stdio.i" + /usr/bin/gcc $(C_DEFINES) $(C_FLAGS) -E /home/softcoder/Code/mojosetup/gui_stdio.c > CMakeFiles/mojosetup.dir/gui_stdio.i + +CMakeFiles/mojosetup.dir/gui_stdio.s: cmake_force + @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green "Compiling C source to assembly CMakeFiles/mojosetup.dir/gui_stdio.s" + /usr/bin/gcc $(C_DEFINES) $(C_FLAGS) -S /home/softcoder/Code/mojosetup/gui_stdio.c -o CMakeFiles/mojosetup.dir/gui_stdio.s + +CMakeFiles/mojosetup.dir/gui_stdio.o.requires: +.PHONY : CMakeFiles/mojosetup.dir/gui_stdio.o.requires + +CMakeFiles/mojosetup.dir/gui_stdio.o.provides: CMakeFiles/mojosetup.dir/gui_stdio.o.requires + $(MAKE) -f CMakeFiles/mojosetup.dir/build.make CMakeFiles/mojosetup.dir/gui_stdio.o.provides.build +.PHONY : CMakeFiles/mojosetup.dir/gui_stdio.o.provides + +CMakeFiles/mojosetup.dir/gui_stdio.o.provides.build: CMakeFiles/mojosetup.dir/gui_stdio.o +.PHONY : CMakeFiles/mojosetup.dir/gui_stdio.o.provides.build + +CMakeFiles/mojosetup.dir/stb_image.o: CMakeFiles/mojosetup.dir/flags.make +CMakeFiles/mojosetup.dir/stb_image.o: ../stb_image.c + $(CMAKE_COMMAND) -E cmake_progress_report /home/softcoder/Code/mojosetup/build/CMakeFiles $(CMAKE_PROGRESS_44) + @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green "Building C object CMakeFiles/mojosetup.dir/stb_image.o" + /usr/bin/gcc $(C_DEFINES) $(C_FLAGS) -o CMakeFiles/mojosetup.dir/stb_image.o -c /home/softcoder/Code/mojosetup/stb_image.c + +CMakeFiles/mojosetup.dir/stb_image.i: cmake_force + @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green "Preprocessing C source to CMakeFiles/mojosetup.dir/stb_image.i" + /usr/bin/gcc $(C_DEFINES) $(C_FLAGS) -E /home/softcoder/Code/mojosetup/stb_image.c > CMakeFiles/mojosetup.dir/stb_image.i + +CMakeFiles/mojosetup.dir/stb_image.s: cmake_force + @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green "Compiling C source to assembly CMakeFiles/mojosetup.dir/stb_image.s" + /usr/bin/gcc $(C_DEFINES) $(C_FLAGS) -S /home/softcoder/Code/mojosetup/stb_image.c -o CMakeFiles/mojosetup.dir/stb_image.s + +CMakeFiles/mojosetup.dir/stb_image.o.requires: +.PHONY : CMakeFiles/mojosetup.dir/stb_image.o.requires + +CMakeFiles/mojosetup.dir/stb_image.o.provides: CMakeFiles/mojosetup.dir/stb_image.o.requires + $(MAKE) -f CMakeFiles/mojosetup.dir/build.make CMakeFiles/mojosetup.dir/stb_image.o.provides.build +.PHONY : CMakeFiles/mojosetup.dir/stb_image.o.provides + +CMakeFiles/mojosetup.dir/stb_image.o.provides.build: CMakeFiles/mojosetup.dir/stb_image.o +.PHONY : CMakeFiles/mojosetup.dir/stb_image.o.provides.build + +CMakeFiles/mojosetup.dir/libfetch/fetch.o: CMakeFiles/mojosetup.dir/flags.make +CMakeFiles/mojosetup.dir/libfetch/fetch.o: ../libfetch/fetch.c + $(CMAKE_COMMAND) -E cmake_progress_report /home/softcoder/Code/mojosetup/build/CMakeFiles $(CMAKE_PROGRESS_45) + @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green "Building C object CMakeFiles/mojosetup.dir/libfetch/fetch.o" + /usr/bin/gcc $(C_DEFINES) $(C_FLAGS) -o CMakeFiles/mojosetup.dir/libfetch/fetch.o -c /home/softcoder/Code/mojosetup/libfetch/fetch.c + +CMakeFiles/mojosetup.dir/libfetch/fetch.i: cmake_force + @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green "Preprocessing C source to CMakeFiles/mojosetup.dir/libfetch/fetch.i" + /usr/bin/gcc $(C_DEFINES) $(C_FLAGS) -E /home/softcoder/Code/mojosetup/libfetch/fetch.c > CMakeFiles/mojosetup.dir/libfetch/fetch.i + +CMakeFiles/mojosetup.dir/libfetch/fetch.s: cmake_force + @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green "Compiling C source to assembly CMakeFiles/mojosetup.dir/libfetch/fetch.s" + /usr/bin/gcc $(C_DEFINES) $(C_FLAGS) -S /home/softcoder/Code/mojosetup/libfetch/fetch.c -o CMakeFiles/mojosetup.dir/libfetch/fetch.s + +CMakeFiles/mojosetup.dir/libfetch/fetch.o.requires: +.PHONY : CMakeFiles/mojosetup.dir/libfetch/fetch.o.requires + +CMakeFiles/mojosetup.dir/libfetch/fetch.o.provides: CMakeFiles/mojosetup.dir/libfetch/fetch.o.requires + $(MAKE) -f CMakeFiles/mojosetup.dir/build.make CMakeFiles/mojosetup.dir/libfetch/fetch.o.provides.build +.PHONY : CMakeFiles/mojosetup.dir/libfetch/fetch.o.provides + +CMakeFiles/mojosetup.dir/libfetch/fetch.o.provides.build: CMakeFiles/mojosetup.dir/libfetch/fetch.o +.PHONY : CMakeFiles/mojosetup.dir/libfetch/fetch.o.provides.build + +CMakeFiles/mojosetup.dir/libfetch/common.o: CMakeFiles/mojosetup.dir/flags.make +CMakeFiles/mojosetup.dir/libfetch/common.o: ../libfetch/common.c + $(CMAKE_COMMAND) -E cmake_progress_report /home/softcoder/Code/mojosetup/build/CMakeFiles $(CMAKE_PROGRESS_46) + @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green "Building C object CMakeFiles/mojosetup.dir/libfetch/common.o" + /usr/bin/gcc $(C_DEFINES) $(C_FLAGS) -o CMakeFiles/mojosetup.dir/libfetch/common.o -c /home/softcoder/Code/mojosetup/libfetch/common.c + +CMakeFiles/mojosetup.dir/libfetch/common.i: cmake_force + @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green "Preprocessing C source to CMakeFiles/mojosetup.dir/libfetch/common.i" + /usr/bin/gcc $(C_DEFINES) $(C_FLAGS) -E /home/softcoder/Code/mojosetup/libfetch/common.c > CMakeFiles/mojosetup.dir/libfetch/common.i + +CMakeFiles/mojosetup.dir/libfetch/common.s: cmake_force + @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green "Compiling C source to assembly CMakeFiles/mojosetup.dir/libfetch/common.s" + /usr/bin/gcc $(C_DEFINES) $(C_FLAGS) -S /home/softcoder/Code/mojosetup/libfetch/common.c -o CMakeFiles/mojosetup.dir/libfetch/common.s + +CMakeFiles/mojosetup.dir/libfetch/common.o.requires: +.PHONY : CMakeFiles/mojosetup.dir/libfetch/common.o.requires + +CMakeFiles/mojosetup.dir/libfetch/common.o.provides: CMakeFiles/mojosetup.dir/libfetch/common.o.requires + $(MAKE) -f CMakeFiles/mojosetup.dir/build.make CMakeFiles/mojosetup.dir/libfetch/common.o.provides.build +.PHONY : CMakeFiles/mojosetup.dir/libfetch/common.o.provides + +CMakeFiles/mojosetup.dir/libfetch/common.o.provides.build: CMakeFiles/mojosetup.dir/libfetch/common.o +.PHONY : CMakeFiles/mojosetup.dir/libfetch/common.o.provides.build + +CMakeFiles/mojosetup.dir/libfetch/ftp.o: CMakeFiles/mojosetup.dir/flags.make +CMakeFiles/mojosetup.dir/libfetch/ftp.o: ../libfetch/ftp.c + $(CMAKE_COMMAND) -E cmake_progress_report /home/softcoder/Code/mojosetup/build/CMakeFiles $(CMAKE_PROGRESS_47) + @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green "Building C object CMakeFiles/mojosetup.dir/libfetch/ftp.o" + /usr/bin/gcc $(C_DEFINES) $(C_FLAGS) -o CMakeFiles/mojosetup.dir/libfetch/ftp.o -c /home/softcoder/Code/mojosetup/libfetch/ftp.c + +CMakeFiles/mojosetup.dir/libfetch/ftp.i: cmake_force + @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green "Preprocessing C source to CMakeFiles/mojosetup.dir/libfetch/ftp.i" + /usr/bin/gcc $(C_DEFINES) $(C_FLAGS) -E /home/softcoder/Code/mojosetup/libfetch/ftp.c > CMakeFiles/mojosetup.dir/libfetch/ftp.i + +CMakeFiles/mojosetup.dir/libfetch/ftp.s: cmake_force + @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green "Compiling C source to assembly CMakeFiles/mojosetup.dir/libfetch/ftp.s" + /usr/bin/gcc $(C_DEFINES) $(C_FLAGS) -S /home/softcoder/Code/mojosetup/libfetch/ftp.c -o CMakeFiles/mojosetup.dir/libfetch/ftp.s + +CMakeFiles/mojosetup.dir/libfetch/ftp.o.requires: +.PHONY : CMakeFiles/mojosetup.dir/libfetch/ftp.o.requires + +CMakeFiles/mojosetup.dir/libfetch/ftp.o.provides: CMakeFiles/mojosetup.dir/libfetch/ftp.o.requires + $(MAKE) -f CMakeFiles/mojosetup.dir/build.make CMakeFiles/mojosetup.dir/libfetch/ftp.o.provides.build +.PHONY : CMakeFiles/mojosetup.dir/libfetch/ftp.o.provides + +CMakeFiles/mojosetup.dir/libfetch/ftp.o.provides.build: CMakeFiles/mojosetup.dir/libfetch/ftp.o +.PHONY : CMakeFiles/mojosetup.dir/libfetch/ftp.o.provides.build + +CMakeFiles/mojosetup.dir/libfetch/http.o: CMakeFiles/mojosetup.dir/flags.make +CMakeFiles/mojosetup.dir/libfetch/http.o: ../libfetch/http.c + $(CMAKE_COMMAND) -E cmake_progress_report /home/softcoder/Code/mojosetup/build/CMakeFiles $(CMAKE_PROGRESS_48) + @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green "Building C object CMakeFiles/mojosetup.dir/libfetch/http.o" + /usr/bin/gcc $(C_DEFINES) $(C_FLAGS) -o CMakeFiles/mojosetup.dir/libfetch/http.o -c /home/softcoder/Code/mojosetup/libfetch/http.c + +CMakeFiles/mojosetup.dir/libfetch/http.i: cmake_force + @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green "Preprocessing C source to CMakeFiles/mojosetup.dir/libfetch/http.i" + /usr/bin/gcc $(C_DEFINES) $(C_FLAGS) -E /home/softcoder/Code/mojosetup/libfetch/http.c > CMakeFiles/mojosetup.dir/libfetch/http.i + +CMakeFiles/mojosetup.dir/libfetch/http.s: cmake_force + @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green "Compiling C source to assembly CMakeFiles/mojosetup.dir/libfetch/http.s" + /usr/bin/gcc $(C_DEFINES) $(C_FLAGS) -S /home/softcoder/Code/mojosetup/libfetch/http.c -o CMakeFiles/mojosetup.dir/libfetch/http.s + +CMakeFiles/mojosetup.dir/libfetch/http.o.requires: +.PHONY : CMakeFiles/mojosetup.dir/libfetch/http.o.requires + +CMakeFiles/mojosetup.dir/libfetch/http.o.provides: CMakeFiles/mojosetup.dir/libfetch/http.o.requires + $(MAKE) -f CMakeFiles/mojosetup.dir/build.make CMakeFiles/mojosetup.dir/libfetch/http.o.provides.build +.PHONY : CMakeFiles/mojosetup.dir/libfetch/http.o.provides + +CMakeFiles/mojosetup.dir/libfetch/http.o.provides.build: CMakeFiles/mojosetup.dir/libfetch/http.o +.PHONY : CMakeFiles/mojosetup.dir/libfetch/http.o.provides.build + +# Object files for target mojosetup +mojosetup_OBJECTS = \ +"CMakeFiles/mojosetup.dir/buildver.o" \ +"CMakeFiles/mojosetup.dir/mojosetup.o" \ +"CMakeFiles/mojosetup.dir/gui.o" \ +"CMakeFiles/mojosetup.dir/fileio.o" \ +"CMakeFiles/mojosetup.dir/archive_zip.o" \ +"CMakeFiles/mojosetup.dir/archive_tar.o" \ +"CMakeFiles/mojosetup.dir/archive_uz2.o" \ +"CMakeFiles/mojosetup.dir/archive_pck.o" \ +"CMakeFiles/mojosetup.dir/checksum_crc32.o" \ +"CMakeFiles/mojosetup.dir/checksum_md5.o" \ +"CMakeFiles/mojosetup.dir/checksum_sha1.o" \ +"CMakeFiles/mojosetup.dir/platform_unix.o" \ +"CMakeFiles/mojosetup.dir/platform_windows.o" \ +"CMakeFiles/mojosetup.dir/lua_glue.o" \ +"CMakeFiles/mojosetup.dir/lua/src/lapi.o" \ +"CMakeFiles/mojosetup.dir/lua/src/ldebug.o" \ +"CMakeFiles/mojosetup.dir/lua/src/ldo.o" \ +"CMakeFiles/mojosetup.dir/lua/src/ldump.o" \ +"CMakeFiles/mojosetup.dir/lua/src/lfunc.o" \ +"CMakeFiles/mojosetup.dir/lua/src/lgc.o" \ +"CMakeFiles/mojosetup.dir/lua/src/lmem.o" \ +"CMakeFiles/mojosetup.dir/lua/src/lobject.o" \ +"CMakeFiles/mojosetup.dir/lua/src/lopcodes.o" \ +"CMakeFiles/mojosetup.dir/lua/src/lstate.o" \ +"CMakeFiles/mojosetup.dir/lua/src/lstring.o" \ +"CMakeFiles/mojosetup.dir/lua/src/ltable.o" \ +"CMakeFiles/mojosetup.dir/lua/src/ltm.o" \ +"CMakeFiles/mojosetup.dir/lua/src/lundump.o" \ +"CMakeFiles/mojosetup.dir/lua/src/lvm.o" \ +"CMakeFiles/mojosetup.dir/lua/src/lzio.o" \ +"CMakeFiles/mojosetup.dir/lua/src/lauxlib.o" \ +"CMakeFiles/mojosetup.dir/lua/src/lbaselib.o" \ +"CMakeFiles/mojosetup.dir/lua/src/lstrlib.o" \ +"CMakeFiles/mojosetup.dir/lua/src/ltablib.o" \ +"CMakeFiles/mojosetup.dir/lua/src/lparser.o" \ +"CMakeFiles/mojosetup.dir/lua/src/llex.o" \ +"CMakeFiles/mojosetup.dir/lua/src/lcode.o" \ +"CMakeFiles/mojosetup.dir/lua/src/liolib.o" \ +"CMakeFiles/mojosetup.dir/lua/src/loslib.o" \ +"CMakeFiles/mojosetup.dir/lua/src/lmathlib.o" \ +"CMakeFiles/mojosetup.dir/lua/src/ldblib.o" \ +"CMakeFiles/mojosetup.dir/lua/src/loadlib.o" \ +"CMakeFiles/mojosetup.dir/gui_stdio.o" \ +"CMakeFiles/mojosetup.dir/stb_image.o" \ +"CMakeFiles/mojosetup.dir/libfetch/fetch.o" \ +"CMakeFiles/mojosetup.dir/libfetch/common.o" \ +"CMakeFiles/mojosetup.dir/libfetch/ftp.o" \ +"CMakeFiles/mojosetup.dir/libfetch/http.o" + +# External object files for target mojosetup +mojosetup_EXTERNAL_OBJECTS = + +mojosetup: CMakeFiles/mojosetup.dir/buildver.o +mojosetup: CMakeFiles/mojosetup.dir/mojosetup.o +mojosetup: CMakeFiles/mojosetup.dir/gui.o +mojosetup: CMakeFiles/mojosetup.dir/fileio.o +mojosetup: CMakeFiles/mojosetup.dir/archive_zip.o +mojosetup: CMakeFiles/mojosetup.dir/archive_tar.o +mojosetup: CMakeFiles/mojosetup.dir/archive_uz2.o +mojosetup: CMakeFiles/mojosetup.dir/archive_pck.o +mojosetup: CMakeFiles/mojosetup.dir/checksum_crc32.o +mojosetup: CMakeFiles/mojosetup.dir/checksum_md5.o +mojosetup: CMakeFiles/mojosetup.dir/checksum_sha1.o +mojosetup: CMakeFiles/mojosetup.dir/platform_unix.o +mojosetup: CMakeFiles/mojosetup.dir/platform_windows.o +mojosetup: CMakeFiles/mojosetup.dir/lua_glue.o +mojosetup: CMakeFiles/mojosetup.dir/lua/src/lapi.o +mojosetup: CMakeFiles/mojosetup.dir/lua/src/ldebug.o +mojosetup: CMakeFiles/mojosetup.dir/lua/src/ldo.o +mojosetup: CMakeFiles/mojosetup.dir/lua/src/ldump.o +mojosetup: CMakeFiles/mojosetup.dir/lua/src/lfunc.o +mojosetup: CMakeFiles/mojosetup.dir/lua/src/lgc.o +mojosetup: CMakeFiles/mojosetup.dir/lua/src/lmem.o +mojosetup: CMakeFiles/mojosetup.dir/lua/src/lobject.o +mojosetup: CMakeFiles/mojosetup.dir/lua/src/lopcodes.o +mojosetup: CMakeFiles/mojosetup.dir/lua/src/lstate.o +mojosetup: CMakeFiles/mojosetup.dir/lua/src/lstring.o +mojosetup: CMakeFiles/mojosetup.dir/lua/src/ltable.o +mojosetup: CMakeFiles/mojosetup.dir/lua/src/ltm.o +mojosetup: CMakeFiles/mojosetup.dir/lua/src/lundump.o +mojosetup: CMakeFiles/mojosetup.dir/lua/src/lvm.o +mojosetup: CMakeFiles/mojosetup.dir/lua/src/lzio.o +mojosetup: CMakeFiles/mojosetup.dir/lua/src/lauxlib.o +mojosetup: CMakeFiles/mojosetup.dir/lua/src/lbaselib.o +mojosetup: CMakeFiles/mojosetup.dir/lua/src/lstrlib.o +mojosetup: CMakeFiles/mojosetup.dir/lua/src/ltablib.o +mojosetup: CMakeFiles/mojosetup.dir/lua/src/lparser.o +mojosetup: CMakeFiles/mojosetup.dir/lua/src/llex.o +mojosetup: CMakeFiles/mojosetup.dir/lua/src/lcode.o +mojosetup: CMakeFiles/mojosetup.dir/lua/src/liolib.o +mojosetup: CMakeFiles/mojosetup.dir/lua/src/loslib.o +mojosetup: CMakeFiles/mojosetup.dir/lua/src/lmathlib.o +mojosetup: CMakeFiles/mojosetup.dir/lua/src/ldblib.o +mojosetup: CMakeFiles/mojosetup.dir/lua/src/loadlib.o +mojosetup: CMakeFiles/mojosetup.dir/gui_stdio.o +mojosetup: CMakeFiles/mojosetup.dir/stb_image.o +mojosetup: CMakeFiles/mojosetup.dir/libfetch/fetch.o +mojosetup: CMakeFiles/mojosetup.dir/libfetch/common.o +mojosetup: CMakeFiles/mojosetup.dir/libfetch/ftp.o +mojosetup: CMakeFiles/mojosetup.dir/libfetch/http.o +mojosetup: CMakeFiles/mojosetup.dir/build.make +mojosetup: CMakeFiles/mojosetup.dir/link.txt + @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --red --bold "Linking C executable mojosetup" + $(CMAKE_COMMAND) -E cmake_link_script CMakeFiles/mojosetup.dir/link.txt --verbose=$(VERBOSE) + +# Rule to build all files generated by this target. +CMakeFiles/mojosetup.dir/build: mojosetup +.PHONY : CMakeFiles/mojosetup.dir/build + +CMakeFiles/mojosetup.dir/requires: CMakeFiles/mojosetup.dir/buildver.o.requires +CMakeFiles/mojosetup.dir/requires: CMakeFiles/mojosetup.dir/mojosetup.o.requires +CMakeFiles/mojosetup.dir/requires: CMakeFiles/mojosetup.dir/gui.o.requires +CMakeFiles/mojosetup.dir/requires: CMakeFiles/mojosetup.dir/fileio.o.requires +CMakeFiles/mojosetup.dir/requires: CMakeFiles/mojosetup.dir/archive_zip.o.requires +CMakeFiles/mojosetup.dir/requires: CMakeFiles/mojosetup.dir/archive_tar.o.requires +CMakeFiles/mojosetup.dir/requires: CMakeFiles/mojosetup.dir/archive_uz2.o.requires +CMakeFiles/mojosetup.dir/requires: CMakeFiles/mojosetup.dir/archive_pck.o.requires +CMakeFiles/mojosetup.dir/requires: CMakeFiles/mojosetup.dir/checksum_crc32.o.requires +CMakeFiles/mojosetup.dir/requires: CMakeFiles/mojosetup.dir/checksum_md5.o.requires +CMakeFiles/mojosetup.dir/requires: CMakeFiles/mojosetup.dir/checksum_sha1.o.requires +CMakeFiles/mojosetup.dir/requires: CMakeFiles/mojosetup.dir/platform_unix.o.requires +CMakeFiles/mojosetup.dir/requires: CMakeFiles/mojosetup.dir/platform_windows.o.requires +CMakeFiles/mojosetup.dir/requires: CMakeFiles/mojosetup.dir/lua_glue.o.requires +CMakeFiles/mojosetup.dir/requires: CMakeFiles/mojosetup.dir/lua/src/lapi.o.requires +CMakeFiles/mojosetup.dir/requires: CMakeFiles/mojosetup.dir/lua/src/ldebug.o.requires +CMakeFiles/mojosetup.dir/requires: CMakeFiles/mojosetup.dir/lua/src/ldo.o.requires +CMakeFiles/mojosetup.dir/requires: CMakeFiles/mojosetup.dir/lua/src/ldump.o.requires +CMakeFiles/mojosetup.dir/requires: CMakeFiles/mojosetup.dir/lua/src/lfunc.o.requires +CMakeFiles/mojosetup.dir/requires: CMakeFiles/mojosetup.dir/lua/src/lgc.o.requires +CMakeFiles/mojosetup.dir/requires: CMakeFiles/mojosetup.dir/lua/src/lmem.o.requires +CMakeFiles/mojosetup.dir/requires: CMakeFiles/mojosetup.dir/lua/src/lobject.o.requires +CMakeFiles/mojosetup.dir/requires: CMakeFiles/mojosetup.dir/lua/src/lopcodes.o.requires +CMakeFiles/mojosetup.dir/requires: CMakeFiles/mojosetup.dir/lua/src/lstate.o.requires +CMakeFiles/mojosetup.dir/requires: CMakeFiles/mojosetup.dir/lua/src/lstring.o.requires +CMakeFiles/mojosetup.dir/requires: CMakeFiles/mojosetup.dir/lua/src/ltable.o.requires +CMakeFiles/mojosetup.dir/requires: CMakeFiles/mojosetup.dir/lua/src/ltm.o.requires +CMakeFiles/mojosetup.dir/requires: CMakeFiles/mojosetup.dir/lua/src/lundump.o.requires +CMakeFiles/mojosetup.dir/requires: CMakeFiles/mojosetup.dir/lua/src/lvm.o.requires +CMakeFiles/mojosetup.dir/requires: CMakeFiles/mojosetup.dir/lua/src/lzio.o.requires +CMakeFiles/mojosetup.dir/requires: CMakeFiles/mojosetup.dir/lua/src/lauxlib.o.requires +CMakeFiles/mojosetup.dir/requires: CMakeFiles/mojosetup.dir/lua/src/lbaselib.o.requires +CMakeFiles/mojosetup.dir/requires: CMakeFiles/mojosetup.dir/lua/src/lstrlib.o.requires +CMakeFiles/mojosetup.dir/requires: CMakeFiles/mojosetup.dir/lua/src/ltablib.o.requires +CMakeFiles/mojosetup.dir/requires: CMakeFiles/mojosetup.dir/lua/src/lparser.o.requires +CMakeFiles/mojosetup.dir/requires: CMakeFiles/mojosetup.dir/lua/src/llex.o.requires +CMakeFiles/mojosetup.dir/requires: CMakeFiles/mojosetup.dir/lua/src/lcode.o.requires +CMakeFiles/mojosetup.dir/requires: CMakeFiles/mojosetup.dir/lua/src/liolib.o.requires +CMakeFiles/mojosetup.dir/requires: CMakeFiles/mojosetup.dir/lua/src/loslib.o.requires +CMakeFiles/mojosetup.dir/requires: CMakeFiles/mojosetup.dir/lua/src/lmathlib.o.requires +CMakeFiles/mojosetup.dir/requires: CMakeFiles/mojosetup.dir/lua/src/ldblib.o.requires +CMakeFiles/mojosetup.dir/requires: CMakeFiles/mojosetup.dir/lua/src/loadlib.o.requires +CMakeFiles/mojosetup.dir/requires: CMakeFiles/mojosetup.dir/gui_stdio.o.requires +CMakeFiles/mojosetup.dir/requires: CMakeFiles/mojosetup.dir/stb_image.o.requires +CMakeFiles/mojosetup.dir/requires: CMakeFiles/mojosetup.dir/libfetch/fetch.o.requires +CMakeFiles/mojosetup.dir/requires: CMakeFiles/mojosetup.dir/libfetch/common.o.requires +CMakeFiles/mojosetup.dir/requires: CMakeFiles/mojosetup.dir/libfetch/ftp.o.requires +CMakeFiles/mojosetup.dir/requires: CMakeFiles/mojosetup.dir/libfetch/http.o.requires +.PHONY : CMakeFiles/mojosetup.dir/requires + +CMakeFiles/mojosetup.dir/clean: + $(CMAKE_COMMAND) -P CMakeFiles/mojosetup.dir/cmake_clean.cmake +.PHONY : CMakeFiles/mojosetup.dir/clean + +CMakeFiles/mojosetup.dir/depend: + cd /home/softcoder/Code/mojosetup/build && $(CMAKE_COMMAND) -E cmake_depends "Unix Makefiles" /home/softcoder/Code/mojosetup /home/softcoder/Code/mojosetup /home/softcoder/Code/mojosetup/build /home/softcoder/Code/mojosetup/build /home/softcoder/Code/mojosetup/build/CMakeFiles/mojosetup.dir/DependInfo.cmake --color=$(COLOR) +.PHONY : CMakeFiles/mojosetup.dir/depend + diff --git a/mk/linux/mojosetup/build/CMakeFiles/mojosetup.dir/cmake_clean.cmake b/mk/linux/mojosetup/build/CMakeFiles/mojosetup.dir/cmake_clean.cmake new file mode 100644 index 00000000..229f3d51 --- /dev/null +++ b/mk/linux/mojosetup/build/CMakeFiles/mojosetup.dir/cmake_clean.cmake @@ -0,0 +1,57 @@ +FILE(REMOVE_RECURSE + "CMakeFiles/mojosetup.dir/buildver.o" + "CMakeFiles/mojosetup.dir/mojosetup.o" + "CMakeFiles/mojosetup.dir/gui.o" + "CMakeFiles/mojosetup.dir/fileio.o" + "CMakeFiles/mojosetup.dir/archive_zip.o" + "CMakeFiles/mojosetup.dir/archive_tar.o" + "CMakeFiles/mojosetup.dir/archive_uz2.o" + "CMakeFiles/mojosetup.dir/archive_pck.o" + "CMakeFiles/mojosetup.dir/checksum_crc32.o" + "CMakeFiles/mojosetup.dir/checksum_md5.o" + "CMakeFiles/mojosetup.dir/checksum_sha1.o" + "CMakeFiles/mojosetup.dir/platform_unix.o" + "CMakeFiles/mojosetup.dir/platform_windows.o" + "CMakeFiles/mojosetup.dir/lua_glue.o" + "CMakeFiles/mojosetup.dir/lua/src/lapi.o" + "CMakeFiles/mojosetup.dir/lua/src/ldebug.o" + "CMakeFiles/mojosetup.dir/lua/src/ldo.o" + "CMakeFiles/mojosetup.dir/lua/src/ldump.o" + "CMakeFiles/mojosetup.dir/lua/src/lfunc.o" + "CMakeFiles/mojosetup.dir/lua/src/lgc.o" + "CMakeFiles/mojosetup.dir/lua/src/lmem.o" + "CMakeFiles/mojosetup.dir/lua/src/lobject.o" + "CMakeFiles/mojosetup.dir/lua/src/lopcodes.o" + "CMakeFiles/mojosetup.dir/lua/src/lstate.o" + "CMakeFiles/mojosetup.dir/lua/src/lstring.o" + "CMakeFiles/mojosetup.dir/lua/src/ltable.o" + "CMakeFiles/mojosetup.dir/lua/src/ltm.o" + "CMakeFiles/mojosetup.dir/lua/src/lundump.o" + "CMakeFiles/mojosetup.dir/lua/src/lvm.o" + "CMakeFiles/mojosetup.dir/lua/src/lzio.o" + "CMakeFiles/mojosetup.dir/lua/src/lauxlib.o" + "CMakeFiles/mojosetup.dir/lua/src/lbaselib.o" + "CMakeFiles/mojosetup.dir/lua/src/lstrlib.o" + "CMakeFiles/mojosetup.dir/lua/src/ltablib.o" + "CMakeFiles/mojosetup.dir/lua/src/lparser.o" + "CMakeFiles/mojosetup.dir/lua/src/llex.o" + "CMakeFiles/mojosetup.dir/lua/src/lcode.o" + "CMakeFiles/mojosetup.dir/lua/src/liolib.o" + "CMakeFiles/mojosetup.dir/lua/src/loslib.o" + "CMakeFiles/mojosetup.dir/lua/src/lmathlib.o" + "CMakeFiles/mojosetup.dir/lua/src/ldblib.o" + "CMakeFiles/mojosetup.dir/lua/src/loadlib.o" + "CMakeFiles/mojosetup.dir/gui_stdio.o" + "CMakeFiles/mojosetup.dir/stb_image.o" + "CMakeFiles/mojosetup.dir/libfetch/fetch.o" + "CMakeFiles/mojosetup.dir/libfetch/common.o" + "CMakeFiles/mojosetup.dir/libfetch/ftp.o" + "CMakeFiles/mojosetup.dir/libfetch/http.o" + "mojosetup.pdb" + "mojosetup" +) + +# Per-language clean rules from dependency scanning. +FOREACH(lang C) + INCLUDE(CMakeFiles/mojosetup.dir/cmake_clean_${lang}.cmake OPTIONAL) +ENDFOREACH(lang) diff --git a/mk/linux/mojosetup/build/CMakeFiles/mojosetup.dir/depend.internal b/mk/linux/mojosetup/build/CMakeFiles/mojosetup.dir/depend.internal new file mode 100644 index 00000000..ecdf5ce1 --- /dev/null +++ b/mk/linux/mojosetup/build/CMakeFiles/mojosetup.dir/depend.internal @@ -0,0 +1,459 @@ +# CMAKE generated file: DO NOT EDIT! +# Generated by "Unix Makefiles" Generator, CMake Version 2.8 + +CMakeFiles/mojosetup.dir/archive_pck.o + /home/softcoder/Code/mojosetup/archive_pck.c + /home/softcoder/Code/mojosetup/fileio.h + /home/softcoder/Code/mojosetup/platform.h + /home/softcoder/Code/mojosetup/universal.h +CMakeFiles/mojosetup.dir/archive_tar.o + /home/softcoder/Code/mojosetup/archive_tar.c + /home/softcoder/Code/mojosetup/fileio.h + /home/softcoder/Code/mojosetup/universal.h +CMakeFiles/mojosetup.dir/archive_uz2.o + /home/softcoder/Code/mojosetup/archive_uz2.c + /home/softcoder/Code/mojosetup/fileio.h + /home/softcoder/Code/mojosetup/platform.h + /home/softcoder/Code/mojosetup/universal.h + /home/softcoder/Code/mojosetup/zlib/zconf.h + /home/softcoder/Code/mojosetup/zlib/zlib.h +CMakeFiles/mojosetup.dir/archive_zip.o + /home/softcoder/Code/mojosetup/archive_zip.c + /home/softcoder/Code/mojosetup/fileio.h + /home/softcoder/Code/mojosetup/universal.h + /home/softcoder/Code/mojosetup/zlib/zconf.h + /home/softcoder/Code/mojosetup/zlib/zlib.h +CMakeFiles/mojosetup.dir/buildver.o + /home/softcoder/Code/mojosetup/buildver.c +CMakeFiles/mojosetup.dir/checksum_crc32.o + /home/softcoder/Code/mojosetup/checksum_crc32.c + /home/softcoder/Code/mojosetup/universal.h +CMakeFiles/mojosetup.dir/checksum_md5.o + /home/softcoder/Code/mojosetup/checksum_md5.c + /home/softcoder/Code/mojosetup/universal.h +CMakeFiles/mojosetup.dir/checksum_sha1.o + /home/softcoder/Code/mojosetup/checksum_sha1.c + /home/softcoder/Code/mojosetup/universal.h +CMakeFiles/mojosetup.dir/fileio.o + /home/softcoder/Code/mojosetup/bzip2/bzlib.h + /home/softcoder/Code/mojosetup/fileio.c + /home/softcoder/Code/mojosetup/fileio.h + /home/softcoder/Code/mojosetup/platform.h + /home/softcoder/Code/mojosetup/universal.h + /home/softcoder/Code/mojosetup/zlib/zconf.h + /home/softcoder/Code/mojosetup/zlib/zlib.h +CMakeFiles/mojosetup.dir/gui.o + /home/softcoder/Code/mojosetup/fileio.h + /home/softcoder/Code/mojosetup/gui.c + /home/softcoder/Code/mojosetup/gui.h + /home/softcoder/Code/mojosetup/platform.h + /home/softcoder/Code/mojosetup/universal.h +CMakeFiles/mojosetup.dir/gui_stdio.o + /home/softcoder/Code/mojosetup/gui.h + /home/softcoder/Code/mojosetup/gui_stdio.c + /home/softcoder/Code/mojosetup/universal.h +CMakeFiles/mojosetup.dir/libfetch/common.o + /home/softcoder/Code/mojosetup/libfetch/../fileio.h + /home/softcoder/Code/mojosetup/libfetch/../platform.h + /home/softcoder/Code/mojosetup/libfetch/../universal.h + /home/softcoder/Code/mojosetup/libfetch/common.c + /home/softcoder/Code/mojosetup/libfetch/common.h + /home/softcoder/Code/mojosetup/libfetch/fetch.h + /home/softcoder/Code/mojosetup/libfetch/mojosetup_libfetch.h +CMakeFiles/mojosetup.dir/libfetch/fetch.o + /home/softcoder/Code/mojosetup/libfetch/../fileio.h + /home/softcoder/Code/mojosetup/libfetch/../platform.h + /home/softcoder/Code/mojosetup/libfetch/../universal.h + /home/softcoder/Code/mojosetup/libfetch/common.h + /home/softcoder/Code/mojosetup/libfetch/fetch.c + /home/softcoder/Code/mojosetup/libfetch/fetch.h + /home/softcoder/Code/mojosetup/libfetch/mojosetup_libfetch.h +CMakeFiles/mojosetup.dir/libfetch/ftp.o + /home/softcoder/Code/mojosetup/libfetch/../fileio.h + /home/softcoder/Code/mojosetup/libfetch/../platform.h + /home/softcoder/Code/mojosetup/libfetch/../universal.h + /home/softcoder/Code/mojosetup/libfetch/common.h + /home/softcoder/Code/mojosetup/libfetch/fetch.h + /home/softcoder/Code/mojosetup/libfetch/ftp.c + /home/softcoder/Code/mojosetup/libfetch/ftperr.h + /home/softcoder/Code/mojosetup/libfetch/mojosetup_libfetch.h +CMakeFiles/mojosetup.dir/libfetch/http.o + /home/softcoder/Code/mojosetup/libfetch/../fileio.h + /home/softcoder/Code/mojosetup/libfetch/../platform.h + /home/softcoder/Code/mojosetup/libfetch/../universal.h + /home/softcoder/Code/mojosetup/libfetch/common.h + /home/softcoder/Code/mojosetup/libfetch/fetch.h + /home/softcoder/Code/mojosetup/libfetch/http.c + /home/softcoder/Code/mojosetup/libfetch/httperr.h + /home/softcoder/Code/mojosetup/libfetch/mojosetup_libfetch.h +CMakeFiles/mojosetup.dir/lua/src/lapi.o + /home/softcoder/Code/mojosetup/lua/src/lapi.c + /home/softcoder/Code/mojosetup/lua/src/lapi.h + /home/softcoder/Code/mojosetup/lua/src/ldebug.h + /home/softcoder/Code/mojosetup/lua/src/ldo.h + /home/softcoder/Code/mojosetup/lua/src/lfunc.h + /home/softcoder/Code/mojosetup/lua/src/lgc.h + /home/softcoder/Code/mojosetup/lua/src/llimits.h + /home/softcoder/Code/mojosetup/lua/src/lmem.h + /home/softcoder/Code/mojosetup/lua/src/lobject.h + /home/softcoder/Code/mojosetup/lua/src/lstate.h + /home/softcoder/Code/mojosetup/lua/src/lstring.h + /home/softcoder/Code/mojosetup/lua/src/ltable.h + /home/softcoder/Code/mojosetup/lua/src/ltm.h + /home/softcoder/Code/mojosetup/lua/src/lua.h + /home/softcoder/Code/mojosetup/lua/src/luaconf.h + /home/softcoder/Code/mojosetup/lua/src/lundump.h + /home/softcoder/Code/mojosetup/lua/src/lvm.h + /home/softcoder/Code/mojosetup/lua/src/lzio.h +CMakeFiles/mojosetup.dir/lua/src/lauxlib.o + /home/softcoder/Code/mojosetup/lua/src/lauxlib.c + /home/softcoder/Code/mojosetup/lua/src/lauxlib.h + /home/softcoder/Code/mojosetup/lua/src/lua.h + /home/softcoder/Code/mojosetup/lua/src/luaconf.h +CMakeFiles/mojosetup.dir/lua/src/lbaselib.o + /home/softcoder/Code/mojosetup/lua/src/lauxlib.h + /home/softcoder/Code/mojosetup/lua/src/lbaselib.c + /home/softcoder/Code/mojosetup/lua/src/lua.h + /home/softcoder/Code/mojosetup/lua/src/luaconf.h + /home/softcoder/Code/mojosetup/lua/src/lualib.h +CMakeFiles/mojosetup.dir/lua/src/lcode.o + /home/softcoder/Code/mojosetup/lua/src/lcode.c + /home/softcoder/Code/mojosetup/lua/src/lcode.h + /home/softcoder/Code/mojosetup/lua/src/ldebug.h + /home/softcoder/Code/mojosetup/lua/src/ldo.h + /home/softcoder/Code/mojosetup/lua/src/lgc.h + /home/softcoder/Code/mojosetup/lua/src/llex.h + /home/softcoder/Code/mojosetup/lua/src/llimits.h + /home/softcoder/Code/mojosetup/lua/src/lmem.h + /home/softcoder/Code/mojosetup/lua/src/lobject.h + /home/softcoder/Code/mojosetup/lua/src/lopcodes.h + /home/softcoder/Code/mojosetup/lua/src/lparser.h + /home/softcoder/Code/mojosetup/lua/src/lstate.h + /home/softcoder/Code/mojosetup/lua/src/ltable.h + /home/softcoder/Code/mojosetup/lua/src/ltm.h + /home/softcoder/Code/mojosetup/lua/src/lua.h + /home/softcoder/Code/mojosetup/lua/src/luaconf.h + /home/softcoder/Code/mojosetup/lua/src/lzio.h +CMakeFiles/mojosetup.dir/lua/src/ldblib.o + /home/softcoder/Code/mojosetup/lua/src/lauxlib.h + /home/softcoder/Code/mojosetup/lua/src/ldblib.c + /home/softcoder/Code/mojosetup/lua/src/lua.h + /home/softcoder/Code/mojosetup/lua/src/luaconf.h + /home/softcoder/Code/mojosetup/lua/src/lualib.h +CMakeFiles/mojosetup.dir/lua/src/ldebug.o + /home/softcoder/Code/mojosetup/lua/src/lapi.h + /home/softcoder/Code/mojosetup/lua/src/lcode.h + /home/softcoder/Code/mojosetup/lua/src/ldebug.c + /home/softcoder/Code/mojosetup/lua/src/ldebug.h + /home/softcoder/Code/mojosetup/lua/src/ldo.h + /home/softcoder/Code/mojosetup/lua/src/lfunc.h + /home/softcoder/Code/mojosetup/lua/src/lgc.h + /home/softcoder/Code/mojosetup/lua/src/llex.h + /home/softcoder/Code/mojosetup/lua/src/llimits.h + /home/softcoder/Code/mojosetup/lua/src/lmem.h + /home/softcoder/Code/mojosetup/lua/src/lobject.h + /home/softcoder/Code/mojosetup/lua/src/lopcodes.h + /home/softcoder/Code/mojosetup/lua/src/lparser.h + /home/softcoder/Code/mojosetup/lua/src/lstate.h + /home/softcoder/Code/mojosetup/lua/src/lstring.h + /home/softcoder/Code/mojosetup/lua/src/ltable.h + /home/softcoder/Code/mojosetup/lua/src/ltm.h + /home/softcoder/Code/mojosetup/lua/src/lua.h + /home/softcoder/Code/mojosetup/lua/src/luaconf.h + /home/softcoder/Code/mojosetup/lua/src/lvm.h + /home/softcoder/Code/mojosetup/lua/src/lzio.h +CMakeFiles/mojosetup.dir/lua/src/ldo.o + /home/softcoder/Code/mojosetup/lua/src/ldebug.h + /home/softcoder/Code/mojosetup/lua/src/ldo.c + /home/softcoder/Code/mojosetup/lua/src/ldo.h + /home/softcoder/Code/mojosetup/lua/src/lfunc.h + /home/softcoder/Code/mojosetup/lua/src/lgc.h + /home/softcoder/Code/mojosetup/lua/src/llimits.h + /home/softcoder/Code/mojosetup/lua/src/lmem.h + /home/softcoder/Code/mojosetup/lua/src/lobject.h + /home/softcoder/Code/mojosetup/lua/src/lopcodes.h + /home/softcoder/Code/mojosetup/lua/src/lparser.h + /home/softcoder/Code/mojosetup/lua/src/lstate.h + /home/softcoder/Code/mojosetup/lua/src/lstring.h + /home/softcoder/Code/mojosetup/lua/src/ltable.h + /home/softcoder/Code/mojosetup/lua/src/ltm.h + /home/softcoder/Code/mojosetup/lua/src/lua.h + /home/softcoder/Code/mojosetup/lua/src/luaconf.h + /home/softcoder/Code/mojosetup/lua/src/lundump.h + /home/softcoder/Code/mojosetup/lua/src/lvm.h + /home/softcoder/Code/mojosetup/lua/src/lzio.h +CMakeFiles/mojosetup.dir/lua/src/ldump.o + /home/softcoder/Code/mojosetup/lua/src/ldump.c + /home/softcoder/Code/mojosetup/lua/src/llimits.h + /home/softcoder/Code/mojosetup/lua/src/lmem.h + /home/softcoder/Code/mojosetup/lua/src/lobject.h + /home/softcoder/Code/mojosetup/lua/src/lstate.h + /home/softcoder/Code/mojosetup/lua/src/ltm.h + /home/softcoder/Code/mojosetup/lua/src/lua.h + /home/softcoder/Code/mojosetup/lua/src/luaconf.h + /home/softcoder/Code/mojosetup/lua/src/lundump.h + /home/softcoder/Code/mojosetup/lua/src/lzio.h +CMakeFiles/mojosetup.dir/lua/src/lfunc.o + /home/softcoder/Code/mojosetup/lua/src/lfunc.c + /home/softcoder/Code/mojosetup/lua/src/lfunc.h + /home/softcoder/Code/mojosetup/lua/src/lgc.h + /home/softcoder/Code/mojosetup/lua/src/llimits.h + /home/softcoder/Code/mojosetup/lua/src/lmem.h + /home/softcoder/Code/mojosetup/lua/src/lobject.h + /home/softcoder/Code/mojosetup/lua/src/lstate.h + /home/softcoder/Code/mojosetup/lua/src/ltm.h + /home/softcoder/Code/mojosetup/lua/src/lua.h + /home/softcoder/Code/mojosetup/lua/src/luaconf.h + /home/softcoder/Code/mojosetup/lua/src/lzio.h +CMakeFiles/mojosetup.dir/lua/src/lgc.o + /home/softcoder/Code/mojosetup/lua/src/ldebug.h + /home/softcoder/Code/mojosetup/lua/src/ldo.h + /home/softcoder/Code/mojosetup/lua/src/lfunc.h + /home/softcoder/Code/mojosetup/lua/src/lgc.c + /home/softcoder/Code/mojosetup/lua/src/lgc.h + /home/softcoder/Code/mojosetup/lua/src/llimits.h + /home/softcoder/Code/mojosetup/lua/src/lmem.h + /home/softcoder/Code/mojosetup/lua/src/lobject.h + /home/softcoder/Code/mojosetup/lua/src/lstate.h + /home/softcoder/Code/mojosetup/lua/src/lstring.h + /home/softcoder/Code/mojosetup/lua/src/ltable.h + /home/softcoder/Code/mojosetup/lua/src/ltm.h + /home/softcoder/Code/mojosetup/lua/src/lua.h + /home/softcoder/Code/mojosetup/lua/src/luaconf.h + /home/softcoder/Code/mojosetup/lua/src/lzio.h +CMakeFiles/mojosetup.dir/lua/src/liolib.o + /home/softcoder/Code/mojosetup/lua/src/lauxlib.h + /home/softcoder/Code/mojosetup/lua/src/liolib.c + /home/softcoder/Code/mojosetup/lua/src/lua.h + /home/softcoder/Code/mojosetup/lua/src/luaconf.h + /home/softcoder/Code/mojosetup/lua/src/lualib.h +CMakeFiles/mojosetup.dir/lua/src/llex.o + /home/softcoder/Code/mojosetup/lua/src/ldo.h + /home/softcoder/Code/mojosetup/lua/src/lgc.h + /home/softcoder/Code/mojosetup/lua/src/llex.c + /home/softcoder/Code/mojosetup/lua/src/llex.h + /home/softcoder/Code/mojosetup/lua/src/llimits.h + /home/softcoder/Code/mojosetup/lua/src/lmem.h + /home/softcoder/Code/mojosetup/lua/src/lobject.h + /home/softcoder/Code/mojosetup/lua/src/lparser.h + /home/softcoder/Code/mojosetup/lua/src/lstate.h + /home/softcoder/Code/mojosetup/lua/src/lstring.h + /home/softcoder/Code/mojosetup/lua/src/ltable.h + /home/softcoder/Code/mojosetup/lua/src/ltm.h + /home/softcoder/Code/mojosetup/lua/src/lua.h + /home/softcoder/Code/mojosetup/lua/src/luaconf.h + /home/softcoder/Code/mojosetup/lua/src/lzio.h +CMakeFiles/mojosetup.dir/lua/src/lmathlib.o + /home/softcoder/Code/mojosetup/lua/src/lauxlib.h + /home/softcoder/Code/mojosetup/lua/src/lmathlib.c + /home/softcoder/Code/mojosetup/lua/src/lua.h + /home/softcoder/Code/mojosetup/lua/src/luaconf.h + /home/softcoder/Code/mojosetup/lua/src/lualib.h +CMakeFiles/mojosetup.dir/lua/src/lmem.o + /home/softcoder/Code/mojosetup/lua/src/ldebug.h + /home/softcoder/Code/mojosetup/lua/src/ldo.h + /home/softcoder/Code/mojosetup/lua/src/llimits.h + /home/softcoder/Code/mojosetup/lua/src/lmem.c + /home/softcoder/Code/mojosetup/lua/src/lmem.h + /home/softcoder/Code/mojosetup/lua/src/lobject.h + /home/softcoder/Code/mojosetup/lua/src/lstate.h + /home/softcoder/Code/mojosetup/lua/src/ltm.h + /home/softcoder/Code/mojosetup/lua/src/lua.h + /home/softcoder/Code/mojosetup/lua/src/luaconf.h + /home/softcoder/Code/mojosetup/lua/src/lzio.h +CMakeFiles/mojosetup.dir/lua/src/loadlib.o + /home/softcoder/Code/mojosetup/lua/src/lauxlib.h + /home/softcoder/Code/mojosetup/lua/src/loadlib.c + /home/softcoder/Code/mojosetup/lua/src/lua.h + /home/softcoder/Code/mojosetup/lua/src/luaconf.h + /home/softcoder/Code/mojosetup/lua/src/lualib.h +CMakeFiles/mojosetup.dir/lua/src/lobject.o + /home/softcoder/Code/mojosetup/lua/src/ldo.h + /home/softcoder/Code/mojosetup/lua/src/lgc.h + /home/softcoder/Code/mojosetup/lua/src/llimits.h + /home/softcoder/Code/mojosetup/lua/src/lmem.h + /home/softcoder/Code/mojosetup/lua/src/lobject.c + /home/softcoder/Code/mojosetup/lua/src/lobject.h + /home/softcoder/Code/mojosetup/lua/src/lstate.h + /home/softcoder/Code/mojosetup/lua/src/lstring.h + /home/softcoder/Code/mojosetup/lua/src/ltm.h + /home/softcoder/Code/mojosetup/lua/src/lua.h + /home/softcoder/Code/mojosetup/lua/src/luaconf.h + /home/softcoder/Code/mojosetup/lua/src/lvm.h + /home/softcoder/Code/mojosetup/lua/src/lzio.h +CMakeFiles/mojosetup.dir/lua/src/lopcodes.o + /home/softcoder/Code/mojosetup/lua/src/llimits.h + /home/softcoder/Code/mojosetup/lua/src/lopcodes.c + /home/softcoder/Code/mojosetup/lua/src/lopcodes.h + /home/softcoder/Code/mojosetup/lua/src/lua.h + /home/softcoder/Code/mojosetup/lua/src/luaconf.h +CMakeFiles/mojosetup.dir/lua/src/loslib.o + /home/softcoder/Code/mojosetup/lua/src/lauxlib.h + /home/softcoder/Code/mojosetup/lua/src/loslib.c + /home/softcoder/Code/mojosetup/lua/src/lua.h + /home/softcoder/Code/mojosetup/lua/src/luaconf.h + /home/softcoder/Code/mojosetup/lua/src/lualib.h +CMakeFiles/mojosetup.dir/lua/src/lparser.o + /home/softcoder/Code/mojosetup/lua/src/lcode.h + /home/softcoder/Code/mojosetup/lua/src/ldebug.h + /home/softcoder/Code/mojosetup/lua/src/ldo.h + /home/softcoder/Code/mojosetup/lua/src/lfunc.h + /home/softcoder/Code/mojosetup/lua/src/lgc.h + /home/softcoder/Code/mojosetup/lua/src/llex.h + /home/softcoder/Code/mojosetup/lua/src/llimits.h + /home/softcoder/Code/mojosetup/lua/src/lmem.h + /home/softcoder/Code/mojosetup/lua/src/lobject.h + /home/softcoder/Code/mojosetup/lua/src/lopcodes.h + /home/softcoder/Code/mojosetup/lua/src/lparser.c + /home/softcoder/Code/mojosetup/lua/src/lparser.h + /home/softcoder/Code/mojosetup/lua/src/lstate.h + /home/softcoder/Code/mojosetup/lua/src/lstring.h + /home/softcoder/Code/mojosetup/lua/src/ltable.h + /home/softcoder/Code/mojosetup/lua/src/ltm.h + /home/softcoder/Code/mojosetup/lua/src/lua.h + /home/softcoder/Code/mojosetup/lua/src/luaconf.h + /home/softcoder/Code/mojosetup/lua/src/lzio.h +CMakeFiles/mojosetup.dir/lua/src/lstate.o + /home/softcoder/Code/mojosetup/lua/src/ldebug.h + /home/softcoder/Code/mojosetup/lua/src/ldo.h + /home/softcoder/Code/mojosetup/lua/src/lfunc.h + /home/softcoder/Code/mojosetup/lua/src/lgc.h + /home/softcoder/Code/mojosetup/lua/src/llex.h + /home/softcoder/Code/mojosetup/lua/src/llimits.h + /home/softcoder/Code/mojosetup/lua/src/lmem.h + /home/softcoder/Code/mojosetup/lua/src/lobject.h + /home/softcoder/Code/mojosetup/lua/src/lstate.c + /home/softcoder/Code/mojosetup/lua/src/lstate.h + /home/softcoder/Code/mojosetup/lua/src/lstring.h + /home/softcoder/Code/mojosetup/lua/src/ltable.h + /home/softcoder/Code/mojosetup/lua/src/ltm.h + /home/softcoder/Code/mojosetup/lua/src/lua.h + /home/softcoder/Code/mojosetup/lua/src/luaconf.h + /home/softcoder/Code/mojosetup/lua/src/lzio.h +CMakeFiles/mojosetup.dir/lua/src/lstring.o + /home/softcoder/Code/mojosetup/lua/src/lgc.h + /home/softcoder/Code/mojosetup/lua/src/llimits.h + /home/softcoder/Code/mojosetup/lua/src/lmem.h + /home/softcoder/Code/mojosetup/lua/src/lobject.h + /home/softcoder/Code/mojosetup/lua/src/lstate.h + /home/softcoder/Code/mojosetup/lua/src/lstring.c + /home/softcoder/Code/mojosetup/lua/src/lstring.h + /home/softcoder/Code/mojosetup/lua/src/ltm.h + /home/softcoder/Code/mojosetup/lua/src/lua.h + /home/softcoder/Code/mojosetup/lua/src/luaconf.h + /home/softcoder/Code/mojosetup/lua/src/lzio.h +CMakeFiles/mojosetup.dir/lua/src/lstrlib.o + /home/softcoder/Code/mojosetup/lua/src/lauxlib.h + /home/softcoder/Code/mojosetup/lua/src/lstrlib.c + /home/softcoder/Code/mojosetup/lua/src/lua.h + /home/softcoder/Code/mojosetup/lua/src/luaconf.h + /home/softcoder/Code/mojosetup/lua/src/lualib.h +CMakeFiles/mojosetup.dir/lua/src/ltable.o + /home/softcoder/Code/mojosetup/lua/src/ldebug.h + /home/softcoder/Code/mojosetup/lua/src/ldo.h + /home/softcoder/Code/mojosetup/lua/src/lgc.h + /home/softcoder/Code/mojosetup/lua/src/llimits.h + /home/softcoder/Code/mojosetup/lua/src/lmem.h + /home/softcoder/Code/mojosetup/lua/src/lobject.h + /home/softcoder/Code/mojosetup/lua/src/lstate.h + /home/softcoder/Code/mojosetup/lua/src/ltable.c + /home/softcoder/Code/mojosetup/lua/src/ltable.h + /home/softcoder/Code/mojosetup/lua/src/ltm.h + /home/softcoder/Code/mojosetup/lua/src/lua.h + /home/softcoder/Code/mojosetup/lua/src/luaconf.h + /home/softcoder/Code/mojosetup/lua/src/lzio.h +CMakeFiles/mojosetup.dir/lua/src/ltablib.o + /home/softcoder/Code/mojosetup/lua/src/lauxlib.h + /home/softcoder/Code/mojosetup/lua/src/ltablib.c + /home/softcoder/Code/mojosetup/lua/src/lua.h + /home/softcoder/Code/mojosetup/lua/src/luaconf.h + /home/softcoder/Code/mojosetup/lua/src/lualib.h +CMakeFiles/mojosetup.dir/lua/src/ltm.o + /home/softcoder/Code/mojosetup/lua/src/lgc.h + /home/softcoder/Code/mojosetup/lua/src/llimits.h + /home/softcoder/Code/mojosetup/lua/src/lmem.h + /home/softcoder/Code/mojosetup/lua/src/lobject.h + /home/softcoder/Code/mojosetup/lua/src/lstate.h + /home/softcoder/Code/mojosetup/lua/src/lstring.h + /home/softcoder/Code/mojosetup/lua/src/ltable.h + /home/softcoder/Code/mojosetup/lua/src/ltm.c + /home/softcoder/Code/mojosetup/lua/src/ltm.h + /home/softcoder/Code/mojosetup/lua/src/lua.h + /home/softcoder/Code/mojosetup/lua/src/luaconf.h + /home/softcoder/Code/mojosetup/lua/src/lzio.h +CMakeFiles/mojosetup.dir/lua/src/lundump.o + /home/softcoder/Code/mojosetup/lua/src/ldebug.h + /home/softcoder/Code/mojosetup/lua/src/ldo.h + /home/softcoder/Code/mojosetup/lua/src/lfunc.h + /home/softcoder/Code/mojosetup/lua/src/lgc.h + /home/softcoder/Code/mojosetup/lua/src/llimits.h + /home/softcoder/Code/mojosetup/lua/src/lmem.h + /home/softcoder/Code/mojosetup/lua/src/lobject.h + /home/softcoder/Code/mojosetup/lua/src/lstate.h + /home/softcoder/Code/mojosetup/lua/src/lstring.h + /home/softcoder/Code/mojosetup/lua/src/ltm.h + /home/softcoder/Code/mojosetup/lua/src/lua.h + /home/softcoder/Code/mojosetup/lua/src/luaconf.h + /home/softcoder/Code/mojosetup/lua/src/lundump.c + /home/softcoder/Code/mojosetup/lua/src/lundump.h + /home/softcoder/Code/mojosetup/lua/src/lzio.h +CMakeFiles/mojosetup.dir/lua/src/lvm.o + /home/softcoder/Code/mojosetup/lua/src/ldebug.h + /home/softcoder/Code/mojosetup/lua/src/ldo.h + /home/softcoder/Code/mojosetup/lua/src/lfunc.h + /home/softcoder/Code/mojosetup/lua/src/lgc.h + /home/softcoder/Code/mojosetup/lua/src/llimits.h + /home/softcoder/Code/mojosetup/lua/src/lmem.h + /home/softcoder/Code/mojosetup/lua/src/lobject.h + /home/softcoder/Code/mojosetup/lua/src/lopcodes.h + /home/softcoder/Code/mojosetup/lua/src/lstate.h + /home/softcoder/Code/mojosetup/lua/src/lstring.h + /home/softcoder/Code/mojosetup/lua/src/ltable.h + /home/softcoder/Code/mojosetup/lua/src/ltm.h + /home/softcoder/Code/mojosetup/lua/src/lua.h + /home/softcoder/Code/mojosetup/lua/src/luaconf.h + /home/softcoder/Code/mojosetup/lua/src/lvm.c + /home/softcoder/Code/mojosetup/lua/src/lvm.h + /home/softcoder/Code/mojosetup/lua/src/lzio.h +CMakeFiles/mojosetup.dir/lua/src/lzio.o + /home/softcoder/Code/mojosetup/lua/src/llimits.h + /home/softcoder/Code/mojosetup/lua/src/lmem.h + /home/softcoder/Code/mojosetup/lua/src/lobject.h + /home/softcoder/Code/mojosetup/lua/src/lstate.h + /home/softcoder/Code/mojosetup/lua/src/ltm.h + /home/softcoder/Code/mojosetup/lua/src/lua.h + /home/softcoder/Code/mojosetup/lua/src/luaconf.h + /home/softcoder/Code/mojosetup/lua/src/lzio.c + /home/softcoder/Code/mojosetup/lua/src/lzio.h +CMakeFiles/mojosetup.dir/lua_glue.o + ../lua/src/lauxlib.h + ../lua/src/lua.h + ../lua/src/luaconf.h + ../lua/src/lualib.h + /home/softcoder/Code/mojosetup/fileio.h + /home/softcoder/Code/mojosetup/gui.h + /home/softcoder/Code/mojosetup/lua_glue.c + /home/softcoder/Code/mojosetup/lua_glue.h + /home/softcoder/Code/mojosetup/platform.h + /home/softcoder/Code/mojosetup/universal.h +CMakeFiles/mojosetup.dir/mojosetup.o + /home/softcoder/Code/mojosetup/fileio.h + /home/softcoder/Code/mojosetup/gui.h + /home/softcoder/Code/mojosetup/lua_glue.h + /home/softcoder/Code/mojosetup/mojosetup.c + /home/softcoder/Code/mojosetup/platform.h + /home/softcoder/Code/mojosetup/universal.h +CMakeFiles/mojosetup.dir/platform_unix.o + /home/softcoder/Code/mojosetup/fileio.h + /home/softcoder/Code/mojosetup/gui.h + /home/softcoder/Code/mojosetup/platform.h + /home/softcoder/Code/mojosetup/platform_unix.c + /home/softcoder/Code/mojosetup/universal.h +CMakeFiles/mojosetup.dir/platform_windows.o + /home/softcoder/Code/mojosetup/gui.h + /home/softcoder/Code/mojosetup/platform.h + /home/softcoder/Code/mojosetup/platform_windows.c + /home/softcoder/Code/mojosetup/universal.h +CMakeFiles/mojosetup.dir/stb_image.o + /home/softcoder/Code/mojosetup/stb_image.c + /home/softcoder/Code/mojosetup/universal.h diff --git a/mk/linux/mojosetup/build/CMakeFiles/mojosetup.dir/depend.make b/mk/linux/mojosetup/build/CMakeFiles/mojosetup.dir/depend.make new file mode 100644 index 00000000..75526912 --- /dev/null +++ b/mk/linux/mojosetup/build/CMakeFiles/mojosetup.dir/depend.make @@ -0,0 +1,459 @@ +# CMAKE generated file: DO NOT EDIT! +# Generated by "Unix Makefiles" Generator, CMake Version 2.8 + +CMakeFiles/mojosetup.dir/archive_pck.o: ../archive_pck.c +CMakeFiles/mojosetup.dir/archive_pck.o: ../fileio.h +CMakeFiles/mojosetup.dir/archive_pck.o: ../platform.h +CMakeFiles/mojosetup.dir/archive_pck.o: ../universal.h + +CMakeFiles/mojosetup.dir/archive_tar.o: ../archive_tar.c +CMakeFiles/mojosetup.dir/archive_tar.o: ../fileio.h +CMakeFiles/mojosetup.dir/archive_tar.o: ../universal.h + +CMakeFiles/mojosetup.dir/archive_uz2.o: ../archive_uz2.c +CMakeFiles/mojosetup.dir/archive_uz2.o: ../fileio.h +CMakeFiles/mojosetup.dir/archive_uz2.o: ../platform.h +CMakeFiles/mojosetup.dir/archive_uz2.o: ../universal.h +CMakeFiles/mojosetup.dir/archive_uz2.o: ../zlib/zconf.h +CMakeFiles/mojosetup.dir/archive_uz2.o: ../zlib/zlib.h + +CMakeFiles/mojosetup.dir/archive_zip.o: ../archive_zip.c +CMakeFiles/mojosetup.dir/archive_zip.o: ../fileio.h +CMakeFiles/mojosetup.dir/archive_zip.o: ../universal.h +CMakeFiles/mojosetup.dir/archive_zip.o: ../zlib/zconf.h +CMakeFiles/mojosetup.dir/archive_zip.o: ../zlib/zlib.h + +CMakeFiles/mojosetup.dir/buildver.o: ../buildver.c + +CMakeFiles/mojosetup.dir/checksum_crc32.o: ../checksum_crc32.c +CMakeFiles/mojosetup.dir/checksum_crc32.o: ../universal.h + +CMakeFiles/mojosetup.dir/checksum_md5.o: ../checksum_md5.c +CMakeFiles/mojosetup.dir/checksum_md5.o: ../universal.h + +CMakeFiles/mojosetup.dir/checksum_sha1.o: ../checksum_sha1.c +CMakeFiles/mojosetup.dir/checksum_sha1.o: ../universal.h + +CMakeFiles/mojosetup.dir/fileio.o: ../bzip2/bzlib.h +CMakeFiles/mojosetup.dir/fileio.o: ../fileio.c +CMakeFiles/mojosetup.dir/fileio.o: ../fileio.h +CMakeFiles/mojosetup.dir/fileio.o: ../platform.h +CMakeFiles/mojosetup.dir/fileio.o: ../universal.h +CMakeFiles/mojosetup.dir/fileio.o: ../zlib/zconf.h +CMakeFiles/mojosetup.dir/fileio.o: ../zlib/zlib.h + +CMakeFiles/mojosetup.dir/gui.o: ../fileio.h +CMakeFiles/mojosetup.dir/gui.o: ../gui.c +CMakeFiles/mojosetup.dir/gui.o: ../gui.h +CMakeFiles/mojosetup.dir/gui.o: ../platform.h +CMakeFiles/mojosetup.dir/gui.o: ../universal.h + +CMakeFiles/mojosetup.dir/gui_stdio.o: ../gui.h +CMakeFiles/mojosetup.dir/gui_stdio.o: ../gui_stdio.c +CMakeFiles/mojosetup.dir/gui_stdio.o: ../universal.h + +CMakeFiles/mojosetup.dir/libfetch/common.o: ../libfetch/../fileio.h +CMakeFiles/mojosetup.dir/libfetch/common.o: ../libfetch/../platform.h +CMakeFiles/mojosetup.dir/libfetch/common.o: ../libfetch/../universal.h +CMakeFiles/mojosetup.dir/libfetch/common.o: ../libfetch/common.c +CMakeFiles/mojosetup.dir/libfetch/common.o: ../libfetch/common.h +CMakeFiles/mojosetup.dir/libfetch/common.o: ../libfetch/fetch.h +CMakeFiles/mojosetup.dir/libfetch/common.o: ../libfetch/mojosetup_libfetch.h + +CMakeFiles/mojosetup.dir/libfetch/fetch.o: ../libfetch/../fileio.h +CMakeFiles/mojosetup.dir/libfetch/fetch.o: ../libfetch/../platform.h +CMakeFiles/mojosetup.dir/libfetch/fetch.o: ../libfetch/../universal.h +CMakeFiles/mojosetup.dir/libfetch/fetch.o: ../libfetch/common.h +CMakeFiles/mojosetup.dir/libfetch/fetch.o: ../libfetch/fetch.c +CMakeFiles/mojosetup.dir/libfetch/fetch.o: ../libfetch/fetch.h +CMakeFiles/mojosetup.dir/libfetch/fetch.o: ../libfetch/mojosetup_libfetch.h + +CMakeFiles/mojosetup.dir/libfetch/ftp.o: ../libfetch/../fileio.h +CMakeFiles/mojosetup.dir/libfetch/ftp.o: ../libfetch/../platform.h +CMakeFiles/mojosetup.dir/libfetch/ftp.o: ../libfetch/../universal.h +CMakeFiles/mojosetup.dir/libfetch/ftp.o: ../libfetch/common.h +CMakeFiles/mojosetup.dir/libfetch/ftp.o: ../libfetch/fetch.h +CMakeFiles/mojosetup.dir/libfetch/ftp.o: ../libfetch/ftp.c +CMakeFiles/mojosetup.dir/libfetch/ftp.o: ../libfetch/ftperr.h +CMakeFiles/mojosetup.dir/libfetch/ftp.o: ../libfetch/mojosetup_libfetch.h + +CMakeFiles/mojosetup.dir/libfetch/http.o: ../libfetch/../fileio.h +CMakeFiles/mojosetup.dir/libfetch/http.o: ../libfetch/../platform.h +CMakeFiles/mojosetup.dir/libfetch/http.o: ../libfetch/../universal.h +CMakeFiles/mojosetup.dir/libfetch/http.o: ../libfetch/common.h +CMakeFiles/mojosetup.dir/libfetch/http.o: ../libfetch/fetch.h +CMakeFiles/mojosetup.dir/libfetch/http.o: ../libfetch/http.c +CMakeFiles/mojosetup.dir/libfetch/http.o: ../libfetch/httperr.h +CMakeFiles/mojosetup.dir/libfetch/http.o: ../libfetch/mojosetup_libfetch.h + +CMakeFiles/mojosetup.dir/lua/src/lapi.o: ../lua/src/lapi.c +CMakeFiles/mojosetup.dir/lua/src/lapi.o: ../lua/src/lapi.h +CMakeFiles/mojosetup.dir/lua/src/lapi.o: ../lua/src/ldebug.h +CMakeFiles/mojosetup.dir/lua/src/lapi.o: ../lua/src/ldo.h +CMakeFiles/mojosetup.dir/lua/src/lapi.o: ../lua/src/lfunc.h +CMakeFiles/mojosetup.dir/lua/src/lapi.o: ../lua/src/lgc.h +CMakeFiles/mojosetup.dir/lua/src/lapi.o: ../lua/src/llimits.h +CMakeFiles/mojosetup.dir/lua/src/lapi.o: ../lua/src/lmem.h +CMakeFiles/mojosetup.dir/lua/src/lapi.o: ../lua/src/lobject.h +CMakeFiles/mojosetup.dir/lua/src/lapi.o: ../lua/src/lstate.h +CMakeFiles/mojosetup.dir/lua/src/lapi.o: ../lua/src/lstring.h +CMakeFiles/mojosetup.dir/lua/src/lapi.o: ../lua/src/ltable.h +CMakeFiles/mojosetup.dir/lua/src/lapi.o: ../lua/src/ltm.h +CMakeFiles/mojosetup.dir/lua/src/lapi.o: ../lua/src/lua.h +CMakeFiles/mojosetup.dir/lua/src/lapi.o: ../lua/src/luaconf.h +CMakeFiles/mojosetup.dir/lua/src/lapi.o: ../lua/src/lundump.h +CMakeFiles/mojosetup.dir/lua/src/lapi.o: ../lua/src/lvm.h +CMakeFiles/mojosetup.dir/lua/src/lapi.o: ../lua/src/lzio.h + +CMakeFiles/mojosetup.dir/lua/src/lauxlib.o: ../lua/src/lauxlib.c +CMakeFiles/mojosetup.dir/lua/src/lauxlib.o: ../lua/src/lauxlib.h +CMakeFiles/mojosetup.dir/lua/src/lauxlib.o: ../lua/src/lua.h +CMakeFiles/mojosetup.dir/lua/src/lauxlib.o: ../lua/src/luaconf.h + +CMakeFiles/mojosetup.dir/lua/src/lbaselib.o: ../lua/src/lauxlib.h +CMakeFiles/mojosetup.dir/lua/src/lbaselib.o: ../lua/src/lbaselib.c +CMakeFiles/mojosetup.dir/lua/src/lbaselib.o: ../lua/src/lua.h +CMakeFiles/mojosetup.dir/lua/src/lbaselib.o: ../lua/src/luaconf.h +CMakeFiles/mojosetup.dir/lua/src/lbaselib.o: ../lua/src/lualib.h + +CMakeFiles/mojosetup.dir/lua/src/lcode.o: ../lua/src/lcode.c +CMakeFiles/mojosetup.dir/lua/src/lcode.o: ../lua/src/lcode.h +CMakeFiles/mojosetup.dir/lua/src/lcode.o: ../lua/src/ldebug.h +CMakeFiles/mojosetup.dir/lua/src/lcode.o: ../lua/src/ldo.h +CMakeFiles/mojosetup.dir/lua/src/lcode.o: ../lua/src/lgc.h +CMakeFiles/mojosetup.dir/lua/src/lcode.o: ../lua/src/llex.h +CMakeFiles/mojosetup.dir/lua/src/lcode.o: ../lua/src/llimits.h +CMakeFiles/mojosetup.dir/lua/src/lcode.o: ../lua/src/lmem.h +CMakeFiles/mojosetup.dir/lua/src/lcode.o: ../lua/src/lobject.h +CMakeFiles/mojosetup.dir/lua/src/lcode.o: ../lua/src/lopcodes.h +CMakeFiles/mojosetup.dir/lua/src/lcode.o: ../lua/src/lparser.h +CMakeFiles/mojosetup.dir/lua/src/lcode.o: ../lua/src/lstate.h +CMakeFiles/mojosetup.dir/lua/src/lcode.o: ../lua/src/ltable.h +CMakeFiles/mojosetup.dir/lua/src/lcode.o: ../lua/src/ltm.h +CMakeFiles/mojosetup.dir/lua/src/lcode.o: ../lua/src/lua.h +CMakeFiles/mojosetup.dir/lua/src/lcode.o: ../lua/src/luaconf.h +CMakeFiles/mojosetup.dir/lua/src/lcode.o: ../lua/src/lzio.h + +CMakeFiles/mojosetup.dir/lua/src/ldblib.o: ../lua/src/lauxlib.h +CMakeFiles/mojosetup.dir/lua/src/ldblib.o: ../lua/src/ldblib.c +CMakeFiles/mojosetup.dir/lua/src/ldblib.o: ../lua/src/lua.h +CMakeFiles/mojosetup.dir/lua/src/ldblib.o: ../lua/src/luaconf.h +CMakeFiles/mojosetup.dir/lua/src/ldblib.o: ../lua/src/lualib.h + +CMakeFiles/mojosetup.dir/lua/src/ldebug.o: ../lua/src/lapi.h +CMakeFiles/mojosetup.dir/lua/src/ldebug.o: ../lua/src/lcode.h +CMakeFiles/mojosetup.dir/lua/src/ldebug.o: ../lua/src/ldebug.c +CMakeFiles/mojosetup.dir/lua/src/ldebug.o: ../lua/src/ldebug.h +CMakeFiles/mojosetup.dir/lua/src/ldebug.o: ../lua/src/ldo.h +CMakeFiles/mojosetup.dir/lua/src/ldebug.o: ../lua/src/lfunc.h +CMakeFiles/mojosetup.dir/lua/src/ldebug.o: ../lua/src/lgc.h +CMakeFiles/mojosetup.dir/lua/src/ldebug.o: ../lua/src/llex.h +CMakeFiles/mojosetup.dir/lua/src/ldebug.o: ../lua/src/llimits.h +CMakeFiles/mojosetup.dir/lua/src/ldebug.o: ../lua/src/lmem.h +CMakeFiles/mojosetup.dir/lua/src/ldebug.o: ../lua/src/lobject.h +CMakeFiles/mojosetup.dir/lua/src/ldebug.o: ../lua/src/lopcodes.h +CMakeFiles/mojosetup.dir/lua/src/ldebug.o: ../lua/src/lparser.h +CMakeFiles/mojosetup.dir/lua/src/ldebug.o: ../lua/src/lstate.h +CMakeFiles/mojosetup.dir/lua/src/ldebug.o: ../lua/src/lstring.h +CMakeFiles/mojosetup.dir/lua/src/ldebug.o: ../lua/src/ltable.h +CMakeFiles/mojosetup.dir/lua/src/ldebug.o: ../lua/src/ltm.h +CMakeFiles/mojosetup.dir/lua/src/ldebug.o: ../lua/src/lua.h +CMakeFiles/mojosetup.dir/lua/src/ldebug.o: ../lua/src/luaconf.h +CMakeFiles/mojosetup.dir/lua/src/ldebug.o: ../lua/src/lvm.h +CMakeFiles/mojosetup.dir/lua/src/ldebug.o: ../lua/src/lzio.h + +CMakeFiles/mojosetup.dir/lua/src/ldo.o: ../lua/src/ldebug.h +CMakeFiles/mojosetup.dir/lua/src/ldo.o: ../lua/src/ldo.c +CMakeFiles/mojosetup.dir/lua/src/ldo.o: ../lua/src/ldo.h +CMakeFiles/mojosetup.dir/lua/src/ldo.o: ../lua/src/lfunc.h +CMakeFiles/mojosetup.dir/lua/src/ldo.o: ../lua/src/lgc.h +CMakeFiles/mojosetup.dir/lua/src/ldo.o: ../lua/src/llimits.h +CMakeFiles/mojosetup.dir/lua/src/ldo.o: ../lua/src/lmem.h +CMakeFiles/mojosetup.dir/lua/src/ldo.o: ../lua/src/lobject.h +CMakeFiles/mojosetup.dir/lua/src/ldo.o: ../lua/src/lopcodes.h +CMakeFiles/mojosetup.dir/lua/src/ldo.o: ../lua/src/lparser.h +CMakeFiles/mojosetup.dir/lua/src/ldo.o: ../lua/src/lstate.h +CMakeFiles/mojosetup.dir/lua/src/ldo.o: ../lua/src/lstring.h +CMakeFiles/mojosetup.dir/lua/src/ldo.o: ../lua/src/ltable.h +CMakeFiles/mojosetup.dir/lua/src/ldo.o: ../lua/src/ltm.h +CMakeFiles/mojosetup.dir/lua/src/ldo.o: ../lua/src/lua.h +CMakeFiles/mojosetup.dir/lua/src/ldo.o: ../lua/src/luaconf.h +CMakeFiles/mojosetup.dir/lua/src/ldo.o: ../lua/src/lundump.h +CMakeFiles/mojosetup.dir/lua/src/ldo.o: ../lua/src/lvm.h +CMakeFiles/mojosetup.dir/lua/src/ldo.o: ../lua/src/lzio.h + +CMakeFiles/mojosetup.dir/lua/src/ldump.o: ../lua/src/ldump.c +CMakeFiles/mojosetup.dir/lua/src/ldump.o: ../lua/src/llimits.h +CMakeFiles/mojosetup.dir/lua/src/ldump.o: ../lua/src/lmem.h +CMakeFiles/mojosetup.dir/lua/src/ldump.o: ../lua/src/lobject.h +CMakeFiles/mojosetup.dir/lua/src/ldump.o: ../lua/src/lstate.h +CMakeFiles/mojosetup.dir/lua/src/ldump.o: ../lua/src/ltm.h +CMakeFiles/mojosetup.dir/lua/src/ldump.o: ../lua/src/lua.h +CMakeFiles/mojosetup.dir/lua/src/ldump.o: ../lua/src/luaconf.h +CMakeFiles/mojosetup.dir/lua/src/ldump.o: ../lua/src/lundump.h +CMakeFiles/mojosetup.dir/lua/src/ldump.o: ../lua/src/lzio.h + +CMakeFiles/mojosetup.dir/lua/src/lfunc.o: ../lua/src/lfunc.c +CMakeFiles/mojosetup.dir/lua/src/lfunc.o: ../lua/src/lfunc.h +CMakeFiles/mojosetup.dir/lua/src/lfunc.o: ../lua/src/lgc.h +CMakeFiles/mojosetup.dir/lua/src/lfunc.o: ../lua/src/llimits.h +CMakeFiles/mojosetup.dir/lua/src/lfunc.o: ../lua/src/lmem.h +CMakeFiles/mojosetup.dir/lua/src/lfunc.o: ../lua/src/lobject.h +CMakeFiles/mojosetup.dir/lua/src/lfunc.o: ../lua/src/lstate.h +CMakeFiles/mojosetup.dir/lua/src/lfunc.o: ../lua/src/ltm.h +CMakeFiles/mojosetup.dir/lua/src/lfunc.o: ../lua/src/lua.h +CMakeFiles/mojosetup.dir/lua/src/lfunc.o: ../lua/src/luaconf.h +CMakeFiles/mojosetup.dir/lua/src/lfunc.o: ../lua/src/lzio.h + +CMakeFiles/mojosetup.dir/lua/src/lgc.o: ../lua/src/ldebug.h +CMakeFiles/mojosetup.dir/lua/src/lgc.o: ../lua/src/ldo.h +CMakeFiles/mojosetup.dir/lua/src/lgc.o: ../lua/src/lfunc.h +CMakeFiles/mojosetup.dir/lua/src/lgc.o: ../lua/src/lgc.c +CMakeFiles/mojosetup.dir/lua/src/lgc.o: ../lua/src/lgc.h +CMakeFiles/mojosetup.dir/lua/src/lgc.o: ../lua/src/llimits.h +CMakeFiles/mojosetup.dir/lua/src/lgc.o: ../lua/src/lmem.h +CMakeFiles/mojosetup.dir/lua/src/lgc.o: ../lua/src/lobject.h +CMakeFiles/mojosetup.dir/lua/src/lgc.o: ../lua/src/lstate.h +CMakeFiles/mojosetup.dir/lua/src/lgc.o: ../lua/src/lstring.h +CMakeFiles/mojosetup.dir/lua/src/lgc.o: ../lua/src/ltable.h +CMakeFiles/mojosetup.dir/lua/src/lgc.o: ../lua/src/ltm.h +CMakeFiles/mojosetup.dir/lua/src/lgc.o: ../lua/src/lua.h +CMakeFiles/mojosetup.dir/lua/src/lgc.o: ../lua/src/luaconf.h +CMakeFiles/mojosetup.dir/lua/src/lgc.o: ../lua/src/lzio.h + +CMakeFiles/mojosetup.dir/lua/src/liolib.o: ../lua/src/lauxlib.h +CMakeFiles/mojosetup.dir/lua/src/liolib.o: ../lua/src/liolib.c +CMakeFiles/mojosetup.dir/lua/src/liolib.o: ../lua/src/lua.h +CMakeFiles/mojosetup.dir/lua/src/liolib.o: ../lua/src/luaconf.h +CMakeFiles/mojosetup.dir/lua/src/liolib.o: ../lua/src/lualib.h + +CMakeFiles/mojosetup.dir/lua/src/llex.o: ../lua/src/ldo.h +CMakeFiles/mojosetup.dir/lua/src/llex.o: ../lua/src/lgc.h +CMakeFiles/mojosetup.dir/lua/src/llex.o: ../lua/src/llex.c +CMakeFiles/mojosetup.dir/lua/src/llex.o: ../lua/src/llex.h +CMakeFiles/mojosetup.dir/lua/src/llex.o: ../lua/src/llimits.h +CMakeFiles/mojosetup.dir/lua/src/llex.o: ../lua/src/lmem.h +CMakeFiles/mojosetup.dir/lua/src/llex.o: ../lua/src/lobject.h +CMakeFiles/mojosetup.dir/lua/src/llex.o: ../lua/src/lparser.h +CMakeFiles/mojosetup.dir/lua/src/llex.o: ../lua/src/lstate.h +CMakeFiles/mojosetup.dir/lua/src/llex.o: ../lua/src/lstring.h +CMakeFiles/mojosetup.dir/lua/src/llex.o: ../lua/src/ltable.h +CMakeFiles/mojosetup.dir/lua/src/llex.o: ../lua/src/ltm.h +CMakeFiles/mojosetup.dir/lua/src/llex.o: ../lua/src/lua.h +CMakeFiles/mojosetup.dir/lua/src/llex.o: ../lua/src/luaconf.h +CMakeFiles/mojosetup.dir/lua/src/llex.o: ../lua/src/lzio.h + +CMakeFiles/mojosetup.dir/lua/src/lmathlib.o: ../lua/src/lauxlib.h +CMakeFiles/mojosetup.dir/lua/src/lmathlib.o: ../lua/src/lmathlib.c +CMakeFiles/mojosetup.dir/lua/src/lmathlib.o: ../lua/src/lua.h +CMakeFiles/mojosetup.dir/lua/src/lmathlib.o: ../lua/src/luaconf.h +CMakeFiles/mojosetup.dir/lua/src/lmathlib.o: ../lua/src/lualib.h + +CMakeFiles/mojosetup.dir/lua/src/lmem.o: ../lua/src/ldebug.h +CMakeFiles/mojosetup.dir/lua/src/lmem.o: ../lua/src/ldo.h +CMakeFiles/mojosetup.dir/lua/src/lmem.o: ../lua/src/llimits.h +CMakeFiles/mojosetup.dir/lua/src/lmem.o: ../lua/src/lmem.c +CMakeFiles/mojosetup.dir/lua/src/lmem.o: ../lua/src/lmem.h +CMakeFiles/mojosetup.dir/lua/src/lmem.o: ../lua/src/lobject.h +CMakeFiles/mojosetup.dir/lua/src/lmem.o: ../lua/src/lstate.h +CMakeFiles/mojosetup.dir/lua/src/lmem.o: ../lua/src/ltm.h +CMakeFiles/mojosetup.dir/lua/src/lmem.o: ../lua/src/lua.h +CMakeFiles/mojosetup.dir/lua/src/lmem.o: ../lua/src/luaconf.h +CMakeFiles/mojosetup.dir/lua/src/lmem.o: ../lua/src/lzio.h + +CMakeFiles/mojosetup.dir/lua/src/loadlib.o: ../lua/src/lauxlib.h +CMakeFiles/mojosetup.dir/lua/src/loadlib.o: ../lua/src/loadlib.c +CMakeFiles/mojosetup.dir/lua/src/loadlib.o: ../lua/src/lua.h +CMakeFiles/mojosetup.dir/lua/src/loadlib.o: ../lua/src/luaconf.h +CMakeFiles/mojosetup.dir/lua/src/loadlib.o: ../lua/src/lualib.h + +CMakeFiles/mojosetup.dir/lua/src/lobject.o: ../lua/src/ldo.h +CMakeFiles/mojosetup.dir/lua/src/lobject.o: ../lua/src/lgc.h +CMakeFiles/mojosetup.dir/lua/src/lobject.o: ../lua/src/llimits.h +CMakeFiles/mojosetup.dir/lua/src/lobject.o: ../lua/src/lmem.h +CMakeFiles/mojosetup.dir/lua/src/lobject.o: ../lua/src/lobject.c +CMakeFiles/mojosetup.dir/lua/src/lobject.o: ../lua/src/lobject.h +CMakeFiles/mojosetup.dir/lua/src/lobject.o: ../lua/src/lstate.h +CMakeFiles/mojosetup.dir/lua/src/lobject.o: ../lua/src/lstring.h +CMakeFiles/mojosetup.dir/lua/src/lobject.o: ../lua/src/ltm.h +CMakeFiles/mojosetup.dir/lua/src/lobject.o: ../lua/src/lua.h +CMakeFiles/mojosetup.dir/lua/src/lobject.o: ../lua/src/luaconf.h +CMakeFiles/mojosetup.dir/lua/src/lobject.o: ../lua/src/lvm.h +CMakeFiles/mojosetup.dir/lua/src/lobject.o: ../lua/src/lzio.h + +CMakeFiles/mojosetup.dir/lua/src/lopcodes.o: ../lua/src/llimits.h +CMakeFiles/mojosetup.dir/lua/src/lopcodes.o: ../lua/src/lopcodes.c +CMakeFiles/mojosetup.dir/lua/src/lopcodes.o: ../lua/src/lopcodes.h +CMakeFiles/mojosetup.dir/lua/src/lopcodes.o: ../lua/src/lua.h +CMakeFiles/mojosetup.dir/lua/src/lopcodes.o: ../lua/src/luaconf.h + +CMakeFiles/mojosetup.dir/lua/src/loslib.o: ../lua/src/lauxlib.h +CMakeFiles/mojosetup.dir/lua/src/loslib.o: ../lua/src/loslib.c +CMakeFiles/mojosetup.dir/lua/src/loslib.o: ../lua/src/lua.h +CMakeFiles/mojosetup.dir/lua/src/loslib.o: ../lua/src/luaconf.h +CMakeFiles/mojosetup.dir/lua/src/loslib.o: ../lua/src/lualib.h + +CMakeFiles/mojosetup.dir/lua/src/lparser.o: ../lua/src/lcode.h +CMakeFiles/mojosetup.dir/lua/src/lparser.o: ../lua/src/ldebug.h +CMakeFiles/mojosetup.dir/lua/src/lparser.o: ../lua/src/ldo.h +CMakeFiles/mojosetup.dir/lua/src/lparser.o: ../lua/src/lfunc.h +CMakeFiles/mojosetup.dir/lua/src/lparser.o: ../lua/src/lgc.h +CMakeFiles/mojosetup.dir/lua/src/lparser.o: ../lua/src/llex.h +CMakeFiles/mojosetup.dir/lua/src/lparser.o: ../lua/src/llimits.h +CMakeFiles/mojosetup.dir/lua/src/lparser.o: ../lua/src/lmem.h +CMakeFiles/mojosetup.dir/lua/src/lparser.o: ../lua/src/lobject.h +CMakeFiles/mojosetup.dir/lua/src/lparser.o: ../lua/src/lopcodes.h +CMakeFiles/mojosetup.dir/lua/src/lparser.o: ../lua/src/lparser.c +CMakeFiles/mojosetup.dir/lua/src/lparser.o: ../lua/src/lparser.h +CMakeFiles/mojosetup.dir/lua/src/lparser.o: ../lua/src/lstate.h +CMakeFiles/mojosetup.dir/lua/src/lparser.o: ../lua/src/lstring.h +CMakeFiles/mojosetup.dir/lua/src/lparser.o: ../lua/src/ltable.h +CMakeFiles/mojosetup.dir/lua/src/lparser.o: ../lua/src/ltm.h +CMakeFiles/mojosetup.dir/lua/src/lparser.o: ../lua/src/lua.h +CMakeFiles/mojosetup.dir/lua/src/lparser.o: ../lua/src/luaconf.h +CMakeFiles/mojosetup.dir/lua/src/lparser.o: ../lua/src/lzio.h + +CMakeFiles/mojosetup.dir/lua/src/lstate.o: ../lua/src/ldebug.h +CMakeFiles/mojosetup.dir/lua/src/lstate.o: ../lua/src/ldo.h +CMakeFiles/mojosetup.dir/lua/src/lstate.o: ../lua/src/lfunc.h +CMakeFiles/mojosetup.dir/lua/src/lstate.o: ../lua/src/lgc.h +CMakeFiles/mojosetup.dir/lua/src/lstate.o: ../lua/src/llex.h +CMakeFiles/mojosetup.dir/lua/src/lstate.o: ../lua/src/llimits.h +CMakeFiles/mojosetup.dir/lua/src/lstate.o: ../lua/src/lmem.h +CMakeFiles/mojosetup.dir/lua/src/lstate.o: ../lua/src/lobject.h +CMakeFiles/mojosetup.dir/lua/src/lstate.o: ../lua/src/lstate.c +CMakeFiles/mojosetup.dir/lua/src/lstate.o: ../lua/src/lstate.h +CMakeFiles/mojosetup.dir/lua/src/lstate.o: ../lua/src/lstring.h +CMakeFiles/mojosetup.dir/lua/src/lstate.o: ../lua/src/ltable.h +CMakeFiles/mojosetup.dir/lua/src/lstate.o: ../lua/src/ltm.h +CMakeFiles/mojosetup.dir/lua/src/lstate.o: ../lua/src/lua.h +CMakeFiles/mojosetup.dir/lua/src/lstate.o: ../lua/src/luaconf.h +CMakeFiles/mojosetup.dir/lua/src/lstate.o: ../lua/src/lzio.h + +CMakeFiles/mojosetup.dir/lua/src/lstring.o: ../lua/src/lgc.h +CMakeFiles/mojosetup.dir/lua/src/lstring.o: ../lua/src/llimits.h +CMakeFiles/mojosetup.dir/lua/src/lstring.o: ../lua/src/lmem.h +CMakeFiles/mojosetup.dir/lua/src/lstring.o: ../lua/src/lobject.h +CMakeFiles/mojosetup.dir/lua/src/lstring.o: ../lua/src/lstate.h +CMakeFiles/mojosetup.dir/lua/src/lstring.o: ../lua/src/lstring.c +CMakeFiles/mojosetup.dir/lua/src/lstring.o: ../lua/src/lstring.h +CMakeFiles/mojosetup.dir/lua/src/lstring.o: ../lua/src/ltm.h +CMakeFiles/mojosetup.dir/lua/src/lstring.o: ../lua/src/lua.h +CMakeFiles/mojosetup.dir/lua/src/lstring.o: ../lua/src/luaconf.h +CMakeFiles/mojosetup.dir/lua/src/lstring.o: ../lua/src/lzio.h + +CMakeFiles/mojosetup.dir/lua/src/lstrlib.o: ../lua/src/lauxlib.h +CMakeFiles/mojosetup.dir/lua/src/lstrlib.o: ../lua/src/lstrlib.c +CMakeFiles/mojosetup.dir/lua/src/lstrlib.o: ../lua/src/lua.h +CMakeFiles/mojosetup.dir/lua/src/lstrlib.o: ../lua/src/luaconf.h +CMakeFiles/mojosetup.dir/lua/src/lstrlib.o: ../lua/src/lualib.h + +CMakeFiles/mojosetup.dir/lua/src/ltable.o: ../lua/src/ldebug.h +CMakeFiles/mojosetup.dir/lua/src/ltable.o: ../lua/src/ldo.h +CMakeFiles/mojosetup.dir/lua/src/ltable.o: ../lua/src/lgc.h +CMakeFiles/mojosetup.dir/lua/src/ltable.o: ../lua/src/llimits.h +CMakeFiles/mojosetup.dir/lua/src/ltable.o: ../lua/src/lmem.h +CMakeFiles/mojosetup.dir/lua/src/ltable.o: ../lua/src/lobject.h +CMakeFiles/mojosetup.dir/lua/src/ltable.o: ../lua/src/lstate.h +CMakeFiles/mojosetup.dir/lua/src/ltable.o: ../lua/src/ltable.c +CMakeFiles/mojosetup.dir/lua/src/ltable.o: ../lua/src/ltable.h +CMakeFiles/mojosetup.dir/lua/src/ltable.o: ../lua/src/ltm.h +CMakeFiles/mojosetup.dir/lua/src/ltable.o: ../lua/src/lua.h +CMakeFiles/mojosetup.dir/lua/src/ltable.o: ../lua/src/luaconf.h +CMakeFiles/mojosetup.dir/lua/src/ltable.o: ../lua/src/lzio.h + +CMakeFiles/mojosetup.dir/lua/src/ltablib.o: ../lua/src/lauxlib.h +CMakeFiles/mojosetup.dir/lua/src/ltablib.o: ../lua/src/ltablib.c +CMakeFiles/mojosetup.dir/lua/src/ltablib.o: ../lua/src/lua.h +CMakeFiles/mojosetup.dir/lua/src/ltablib.o: ../lua/src/luaconf.h +CMakeFiles/mojosetup.dir/lua/src/ltablib.o: ../lua/src/lualib.h + +CMakeFiles/mojosetup.dir/lua/src/ltm.o: ../lua/src/lgc.h +CMakeFiles/mojosetup.dir/lua/src/ltm.o: ../lua/src/llimits.h +CMakeFiles/mojosetup.dir/lua/src/ltm.o: ../lua/src/lmem.h +CMakeFiles/mojosetup.dir/lua/src/ltm.o: ../lua/src/lobject.h +CMakeFiles/mojosetup.dir/lua/src/ltm.o: ../lua/src/lstate.h +CMakeFiles/mojosetup.dir/lua/src/ltm.o: ../lua/src/lstring.h +CMakeFiles/mojosetup.dir/lua/src/ltm.o: ../lua/src/ltable.h +CMakeFiles/mojosetup.dir/lua/src/ltm.o: ../lua/src/ltm.c +CMakeFiles/mojosetup.dir/lua/src/ltm.o: ../lua/src/ltm.h +CMakeFiles/mojosetup.dir/lua/src/ltm.o: ../lua/src/lua.h +CMakeFiles/mojosetup.dir/lua/src/ltm.o: ../lua/src/luaconf.h +CMakeFiles/mojosetup.dir/lua/src/ltm.o: ../lua/src/lzio.h + +CMakeFiles/mojosetup.dir/lua/src/lundump.o: ../lua/src/ldebug.h +CMakeFiles/mojosetup.dir/lua/src/lundump.o: ../lua/src/ldo.h +CMakeFiles/mojosetup.dir/lua/src/lundump.o: ../lua/src/lfunc.h +CMakeFiles/mojosetup.dir/lua/src/lundump.o: ../lua/src/lgc.h +CMakeFiles/mojosetup.dir/lua/src/lundump.o: ../lua/src/llimits.h +CMakeFiles/mojosetup.dir/lua/src/lundump.o: ../lua/src/lmem.h +CMakeFiles/mojosetup.dir/lua/src/lundump.o: ../lua/src/lobject.h +CMakeFiles/mojosetup.dir/lua/src/lundump.o: ../lua/src/lstate.h +CMakeFiles/mojosetup.dir/lua/src/lundump.o: ../lua/src/lstring.h +CMakeFiles/mojosetup.dir/lua/src/lundump.o: ../lua/src/ltm.h +CMakeFiles/mojosetup.dir/lua/src/lundump.o: ../lua/src/lua.h +CMakeFiles/mojosetup.dir/lua/src/lundump.o: ../lua/src/luaconf.h +CMakeFiles/mojosetup.dir/lua/src/lundump.o: ../lua/src/lundump.c +CMakeFiles/mojosetup.dir/lua/src/lundump.o: ../lua/src/lundump.h +CMakeFiles/mojosetup.dir/lua/src/lundump.o: ../lua/src/lzio.h + +CMakeFiles/mojosetup.dir/lua/src/lvm.o: ../lua/src/ldebug.h +CMakeFiles/mojosetup.dir/lua/src/lvm.o: ../lua/src/ldo.h +CMakeFiles/mojosetup.dir/lua/src/lvm.o: ../lua/src/lfunc.h +CMakeFiles/mojosetup.dir/lua/src/lvm.o: ../lua/src/lgc.h +CMakeFiles/mojosetup.dir/lua/src/lvm.o: ../lua/src/llimits.h +CMakeFiles/mojosetup.dir/lua/src/lvm.o: ../lua/src/lmem.h +CMakeFiles/mojosetup.dir/lua/src/lvm.o: ../lua/src/lobject.h +CMakeFiles/mojosetup.dir/lua/src/lvm.o: ../lua/src/lopcodes.h +CMakeFiles/mojosetup.dir/lua/src/lvm.o: ../lua/src/lstate.h +CMakeFiles/mojosetup.dir/lua/src/lvm.o: ../lua/src/lstring.h +CMakeFiles/mojosetup.dir/lua/src/lvm.o: ../lua/src/ltable.h +CMakeFiles/mojosetup.dir/lua/src/lvm.o: ../lua/src/ltm.h +CMakeFiles/mojosetup.dir/lua/src/lvm.o: ../lua/src/lua.h +CMakeFiles/mojosetup.dir/lua/src/lvm.o: ../lua/src/luaconf.h +CMakeFiles/mojosetup.dir/lua/src/lvm.o: ../lua/src/lvm.c +CMakeFiles/mojosetup.dir/lua/src/lvm.o: ../lua/src/lvm.h +CMakeFiles/mojosetup.dir/lua/src/lvm.o: ../lua/src/lzio.h + +CMakeFiles/mojosetup.dir/lua/src/lzio.o: ../lua/src/llimits.h +CMakeFiles/mojosetup.dir/lua/src/lzio.o: ../lua/src/lmem.h +CMakeFiles/mojosetup.dir/lua/src/lzio.o: ../lua/src/lobject.h +CMakeFiles/mojosetup.dir/lua/src/lzio.o: ../lua/src/lstate.h +CMakeFiles/mojosetup.dir/lua/src/lzio.o: ../lua/src/ltm.h +CMakeFiles/mojosetup.dir/lua/src/lzio.o: ../lua/src/lua.h +CMakeFiles/mojosetup.dir/lua/src/lzio.o: ../lua/src/luaconf.h +CMakeFiles/mojosetup.dir/lua/src/lzio.o: ../lua/src/lzio.c +CMakeFiles/mojosetup.dir/lua/src/lzio.o: ../lua/src/lzio.h + +CMakeFiles/mojosetup.dir/lua_glue.o: ../lua/src/lauxlib.h +CMakeFiles/mojosetup.dir/lua_glue.o: ../lua/src/lua.h +CMakeFiles/mojosetup.dir/lua_glue.o: ../lua/src/luaconf.h +CMakeFiles/mojosetup.dir/lua_glue.o: ../lua/src/lualib.h +CMakeFiles/mojosetup.dir/lua_glue.o: ../fileio.h +CMakeFiles/mojosetup.dir/lua_glue.o: ../gui.h +CMakeFiles/mojosetup.dir/lua_glue.o: ../lua_glue.c +CMakeFiles/mojosetup.dir/lua_glue.o: ../lua_glue.h +CMakeFiles/mojosetup.dir/lua_glue.o: ../platform.h +CMakeFiles/mojosetup.dir/lua_glue.o: ../universal.h + +CMakeFiles/mojosetup.dir/mojosetup.o: ../fileio.h +CMakeFiles/mojosetup.dir/mojosetup.o: ../gui.h +CMakeFiles/mojosetup.dir/mojosetup.o: ../lua_glue.h +CMakeFiles/mojosetup.dir/mojosetup.o: ../mojosetup.c +CMakeFiles/mojosetup.dir/mojosetup.o: ../platform.h +CMakeFiles/mojosetup.dir/mojosetup.o: ../universal.h + +CMakeFiles/mojosetup.dir/platform_unix.o: ../fileio.h +CMakeFiles/mojosetup.dir/platform_unix.o: ../gui.h +CMakeFiles/mojosetup.dir/platform_unix.o: ../platform.h +CMakeFiles/mojosetup.dir/platform_unix.o: ../platform_unix.c +CMakeFiles/mojosetup.dir/platform_unix.o: ../universal.h + +CMakeFiles/mojosetup.dir/platform_windows.o: ../gui.h +CMakeFiles/mojosetup.dir/platform_windows.o: ../platform.h +CMakeFiles/mojosetup.dir/platform_windows.o: ../platform_windows.c +CMakeFiles/mojosetup.dir/platform_windows.o: ../universal.h + +CMakeFiles/mojosetup.dir/stb_image.o: ../stb_image.c +CMakeFiles/mojosetup.dir/stb_image.o: ../universal.h + diff --git a/mk/linux/mojosetup/build/CMakeFiles/mojosetup.dir/flags.make b/mk/linux/mojosetup/build/CMakeFiles/mojosetup.dir/flags.make new file mode 100644 index 00000000..af60b456 --- /dev/null +++ b/mk/linux/mojosetup/build/CMakeFiles/mojosetup.dir/flags.make @@ -0,0 +1,8 @@ +# CMAKE generated file: DO NOT EDIT! +# Generated by "Unix Makefiles" Generator, CMake Version 2.8 + +# compile C with /usr/bin/gcc +C_FLAGS = -I/home/softcoder/Code/mojosetup/. -I/home/softcoder/Code/mojosetup/lua/src -DAPPREV="hg-767:48f7a9461c37" -pipe -Wall -Werror -fsigned-char -fvisibility=hidden -fno-stack-protector -DPNG_NO_MMX_CODE -I/usr/include/gtk-2.0 -I/usr/lib/gtk-2.0/include -I/usr/include/atk-1.0 -I/usr/include/cairo -I/usr/include/pango-1.0 -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include -I/usr/include/freetype2 -I/usr/include/libpng12 + +C_DEFINES = -D__MOJOSETUP__=1 -DAPPID=mojosetup -D_REENTRANT -D_THREAD_SAFE -DPLATFORM_UNIX=1 -DLUA_USE_MKSTEMP=1 -DLUA_USE_ULONGJMP=1 -DPLATFORM_LITTLEENDIAN=1 -DSUPPORT_LUALIB_IO=1 -DSUPPORT_LUALIB_OS=1 -DSUPPORT_LUALIB_MATH=1 -DSUPPORT_LUALIB_DB=1 -DSUPPORT_LUALIB_PACKAGE=1 -DSUPPORT_CRC32=1 -DSUPPORT_MD5=1 -DSUPPORT_SHA1=1 -DSUPPORT_GUI_STDIO=1 -DGUI_STATIC_LINK_STDIO=1 -DSUPPORT_GUI_GTKPLUS2=1 -DSUPPORT_ZIP=1 -DSUPPORT_TAR=1 -DSUPPORT_GZIP=1 -DSUPPORT_BZIP2=1 -DBZ_NO_STDIO=1 -DSUPPORT_JPG=1 -DSUPPORT_PNG=1 -DSUPPORT_STBIMAGE=1 -DSUPPORT_URL_HTTP=1 -DSUPPORT_URL_FTP=1 -DMOJOSETUP_HAVE_MNTENT_H=1 + diff --git a/mk/linux/mojosetup/build/CMakeFiles/mojosetup.dir/link.txt b/mk/linux/mojosetup/build/CMakeFiles/mojosetup.dir/link.txt new file mode 100644 index 00000000..5c014c13 --- /dev/null +++ b/mk/linux/mojosetup/build/CMakeFiles/mojosetup.dir/link.txt @@ -0,0 +1 @@ +/usr/bin/gcc CMakeFiles/mojosetup.dir/buildver.o CMakeFiles/mojosetup.dir/mojosetup.o CMakeFiles/mojosetup.dir/gui.o CMakeFiles/mojosetup.dir/fileio.o CMakeFiles/mojosetup.dir/archive_zip.o CMakeFiles/mojosetup.dir/archive_tar.o CMakeFiles/mojosetup.dir/archive_uz2.o CMakeFiles/mojosetup.dir/archive_pck.o CMakeFiles/mojosetup.dir/checksum_crc32.o CMakeFiles/mojosetup.dir/checksum_md5.o CMakeFiles/mojosetup.dir/checksum_sha1.o CMakeFiles/mojosetup.dir/platform_unix.o CMakeFiles/mojosetup.dir/platform_windows.o CMakeFiles/mojosetup.dir/lua_glue.o CMakeFiles/mojosetup.dir/lua/src/lapi.o CMakeFiles/mojosetup.dir/lua/src/ldebug.o CMakeFiles/mojosetup.dir/lua/src/ldo.o CMakeFiles/mojosetup.dir/lua/src/ldump.o CMakeFiles/mojosetup.dir/lua/src/lfunc.o CMakeFiles/mojosetup.dir/lua/src/lgc.o CMakeFiles/mojosetup.dir/lua/src/lmem.o CMakeFiles/mojosetup.dir/lua/src/lobject.o CMakeFiles/mojosetup.dir/lua/src/lopcodes.o CMakeFiles/mojosetup.dir/lua/src/lstate.o CMakeFiles/mojosetup.dir/lua/src/lstring.o CMakeFiles/mojosetup.dir/lua/src/ltable.o CMakeFiles/mojosetup.dir/lua/src/ltm.o CMakeFiles/mojosetup.dir/lua/src/lundump.o CMakeFiles/mojosetup.dir/lua/src/lvm.o CMakeFiles/mojosetup.dir/lua/src/lzio.o CMakeFiles/mojosetup.dir/lua/src/lauxlib.o CMakeFiles/mojosetup.dir/lua/src/lbaselib.o CMakeFiles/mojosetup.dir/lua/src/lstrlib.o CMakeFiles/mojosetup.dir/lua/src/ltablib.o CMakeFiles/mojosetup.dir/lua/src/lparser.o CMakeFiles/mojosetup.dir/lua/src/llex.o CMakeFiles/mojosetup.dir/lua/src/lcode.o CMakeFiles/mojosetup.dir/lua/src/liolib.o CMakeFiles/mojosetup.dir/lua/src/loslib.o CMakeFiles/mojosetup.dir/lua/src/lmathlib.o CMakeFiles/mojosetup.dir/lua/src/ldblib.o CMakeFiles/mojosetup.dir/lua/src/loadlib.o CMakeFiles/mojosetup.dir/gui_stdio.o CMakeFiles/mojosetup.dir/stb_image.o CMakeFiles/mojosetup.dir/libfetch/fetch.o CMakeFiles/mojosetup.dir/libfetch/common.o CMakeFiles/mojosetup.dir/libfetch/ftp.o CMakeFiles/mojosetup.dir/libfetch/http.o -o mojosetup -lpthread -lz -lbz2 -ldl -lm diff --git a/mk/linux/mojosetup/build/CMakeFiles/mojosetup.dir/progress.make b/mk/linux/mojosetup/build/CMakeFiles/mojosetup.dir/progress.make new file mode 100644 index 00000000..369321ff --- /dev/null +++ b/mk/linux/mojosetup/build/CMakeFiles/mojosetup.dir/progress.make @@ -0,0 +1,49 @@ +CMAKE_PROGRESS_1 = 32 +CMAKE_PROGRESS_2 = 33 +CMAKE_PROGRESS_3 = 34 +CMAKE_PROGRESS_4 = 35 +CMAKE_PROGRESS_5 = 36 +CMAKE_PROGRESS_6 = 37 +CMAKE_PROGRESS_7 = 38 +CMAKE_PROGRESS_8 = 39 +CMAKE_PROGRESS_9 = 40 +CMAKE_PROGRESS_10 = 41 +CMAKE_PROGRESS_11 = 42 +CMAKE_PROGRESS_12 = 43 +CMAKE_PROGRESS_13 = 44 +CMAKE_PROGRESS_14 = 45 +CMAKE_PROGRESS_15 = 46 +CMAKE_PROGRESS_16 = 47 +CMAKE_PROGRESS_17 = 48 +CMAKE_PROGRESS_18 = 49 +CMAKE_PROGRESS_19 = 50 +CMAKE_PROGRESS_20 = 51 +CMAKE_PROGRESS_21 = 52 +CMAKE_PROGRESS_22 = 53 +CMAKE_PROGRESS_23 = 54 +CMAKE_PROGRESS_24 = 55 +CMAKE_PROGRESS_25 = 56 +CMAKE_PROGRESS_26 = 57 +CMAKE_PROGRESS_27 = 58 +CMAKE_PROGRESS_28 = 59 +CMAKE_PROGRESS_29 = 60 +CMAKE_PROGRESS_30 = 61 +CMAKE_PROGRESS_31 = 62 +CMAKE_PROGRESS_32 = 63 +CMAKE_PROGRESS_33 = 64 +CMAKE_PROGRESS_34 = 65 +CMAKE_PROGRESS_35 = 66 +CMAKE_PROGRESS_36 = 67 +CMAKE_PROGRESS_37 = 68 +CMAKE_PROGRESS_38 = 69 +CMAKE_PROGRESS_39 = 70 +CMAKE_PROGRESS_40 = 71 +CMAKE_PROGRESS_41 = 72 +CMAKE_PROGRESS_42 = 73 +CMAKE_PROGRESS_43 = 74 +CMAKE_PROGRESS_44 = 75 +CMAKE_PROGRESS_45 = 76 +CMAKE_PROGRESS_46 = 77 +CMAKE_PROGRESS_47 = 78 +CMAKE_PROGRESS_48 = 79 + diff --git a/mk/linux/mojosetup/build/CMakeFiles/mojosetupgui_gtkplus2.dir/C.includecache b/mk/linux/mojosetup/build/CMakeFiles/mojosetupgui_gtkplus2.dir/C.includecache new file mode 100644 index 00000000..328d51cd --- /dev/null +++ b/mk/linux/mojosetup/build/CMakeFiles/mojosetupgui_gtkplus2.dir/C.includecache @@ -0,0 +1,32 @@ +#IncludeRegexLine: ^[ ]*#[ ]*(include|import)[ ]*[<"]([^">]+)([">]) + +#IncludeRegexScan: ^.*$ + +#IncludeRegexComplain: ^$ + +#IncludeRegexTransform: + +/home/softcoder/Code/mojosetup/gui.h +universal.h +/home/softcoder/Code/mojosetup/universal.h + +/home/softcoder/Code/mojosetup/gui_gtkplus2.c +gui.h +/home/softcoder/Code/mojosetup/gui.h +gtk/gtk.h +- + +/home/softcoder/Code/mojosetup/universal.h +stdio.h +- +stdlib.h +- +string.h +- +assert.h +- +time.h +- +malloc.h +- + diff --git a/mk/linux/mojosetup/build/CMakeFiles/mojosetupgui_gtkplus2.dir/DependInfo.cmake b/mk/linux/mojosetup/build/CMakeFiles/mojosetupgui_gtkplus2.dir/DependInfo.cmake new file mode 100644 index 00000000..f6782a55 --- /dev/null +++ b/mk/linux/mojosetup/build/CMakeFiles/mojosetupgui_gtkplus2.dir/DependInfo.cmake @@ -0,0 +1,47 @@ +# The set of languages for which implicit dependencies are needed: +SET(CMAKE_DEPENDS_LANGUAGES + "C" + ) +# The set of files for implicit dependencies of each language: +SET(CMAKE_DEPENDS_CHECK_C + "/home/softcoder/Code/mojosetup/gui_gtkplus2.c" "/home/softcoder/Code/mojosetup/build/CMakeFiles/mojosetupgui_gtkplus2.dir/gui_gtkplus2.o" + ) +SET(CMAKE_C_COMPILER_ID "GNU") + +# Preprocessor definitions for this target. +SET(CMAKE_TARGET_DEFINITIONS + "__MOJOSETUP__=1" + "APPID=mojosetup" + "_REENTRANT" + "_THREAD_SAFE" + "PLATFORM_UNIX=1" + "LUA_USE_MKSTEMP=1" + "LUA_USE_ULONGJMP=1" + "PLATFORM_LITTLEENDIAN=1" + "SUPPORT_LUALIB_IO=1" + "SUPPORT_LUALIB_OS=1" + "SUPPORT_LUALIB_MATH=1" + "SUPPORT_LUALIB_DB=1" + "SUPPORT_LUALIB_PACKAGE=1" + "SUPPORT_CRC32=1" + "SUPPORT_MD5=1" + "SUPPORT_SHA1=1" + "SUPPORT_GUI_STDIO=1" + "GUI_STATIC_LINK_STDIO=1" + "SUPPORT_GUI_GTKPLUS2=1" + "SUPPORT_ZIP=1" + "SUPPORT_TAR=1" + "SUPPORT_GZIP=1" + "SUPPORT_BZIP2=1" + "BZ_NO_STDIO=1" + "SUPPORT_JPG=1" + "SUPPORT_PNG=1" + "SUPPORT_STBIMAGE=1" + "SUPPORT_URL_HTTP=1" + "SUPPORT_URL_FTP=1" + "MOJOSETUP_HAVE_MNTENT_H=1" + ) + +# Targets to which this target links. +SET(CMAKE_TARGET_LINKED_INFO_FILES + ) diff --git a/mk/linux/mojosetup/build/CMakeFiles/mojosetupgui_gtkplus2.dir/build.make b/mk/linux/mojosetup/build/CMakeFiles/mojosetupgui_gtkplus2.dir/build.make new file mode 100644 index 00000000..3daa8a67 --- /dev/null +++ b/mk/linux/mojosetup/build/CMakeFiles/mojosetupgui_gtkplus2.dir/build.make @@ -0,0 +1,100 @@ +# CMAKE generated file: DO NOT EDIT! +# Generated by "Unix Makefiles" Generator, CMake Version 2.8 + +#============================================================================= +# Special targets provided by cmake. + +# Disable implicit rules so canoncical targets will work. +.SUFFIXES: + +# Remove some rules from gmake that .SUFFIXES does not remove. +SUFFIXES = + +.SUFFIXES: .hpux_make_needs_suffix_list + +# Suppress display of executed commands. +$(VERBOSE).SILENT: + +# A target that is always out of date. +cmake_force: +.PHONY : cmake_force + +#============================================================================= +# Set environment variables for the build. + +# The shell in which to execute make rules. +SHELL = /bin/sh + +# The CMake executable. +CMAKE_COMMAND = /usr/bin/cmake + +# The command to remove a file. +RM = /usr/bin/cmake -E remove -f + +# The top-level source directory on which CMake was run. +CMAKE_SOURCE_DIR = /home/softcoder/Code/mojosetup + +# The top-level build directory on which CMake was run. +CMAKE_BINARY_DIR = /home/softcoder/Code/mojosetup/build + +# Include any dependencies generated for this target. +include CMakeFiles/mojosetupgui_gtkplus2.dir/depend.make + +# Include the progress variables for this target. +include CMakeFiles/mojosetupgui_gtkplus2.dir/progress.make + +# Include the compile flags for this target's objects. +include CMakeFiles/mojosetupgui_gtkplus2.dir/flags.make + +CMakeFiles/mojosetupgui_gtkplus2.dir/gui_gtkplus2.o: CMakeFiles/mojosetupgui_gtkplus2.dir/flags.make +CMakeFiles/mojosetupgui_gtkplus2.dir/gui_gtkplus2.o: ../gui_gtkplus2.c + $(CMAKE_COMMAND) -E cmake_progress_report /home/softcoder/Code/mojosetup/build/CMakeFiles $(CMAKE_PROGRESS_1) + @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green "Building C object CMakeFiles/mojosetupgui_gtkplus2.dir/gui_gtkplus2.o" + /usr/bin/gcc $(C_DEFINES) $(C_FLAGS) -o CMakeFiles/mojosetupgui_gtkplus2.dir/gui_gtkplus2.o -c /home/softcoder/Code/mojosetup/gui_gtkplus2.c + +CMakeFiles/mojosetupgui_gtkplus2.dir/gui_gtkplus2.i: cmake_force + @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green "Preprocessing C source to CMakeFiles/mojosetupgui_gtkplus2.dir/gui_gtkplus2.i" + /usr/bin/gcc $(C_DEFINES) $(C_FLAGS) -E /home/softcoder/Code/mojosetup/gui_gtkplus2.c > CMakeFiles/mojosetupgui_gtkplus2.dir/gui_gtkplus2.i + +CMakeFiles/mojosetupgui_gtkplus2.dir/gui_gtkplus2.s: cmake_force + @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green "Compiling C source to assembly CMakeFiles/mojosetupgui_gtkplus2.dir/gui_gtkplus2.s" + /usr/bin/gcc $(C_DEFINES) $(C_FLAGS) -S /home/softcoder/Code/mojosetup/gui_gtkplus2.c -o CMakeFiles/mojosetupgui_gtkplus2.dir/gui_gtkplus2.s + +CMakeFiles/mojosetupgui_gtkplus2.dir/gui_gtkplus2.o.requires: +.PHONY : CMakeFiles/mojosetupgui_gtkplus2.dir/gui_gtkplus2.o.requires + +CMakeFiles/mojosetupgui_gtkplus2.dir/gui_gtkplus2.o.provides: CMakeFiles/mojosetupgui_gtkplus2.dir/gui_gtkplus2.o.requires + $(MAKE) -f CMakeFiles/mojosetupgui_gtkplus2.dir/build.make CMakeFiles/mojosetupgui_gtkplus2.dir/gui_gtkplus2.o.provides.build +.PHONY : CMakeFiles/mojosetupgui_gtkplus2.dir/gui_gtkplus2.o.provides + +CMakeFiles/mojosetupgui_gtkplus2.dir/gui_gtkplus2.o.provides.build: CMakeFiles/mojosetupgui_gtkplus2.dir/gui_gtkplus2.o +.PHONY : CMakeFiles/mojosetupgui_gtkplus2.dir/gui_gtkplus2.o.provides.build + +# Object files for target mojosetupgui_gtkplus2 +mojosetupgui_gtkplus2_OBJECTS = \ +"CMakeFiles/mojosetupgui_gtkplus2.dir/gui_gtkplus2.o" + +# External object files for target mojosetupgui_gtkplus2 +mojosetupgui_gtkplus2_EXTERNAL_OBJECTS = + +libmojosetupgui_gtkplus2.so: CMakeFiles/mojosetupgui_gtkplus2.dir/gui_gtkplus2.o +libmojosetupgui_gtkplus2.so: CMakeFiles/mojosetupgui_gtkplus2.dir/build.make +libmojosetupgui_gtkplus2.so: CMakeFiles/mojosetupgui_gtkplus2.dir/link.txt + @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --red --bold "Linking C shared library libmojosetupgui_gtkplus2.so" + $(CMAKE_COMMAND) -E cmake_link_script CMakeFiles/mojosetupgui_gtkplus2.dir/link.txt --verbose=$(VERBOSE) + +# Rule to build all files generated by this target. +CMakeFiles/mojosetupgui_gtkplus2.dir/build: libmojosetupgui_gtkplus2.so +.PHONY : CMakeFiles/mojosetupgui_gtkplus2.dir/build + +CMakeFiles/mojosetupgui_gtkplus2.dir/requires: CMakeFiles/mojosetupgui_gtkplus2.dir/gui_gtkplus2.o.requires +.PHONY : CMakeFiles/mojosetupgui_gtkplus2.dir/requires + +CMakeFiles/mojosetupgui_gtkplus2.dir/clean: + $(CMAKE_COMMAND) -P CMakeFiles/mojosetupgui_gtkplus2.dir/cmake_clean.cmake +.PHONY : CMakeFiles/mojosetupgui_gtkplus2.dir/clean + +CMakeFiles/mojosetupgui_gtkplus2.dir/depend: + cd /home/softcoder/Code/mojosetup/build && $(CMAKE_COMMAND) -E cmake_depends "Unix Makefiles" /home/softcoder/Code/mojosetup /home/softcoder/Code/mojosetup /home/softcoder/Code/mojosetup/build /home/softcoder/Code/mojosetup/build /home/softcoder/Code/mojosetup/build/CMakeFiles/mojosetupgui_gtkplus2.dir/DependInfo.cmake --color=$(COLOR) +.PHONY : CMakeFiles/mojosetupgui_gtkplus2.dir/depend + diff --git a/mk/linux/mojosetup/build/CMakeFiles/mojosetupgui_gtkplus2.dir/cmake_clean.cmake b/mk/linux/mojosetup/build/CMakeFiles/mojosetupgui_gtkplus2.dir/cmake_clean.cmake new file mode 100644 index 00000000..ae24bcf8 --- /dev/null +++ b/mk/linux/mojosetup/build/CMakeFiles/mojosetupgui_gtkplus2.dir/cmake_clean.cmake @@ -0,0 +1,10 @@ +FILE(REMOVE_RECURSE + "CMakeFiles/mojosetupgui_gtkplus2.dir/gui_gtkplus2.o" + "libmojosetupgui_gtkplus2.pdb" + "libmojosetupgui_gtkplus2.so" +) + +# Per-language clean rules from dependency scanning. +FOREACH(lang C) + INCLUDE(CMakeFiles/mojosetupgui_gtkplus2.dir/cmake_clean_${lang}.cmake OPTIONAL) +ENDFOREACH(lang) diff --git a/mk/linux/mojosetup/build/CMakeFiles/mojosetupgui_gtkplus2.dir/depend.internal b/mk/linux/mojosetup/build/CMakeFiles/mojosetupgui_gtkplus2.dir/depend.internal new file mode 100644 index 00000000..672bb642 --- /dev/null +++ b/mk/linux/mojosetup/build/CMakeFiles/mojosetupgui_gtkplus2.dir/depend.internal @@ -0,0 +1,7 @@ +# CMAKE generated file: DO NOT EDIT! +# Generated by "Unix Makefiles" Generator, CMake Version 2.8 + +CMakeFiles/mojosetupgui_gtkplus2.dir/gui_gtkplus2.o + /home/softcoder/Code/mojosetup/gui.h + /home/softcoder/Code/mojosetup/gui_gtkplus2.c + /home/softcoder/Code/mojosetup/universal.h diff --git a/mk/linux/mojosetup/build/CMakeFiles/mojosetupgui_gtkplus2.dir/depend.make b/mk/linux/mojosetup/build/CMakeFiles/mojosetupgui_gtkplus2.dir/depend.make new file mode 100644 index 00000000..7431b41e --- /dev/null +++ b/mk/linux/mojosetup/build/CMakeFiles/mojosetupgui_gtkplus2.dir/depend.make @@ -0,0 +1,7 @@ +# CMAKE generated file: DO NOT EDIT! +# Generated by "Unix Makefiles" Generator, CMake Version 2.8 + +CMakeFiles/mojosetupgui_gtkplus2.dir/gui_gtkplus2.o: ../gui.h +CMakeFiles/mojosetupgui_gtkplus2.dir/gui_gtkplus2.o: ../gui_gtkplus2.c +CMakeFiles/mojosetupgui_gtkplus2.dir/gui_gtkplus2.o: ../universal.h + diff --git a/mk/linux/mojosetup/build/CMakeFiles/mojosetupgui_gtkplus2.dir/flags.make b/mk/linux/mojosetup/build/CMakeFiles/mojosetupgui_gtkplus2.dir/flags.make new file mode 100644 index 00000000..61aa8a9a --- /dev/null +++ b/mk/linux/mojosetup/build/CMakeFiles/mojosetupgui_gtkplus2.dir/flags.make @@ -0,0 +1,8 @@ +# CMAKE generated file: DO NOT EDIT! +# Generated by "Unix Makefiles" Generator, CMake Version 2.8 + +# compile C with /usr/bin/gcc +C_FLAGS = -fPIC -I/home/softcoder/Code/mojosetup/. -I/home/softcoder/Code/mojosetup/lua/src -DAPPREV="hg-767:48f7a9461c37" -pipe -Wall -Werror -fsigned-char -fvisibility=hidden -fno-stack-protector -DPNG_NO_MMX_CODE -I/usr/include/gtk-2.0 -I/usr/lib/gtk-2.0/include -I/usr/include/atk-1.0 -I/usr/include/cairo -I/usr/include/pango-1.0 -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include -I/usr/include/freetype2 -I/usr/include/libpng12 + +C_DEFINES = -Dmojosetupgui_gtkplus2_EXPORTS -D__MOJOSETUP__=1 -DAPPID=mojosetup -D_REENTRANT -D_THREAD_SAFE -DPLATFORM_UNIX=1 -DLUA_USE_MKSTEMP=1 -DLUA_USE_ULONGJMP=1 -DPLATFORM_LITTLEENDIAN=1 -DSUPPORT_LUALIB_IO=1 -DSUPPORT_LUALIB_OS=1 -DSUPPORT_LUALIB_MATH=1 -DSUPPORT_LUALIB_DB=1 -DSUPPORT_LUALIB_PACKAGE=1 -DSUPPORT_CRC32=1 -DSUPPORT_MD5=1 -DSUPPORT_SHA1=1 -DSUPPORT_GUI_STDIO=1 -DGUI_STATIC_LINK_STDIO=1 -DSUPPORT_GUI_GTKPLUS2=1 -DSUPPORT_ZIP=1 -DSUPPORT_TAR=1 -DSUPPORT_GZIP=1 -DSUPPORT_BZIP2=1 -DBZ_NO_STDIO=1 -DSUPPORT_JPG=1 -DSUPPORT_PNG=1 -DSUPPORT_STBIMAGE=1 -DSUPPORT_URL_HTTP=1 -DSUPPORT_URL_FTP=1 -DMOJOSETUP_HAVE_MNTENT_H=1 + diff --git a/mk/linux/mojosetup/build/CMakeFiles/mojosetupgui_gtkplus2.dir/link.txt b/mk/linux/mojosetup/build/CMakeFiles/mojosetupgui_gtkplus2.dir/link.txt new file mode 100644 index 00000000..aa8e0d32 --- /dev/null +++ b/mk/linux/mojosetup/build/CMakeFiles/mojosetupgui_gtkplus2.dir/link.txt @@ -0,0 +1 @@ +/usr/bin/gcc -fPIC -shared -Wl,-soname,libmojosetupgui_gtkplus2.so -o libmojosetupgui_gtkplus2.so CMakeFiles/mojosetupgui_gtkplus2.dir/gui_gtkplus2.o -lgtk-x11-2.0 diff --git a/mk/linux/mojosetup/build/CMakeFiles/mojosetupgui_gtkplus2.dir/progress.make b/mk/linux/mojosetup/build/CMakeFiles/mojosetupgui_gtkplus2.dir/progress.make new file mode 100644 index 00000000..e12baea5 --- /dev/null +++ b/mk/linux/mojosetup/build/CMakeFiles/mojosetupgui_gtkplus2.dir/progress.make @@ -0,0 +1,2 @@ +CMAKE_PROGRESS_1 = 80 + diff --git a/mk/linux/mojosetup/build/CMakeFiles/progress.marks b/mk/linux/mojosetup/build/CMakeFiles/progress.marks new file mode 100644 index 00000000..d15a2cc4 --- /dev/null +++ b/mk/linux/mojosetup/build/CMakeFiles/progress.marks @@ -0,0 +1 @@ +80 diff --git a/mk/linux/mojosetup/build/CMakeFiles/skeleton.dir/DependInfo.cmake b/mk/linux/mojosetup/build/CMakeFiles/skeleton.dir/DependInfo.cmake new file mode 100644 index 00000000..c6c259e1 --- /dev/null +++ b/mk/linux/mojosetup/build/CMakeFiles/skeleton.dir/DependInfo.cmake @@ -0,0 +1,42 @@ +# The set of languages for which implicit dependencies are needed: +SET(CMAKE_DEPENDS_LANGUAGES + ) +# The set of files for implicit dependencies of each language: + +# Preprocessor definitions for this target. +SET(CMAKE_TARGET_DEFINITIONS + "__MOJOSETUP__=1" + "APPID=mojosetup" + "_REENTRANT" + "_THREAD_SAFE" + "PLATFORM_UNIX=1" + "LUA_USE_MKSTEMP=1" + "LUA_USE_ULONGJMP=1" + "PLATFORM_LITTLEENDIAN=1" + "SUPPORT_LUALIB_IO=1" + "SUPPORT_LUALIB_OS=1" + "SUPPORT_LUALIB_MATH=1" + "SUPPORT_LUALIB_DB=1" + "SUPPORT_LUALIB_PACKAGE=1" + "SUPPORT_CRC32=1" + "SUPPORT_MD5=1" + "SUPPORT_SHA1=1" + "SUPPORT_GUI_STDIO=1" + "GUI_STATIC_LINK_STDIO=1" + "SUPPORT_GUI_GTKPLUS2=1" + "SUPPORT_ZIP=1" + "SUPPORT_TAR=1" + "SUPPORT_GZIP=1" + "SUPPORT_BZIP2=1" + "BZ_NO_STDIO=1" + "SUPPORT_JPG=1" + "SUPPORT_PNG=1" + "SUPPORT_STBIMAGE=1" + "SUPPORT_URL_HTTP=1" + "SUPPORT_URL_FTP=1" + "MOJOSETUP_HAVE_MNTENT_H=1" + ) + +# Targets to which this target links. +SET(CMAKE_TARGET_LINKED_INFO_FILES + ) diff --git a/mk/linux/mojosetup/build/CMakeFiles/skeleton.dir/build.make b/mk/linux/mojosetup/build/CMakeFiles/skeleton.dir/build.make new file mode 100644 index 00000000..166dbc7b --- /dev/null +++ b/mk/linux/mojosetup/build/CMakeFiles/skeleton.dir/build.make @@ -0,0 +1,69 @@ +# CMAKE generated file: DO NOT EDIT! +# Generated by "Unix Makefiles" Generator, CMake Version 2.8 + +#============================================================================= +# Special targets provided by cmake. + +# Disable implicit rules so canoncical targets will work. +.SUFFIXES: + +# Remove some rules from gmake that .SUFFIXES does not remove. +SUFFIXES = + +.SUFFIXES: .hpux_make_needs_suffix_list + +# Suppress display of executed commands. +$(VERBOSE).SILENT: + +# A target that is always out of date. +cmake_force: +.PHONY : cmake_force + +#============================================================================= +# Set environment variables for the build. + +# The shell in which to execute make rules. +SHELL = /bin/sh + +# The CMake executable. +CMAKE_COMMAND = /usr/bin/cmake + +# The command to remove a file. +RM = /usr/bin/cmake -E remove -f + +# The top-level source directory on which CMake was run. +CMAKE_SOURCE_DIR = /home/softcoder/Code/mojosetup + +# The top-level build directory on which CMake was run. +CMAKE_BINARY_DIR = /home/softcoder/Code/mojosetup/build + +# Utility rule file for skeleton. + +CMakeFiles/skeleton: + $(CMAKE_COMMAND) -E cmake_progress_report /home/softcoder/Code/mojosetup/build/CMakeFiles $(CMAKE_PROGRESS_1) + @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --blue --bold "Assembling Skeleton..." + /usr/bin/cmake -DDIR=/home/softcoder/Code/mojosetup/build/skeleton -P /home/softcoder/Code/mojosetup/misc/rm_recurse.cmake + /usr/bin/cmake -DDIR=/home/softcoder/Code/mojosetup/build/skeleton -P /home/softcoder/Code/mojosetup/misc/mkdir.cmake + /usr/bin/cmake -DDIR=/home/softcoder/Code/mojosetup/build/skeleton/scripts -P /home/softcoder/Code/mojosetup/misc/mkdir.cmake + /usr/bin/cmake -DDIR=/home/softcoder/Code/mojosetup/build/skeleton/guis -P /home/softcoder/Code/mojosetup/misc/mkdir.cmake + /usr/bin/cmake -DDIR=/home/softcoder/Code/mojosetup/build/skeleton/data -P /home/softcoder/Code/mojosetup/misc/mkdir.cmake + /usr/bin/cmake -DFROM=/home/softcoder/Code/mojosetup/scripts/*.lua -DTO=/home/softcoder/Code/mojosetup/build/skeleton/scripts -P /home/softcoder/Code/mojosetup/misc/cp.cmake + /usr/bin/cmake -DFROM=/home/softcoder/Code/mojosetup/*mojosetupgui*.* -DTO=/home/softcoder/Code/mojosetup/build/skeleton/guis -P /home/softcoder/Code/mojosetup/misc/cp.cmake + /usr/bin/cmake -DFROM=/home/softcoder/Code/mojosetup/build/mojosetup -DTO=/home/softcoder/Code/mojosetup/build/skeleton -P /home/softcoder/Code/mojosetup/misc/cp.cmake + +skeleton: CMakeFiles/skeleton +skeleton: CMakeFiles/skeleton.dir/build.make +.PHONY : skeleton + +# Rule to build all files generated by this target. +CMakeFiles/skeleton.dir/build: skeleton +.PHONY : CMakeFiles/skeleton.dir/build + +CMakeFiles/skeleton.dir/clean: + $(CMAKE_COMMAND) -P CMakeFiles/skeleton.dir/cmake_clean.cmake +.PHONY : CMakeFiles/skeleton.dir/clean + +CMakeFiles/skeleton.dir/depend: + cd /home/softcoder/Code/mojosetup/build && $(CMAKE_COMMAND) -E cmake_depends "Unix Makefiles" /home/softcoder/Code/mojosetup /home/softcoder/Code/mojosetup /home/softcoder/Code/mojosetup/build /home/softcoder/Code/mojosetup/build /home/softcoder/Code/mojosetup/build/CMakeFiles/skeleton.dir/DependInfo.cmake --color=$(COLOR) +.PHONY : CMakeFiles/skeleton.dir/depend + diff --git a/mk/linux/mojosetup/build/CMakeFiles/skeleton.dir/cmake_clean.cmake b/mk/linux/mojosetup/build/CMakeFiles/skeleton.dir/cmake_clean.cmake new file mode 100644 index 00000000..1dc597d1 --- /dev/null +++ b/mk/linux/mojosetup/build/CMakeFiles/skeleton.dir/cmake_clean.cmake @@ -0,0 +1,8 @@ +FILE(REMOVE_RECURSE + "CMakeFiles/skeleton" +) + +# Per-language clean rules from dependency scanning. +FOREACH(lang) + INCLUDE(CMakeFiles/skeleton.dir/cmake_clean_${lang}.cmake OPTIONAL) +ENDFOREACH(lang) diff --git a/mk/linux/mojosetup/build/CMakeFiles/skeleton.dir/progress.make b/mk/linux/mojosetup/build/CMakeFiles/skeleton.dir/progress.make new file mode 100644 index 00000000..4e4c166c --- /dev/null +++ b/mk/linux/mojosetup/build/CMakeFiles/skeleton.dir/progress.make @@ -0,0 +1,2 @@ +CMAKE_PROGRESS_1 = 81 + diff --git a/mk/linux/mojosetup/build/Makefile b/mk/linux/mojosetup/build/Makefile new file mode 100644 index 00000000..adc9c139 --- /dev/null +++ b/mk/linux/mojosetup/build/Makefile @@ -0,0 +1,1209 @@ +# CMAKE generated file: DO NOT EDIT! +# Generated by "Unix Makefiles" Generator, CMake Version 2.8 + +# Default target executed when no arguments are given to make. +default_target: all +.PHONY : default_target + +#============================================================================= +# Special targets provided by cmake. + +# Disable implicit rules so canoncical targets will work. +.SUFFIXES: + +# Remove some rules from gmake that .SUFFIXES does not remove. +SUFFIXES = + +.SUFFIXES: .hpux_make_needs_suffix_list + +# Suppress display of executed commands. +$(VERBOSE).SILENT: + +# A target that is always out of date. +cmake_force: +.PHONY : cmake_force + +#============================================================================= +# Set environment variables for the build. + +# The shell in which to execute make rules. +SHELL = /bin/sh + +# The CMake executable. +CMAKE_COMMAND = /usr/bin/cmake + +# The command to remove a file. +RM = /usr/bin/cmake -E remove -f + +# The top-level source directory on which CMake was run. +CMAKE_SOURCE_DIR = /home/softcoder/Code/mojosetup + +# The top-level build directory on which CMake was run. +CMAKE_BINARY_DIR = /home/softcoder/Code/mojosetup/build + +#============================================================================= +# Targets provided globally by CMake. + +# Special rule for the target edit_cache +edit_cache: + @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --cyan "Running interactive CMake command-line interface..." + /usr/bin/cmake -i . +.PHONY : edit_cache + +# Special rule for the target edit_cache +edit_cache/fast: edit_cache +.PHONY : edit_cache/fast + +# Special rule for the target rebuild_cache +rebuild_cache: + @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --cyan "Running CMake to regenerate build system..." + /usr/bin/cmake -H$(CMAKE_SOURCE_DIR) -B$(CMAKE_BINARY_DIR) +.PHONY : rebuild_cache + +# Special rule for the target rebuild_cache +rebuild_cache/fast: rebuild_cache +.PHONY : rebuild_cache/fast + +# The main all target +all: cmake_check_build_system + $(CMAKE_COMMAND) -E cmake_progress_start /home/softcoder/Code/mojosetup/build/CMakeFiles /home/softcoder/Code/mojosetup/build/CMakeFiles/progress.marks + $(MAKE) -f CMakeFiles/Makefile2 all + $(CMAKE_COMMAND) -E cmake_progress_start /home/softcoder/Code/mojosetup/build/CMakeFiles 0 +.PHONY : all + +# The main clean target +clean: + $(MAKE) -f CMakeFiles/Makefile2 clean +.PHONY : clean + +# The main clean target +clean/fast: clean +.PHONY : clean/fast + +# Prepare targets for installation. +preinstall: all + $(MAKE) -f CMakeFiles/Makefile2 preinstall +.PHONY : preinstall + +# Prepare targets for installation. +preinstall/fast: + $(MAKE) -f CMakeFiles/Makefile2 preinstall +.PHONY : preinstall/fast + +# clear depends +depend: + $(CMAKE_COMMAND) -H$(CMAKE_SOURCE_DIR) -B$(CMAKE_BINARY_DIR) --check-build-system CMakeFiles/Makefile.cmake 1 +.PHONY : depend + +#============================================================================= +# Target rules for targets named lua + +# Build rule for target. +lua: cmake_check_build_system + $(MAKE) -f CMakeFiles/Makefile2 lua +.PHONY : lua + +# fast build rule for target. +lua/fast: + $(MAKE) -f CMakeFiles/lua.dir/build.make CMakeFiles/lua.dir/build +.PHONY : lua/fast + +#============================================================================= +# Target rules for targets named mojoluac + +# Build rule for target. +mojoluac: cmake_check_build_system + $(MAKE) -f CMakeFiles/Makefile2 mojoluac +.PHONY : mojoluac + +# fast build rule for target. +mojoluac/fast: + $(MAKE) -f CMakeFiles/mojoluac.dir/build.make CMakeFiles/mojoluac.dir/build +.PHONY : mojoluac/fast + +#============================================================================= +# Target rules for targets named mojosetup + +# Build rule for target. +mojosetup: cmake_check_build_system + $(MAKE) -f CMakeFiles/Makefile2 mojosetup +.PHONY : mojosetup + +# fast build rule for target. +mojosetup/fast: + $(MAKE) -f CMakeFiles/mojosetup.dir/build.make CMakeFiles/mojosetup.dir/build +.PHONY : mojosetup/fast + +#============================================================================= +# Target rules for targets named mojosetupgui_gtkplus2 + +# Build rule for target. +mojosetupgui_gtkplus2: cmake_check_build_system + $(MAKE) -f CMakeFiles/Makefile2 mojosetupgui_gtkplus2 +.PHONY : mojosetupgui_gtkplus2 + +# fast build rule for target. +mojosetupgui_gtkplus2/fast: + $(MAKE) -f CMakeFiles/mojosetupgui_gtkplus2.dir/build.make CMakeFiles/mojosetupgui_gtkplus2.dir/build +.PHONY : mojosetupgui_gtkplus2/fast + +#============================================================================= +# Target rules for targets named skeleton + +# Build rule for target. +skeleton: cmake_check_build_system + $(MAKE) -f CMakeFiles/Makefile2 skeleton +.PHONY : skeleton + +# fast build rule for target. +skeleton/fast: + $(MAKE) -f CMakeFiles/skeleton.dir/build.make CMakeFiles/skeleton.dir/build +.PHONY : skeleton/fast + +# target to build an object file +archive_pck.o: + $(MAKE) -f CMakeFiles/mojosetup.dir/build.make CMakeFiles/mojosetup.dir/archive_pck.o +.PHONY : archive_pck.o + +# target to preprocess a source file +archive_pck.i: + $(MAKE) -f CMakeFiles/mojosetup.dir/build.make CMakeFiles/mojosetup.dir/archive_pck.i +.PHONY : archive_pck.i + +# target to generate assembly for a file +archive_pck.s: + $(MAKE) -f CMakeFiles/mojosetup.dir/build.make CMakeFiles/mojosetup.dir/archive_pck.s +.PHONY : archive_pck.s + +# target to build an object file +archive_tar.o: + $(MAKE) -f CMakeFiles/mojosetup.dir/build.make CMakeFiles/mojosetup.dir/archive_tar.o +.PHONY : archive_tar.o + +# target to preprocess a source file +archive_tar.i: + $(MAKE) -f CMakeFiles/mojosetup.dir/build.make CMakeFiles/mojosetup.dir/archive_tar.i +.PHONY : archive_tar.i + +# target to generate assembly for a file +archive_tar.s: + $(MAKE) -f CMakeFiles/mojosetup.dir/build.make CMakeFiles/mojosetup.dir/archive_tar.s +.PHONY : archive_tar.s + +# target to build an object file +archive_uz2.o: + $(MAKE) -f CMakeFiles/mojosetup.dir/build.make CMakeFiles/mojosetup.dir/archive_uz2.o +.PHONY : archive_uz2.o + +# target to preprocess a source file +archive_uz2.i: + $(MAKE) -f CMakeFiles/mojosetup.dir/build.make CMakeFiles/mojosetup.dir/archive_uz2.i +.PHONY : archive_uz2.i + +# target to generate assembly for a file +archive_uz2.s: + $(MAKE) -f CMakeFiles/mojosetup.dir/build.make CMakeFiles/mojosetup.dir/archive_uz2.s +.PHONY : archive_uz2.s + +# target to build an object file +archive_zip.o: + $(MAKE) -f CMakeFiles/mojosetup.dir/build.make CMakeFiles/mojosetup.dir/archive_zip.o +.PHONY : archive_zip.o + +# target to preprocess a source file +archive_zip.i: + $(MAKE) -f CMakeFiles/mojosetup.dir/build.make CMakeFiles/mojosetup.dir/archive_zip.i +.PHONY : archive_zip.i + +# target to generate assembly for a file +archive_zip.s: + $(MAKE) -f CMakeFiles/mojosetup.dir/build.make CMakeFiles/mojosetup.dir/archive_zip.s +.PHONY : archive_zip.s + +# target to build an object file +buildver.o: + $(MAKE) -f CMakeFiles/mojosetup.dir/build.make CMakeFiles/mojosetup.dir/buildver.o +.PHONY : buildver.o + +# target to preprocess a source file +buildver.i: + $(MAKE) -f CMakeFiles/mojosetup.dir/build.make CMakeFiles/mojosetup.dir/buildver.i +.PHONY : buildver.i + +# target to generate assembly for a file +buildver.s: + $(MAKE) -f CMakeFiles/mojosetup.dir/build.make CMakeFiles/mojosetup.dir/buildver.s +.PHONY : buildver.s + +# target to build an object file +checksum_crc32.o: + $(MAKE) -f CMakeFiles/mojosetup.dir/build.make CMakeFiles/mojosetup.dir/checksum_crc32.o +.PHONY : checksum_crc32.o + +# target to preprocess a source file +checksum_crc32.i: + $(MAKE) -f CMakeFiles/mojosetup.dir/build.make CMakeFiles/mojosetup.dir/checksum_crc32.i +.PHONY : checksum_crc32.i + +# target to generate assembly for a file +checksum_crc32.s: + $(MAKE) -f CMakeFiles/mojosetup.dir/build.make CMakeFiles/mojosetup.dir/checksum_crc32.s +.PHONY : checksum_crc32.s + +# target to build an object file +checksum_md5.o: + $(MAKE) -f CMakeFiles/mojosetup.dir/build.make CMakeFiles/mojosetup.dir/checksum_md5.o +.PHONY : checksum_md5.o + +# target to preprocess a source file +checksum_md5.i: + $(MAKE) -f CMakeFiles/mojosetup.dir/build.make CMakeFiles/mojosetup.dir/checksum_md5.i +.PHONY : checksum_md5.i + +# target to generate assembly for a file +checksum_md5.s: + $(MAKE) -f CMakeFiles/mojosetup.dir/build.make CMakeFiles/mojosetup.dir/checksum_md5.s +.PHONY : checksum_md5.s + +# target to build an object file +checksum_sha1.o: + $(MAKE) -f CMakeFiles/mojosetup.dir/build.make CMakeFiles/mojosetup.dir/checksum_sha1.o +.PHONY : checksum_sha1.o + +# target to preprocess a source file +checksum_sha1.i: + $(MAKE) -f CMakeFiles/mojosetup.dir/build.make CMakeFiles/mojosetup.dir/checksum_sha1.i +.PHONY : checksum_sha1.i + +# target to generate assembly for a file +checksum_sha1.s: + $(MAKE) -f CMakeFiles/mojosetup.dir/build.make CMakeFiles/mojosetup.dir/checksum_sha1.s +.PHONY : checksum_sha1.s + +# target to build an object file +fileio.o: + $(MAKE) -f CMakeFiles/mojosetup.dir/build.make CMakeFiles/mojosetup.dir/fileio.o +.PHONY : fileio.o + +# target to preprocess a source file +fileio.i: + $(MAKE) -f CMakeFiles/mojosetup.dir/build.make CMakeFiles/mojosetup.dir/fileio.i +.PHONY : fileio.i + +# target to generate assembly for a file +fileio.s: + $(MAKE) -f CMakeFiles/mojosetup.dir/build.make CMakeFiles/mojosetup.dir/fileio.s +.PHONY : fileio.s + +# target to build an object file +gui.o: + $(MAKE) -f CMakeFiles/mojosetup.dir/build.make CMakeFiles/mojosetup.dir/gui.o +.PHONY : gui.o + +# target to preprocess a source file +gui.i: + $(MAKE) -f CMakeFiles/mojosetup.dir/build.make CMakeFiles/mojosetup.dir/gui.i +.PHONY : gui.i + +# target to generate assembly for a file +gui.s: + $(MAKE) -f CMakeFiles/mojosetup.dir/build.make CMakeFiles/mojosetup.dir/gui.s +.PHONY : gui.s + +# target to build an object file +gui_gtkplus2.o: + $(MAKE) -f CMakeFiles/mojosetupgui_gtkplus2.dir/build.make CMakeFiles/mojosetupgui_gtkplus2.dir/gui_gtkplus2.o +.PHONY : gui_gtkplus2.o + +# target to preprocess a source file +gui_gtkplus2.i: + $(MAKE) -f CMakeFiles/mojosetupgui_gtkplus2.dir/build.make CMakeFiles/mojosetupgui_gtkplus2.dir/gui_gtkplus2.i +.PHONY : gui_gtkplus2.i + +# target to generate assembly for a file +gui_gtkplus2.s: + $(MAKE) -f CMakeFiles/mojosetupgui_gtkplus2.dir/build.make CMakeFiles/mojosetupgui_gtkplus2.dir/gui_gtkplus2.s +.PHONY : gui_gtkplus2.s + +# target to build an object file +gui_stdio.o: + $(MAKE) -f CMakeFiles/mojosetup.dir/build.make CMakeFiles/mojosetup.dir/gui_stdio.o +.PHONY : gui_stdio.o + +# target to preprocess a source file +gui_stdio.i: + $(MAKE) -f CMakeFiles/mojosetup.dir/build.make CMakeFiles/mojosetup.dir/gui_stdio.i +.PHONY : gui_stdio.i + +# target to generate assembly for a file +gui_stdio.s: + $(MAKE) -f CMakeFiles/mojosetup.dir/build.make CMakeFiles/mojosetup.dir/gui_stdio.s +.PHONY : gui_stdio.s + +# target to build an object file +libfetch/common.o: + $(MAKE) -f CMakeFiles/mojosetup.dir/build.make CMakeFiles/mojosetup.dir/libfetch/common.o +.PHONY : libfetch/common.o + +# target to preprocess a source file +libfetch/common.i: + $(MAKE) -f CMakeFiles/mojosetup.dir/build.make CMakeFiles/mojosetup.dir/libfetch/common.i +.PHONY : libfetch/common.i + +# target to generate assembly for a file +libfetch/common.s: + $(MAKE) -f CMakeFiles/mojosetup.dir/build.make CMakeFiles/mojosetup.dir/libfetch/common.s +.PHONY : libfetch/common.s + +# target to build an object file +libfetch/fetch.o: + $(MAKE) -f CMakeFiles/mojosetup.dir/build.make CMakeFiles/mojosetup.dir/libfetch/fetch.o +.PHONY : libfetch/fetch.o + +# target to preprocess a source file +libfetch/fetch.i: + $(MAKE) -f CMakeFiles/mojosetup.dir/build.make CMakeFiles/mojosetup.dir/libfetch/fetch.i +.PHONY : libfetch/fetch.i + +# target to generate assembly for a file +libfetch/fetch.s: + $(MAKE) -f CMakeFiles/mojosetup.dir/build.make CMakeFiles/mojosetup.dir/libfetch/fetch.s +.PHONY : libfetch/fetch.s + +# target to build an object file +libfetch/ftp.o: + $(MAKE) -f CMakeFiles/mojosetup.dir/build.make CMakeFiles/mojosetup.dir/libfetch/ftp.o +.PHONY : libfetch/ftp.o + +# target to preprocess a source file +libfetch/ftp.i: + $(MAKE) -f CMakeFiles/mojosetup.dir/build.make CMakeFiles/mojosetup.dir/libfetch/ftp.i +.PHONY : libfetch/ftp.i + +# target to generate assembly for a file +libfetch/ftp.s: + $(MAKE) -f CMakeFiles/mojosetup.dir/build.make CMakeFiles/mojosetup.dir/libfetch/ftp.s +.PHONY : libfetch/ftp.s + +# target to build an object file +libfetch/http.o: + $(MAKE) -f CMakeFiles/mojosetup.dir/build.make CMakeFiles/mojosetup.dir/libfetch/http.o +.PHONY : libfetch/http.o + +# target to preprocess a source file +libfetch/http.i: + $(MAKE) -f CMakeFiles/mojosetup.dir/build.make CMakeFiles/mojosetup.dir/libfetch/http.i +.PHONY : libfetch/http.i + +# target to generate assembly for a file +libfetch/http.s: + $(MAKE) -f CMakeFiles/mojosetup.dir/build.make CMakeFiles/mojosetup.dir/libfetch/http.s +.PHONY : libfetch/http.s + +# target to build an object file +lua/src/lapi.o: + $(MAKE) -f CMakeFiles/mojoluac.dir/build.make CMakeFiles/mojoluac.dir/lua/src/lapi.o + $(MAKE) -f CMakeFiles/mojosetup.dir/build.make CMakeFiles/mojosetup.dir/lua/src/lapi.o +.PHONY : lua/src/lapi.o + +# target to preprocess a source file +lua/src/lapi.i: + $(MAKE) -f CMakeFiles/mojoluac.dir/build.make CMakeFiles/mojoluac.dir/lua/src/lapi.i + $(MAKE) -f CMakeFiles/mojosetup.dir/build.make CMakeFiles/mojosetup.dir/lua/src/lapi.i +.PHONY : lua/src/lapi.i + +# target to generate assembly for a file +lua/src/lapi.s: + $(MAKE) -f CMakeFiles/mojoluac.dir/build.make CMakeFiles/mojoluac.dir/lua/src/lapi.s + $(MAKE) -f CMakeFiles/mojosetup.dir/build.make CMakeFiles/mojosetup.dir/lua/src/lapi.s +.PHONY : lua/src/lapi.s + +# target to build an object file +lua/src/lauxlib.o: + $(MAKE) -f CMakeFiles/mojoluac.dir/build.make CMakeFiles/mojoluac.dir/lua/src/lauxlib.o + $(MAKE) -f CMakeFiles/mojosetup.dir/build.make CMakeFiles/mojosetup.dir/lua/src/lauxlib.o +.PHONY : lua/src/lauxlib.o + +# target to preprocess a source file +lua/src/lauxlib.i: + $(MAKE) -f CMakeFiles/mojoluac.dir/build.make CMakeFiles/mojoluac.dir/lua/src/lauxlib.i + $(MAKE) -f CMakeFiles/mojosetup.dir/build.make CMakeFiles/mojosetup.dir/lua/src/lauxlib.i +.PHONY : lua/src/lauxlib.i + +# target to generate assembly for a file +lua/src/lauxlib.s: + $(MAKE) -f CMakeFiles/mojoluac.dir/build.make CMakeFiles/mojoluac.dir/lua/src/lauxlib.s + $(MAKE) -f CMakeFiles/mojosetup.dir/build.make CMakeFiles/mojosetup.dir/lua/src/lauxlib.s +.PHONY : lua/src/lauxlib.s + +# target to build an object file +lua/src/lbaselib.o: + $(MAKE) -f CMakeFiles/mojoluac.dir/build.make CMakeFiles/mojoluac.dir/lua/src/lbaselib.o + $(MAKE) -f CMakeFiles/mojosetup.dir/build.make CMakeFiles/mojosetup.dir/lua/src/lbaselib.o +.PHONY : lua/src/lbaselib.o + +# target to preprocess a source file +lua/src/lbaselib.i: + $(MAKE) -f CMakeFiles/mojoluac.dir/build.make CMakeFiles/mojoluac.dir/lua/src/lbaselib.i + $(MAKE) -f CMakeFiles/mojosetup.dir/build.make CMakeFiles/mojosetup.dir/lua/src/lbaselib.i +.PHONY : lua/src/lbaselib.i + +# target to generate assembly for a file +lua/src/lbaselib.s: + $(MAKE) -f CMakeFiles/mojoluac.dir/build.make CMakeFiles/mojoluac.dir/lua/src/lbaselib.s + $(MAKE) -f CMakeFiles/mojosetup.dir/build.make CMakeFiles/mojosetup.dir/lua/src/lbaselib.s +.PHONY : lua/src/lbaselib.s + +# target to build an object file +lua/src/lcode.o: + $(MAKE) -f CMakeFiles/mojoluac.dir/build.make CMakeFiles/mojoluac.dir/lua/src/lcode.o + $(MAKE) -f CMakeFiles/mojosetup.dir/build.make CMakeFiles/mojosetup.dir/lua/src/lcode.o +.PHONY : lua/src/lcode.o + +# target to preprocess a source file +lua/src/lcode.i: + $(MAKE) -f CMakeFiles/mojoluac.dir/build.make CMakeFiles/mojoluac.dir/lua/src/lcode.i + $(MAKE) -f CMakeFiles/mojosetup.dir/build.make CMakeFiles/mojosetup.dir/lua/src/lcode.i +.PHONY : lua/src/lcode.i + +# target to generate assembly for a file +lua/src/lcode.s: + $(MAKE) -f CMakeFiles/mojoluac.dir/build.make CMakeFiles/mojoluac.dir/lua/src/lcode.s + $(MAKE) -f CMakeFiles/mojosetup.dir/build.make CMakeFiles/mojosetup.dir/lua/src/lcode.s +.PHONY : lua/src/lcode.s + +# target to build an object file +lua/src/ldblib.o: + $(MAKE) -f CMakeFiles/mojoluac.dir/build.make CMakeFiles/mojoluac.dir/lua/src/ldblib.o + $(MAKE) -f CMakeFiles/mojosetup.dir/build.make CMakeFiles/mojosetup.dir/lua/src/ldblib.o +.PHONY : lua/src/ldblib.o + +# target to preprocess a source file +lua/src/ldblib.i: + $(MAKE) -f CMakeFiles/mojoluac.dir/build.make CMakeFiles/mojoluac.dir/lua/src/ldblib.i + $(MAKE) -f CMakeFiles/mojosetup.dir/build.make CMakeFiles/mojosetup.dir/lua/src/ldblib.i +.PHONY : lua/src/ldblib.i + +# target to generate assembly for a file +lua/src/ldblib.s: + $(MAKE) -f CMakeFiles/mojoluac.dir/build.make CMakeFiles/mojoluac.dir/lua/src/ldblib.s + $(MAKE) -f CMakeFiles/mojosetup.dir/build.make CMakeFiles/mojosetup.dir/lua/src/ldblib.s +.PHONY : lua/src/ldblib.s + +# target to build an object file +lua/src/ldebug.o: + $(MAKE) -f CMakeFiles/mojoluac.dir/build.make CMakeFiles/mojoluac.dir/lua/src/ldebug.o + $(MAKE) -f CMakeFiles/mojosetup.dir/build.make CMakeFiles/mojosetup.dir/lua/src/ldebug.o +.PHONY : lua/src/ldebug.o + +# target to preprocess a source file +lua/src/ldebug.i: + $(MAKE) -f CMakeFiles/mojoluac.dir/build.make CMakeFiles/mojoluac.dir/lua/src/ldebug.i + $(MAKE) -f CMakeFiles/mojosetup.dir/build.make CMakeFiles/mojosetup.dir/lua/src/ldebug.i +.PHONY : lua/src/ldebug.i + +# target to generate assembly for a file +lua/src/ldebug.s: + $(MAKE) -f CMakeFiles/mojoluac.dir/build.make CMakeFiles/mojoluac.dir/lua/src/ldebug.s + $(MAKE) -f CMakeFiles/mojosetup.dir/build.make CMakeFiles/mojosetup.dir/lua/src/ldebug.s +.PHONY : lua/src/ldebug.s + +# target to build an object file +lua/src/ldo.o: + $(MAKE) -f CMakeFiles/mojoluac.dir/build.make CMakeFiles/mojoluac.dir/lua/src/ldo.o + $(MAKE) -f CMakeFiles/mojosetup.dir/build.make CMakeFiles/mojosetup.dir/lua/src/ldo.o +.PHONY : lua/src/ldo.o + +# target to preprocess a source file +lua/src/ldo.i: + $(MAKE) -f CMakeFiles/mojoluac.dir/build.make CMakeFiles/mojoluac.dir/lua/src/ldo.i + $(MAKE) -f CMakeFiles/mojosetup.dir/build.make CMakeFiles/mojosetup.dir/lua/src/ldo.i +.PHONY : lua/src/ldo.i + +# target to generate assembly for a file +lua/src/ldo.s: + $(MAKE) -f CMakeFiles/mojoluac.dir/build.make CMakeFiles/mojoluac.dir/lua/src/ldo.s + $(MAKE) -f CMakeFiles/mojosetup.dir/build.make CMakeFiles/mojosetup.dir/lua/src/ldo.s +.PHONY : lua/src/ldo.s + +# target to build an object file +lua/src/ldump.o: + $(MAKE) -f CMakeFiles/mojoluac.dir/build.make CMakeFiles/mojoluac.dir/lua/src/ldump.o + $(MAKE) -f CMakeFiles/mojosetup.dir/build.make CMakeFiles/mojosetup.dir/lua/src/ldump.o +.PHONY : lua/src/ldump.o + +# target to preprocess a source file +lua/src/ldump.i: + $(MAKE) -f CMakeFiles/mojoluac.dir/build.make CMakeFiles/mojoluac.dir/lua/src/ldump.i + $(MAKE) -f CMakeFiles/mojosetup.dir/build.make CMakeFiles/mojosetup.dir/lua/src/ldump.i +.PHONY : lua/src/ldump.i + +# target to generate assembly for a file +lua/src/ldump.s: + $(MAKE) -f CMakeFiles/mojoluac.dir/build.make CMakeFiles/mojoluac.dir/lua/src/ldump.s + $(MAKE) -f CMakeFiles/mojosetup.dir/build.make CMakeFiles/mojosetup.dir/lua/src/ldump.s +.PHONY : lua/src/ldump.s + +# target to build an object file +lua/src/lfunc.o: + $(MAKE) -f CMakeFiles/mojoluac.dir/build.make CMakeFiles/mojoluac.dir/lua/src/lfunc.o + $(MAKE) -f CMakeFiles/mojosetup.dir/build.make CMakeFiles/mojosetup.dir/lua/src/lfunc.o +.PHONY : lua/src/lfunc.o + +# target to preprocess a source file +lua/src/lfunc.i: + $(MAKE) -f CMakeFiles/mojoluac.dir/build.make CMakeFiles/mojoluac.dir/lua/src/lfunc.i + $(MAKE) -f CMakeFiles/mojosetup.dir/build.make CMakeFiles/mojosetup.dir/lua/src/lfunc.i +.PHONY : lua/src/lfunc.i + +# target to generate assembly for a file +lua/src/lfunc.s: + $(MAKE) -f CMakeFiles/mojoluac.dir/build.make CMakeFiles/mojoluac.dir/lua/src/lfunc.s + $(MAKE) -f CMakeFiles/mojosetup.dir/build.make CMakeFiles/mojosetup.dir/lua/src/lfunc.s +.PHONY : lua/src/lfunc.s + +# target to build an object file +lua/src/lgc.o: + $(MAKE) -f CMakeFiles/mojoluac.dir/build.make CMakeFiles/mojoluac.dir/lua/src/lgc.o + $(MAKE) -f CMakeFiles/mojosetup.dir/build.make CMakeFiles/mojosetup.dir/lua/src/lgc.o +.PHONY : lua/src/lgc.o + +# target to preprocess a source file +lua/src/lgc.i: + $(MAKE) -f CMakeFiles/mojoluac.dir/build.make CMakeFiles/mojoluac.dir/lua/src/lgc.i + $(MAKE) -f CMakeFiles/mojosetup.dir/build.make CMakeFiles/mojosetup.dir/lua/src/lgc.i +.PHONY : lua/src/lgc.i + +# target to generate assembly for a file +lua/src/lgc.s: + $(MAKE) -f CMakeFiles/mojoluac.dir/build.make CMakeFiles/mojoluac.dir/lua/src/lgc.s + $(MAKE) -f CMakeFiles/mojosetup.dir/build.make CMakeFiles/mojosetup.dir/lua/src/lgc.s +.PHONY : lua/src/lgc.s + +# target to build an object file +lua/src/linit.o: + $(MAKE) -f CMakeFiles/mojoluac.dir/build.make CMakeFiles/mojoluac.dir/lua/src/linit.o +.PHONY : lua/src/linit.o + +# target to preprocess a source file +lua/src/linit.i: + $(MAKE) -f CMakeFiles/mojoluac.dir/build.make CMakeFiles/mojoluac.dir/lua/src/linit.i +.PHONY : lua/src/linit.i + +# target to generate assembly for a file +lua/src/linit.s: + $(MAKE) -f CMakeFiles/mojoluac.dir/build.make CMakeFiles/mojoluac.dir/lua/src/linit.s +.PHONY : lua/src/linit.s + +# target to build an object file +lua/src/liolib.o: + $(MAKE) -f CMakeFiles/mojoluac.dir/build.make CMakeFiles/mojoluac.dir/lua/src/liolib.o + $(MAKE) -f CMakeFiles/mojosetup.dir/build.make CMakeFiles/mojosetup.dir/lua/src/liolib.o +.PHONY : lua/src/liolib.o + +# target to preprocess a source file +lua/src/liolib.i: + $(MAKE) -f CMakeFiles/mojoluac.dir/build.make CMakeFiles/mojoluac.dir/lua/src/liolib.i + $(MAKE) -f CMakeFiles/mojosetup.dir/build.make CMakeFiles/mojosetup.dir/lua/src/liolib.i +.PHONY : lua/src/liolib.i + +# target to generate assembly for a file +lua/src/liolib.s: + $(MAKE) -f CMakeFiles/mojoluac.dir/build.make CMakeFiles/mojoluac.dir/lua/src/liolib.s + $(MAKE) -f CMakeFiles/mojosetup.dir/build.make CMakeFiles/mojosetup.dir/lua/src/liolib.s +.PHONY : lua/src/liolib.s + +# target to build an object file +lua/src/llex.o: + $(MAKE) -f CMakeFiles/mojoluac.dir/build.make CMakeFiles/mojoluac.dir/lua/src/llex.o + $(MAKE) -f CMakeFiles/mojosetup.dir/build.make CMakeFiles/mojosetup.dir/lua/src/llex.o +.PHONY : lua/src/llex.o + +# target to preprocess a source file +lua/src/llex.i: + $(MAKE) -f CMakeFiles/mojoluac.dir/build.make CMakeFiles/mojoluac.dir/lua/src/llex.i + $(MAKE) -f CMakeFiles/mojosetup.dir/build.make CMakeFiles/mojosetup.dir/lua/src/llex.i +.PHONY : lua/src/llex.i + +# target to generate assembly for a file +lua/src/llex.s: + $(MAKE) -f CMakeFiles/mojoluac.dir/build.make CMakeFiles/mojoluac.dir/lua/src/llex.s + $(MAKE) -f CMakeFiles/mojosetup.dir/build.make CMakeFiles/mojosetup.dir/lua/src/llex.s +.PHONY : lua/src/llex.s + +# target to build an object file +lua/src/lmathlib.o: + $(MAKE) -f CMakeFiles/mojoluac.dir/build.make CMakeFiles/mojoluac.dir/lua/src/lmathlib.o + $(MAKE) -f CMakeFiles/mojosetup.dir/build.make CMakeFiles/mojosetup.dir/lua/src/lmathlib.o +.PHONY : lua/src/lmathlib.o + +# target to preprocess a source file +lua/src/lmathlib.i: + $(MAKE) -f CMakeFiles/mojoluac.dir/build.make CMakeFiles/mojoluac.dir/lua/src/lmathlib.i + $(MAKE) -f CMakeFiles/mojosetup.dir/build.make CMakeFiles/mojosetup.dir/lua/src/lmathlib.i +.PHONY : lua/src/lmathlib.i + +# target to generate assembly for a file +lua/src/lmathlib.s: + $(MAKE) -f CMakeFiles/mojoluac.dir/build.make CMakeFiles/mojoluac.dir/lua/src/lmathlib.s + $(MAKE) -f CMakeFiles/mojosetup.dir/build.make CMakeFiles/mojosetup.dir/lua/src/lmathlib.s +.PHONY : lua/src/lmathlib.s + +# target to build an object file +lua/src/lmem.o: + $(MAKE) -f CMakeFiles/mojoluac.dir/build.make CMakeFiles/mojoluac.dir/lua/src/lmem.o + $(MAKE) -f CMakeFiles/mojosetup.dir/build.make CMakeFiles/mojosetup.dir/lua/src/lmem.o +.PHONY : lua/src/lmem.o + +# target to preprocess a source file +lua/src/lmem.i: + $(MAKE) -f CMakeFiles/mojoluac.dir/build.make CMakeFiles/mojoluac.dir/lua/src/lmem.i + $(MAKE) -f CMakeFiles/mojosetup.dir/build.make CMakeFiles/mojosetup.dir/lua/src/lmem.i +.PHONY : lua/src/lmem.i + +# target to generate assembly for a file +lua/src/lmem.s: + $(MAKE) -f CMakeFiles/mojoluac.dir/build.make CMakeFiles/mojoluac.dir/lua/src/lmem.s + $(MAKE) -f CMakeFiles/mojosetup.dir/build.make CMakeFiles/mojosetup.dir/lua/src/lmem.s +.PHONY : lua/src/lmem.s + +# target to build an object file +lua/src/loadlib.o: + $(MAKE) -f CMakeFiles/mojoluac.dir/build.make CMakeFiles/mojoluac.dir/lua/src/loadlib.o + $(MAKE) -f CMakeFiles/mojosetup.dir/build.make CMakeFiles/mojosetup.dir/lua/src/loadlib.o +.PHONY : lua/src/loadlib.o + +# target to preprocess a source file +lua/src/loadlib.i: + $(MAKE) -f CMakeFiles/mojoluac.dir/build.make CMakeFiles/mojoluac.dir/lua/src/loadlib.i + $(MAKE) -f CMakeFiles/mojosetup.dir/build.make CMakeFiles/mojosetup.dir/lua/src/loadlib.i +.PHONY : lua/src/loadlib.i + +# target to generate assembly for a file +lua/src/loadlib.s: + $(MAKE) -f CMakeFiles/mojoluac.dir/build.make CMakeFiles/mojoluac.dir/lua/src/loadlib.s + $(MAKE) -f CMakeFiles/mojosetup.dir/build.make CMakeFiles/mojosetup.dir/lua/src/loadlib.s +.PHONY : lua/src/loadlib.s + +# target to build an object file +lua/src/lobject.o: + $(MAKE) -f CMakeFiles/mojoluac.dir/build.make CMakeFiles/mojoluac.dir/lua/src/lobject.o + $(MAKE) -f CMakeFiles/mojosetup.dir/build.make CMakeFiles/mojosetup.dir/lua/src/lobject.o +.PHONY : lua/src/lobject.o + +# target to preprocess a source file +lua/src/lobject.i: + $(MAKE) -f CMakeFiles/mojoluac.dir/build.make CMakeFiles/mojoluac.dir/lua/src/lobject.i + $(MAKE) -f CMakeFiles/mojosetup.dir/build.make CMakeFiles/mojosetup.dir/lua/src/lobject.i +.PHONY : lua/src/lobject.i + +# target to generate assembly for a file +lua/src/lobject.s: + $(MAKE) -f CMakeFiles/mojoluac.dir/build.make CMakeFiles/mojoluac.dir/lua/src/lobject.s + $(MAKE) -f CMakeFiles/mojosetup.dir/build.make CMakeFiles/mojosetup.dir/lua/src/lobject.s +.PHONY : lua/src/lobject.s + +# target to build an object file +lua/src/lopcodes.o: + $(MAKE) -f CMakeFiles/mojoluac.dir/build.make CMakeFiles/mojoluac.dir/lua/src/lopcodes.o + $(MAKE) -f CMakeFiles/mojosetup.dir/build.make CMakeFiles/mojosetup.dir/lua/src/lopcodes.o +.PHONY : lua/src/lopcodes.o + +# target to preprocess a source file +lua/src/lopcodes.i: + $(MAKE) -f CMakeFiles/mojoluac.dir/build.make CMakeFiles/mojoluac.dir/lua/src/lopcodes.i + $(MAKE) -f CMakeFiles/mojosetup.dir/build.make CMakeFiles/mojosetup.dir/lua/src/lopcodes.i +.PHONY : lua/src/lopcodes.i + +# target to generate assembly for a file +lua/src/lopcodes.s: + $(MAKE) -f CMakeFiles/mojoluac.dir/build.make CMakeFiles/mojoluac.dir/lua/src/lopcodes.s + $(MAKE) -f CMakeFiles/mojosetup.dir/build.make CMakeFiles/mojosetup.dir/lua/src/lopcodes.s +.PHONY : lua/src/lopcodes.s + +# target to build an object file +lua/src/loslib.o: + $(MAKE) -f CMakeFiles/mojoluac.dir/build.make CMakeFiles/mojoluac.dir/lua/src/loslib.o + $(MAKE) -f CMakeFiles/mojosetup.dir/build.make CMakeFiles/mojosetup.dir/lua/src/loslib.o +.PHONY : lua/src/loslib.o + +# target to preprocess a source file +lua/src/loslib.i: + $(MAKE) -f CMakeFiles/mojoluac.dir/build.make CMakeFiles/mojoluac.dir/lua/src/loslib.i + $(MAKE) -f CMakeFiles/mojosetup.dir/build.make CMakeFiles/mojosetup.dir/lua/src/loslib.i +.PHONY : lua/src/loslib.i + +# target to generate assembly for a file +lua/src/loslib.s: + $(MAKE) -f CMakeFiles/mojoluac.dir/build.make CMakeFiles/mojoluac.dir/lua/src/loslib.s + $(MAKE) -f CMakeFiles/mojosetup.dir/build.make CMakeFiles/mojosetup.dir/lua/src/loslib.s +.PHONY : lua/src/loslib.s + +# target to build an object file +lua/src/lparser.o: + $(MAKE) -f CMakeFiles/mojoluac.dir/build.make CMakeFiles/mojoluac.dir/lua/src/lparser.o + $(MAKE) -f CMakeFiles/mojosetup.dir/build.make CMakeFiles/mojosetup.dir/lua/src/lparser.o +.PHONY : lua/src/lparser.o + +# target to preprocess a source file +lua/src/lparser.i: + $(MAKE) -f CMakeFiles/mojoluac.dir/build.make CMakeFiles/mojoluac.dir/lua/src/lparser.i + $(MAKE) -f CMakeFiles/mojosetup.dir/build.make CMakeFiles/mojosetup.dir/lua/src/lparser.i +.PHONY : lua/src/lparser.i + +# target to generate assembly for a file +lua/src/lparser.s: + $(MAKE) -f CMakeFiles/mojoluac.dir/build.make CMakeFiles/mojoluac.dir/lua/src/lparser.s + $(MAKE) -f CMakeFiles/mojosetup.dir/build.make CMakeFiles/mojosetup.dir/lua/src/lparser.s +.PHONY : lua/src/lparser.s + +# target to build an object file +lua/src/lstate.o: + $(MAKE) -f CMakeFiles/mojoluac.dir/build.make CMakeFiles/mojoluac.dir/lua/src/lstate.o + $(MAKE) -f CMakeFiles/mojosetup.dir/build.make CMakeFiles/mojosetup.dir/lua/src/lstate.o +.PHONY : lua/src/lstate.o + +# target to preprocess a source file +lua/src/lstate.i: + $(MAKE) -f CMakeFiles/mojoluac.dir/build.make CMakeFiles/mojoluac.dir/lua/src/lstate.i + $(MAKE) -f CMakeFiles/mojosetup.dir/build.make CMakeFiles/mojosetup.dir/lua/src/lstate.i +.PHONY : lua/src/lstate.i + +# target to generate assembly for a file +lua/src/lstate.s: + $(MAKE) -f CMakeFiles/mojoluac.dir/build.make CMakeFiles/mojoluac.dir/lua/src/lstate.s + $(MAKE) -f CMakeFiles/mojosetup.dir/build.make CMakeFiles/mojosetup.dir/lua/src/lstate.s +.PHONY : lua/src/lstate.s + +# target to build an object file +lua/src/lstring.o: + $(MAKE) -f CMakeFiles/mojoluac.dir/build.make CMakeFiles/mojoluac.dir/lua/src/lstring.o + $(MAKE) -f CMakeFiles/mojosetup.dir/build.make CMakeFiles/mojosetup.dir/lua/src/lstring.o +.PHONY : lua/src/lstring.o + +# target to preprocess a source file +lua/src/lstring.i: + $(MAKE) -f CMakeFiles/mojoluac.dir/build.make CMakeFiles/mojoluac.dir/lua/src/lstring.i + $(MAKE) -f CMakeFiles/mojosetup.dir/build.make CMakeFiles/mojosetup.dir/lua/src/lstring.i +.PHONY : lua/src/lstring.i + +# target to generate assembly for a file +lua/src/lstring.s: + $(MAKE) -f CMakeFiles/mojoluac.dir/build.make CMakeFiles/mojoluac.dir/lua/src/lstring.s + $(MAKE) -f CMakeFiles/mojosetup.dir/build.make CMakeFiles/mojosetup.dir/lua/src/lstring.s +.PHONY : lua/src/lstring.s + +# target to build an object file +lua/src/lstrlib.o: + $(MAKE) -f CMakeFiles/mojoluac.dir/build.make CMakeFiles/mojoluac.dir/lua/src/lstrlib.o + $(MAKE) -f CMakeFiles/mojosetup.dir/build.make CMakeFiles/mojosetup.dir/lua/src/lstrlib.o +.PHONY : lua/src/lstrlib.o + +# target to preprocess a source file +lua/src/lstrlib.i: + $(MAKE) -f CMakeFiles/mojoluac.dir/build.make CMakeFiles/mojoluac.dir/lua/src/lstrlib.i + $(MAKE) -f CMakeFiles/mojosetup.dir/build.make CMakeFiles/mojosetup.dir/lua/src/lstrlib.i +.PHONY : lua/src/lstrlib.i + +# target to generate assembly for a file +lua/src/lstrlib.s: + $(MAKE) -f CMakeFiles/mojoluac.dir/build.make CMakeFiles/mojoluac.dir/lua/src/lstrlib.s + $(MAKE) -f CMakeFiles/mojosetup.dir/build.make CMakeFiles/mojosetup.dir/lua/src/lstrlib.s +.PHONY : lua/src/lstrlib.s + +# target to build an object file +lua/src/ltable.o: + $(MAKE) -f CMakeFiles/mojoluac.dir/build.make CMakeFiles/mojoluac.dir/lua/src/ltable.o + $(MAKE) -f CMakeFiles/mojosetup.dir/build.make CMakeFiles/mojosetup.dir/lua/src/ltable.o +.PHONY : lua/src/ltable.o + +# target to preprocess a source file +lua/src/ltable.i: + $(MAKE) -f CMakeFiles/mojoluac.dir/build.make CMakeFiles/mojoluac.dir/lua/src/ltable.i + $(MAKE) -f CMakeFiles/mojosetup.dir/build.make CMakeFiles/mojosetup.dir/lua/src/ltable.i +.PHONY : lua/src/ltable.i + +# target to generate assembly for a file +lua/src/ltable.s: + $(MAKE) -f CMakeFiles/mojoluac.dir/build.make CMakeFiles/mojoluac.dir/lua/src/ltable.s + $(MAKE) -f CMakeFiles/mojosetup.dir/build.make CMakeFiles/mojosetup.dir/lua/src/ltable.s +.PHONY : lua/src/ltable.s + +# target to build an object file +lua/src/ltablib.o: + $(MAKE) -f CMakeFiles/mojoluac.dir/build.make CMakeFiles/mojoluac.dir/lua/src/ltablib.o + $(MAKE) -f CMakeFiles/mojosetup.dir/build.make CMakeFiles/mojosetup.dir/lua/src/ltablib.o +.PHONY : lua/src/ltablib.o + +# target to preprocess a source file +lua/src/ltablib.i: + $(MAKE) -f CMakeFiles/mojoluac.dir/build.make CMakeFiles/mojoluac.dir/lua/src/ltablib.i + $(MAKE) -f CMakeFiles/mojosetup.dir/build.make CMakeFiles/mojosetup.dir/lua/src/ltablib.i +.PHONY : lua/src/ltablib.i + +# target to generate assembly for a file +lua/src/ltablib.s: + $(MAKE) -f CMakeFiles/mojoluac.dir/build.make CMakeFiles/mojoluac.dir/lua/src/ltablib.s + $(MAKE) -f CMakeFiles/mojosetup.dir/build.make CMakeFiles/mojosetup.dir/lua/src/ltablib.s +.PHONY : lua/src/ltablib.s + +# target to build an object file +lua/src/ltm.o: + $(MAKE) -f CMakeFiles/mojoluac.dir/build.make CMakeFiles/mojoluac.dir/lua/src/ltm.o + $(MAKE) -f CMakeFiles/mojosetup.dir/build.make CMakeFiles/mojosetup.dir/lua/src/ltm.o +.PHONY : lua/src/ltm.o + +# target to preprocess a source file +lua/src/ltm.i: + $(MAKE) -f CMakeFiles/mojoluac.dir/build.make CMakeFiles/mojoluac.dir/lua/src/ltm.i + $(MAKE) -f CMakeFiles/mojosetup.dir/build.make CMakeFiles/mojosetup.dir/lua/src/ltm.i +.PHONY : lua/src/ltm.i + +# target to generate assembly for a file +lua/src/ltm.s: + $(MAKE) -f CMakeFiles/mojoluac.dir/build.make CMakeFiles/mojoluac.dir/lua/src/ltm.s + $(MAKE) -f CMakeFiles/mojosetup.dir/build.make CMakeFiles/mojosetup.dir/lua/src/ltm.s +.PHONY : lua/src/ltm.s + +# target to build an object file +lua/src/luac.o: + $(MAKE) -f CMakeFiles/mojoluac.dir/build.make CMakeFiles/mojoluac.dir/lua/src/luac.o +.PHONY : lua/src/luac.o + +# target to preprocess a source file +lua/src/luac.i: + $(MAKE) -f CMakeFiles/mojoluac.dir/build.make CMakeFiles/mojoluac.dir/lua/src/luac.i +.PHONY : lua/src/luac.i + +# target to generate assembly for a file +lua/src/luac.s: + $(MAKE) -f CMakeFiles/mojoluac.dir/build.make CMakeFiles/mojoluac.dir/lua/src/luac.s +.PHONY : lua/src/luac.s + +# target to build an object file +lua/src/lundump.o: + $(MAKE) -f CMakeFiles/mojoluac.dir/build.make CMakeFiles/mojoluac.dir/lua/src/lundump.o + $(MAKE) -f CMakeFiles/mojosetup.dir/build.make CMakeFiles/mojosetup.dir/lua/src/lundump.o +.PHONY : lua/src/lundump.o + +# target to preprocess a source file +lua/src/lundump.i: + $(MAKE) -f CMakeFiles/mojoluac.dir/build.make CMakeFiles/mojoluac.dir/lua/src/lundump.i + $(MAKE) -f CMakeFiles/mojosetup.dir/build.make CMakeFiles/mojosetup.dir/lua/src/lundump.i +.PHONY : lua/src/lundump.i + +# target to generate assembly for a file +lua/src/lundump.s: + $(MAKE) -f CMakeFiles/mojoluac.dir/build.make CMakeFiles/mojoluac.dir/lua/src/lundump.s + $(MAKE) -f CMakeFiles/mojosetup.dir/build.make CMakeFiles/mojosetup.dir/lua/src/lundump.s +.PHONY : lua/src/lundump.s + +# target to build an object file +lua/src/lvm.o: + $(MAKE) -f CMakeFiles/mojoluac.dir/build.make CMakeFiles/mojoluac.dir/lua/src/lvm.o + $(MAKE) -f CMakeFiles/mojosetup.dir/build.make CMakeFiles/mojosetup.dir/lua/src/lvm.o +.PHONY : lua/src/lvm.o + +# target to preprocess a source file +lua/src/lvm.i: + $(MAKE) -f CMakeFiles/mojoluac.dir/build.make CMakeFiles/mojoluac.dir/lua/src/lvm.i + $(MAKE) -f CMakeFiles/mojosetup.dir/build.make CMakeFiles/mojosetup.dir/lua/src/lvm.i +.PHONY : lua/src/lvm.i + +# target to generate assembly for a file +lua/src/lvm.s: + $(MAKE) -f CMakeFiles/mojoluac.dir/build.make CMakeFiles/mojoluac.dir/lua/src/lvm.s + $(MAKE) -f CMakeFiles/mojosetup.dir/build.make CMakeFiles/mojosetup.dir/lua/src/lvm.s +.PHONY : lua/src/lvm.s + +# target to build an object file +lua/src/lzio.o: + $(MAKE) -f CMakeFiles/mojoluac.dir/build.make CMakeFiles/mojoluac.dir/lua/src/lzio.o + $(MAKE) -f CMakeFiles/mojosetup.dir/build.make CMakeFiles/mojosetup.dir/lua/src/lzio.o +.PHONY : lua/src/lzio.o + +# target to preprocess a source file +lua/src/lzio.i: + $(MAKE) -f CMakeFiles/mojoluac.dir/build.make CMakeFiles/mojoluac.dir/lua/src/lzio.i + $(MAKE) -f CMakeFiles/mojosetup.dir/build.make CMakeFiles/mojosetup.dir/lua/src/lzio.i +.PHONY : lua/src/lzio.i + +# target to generate assembly for a file +lua/src/lzio.s: + $(MAKE) -f CMakeFiles/mojoluac.dir/build.make CMakeFiles/mojoluac.dir/lua/src/lzio.s + $(MAKE) -f CMakeFiles/mojosetup.dir/build.make CMakeFiles/mojosetup.dir/lua/src/lzio.s +.PHONY : lua/src/lzio.s + +# target to build an object file +lua/src/print.o: + $(MAKE) -f CMakeFiles/mojoluac.dir/build.make CMakeFiles/mojoluac.dir/lua/src/print.o +.PHONY : lua/src/print.o + +# target to preprocess a source file +lua/src/print.i: + $(MAKE) -f CMakeFiles/mojoluac.dir/build.make CMakeFiles/mojoluac.dir/lua/src/print.i +.PHONY : lua/src/print.i + +# target to generate assembly for a file +lua/src/print.s: + $(MAKE) -f CMakeFiles/mojoluac.dir/build.make CMakeFiles/mojoluac.dir/lua/src/print.s +.PHONY : lua/src/print.s + +# target to build an object file +lua_glue.o: + $(MAKE) -f CMakeFiles/mojosetup.dir/build.make CMakeFiles/mojosetup.dir/lua_glue.o +.PHONY : lua_glue.o + +# target to preprocess a source file +lua_glue.i: + $(MAKE) -f CMakeFiles/mojosetup.dir/build.make CMakeFiles/mojosetup.dir/lua_glue.i +.PHONY : lua_glue.i + +# target to generate assembly for a file +lua_glue.s: + $(MAKE) -f CMakeFiles/mojosetup.dir/build.make CMakeFiles/mojosetup.dir/lua_glue.s +.PHONY : lua_glue.s + +# target to build an object file +mojosetup.o: + $(MAKE) -f CMakeFiles/mojosetup.dir/build.make CMakeFiles/mojosetup.dir/mojosetup.o +.PHONY : mojosetup.o + +# target to preprocess a source file +mojosetup.i: + $(MAKE) -f CMakeFiles/mojosetup.dir/build.make CMakeFiles/mojosetup.dir/mojosetup.i +.PHONY : mojosetup.i + +# target to generate assembly for a file +mojosetup.s: + $(MAKE) -f CMakeFiles/mojosetup.dir/build.make CMakeFiles/mojosetup.dir/mojosetup.s +.PHONY : mojosetup.s + +# target to build an object file +platform_unix.o: + $(MAKE) -f CMakeFiles/mojosetup.dir/build.make CMakeFiles/mojosetup.dir/platform_unix.o +.PHONY : platform_unix.o + +# target to preprocess a source file +platform_unix.i: + $(MAKE) -f CMakeFiles/mojosetup.dir/build.make CMakeFiles/mojosetup.dir/platform_unix.i +.PHONY : platform_unix.i + +# target to generate assembly for a file +platform_unix.s: + $(MAKE) -f CMakeFiles/mojosetup.dir/build.make CMakeFiles/mojosetup.dir/platform_unix.s +.PHONY : platform_unix.s + +# target to build an object file +platform_windows.o: + $(MAKE) -f CMakeFiles/mojosetup.dir/build.make CMakeFiles/mojosetup.dir/platform_windows.o +.PHONY : platform_windows.o + +# target to preprocess a source file +platform_windows.i: + $(MAKE) -f CMakeFiles/mojosetup.dir/build.make CMakeFiles/mojosetup.dir/platform_windows.i +.PHONY : platform_windows.i + +# target to generate assembly for a file +platform_windows.s: + $(MAKE) -f CMakeFiles/mojosetup.dir/build.make CMakeFiles/mojosetup.dir/platform_windows.s +.PHONY : platform_windows.s + +# target to build an object file +stb_image.o: + $(MAKE) -f CMakeFiles/mojosetup.dir/build.make CMakeFiles/mojosetup.dir/stb_image.o +.PHONY : stb_image.o + +# target to preprocess a source file +stb_image.i: + $(MAKE) -f CMakeFiles/mojosetup.dir/build.make CMakeFiles/mojosetup.dir/stb_image.i +.PHONY : stb_image.i + +# target to generate assembly for a file +stb_image.s: + $(MAKE) -f CMakeFiles/mojosetup.dir/build.make CMakeFiles/mojosetup.dir/stb_image.s +.PHONY : stb_image.s + +# Help Target +help: + @echo "The following are some of the valid targets for this Makefile:" + @echo "... all (the default if no target is provided)" + @echo "... clean" + @echo "... depend" + @echo "... edit_cache" + @echo "... lua" + @echo "... mojoluac" + @echo "... mojosetup" + @echo "... mojosetupgui_gtkplus2" + @echo "... rebuild_cache" + @echo "... skeleton" + @echo "... archive_pck.o" + @echo "... archive_pck.i" + @echo "... archive_pck.s" + @echo "... archive_tar.o" + @echo "... archive_tar.i" + @echo "... archive_tar.s" + @echo "... archive_uz2.o" + @echo "... archive_uz2.i" + @echo "... archive_uz2.s" + @echo "... archive_zip.o" + @echo "... archive_zip.i" + @echo "... archive_zip.s" + @echo "... buildver.o" + @echo "... buildver.i" + @echo "... buildver.s" + @echo "... checksum_crc32.o" + @echo "... checksum_crc32.i" + @echo "... checksum_crc32.s" + @echo "... checksum_md5.o" + @echo "... checksum_md5.i" + @echo "... checksum_md5.s" + @echo "... checksum_sha1.o" + @echo "... checksum_sha1.i" + @echo "... checksum_sha1.s" + @echo "... fileio.o" + @echo "... fileio.i" + @echo "... fileio.s" + @echo "... gui.o" + @echo "... gui.i" + @echo "... gui.s" + @echo "... gui_gtkplus2.o" + @echo "... gui_gtkplus2.i" + @echo "... gui_gtkplus2.s" + @echo "... gui_stdio.o" + @echo "... gui_stdio.i" + @echo "... gui_stdio.s" + @echo "... libfetch/common.o" + @echo "... libfetch/common.i" + @echo "... libfetch/common.s" + @echo "... libfetch/fetch.o" + @echo "... libfetch/fetch.i" + @echo "... libfetch/fetch.s" + @echo "... libfetch/ftp.o" + @echo "... libfetch/ftp.i" + @echo "... libfetch/ftp.s" + @echo "... libfetch/http.o" + @echo "... libfetch/http.i" + @echo "... libfetch/http.s" + @echo "... lua/src/lapi.o" + @echo "... lua/src/lapi.i" + @echo "... lua/src/lapi.s" + @echo "... lua/src/lauxlib.o" + @echo "... lua/src/lauxlib.i" + @echo "... lua/src/lauxlib.s" + @echo "... lua/src/lbaselib.o" + @echo "... lua/src/lbaselib.i" + @echo "... lua/src/lbaselib.s" + @echo "... lua/src/lcode.o" + @echo "... lua/src/lcode.i" + @echo "... lua/src/lcode.s" + @echo "... lua/src/ldblib.o" + @echo "... lua/src/ldblib.i" + @echo "... lua/src/ldblib.s" + @echo "... lua/src/ldebug.o" + @echo "... lua/src/ldebug.i" + @echo "... lua/src/ldebug.s" + @echo "... lua/src/ldo.o" + @echo "... lua/src/ldo.i" + @echo "... lua/src/ldo.s" + @echo "... lua/src/ldump.o" + @echo "... lua/src/ldump.i" + @echo "... lua/src/ldump.s" + @echo "... lua/src/lfunc.o" + @echo "... lua/src/lfunc.i" + @echo "... lua/src/lfunc.s" + @echo "... lua/src/lgc.o" + @echo "... lua/src/lgc.i" + @echo "... lua/src/lgc.s" + @echo "... lua/src/linit.o" + @echo "... lua/src/linit.i" + @echo "... lua/src/linit.s" + @echo "... lua/src/liolib.o" + @echo "... lua/src/liolib.i" + @echo "... lua/src/liolib.s" + @echo "... lua/src/llex.o" + @echo "... lua/src/llex.i" + @echo "... lua/src/llex.s" + @echo "... lua/src/lmathlib.o" + @echo "... lua/src/lmathlib.i" + @echo "... lua/src/lmathlib.s" + @echo "... lua/src/lmem.o" + @echo "... lua/src/lmem.i" + @echo "... lua/src/lmem.s" + @echo "... lua/src/loadlib.o" + @echo "... lua/src/loadlib.i" + @echo "... lua/src/loadlib.s" + @echo "... lua/src/lobject.o" + @echo "... lua/src/lobject.i" + @echo "... lua/src/lobject.s" + @echo "... lua/src/lopcodes.o" + @echo "... lua/src/lopcodes.i" + @echo "... lua/src/lopcodes.s" + @echo "... lua/src/loslib.o" + @echo "... lua/src/loslib.i" + @echo "... lua/src/loslib.s" + @echo "... lua/src/lparser.o" + @echo "... lua/src/lparser.i" + @echo "... lua/src/lparser.s" + @echo "... lua/src/lstate.o" + @echo "... lua/src/lstate.i" + @echo "... lua/src/lstate.s" + @echo "... lua/src/lstring.o" + @echo "... lua/src/lstring.i" + @echo "... lua/src/lstring.s" + @echo "... lua/src/lstrlib.o" + @echo "... lua/src/lstrlib.i" + @echo "... lua/src/lstrlib.s" + @echo "... lua/src/ltable.o" + @echo "... lua/src/ltable.i" + @echo "... lua/src/ltable.s" + @echo "... lua/src/ltablib.o" + @echo "... lua/src/ltablib.i" + @echo "... lua/src/ltablib.s" + @echo "... lua/src/ltm.o" + @echo "... lua/src/ltm.i" + @echo "... lua/src/ltm.s" + @echo "... lua/src/luac.o" + @echo "... lua/src/luac.i" + @echo "... lua/src/luac.s" + @echo "... lua/src/lundump.o" + @echo "... lua/src/lundump.i" + @echo "... lua/src/lundump.s" + @echo "... lua/src/lvm.o" + @echo "... lua/src/lvm.i" + @echo "... lua/src/lvm.s" + @echo "... lua/src/lzio.o" + @echo "... lua/src/lzio.i" + @echo "... lua/src/lzio.s" + @echo "... lua/src/print.o" + @echo "... lua/src/print.i" + @echo "... lua/src/print.s" + @echo "... lua_glue.o" + @echo "... lua_glue.i" + @echo "... lua_glue.s" + @echo "... mojosetup.o" + @echo "... mojosetup.i" + @echo "... mojosetup.s" + @echo "... platform_unix.o" + @echo "... platform_unix.i" + @echo "... platform_unix.s" + @echo "... platform_windows.o" + @echo "... platform_windows.i" + @echo "... platform_windows.s" + @echo "... stb_image.o" + @echo "... stb_image.i" + @echo "... stb_image.s" +.PHONY : help + + + +#============================================================================= +# Special targets to cleanup operation of make. + +# Special rule to run CMake to check the build system integrity. +# No rule that depends on this can have commands that come from listfiles +# because they might be regenerated. +cmake_check_build_system: + $(CMAKE_COMMAND) -H$(CMAKE_SOURCE_DIR) -B$(CMAKE_BINARY_DIR) --check-build-system CMakeFiles/Makefile.cmake 0 +.PHONY : cmake_check_build_system + diff --git a/mk/linux/mojosetup/build/cmake_install.cmake b/mk/linux/mojosetup/build/cmake_install.cmake new file mode 100644 index 00000000..3e0048dc --- /dev/null +++ b/mk/linux/mojosetup/build/cmake_install.cmake @@ -0,0 +1,44 @@ +# Install script for directory: /home/softcoder/Code/mojosetup + +# Set the install prefix +IF(NOT DEFINED CMAKE_INSTALL_PREFIX) + SET(CMAKE_INSTALL_PREFIX "/usr/local") +ENDIF(NOT DEFINED CMAKE_INSTALL_PREFIX) +STRING(REGEX REPLACE "/$" "" CMAKE_INSTALL_PREFIX "${CMAKE_INSTALL_PREFIX}") + +# Set the install configuration name. +IF(NOT DEFINED CMAKE_INSTALL_CONFIG_NAME) + IF(BUILD_TYPE) + STRING(REGEX REPLACE "^[^A-Za-z0-9_]+" "" + CMAKE_INSTALL_CONFIG_NAME "${BUILD_TYPE}") + ELSE(BUILD_TYPE) + SET(CMAKE_INSTALL_CONFIG_NAME "") + ENDIF(BUILD_TYPE) + MESSAGE(STATUS "Install configuration: \"${CMAKE_INSTALL_CONFIG_NAME}\"") +ENDIF(NOT DEFINED CMAKE_INSTALL_CONFIG_NAME) + +# Set the component getting installed. +IF(NOT CMAKE_INSTALL_COMPONENT) + IF(COMPONENT) + MESSAGE(STATUS "Install component: \"${COMPONENT}\"") + SET(CMAKE_INSTALL_COMPONENT "${COMPONENT}") + ELSE(COMPONENT) + SET(CMAKE_INSTALL_COMPONENT) + ENDIF(COMPONENT) +ENDIF(NOT CMAKE_INSTALL_COMPONENT) + +# Install shared libraries without execute permission? +IF(NOT DEFINED CMAKE_INSTALL_SO_NO_EXE) + SET(CMAKE_INSTALL_SO_NO_EXE "1") +ENDIF(NOT DEFINED CMAKE_INSTALL_SO_NO_EXE) + +IF(CMAKE_INSTALL_COMPONENT) + SET(CMAKE_INSTALL_MANIFEST "install_manifest_${CMAKE_INSTALL_COMPONENT}.txt") +ELSE(CMAKE_INSTALL_COMPONENT) + SET(CMAKE_INSTALL_MANIFEST "install_manifest.txt") +ENDIF(CMAKE_INSTALL_COMPONENT) + +FILE(WRITE "/home/softcoder/Code/mojosetup/build/${CMAKE_INSTALL_MANIFEST}" "") +FOREACH(file ${CMAKE_INSTALL_MANIFEST_FILES}) + FILE(APPEND "/home/softcoder/Code/mojosetup/build/${CMAKE_INSTALL_MANIFEST}" "${file}\n") +ENDFOREACH(file) diff --git a/mk/linux/mojosetup/build/mojoluac b/mk/linux/mojosetup/build/mojoluac new file mode 100755 index 00000000..fb32ee01 Binary files /dev/null and b/mk/linux/mojosetup/build/mojoluac differ diff --git a/mk/linux/mojosetup/build/mojosetup b/mk/linux/mojosetup/build/mojosetup new file mode 100755 index 00000000..b738864c Binary files /dev/null and b/mk/linux/mojosetup/build/mojosetup differ diff --git a/mk/linux/mojosetup/buildver.c b/mk/linux/mojosetup/buildver.c new file mode 100644 index 00000000..cd14aaad --- /dev/null +++ b/mk/linux/mojosetup/buildver.c @@ -0,0 +1,74 @@ +/** + * MojoSetup; a portable, flexible installation application. + * + * Please see the file LICENSE.txt in the source's root directory. + * + * This file written by Ryan C. Gordon. + */ + +/* + * This is in a separate file so that we can recompile it every time + * without it forcing a recompile on something ccache would otherwise not + * have to rebuild...this file's checksum changes every time you build it + * due to the __DATE__ and __TIME__ macros. + * + * The makefile will rebuild this file everytime it relinks an executable + * so that we'll always have a unique build string. + * + * APPNAME and APPREV need to be predefined in the build system. + * The rest are supposed to be supplied by the compiler. + */ + +#ifndef APPID +#error Please define APPID in the build system. +#endif + +#ifndef APPREV +#error Please define APPREV in the build system. +#endif + +#if (defined __GNUC__) +# define VERSTR2(x) #x +# define VERSTR(x) VERSTR2(x) +# define COMPILERVER " " VERSTR(__GNUC__) "." VERSTR(__GNUC_MINOR__) "." VERSTR(__GNUC_PATCHLEVEL__) +#elif (defined __SUNPRO_C) +# define VERSTR2(x) #x +# define VERSTR(x) VERSTR2(x) +# define COMPILERVER " " VERSTR(__SUNPRO_C) +#elif (defined __VERSION__) +# define COMPILERVER " " __VERSION__ +#else +# define COMPILERVER "" +#endif + +#ifndef __DATE__ +#define __DATE__ "(Unknown build date)" +#endif + +#ifndef __TIME__ +#define __TIME__ "(Unknown build time)" +#endif + +#ifndef COMPILER + #if (defined __GNUC__) + #define COMPILER "GCC" + #elif (defined _MSC_VER) + #define COMPILER "Visual Studio" + #elif (defined __SUNPRO_C) + #define COMPILER "Sun Studio" + #else + #error Please define your platform. + #endif +#endif + +// macro mess so we can turn APPID and APPREV into a string literal... +#define MAKEBUILDVERSTRINGLITERAL2(id, rev) \ + #id ", revision " #rev ", built " __DATE__ " " __TIME__ \ + ", by " COMPILER COMPILERVER + +#define MAKEBUILDVERSTRINGLITERAL(id, rev) MAKEBUILDVERSTRINGLITERAL2(id, rev) + +const char *GBuildVer = MAKEBUILDVERSTRINGLITERAL(APPID, APPREV); + +// end of buildver.c ... + diff --git a/mk/linux/mojosetup/bzip2/blocksort.c b/mk/linux/mojosetup/bzip2/blocksort.c new file mode 100644 index 00000000..bd2dec15 --- /dev/null +++ b/mk/linux/mojosetup/bzip2/blocksort.c @@ -0,0 +1,1094 @@ + +/*-------------------------------------------------------------*/ +/*--- Block sorting machinery ---*/ +/*--- blocksort.c ---*/ +/*-------------------------------------------------------------*/ + +/* ------------------------------------------------------------------ + This file is part of bzip2/libbzip2, a program and library for + lossless, block-sorting data compression. + + bzip2/libbzip2 version 1.0.5 of 10 December 2007 + Copyright (C) 1996-2007 Julian Seward + + Please read the WARNING, DISCLAIMER and PATENTS sections in the + README file. + + This program is released under the terms of the license contained + in the file LICENSE. + ------------------------------------------------------------------ */ + + +#include "bzlib_private.h" + +/*---------------------------------------------*/ +/*--- Fallback O(N log(N)^2) sorting ---*/ +/*--- algorithm, for repetitive blocks ---*/ +/*---------------------------------------------*/ + +/*---------------------------------------------*/ +static +__inline__ +void fallbackSimpleSort ( UInt32* fmap, + UInt32* eclass, + Int32 lo, + Int32 hi ) +{ + Int32 i, j, tmp; + UInt32 ec_tmp; + + if (lo == hi) return; + + if (hi - lo > 3) { + for ( i = hi-4; i >= lo; i-- ) { + tmp = fmap[i]; + ec_tmp = eclass[tmp]; + for ( j = i+4; j <= hi && ec_tmp > eclass[fmap[j]]; j += 4 ) + fmap[j-4] = fmap[j]; + fmap[j-4] = tmp; + } + } + + for ( i = hi-1; i >= lo; i-- ) { + tmp = fmap[i]; + ec_tmp = eclass[tmp]; + for ( j = i+1; j <= hi && ec_tmp > eclass[fmap[j]]; j++ ) + fmap[j-1] = fmap[j]; + fmap[j-1] = tmp; + } +} + + +/*---------------------------------------------*/ +#define fswap(zz1, zz2) \ + { Int32 zztmp = zz1; zz1 = zz2; zz2 = zztmp; } + +#define fvswap(zzp1, zzp2, zzn) \ +{ \ + Int32 yyp1 = (zzp1); \ + Int32 yyp2 = (zzp2); \ + Int32 yyn = (zzn); \ + while (yyn > 0) { \ + fswap(fmap[yyp1], fmap[yyp2]); \ + yyp1++; yyp2++; yyn--; \ + } \ +} + + +#define fmin(a,b) ((a) < (b)) ? (a) : (b) + +#define fpush(lz,hz) { stackLo[sp] = lz; \ + stackHi[sp] = hz; \ + sp++; } + +#define fpop(lz,hz) { sp--; \ + lz = stackLo[sp]; \ + hz = stackHi[sp]; } + +#define FALLBACK_QSORT_SMALL_THRESH 10 +#define FALLBACK_QSORT_STACK_SIZE 100 + + +static +void fallbackQSort3 ( UInt32* fmap, + UInt32* eclass, + Int32 loSt, + Int32 hiSt ) +{ + Int32 unLo, unHi, ltLo, gtHi, n, m; + Int32 sp, lo, hi; + UInt32 med, r, r3; + Int32 stackLo[FALLBACK_QSORT_STACK_SIZE]; + Int32 stackHi[FALLBACK_QSORT_STACK_SIZE]; + + r = 0; + + sp = 0; + fpush ( loSt, hiSt ); + + while (sp > 0) { + + AssertH ( sp < FALLBACK_QSORT_STACK_SIZE - 1, 1004 ); + + fpop ( lo, hi ); + if (hi - lo < FALLBACK_QSORT_SMALL_THRESH) { + fallbackSimpleSort ( fmap, eclass, lo, hi ); + continue; + } + + /* Random partitioning. Median of 3 sometimes fails to + avoid bad cases. Median of 9 seems to help but + looks rather expensive. This too seems to work but + is cheaper. Guidance for the magic constants + 7621 and 32768 is taken from Sedgewick's algorithms + book, chapter 35. + */ + r = ((r * 7621) + 1) % 32768; + r3 = r % 3; + if (r3 == 0) med = eclass[fmap[lo]]; else + if (r3 == 1) med = eclass[fmap[(lo+hi)>>1]]; else + med = eclass[fmap[hi]]; + + unLo = ltLo = lo; + unHi = gtHi = hi; + + while (1) { + while (1) { + if (unLo > unHi) break; + n = (Int32)eclass[fmap[unLo]] - (Int32)med; + if (n == 0) { + fswap(fmap[unLo], fmap[ltLo]); + ltLo++; unLo++; + continue; + }; + if (n > 0) break; + unLo++; + } + while (1) { + if (unLo > unHi) break; + n = (Int32)eclass[fmap[unHi]] - (Int32)med; + if (n == 0) { + fswap(fmap[unHi], fmap[gtHi]); + gtHi--; unHi--; + continue; + }; + if (n < 0) break; + unHi--; + } + if (unLo > unHi) break; + fswap(fmap[unLo], fmap[unHi]); unLo++; unHi--; + } + + AssertD ( unHi == unLo-1, "fallbackQSort3(2)" ); + + if (gtHi < ltLo) continue; + + n = fmin(ltLo-lo, unLo-ltLo); fvswap(lo, unLo-n, n); + m = fmin(hi-gtHi, gtHi-unHi); fvswap(unLo, hi-m+1, m); + + n = lo + unLo - ltLo - 1; + m = hi - (gtHi - unHi) + 1; + + if (n - lo > hi - m) { + fpush ( lo, n ); + fpush ( m, hi ); + } else { + fpush ( m, hi ); + fpush ( lo, n ); + } + } +} + +#undef fmin +#undef fpush +#undef fpop +#undef fswap +#undef fvswap +#undef FALLBACK_QSORT_SMALL_THRESH +#undef FALLBACK_QSORT_STACK_SIZE + + +/*---------------------------------------------*/ +/* Pre: + nblock > 0 + eclass exists for [0 .. nblock-1] + ((UChar*)eclass) [0 .. nblock-1] holds block + ptr exists for [0 .. nblock-1] + + Post: + ((UChar*)eclass) [0 .. nblock-1] holds block + All other areas of eclass destroyed + fmap [0 .. nblock-1] holds sorted order + bhtab [ 0 .. 2+(nblock/32) ] destroyed +*/ + +#define SET_BH(zz) bhtab[(zz) >> 5] |= (1 << ((zz) & 31)) +#define CLEAR_BH(zz) bhtab[(zz) >> 5] &= ~(1 << ((zz) & 31)) +#define ISSET_BH(zz) (bhtab[(zz) >> 5] & (1 << ((zz) & 31))) +#define WORD_BH(zz) bhtab[(zz) >> 5] +#define UNALIGNED_BH(zz) ((zz) & 0x01f) + +static +void fallbackSort ( UInt32* fmap, + UInt32* eclass, + UInt32* bhtab, + Int32 nblock, + Int32 verb ) +{ + Int32 ftab[257]; + Int32 ftabCopy[256]; + Int32 H, i, j, k, l, r, cc, cc1; + Int32 nNotDone; + Int32 nBhtab; + UChar* eclass8 = (UChar*)eclass; + + /*-- + Initial 1-char radix sort to generate + initial fmap and initial BH bits. + --*/ + if (verb >= 4) + VPrintf0 ( " bucket sorting ...\n" ); + for (i = 0; i < 257; i++) ftab[i] = 0; + for (i = 0; i < nblock; i++) ftab[eclass8[i]]++; + for (i = 0; i < 256; i++) ftabCopy[i] = ftab[i]; + for (i = 1; i < 257; i++) ftab[i] += ftab[i-1]; + + for (i = 0; i < nblock; i++) { + j = eclass8[i]; + k = ftab[j] - 1; + ftab[j] = k; + fmap[k] = i; + } + + nBhtab = 2 + (nblock / 32); + for (i = 0; i < nBhtab; i++) bhtab[i] = 0; + for (i = 0; i < 256; i++) SET_BH(ftab[i]); + + /*-- + Inductively refine the buckets. Kind-of an + "exponential radix sort" (!), inspired by the + Manber-Myers suffix array construction algorithm. + --*/ + + /*-- set sentinel bits for block-end detection --*/ + for (i = 0; i < 32; i++) { + SET_BH(nblock + 2*i); + CLEAR_BH(nblock + 2*i + 1); + } + + /*-- the log(N) loop --*/ + H = 1; + while (1) { + + if (verb >= 4) + VPrintf1 ( " depth %6d has ", H ); + + j = 0; + for (i = 0; i < nblock; i++) { + if (ISSET_BH(i)) j = i; + k = fmap[i] - H; if (k < 0) k += nblock; + eclass[k] = j; + } + + nNotDone = 0; + r = -1; + while (1) { + + /*-- find the next non-singleton bucket --*/ + k = r + 1; + while (ISSET_BH(k) && UNALIGNED_BH(k)) k++; + if (ISSET_BH(k)) { + while (WORD_BH(k) == 0xffffffff) k += 32; + while (ISSET_BH(k)) k++; + } + l = k - 1; + if (l >= nblock) break; + while (!ISSET_BH(k) && UNALIGNED_BH(k)) k++; + if (!ISSET_BH(k)) { + while (WORD_BH(k) == 0x00000000) k += 32; + while (!ISSET_BH(k)) k++; + } + r = k - 1; + if (r >= nblock) break; + + /*-- now [l, r] bracket current bucket --*/ + if (r > l) { + nNotDone += (r - l + 1); + fallbackQSort3 ( fmap, eclass, l, r ); + + /*-- scan bucket and generate header bits-- */ + cc = -1; + for (i = l; i <= r; i++) { + cc1 = eclass[fmap[i]]; + if (cc != cc1) { SET_BH(i); cc = cc1; }; + } + } + } + + if (verb >= 4) + VPrintf1 ( "%6d unresolved strings\n", nNotDone ); + + H *= 2; + if (H > nblock || nNotDone == 0) break; + } + + /*-- + Reconstruct the original block in + eclass8 [0 .. nblock-1], since the + previous phase destroyed it. + --*/ + if (verb >= 4) + VPrintf0 ( " reconstructing block ...\n" ); + j = 0; + for (i = 0; i < nblock; i++) { + while (ftabCopy[j] == 0) j++; + ftabCopy[j]--; + eclass8[fmap[i]] = (UChar)j; + } + AssertH ( j < 256, 1005 ); +} + +#undef SET_BH +#undef CLEAR_BH +#undef ISSET_BH +#undef WORD_BH +#undef UNALIGNED_BH + + +/*---------------------------------------------*/ +/*--- The main, O(N^2 log(N)) sorting ---*/ +/*--- algorithm. Faster for "normal" ---*/ +/*--- non-repetitive blocks. ---*/ +/*---------------------------------------------*/ + +/*---------------------------------------------*/ +static +__inline__ +Bool mainGtU ( UInt32 i1, + UInt32 i2, + UChar* block, + UInt16* quadrant, + UInt32 nblock, + Int32* budget ) +{ + Int32 k; + UChar c1, c2; + UInt16 s1, s2; + + AssertD ( i1 != i2, "mainGtU" ); + /* 1 */ + c1 = block[i1]; c2 = block[i2]; + if (c1 != c2) return (c1 > c2); + i1++; i2++; + /* 2 */ + c1 = block[i1]; c2 = block[i2]; + if (c1 != c2) return (c1 > c2); + i1++; i2++; + /* 3 */ + c1 = block[i1]; c2 = block[i2]; + if (c1 != c2) return (c1 > c2); + i1++; i2++; + /* 4 */ + c1 = block[i1]; c2 = block[i2]; + if (c1 != c2) return (c1 > c2); + i1++; i2++; + /* 5 */ + c1 = block[i1]; c2 = block[i2]; + if (c1 != c2) return (c1 > c2); + i1++; i2++; + /* 6 */ + c1 = block[i1]; c2 = block[i2]; + if (c1 != c2) return (c1 > c2); + i1++; i2++; + /* 7 */ + c1 = block[i1]; c2 = block[i2]; + if (c1 != c2) return (c1 > c2); + i1++; i2++; + /* 8 */ + c1 = block[i1]; c2 = block[i2]; + if (c1 != c2) return (c1 > c2); + i1++; i2++; + /* 9 */ + c1 = block[i1]; c2 = block[i2]; + if (c1 != c2) return (c1 > c2); + i1++; i2++; + /* 10 */ + c1 = block[i1]; c2 = block[i2]; + if (c1 != c2) return (c1 > c2); + i1++; i2++; + /* 11 */ + c1 = block[i1]; c2 = block[i2]; + if (c1 != c2) return (c1 > c2); + i1++; i2++; + /* 12 */ + c1 = block[i1]; c2 = block[i2]; + if (c1 != c2) return (c1 > c2); + i1++; i2++; + + k = nblock + 8; + + do { + /* 1 */ + c1 = block[i1]; c2 = block[i2]; + if (c1 != c2) return (c1 > c2); + s1 = quadrant[i1]; s2 = quadrant[i2]; + if (s1 != s2) return (s1 > s2); + i1++; i2++; + /* 2 */ + c1 = block[i1]; c2 = block[i2]; + if (c1 != c2) return (c1 > c2); + s1 = quadrant[i1]; s2 = quadrant[i2]; + if (s1 != s2) return (s1 > s2); + i1++; i2++; + /* 3 */ + c1 = block[i1]; c2 = block[i2]; + if (c1 != c2) return (c1 > c2); + s1 = quadrant[i1]; s2 = quadrant[i2]; + if (s1 != s2) return (s1 > s2); + i1++; i2++; + /* 4 */ + c1 = block[i1]; c2 = block[i2]; + if (c1 != c2) return (c1 > c2); + s1 = quadrant[i1]; s2 = quadrant[i2]; + if (s1 != s2) return (s1 > s2); + i1++; i2++; + /* 5 */ + c1 = block[i1]; c2 = block[i2]; + if (c1 != c2) return (c1 > c2); + s1 = quadrant[i1]; s2 = quadrant[i2]; + if (s1 != s2) return (s1 > s2); + i1++; i2++; + /* 6 */ + c1 = block[i1]; c2 = block[i2]; + if (c1 != c2) return (c1 > c2); + s1 = quadrant[i1]; s2 = quadrant[i2]; + if (s1 != s2) return (s1 > s2); + i1++; i2++; + /* 7 */ + c1 = block[i1]; c2 = block[i2]; + if (c1 != c2) return (c1 > c2); + s1 = quadrant[i1]; s2 = quadrant[i2]; + if (s1 != s2) return (s1 > s2); + i1++; i2++; + /* 8 */ + c1 = block[i1]; c2 = block[i2]; + if (c1 != c2) return (c1 > c2); + s1 = quadrant[i1]; s2 = quadrant[i2]; + if (s1 != s2) return (s1 > s2); + i1++; i2++; + + if (i1 >= nblock) i1 -= nblock; + if (i2 >= nblock) i2 -= nblock; + + k -= 8; + (*budget)--; + } + while (k >= 0); + + return False; +} + + +/*---------------------------------------------*/ +/*-- + Knuth's increments seem to work better + than Incerpi-Sedgewick here. Possibly + because the number of elems to sort is + usually small, typically <= 20. +--*/ +static +Int32 incs[14] = { 1, 4, 13, 40, 121, 364, 1093, 3280, + 9841, 29524, 88573, 265720, + 797161, 2391484 }; + +static +void mainSimpleSort ( UInt32* ptr, + UChar* block, + UInt16* quadrant, + Int32 nblock, + Int32 lo, + Int32 hi, + Int32 d, + Int32* budget ) +{ + Int32 i, j, h, bigN, hp; + UInt32 v; + + bigN = hi - lo + 1; + if (bigN < 2) return; + + hp = 0; + while (incs[hp] < bigN) hp++; + hp--; + + for (; hp >= 0; hp--) { + h = incs[hp]; + + i = lo + h; + while (True) { + + /*-- copy 1 --*/ + if (i > hi) break; + v = ptr[i]; + j = i; + while ( mainGtU ( + ptr[j-h]+d, v+d, block, quadrant, nblock, budget + ) ) { + ptr[j] = ptr[j-h]; + j = j - h; + if (j <= (lo + h - 1)) break; + } + ptr[j] = v; + i++; + + /*-- copy 2 --*/ + if (i > hi) break; + v = ptr[i]; + j = i; + while ( mainGtU ( + ptr[j-h]+d, v+d, block, quadrant, nblock, budget + ) ) { + ptr[j] = ptr[j-h]; + j = j - h; + if (j <= (lo + h - 1)) break; + } + ptr[j] = v; + i++; + + /*-- copy 3 --*/ + if (i > hi) break; + v = ptr[i]; + j = i; + while ( mainGtU ( + ptr[j-h]+d, v+d, block, quadrant, nblock, budget + ) ) { + ptr[j] = ptr[j-h]; + j = j - h; + if (j <= (lo + h - 1)) break; + } + ptr[j] = v; + i++; + + if (*budget < 0) return; + } + } +} + + +/*---------------------------------------------*/ +/*-- + The following is an implementation of + an elegant 3-way quicksort for strings, + described in a paper "Fast Algorithms for + Sorting and Searching Strings", by Robert + Sedgewick and Jon L. Bentley. +--*/ + +#define mswap(zz1, zz2) \ + { Int32 zztmp = zz1; zz1 = zz2; zz2 = zztmp; } + +#define mvswap(zzp1, zzp2, zzn) \ +{ \ + Int32 yyp1 = (zzp1); \ + Int32 yyp2 = (zzp2); \ + Int32 yyn = (zzn); \ + while (yyn > 0) { \ + mswap(ptr[yyp1], ptr[yyp2]); \ + yyp1++; yyp2++; yyn--; \ + } \ +} + +static +__inline__ +UChar mmed3 ( UChar a, UChar b, UChar c ) +{ + UChar t; + if (a > b) { t = a; a = b; b = t; }; + if (b > c) { + b = c; + if (a > b) b = a; + } + return b; +} + +#define mmin(a,b) ((a) < (b)) ? (a) : (b) + +#define mpush(lz,hz,dz) { stackLo[sp] = lz; \ + stackHi[sp] = hz; \ + stackD [sp] = dz; \ + sp++; } + +#define mpop(lz,hz,dz) { sp--; \ + lz = stackLo[sp]; \ + hz = stackHi[sp]; \ + dz = stackD [sp]; } + + +#define mnextsize(az) (nextHi[az]-nextLo[az]) + +#define mnextswap(az,bz) \ + { Int32 tz; \ + tz = nextLo[az]; nextLo[az] = nextLo[bz]; nextLo[bz] = tz; \ + tz = nextHi[az]; nextHi[az] = nextHi[bz]; nextHi[bz] = tz; \ + tz = nextD [az]; nextD [az] = nextD [bz]; nextD [bz] = tz; } + + +#define MAIN_QSORT_SMALL_THRESH 20 +#define MAIN_QSORT_DEPTH_THRESH (BZ_N_RADIX + BZ_N_QSORT) +#define MAIN_QSORT_STACK_SIZE 100 + +static +void mainQSort3 ( UInt32* ptr, + UChar* block, + UInt16* quadrant, + Int32 nblock, + Int32 loSt, + Int32 hiSt, + Int32 dSt, + Int32* budget ) +{ + Int32 unLo, unHi, ltLo, gtHi, n, m, med; + Int32 sp, lo, hi, d; + + Int32 stackLo[MAIN_QSORT_STACK_SIZE]; + Int32 stackHi[MAIN_QSORT_STACK_SIZE]; + Int32 stackD [MAIN_QSORT_STACK_SIZE]; + + Int32 nextLo[3]; + Int32 nextHi[3]; + Int32 nextD [3]; + + sp = 0; + mpush ( loSt, hiSt, dSt ); + + while (sp > 0) { + + AssertH ( sp < MAIN_QSORT_STACK_SIZE - 2, 1001 ); + + mpop ( lo, hi, d ); + if (hi - lo < MAIN_QSORT_SMALL_THRESH || + d > MAIN_QSORT_DEPTH_THRESH) { + mainSimpleSort ( ptr, block, quadrant, nblock, lo, hi, d, budget ); + if (*budget < 0) return; + continue; + } + + med = (Int32) + mmed3 ( block[ptr[ lo ]+d], + block[ptr[ hi ]+d], + block[ptr[ (lo+hi)>>1 ]+d] ); + + unLo = ltLo = lo; + unHi = gtHi = hi; + + while (True) { + while (True) { + if (unLo > unHi) break; + n = ((Int32)block[ptr[unLo]+d]) - med; + if (n == 0) { + mswap(ptr[unLo], ptr[ltLo]); + ltLo++; unLo++; continue; + }; + if (n > 0) break; + unLo++; + } + while (True) { + if (unLo > unHi) break; + n = ((Int32)block[ptr[unHi]+d]) - med; + if (n == 0) { + mswap(ptr[unHi], ptr[gtHi]); + gtHi--; unHi--; continue; + }; + if (n < 0) break; + unHi--; + } + if (unLo > unHi) break; + mswap(ptr[unLo], ptr[unHi]); unLo++; unHi--; + } + + AssertD ( unHi == unLo-1, "mainQSort3(2)" ); + + if (gtHi < ltLo) { + mpush(lo, hi, d+1 ); + continue; + } + + n = mmin(ltLo-lo, unLo-ltLo); mvswap(lo, unLo-n, n); + m = mmin(hi-gtHi, gtHi-unHi); mvswap(unLo, hi-m+1, m); + + n = lo + unLo - ltLo - 1; + m = hi - (gtHi - unHi) + 1; + + nextLo[0] = lo; nextHi[0] = n; nextD[0] = d; + nextLo[1] = m; nextHi[1] = hi; nextD[1] = d; + nextLo[2] = n+1; nextHi[2] = m-1; nextD[2] = d+1; + + if (mnextsize(0) < mnextsize(1)) mnextswap(0,1); + if (mnextsize(1) < mnextsize(2)) mnextswap(1,2); + if (mnextsize(0) < mnextsize(1)) mnextswap(0,1); + + AssertD (mnextsize(0) >= mnextsize(1), "mainQSort3(8)" ); + AssertD (mnextsize(1) >= mnextsize(2), "mainQSort3(9)" ); + + mpush (nextLo[0], nextHi[0], nextD[0]); + mpush (nextLo[1], nextHi[1], nextD[1]); + mpush (nextLo[2], nextHi[2], nextD[2]); + } +} + +#undef mswap +#undef mvswap +#undef mpush +#undef mpop +#undef mmin +#undef mnextsize +#undef mnextswap +#undef MAIN_QSORT_SMALL_THRESH +#undef MAIN_QSORT_DEPTH_THRESH +#undef MAIN_QSORT_STACK_SIZE + + +/*---------------------------------------------*/ +/* Pre: + nblock > N_OVERSHOOT + block32 exists for [0 .. nblock-1 +N_OVERSHOOT] + ((UChar*)block32) [0 .. nblock-1] holds block + ptr exists for [0 .. nblock-1] + + Post: + ((UChar*)block32) [0 .. nblock-1] holds block + All other areas of block32 destroyed + ftab [0 .. 65536 ] destroyed + ptr [0 .. nblock-1] holds sorted order + if (*budget < 0), sorting was abandoned +*/ + +#define BIGFREQ(b) (ftab[((b)+1) << 8] - ftab[(b) << 8]) +#define SETMASK (1 << 21) +#define CLEARMASK (~(SETMASK)) + +static +void mainSort ( UInt32* ptr, + UChar* block, + UInt16* quadrant, + UInt32* ftab, + Int32 nblock, + Int32 verb, + Int32* budget ) +{ + Int32 i, j, k, ss, sb; + Int32 runningOrder[256]; + Bool bigDone[256]; + Int32 copyStart[256]; + Int32 copyEnd [256]; + UChar c1; + Int32 numQSorted; + UInt16 s; + if (verb >= 4) VPrintf0 ( " main sort initialise ...\n" ); + + /*-- set up the 2-byte frequency table --*/ + for (i = 65536; i >= 0; i--) ftab[i] = 0; + + j = block[0] << 8; + i = nblock-1; + for (; i >= 3; i -= 4) { + quadrant[i] = 0; + j = (j >> 8) | ( ((UInt16)block[i]) << 8); + ftab[j]++; + quadrant[i-1] = 0; + j = (j >> 8) | ( ((UInt16)block[i-1]) << 8); + ftab[j]++; + quadrant[i-2] = 0; + j = (j >> 8) | ( ((UInt16)block[i-2]) << 8); + ftab[j]++; + quadrant[i-3] = 0; + j = (j >> 8) | ( ((UInt16)block[i-3]) << 8); + ftab[j]++; + } + for (; i >= 0; i--) { + quadrant[i] = 0; + j = (j >> 8) | ( ((UInt16)block[i]) << 8); + ftab[j]++; + } + + /*-- (emphasises close relationship of block & quadrant) --*/ + for (i = 0; i < BZ_N_OVERSHOOT; i++) { + block [nblock+i] = block[i]; + quadrant[nblock+i] = 0; + } + + if (verb >= 4) VPrintf0 ( " bucket sorting ...\n" ); + + /*-- Complete the initial radix sort --*/ + for (i = 1; i <= 65536; i++) ftab[i] += ftab[i-1]; + + s = block[0] << 8; + i = nblock-1; + for (; i >= 3; i -= 4) { + s = (s >> 8) | (block[i] << 8); + j = ftab[s] -1; + ftab[s] = j; + ptr[j] = i; + s = (s >> 8) | (block[i-1] << 8); + j = ftab[s] -1; + ftab[s] = j; + ptr[j] = i-1; + s = (s >> 8) | (block[i-2] << 8); + j = ftab[s] -1; + ftab[s] = j; + ptr[j] = i-2; + s = (s >> 8) | (block[i-3] << 8); + j = ftab[s] -1; + ftab[s] = j; + ptr[j] = i-3; + } + for (; i >= 0; i--) { + s = (s >> 8) | (block[i] << 8); + j = ftab[s] -1; + ftab[s] = j; + ptr[j] = i; + } + + /*-- + Now ftab contains the first loc of every small bucket. + Calculate the running order, from smallest to largest + big bucket. + --*/ + for (i = 0; i <= 255; i++) { + bigDone [i] = False; + runningOrder[i] = i; + } + + { + Int32 vv; + Int32 h = 1; + do h = 3 * h + 1; while (h <= 256); + do { + h = h / 3; + for (i = h; i <= 255; i++) { + vv = runningOrder[i]; + j = i; + while ( BIGFREQ(runningOrder[j-h]) > BIGFREQ(vv) ) { + runningOrder[j] = runningOrder[j-h]; + j = j - h; + if (j <= (h - 1)) goto zero; + } + zero: + runningOrder[j] = vv; + } + } while (h != 1); + } + + /*-- + The main sorting loop. + --*/ + + numQSorted = 0; + + for (i = 0; i <= 255; i++) { + + /*-- + Process big buckets, starting with the least full. + Basically this is a 3-step process in which we call + mainQSort3 to sort the small buckets [ss, j], but + also make a big effort to avoid the calls if we can. + --*/ + ss = runningOrder[i]; + + /*-- + Step 1: + Complete the big bucket [ss] by quicksorting + any unsorted small buckets [ss, j], for j != ss. + Hopefully previous pointer-scanning phases have already + completed many of the small buckets [ss, j], so + we don't have to sort them at all. + --*/ + for (j = 0; j <= 255; j++) { + if (j != ss) { + sb = (ss << 8) + j; + if ( ! (ftab[sb] & SETMASK) ) { + Int32 lo = ftab[sb] & CLEARMASK; + Int32 hi = (ftab[sb+1] & CLEARMASK) - 1; + if (hi > lo) { + if (verb >= 4) + VPrintf4 ( " qsort [0x%x, 0x%x] " + "done %d this %d\n", + ss, j, numQSorted, hi - lo + 1 ); + mainQSort3 ( + ptr, block, quadrant, nblock, + lo, hi, BZ_N_RADIX, budget + ); + numQSorted += (hi - lo + 1); + if (*budget < 0) return; + } + } + ftab[sb] |= SETMASK; + } + } + + AssertH ( !bigDone[ss], 1006 ); + + /*-- + Step 2: + Now scan this big bucket [ss] so as to synthesise the + sorted order for small buckets [t, ss] for all t, + including, magically, the bucket [ss,ss] too. + This will avoid doing Real Work in subsequent Step 1's. + --*/ + { + for (j = 0; j <= 255; j++) { + copyStart[j] = ftab[(j << 8) + ss] & CLEARMASK; + copyEnd [j] = (ftab[(j << 8) + ss + 1] & CLEARMASK) - 1; + } + for (j = ftab[ss << 8] & CLEARMASK; j < copyStart[ss]; j++) { + k = ptr[j]-1; if (k < 0) k += nblock; + c1 = block[k]; + if (!bigDone[c1]) + ptr[ copyStart[c1]++ ] = k; + } + for (j = (ftab[(ss+1) << 8] & CLEARMASK) - 1; j > copyEnd[ss]; j--) { + k = ptr[j]-1; if (k < 0) k += nblock; + c1 = block[k]; + if (!bigDone[c1]) + ptr[ copyEnd[c1]-- ] = k; + } + } + + AssertH ( (copyStart[ss]-1 == copyEnd[ss]) + || + /* Extremely rare case missing in bzip2-1.0.0 and 1.0.1. + Necessity for this case is demonstrated by compressing + a sequence of approximately 48.5 million of character + 251; 1.0.0/1.0.1 will then die here. */ + (copyStart[ss] == 0 && copyEnd[ss] == nblock-1), + 1007 ) + + for (j = 0; j <= 255; j++) ftab[(j << 8) + ss] |= SETMASK; + + /*-- + Step 3: + The [ss] big bucket is now done. Record this fact, + and update the quadrant descriptors. Remember to + update quadrants in the overshoot area too, if + necessary. The "if (i < 255)" test merely skips + this updating for the last bucket processed, since + updating for the last bucket is pointless. + + The quadrant array provides a way to incrementally + cache sort orderings, as they appear, so as to + make subsequent comparisons in fullGtU() complete + faster. For repetitive blocks this makes a big + difference (but not big enough to be able to avoid + the fallback sorting mechanism, exponential radix sort). + + The precise meaning is: at all times: + + for 0 <= i < nblock and 0 <= j <= nblock + + if block[i] != block[j], + + then the relative values of quadrant[i] and + quadrant[j] are meaningless. + + else { + if quadrant[i] < quadrant[j] + then the string starting at i lexicographically + precedes the string starting at j + + else if quadrant[i] > quadrant[j] + then the string starting at j lexicographically + precedes the string starting at i + + else + the relative ordering of the strings starting + at i and j has not yet been determined. + } + --*/ + bigDone[ss] = True; + + if (i < 255) { + Int32 bbStart = ftab[ss << 8] & CLEARMASK; + Int32 bbSize = (ftab[(ss+1) << 8] & CLEARMASK) - bbStart; + Int32 shifts = 0; + + while ((bbSize >> shifts) > 65534) shifts++; + + for (j = bbSize-1; j >= 0; j--) { + Int32 a2update = ptr[bbStart + j]; + UInt16 qVal = (UInt16)(j >> shifts); + quadrant[a2update] = qVal; + if (a2update < BZ_N_OVERSHOOT) + quadrant[a2update + nblock] = qVal; + } + AssertH ( ((bbSize-1) >> shifts) <= 65535, 1002 ); + } + + } + + if (verb >= 4) + VPrintf3 ( " %d pointers, %d sorted, %d scanned\n", + nblock, numQSorted, nblock - numQSorted ); +} + +#undef BIGFREQ +#undef SETMASK +#undef CLEARMASK + + +/*---------------------------------------------*/ +/* Pre: + nblock > 0 + arr2 exists for [0 .. nblock-1 +N_OVERSHOOT] + ((UChar*)arr2) [0 .. nblock-1] holds block + arr1 exists for [0 .. nblock-1] + + Post: + ((UChar*)arr2) [0 .. nblock-1] holds block + All other areas of block destroyed + ftab [ 0 .. 65536 ] destroyed + arr1 [0 .. nblock-1] holds sorted order +*/ +void BZ2_blockSort ( EState* s ) +{ + UInt32* ptr = s->ptr; + UChar* block = s->block; + UInt32* ftab = s->ftab; + Int32 nblock = s->nblock; + Int32 verb = s->verbosity; + Int32 wfact = s->workFactor; + UInt16* quadrant; + Int32 budget; + Int32 budgetInit; + Int32 i; + + if (nblock < 10000) { + fallbackSort ( s->arr1, s->arr2, ftab, nblock, verb ); + } else { + /* Calculate the location for quadrant, remembering to get + the alignment right. Assumes that &(block[0]) is at least + 2-byte aligned -- this should be ok since block is really + the first section of arr2. + */ + i = nblock+BZ_N_OVERSHOOT; + if (i & 1) i++; + quadrant = (UInt16*)(&(block[i])); + + /* (wfact-1) / 3 puts the default-factor-30 + transition point at very roughly the same place as + with v0.1 and v0.9.0. + Not that it particularly matters any more, since the + resulting compressed stream is now the same regardless + of whether or not we use the main sort or fallback sort. + */ + if (wfact < 1 ) wfact = 1; + if (wfact > 100) wfact = 100; + budgetInit = nblock * ((wfact-1) / 3); + budget = budgetInit; + + mainSort ( ptr, block, quadrant, ftab, nblock, verb, &budget ); + if (verb >= 3) + VPrintf3 ( " %d work, %d block, ratio %5.2f\n", + budgetInit - budget, + nblock, + (float)(budgetInit - budget) / + (float)(nblock==0 ? 1 : nblock) ); + if (budget < 0) { + if (verb >= 2) + VPrintf0 ( " too repetitive; using fallback" + " sorting algorithm\n" ); + fallbackSort ( s->arr1, s->arr2, ftab, nblock, verb ); + } + } + + s->origPtr = -1; + for (i = 0; i < s->nblock; i++) + if (ptr[i] == 0) + { s->origPtr = i; break; }; + + AssertH( s->origPtr != -1, 1003 ); +} + + +/*-------------------------------------------------------------*/ +/*--- end blocksort.c ---*/ +/*-------------------------------------------------------------*/ diff --git a/mk/linux/mojosetup/bzip2/bzlib.c b/mk/linux/mojosetup/bzip2/bzlib.c new file mode 100644 index 00000000..ef86c91e --- /dev/null +++ b/mk/linux/mojosetup/bzip2/bzlib.c @@ -0,0 +1,1572 @@ + +/*-------------------------------------------------------------*/ +/*--- Library top-level functions. ---*/ +/*--- bzlib.c ---*/ +/*-------------------------------------------------------------*/ + +/* ------------------------------------------------------------------ + This file is part of bzip2/libbzip2, a program and library for + lossless, block-sorting data compression. + + bzip2/libbzip2 version 1.0.5 of 10 December 2007 + Copyright (C) 1996-2007 Julian Seward + + Please read the WARNING, DISCLAIMER and PATENTS sections in the + README file. + + This program is released under the terms of the license contained + in the file LICENSE. + ------------------------------------------------------------------ */ + +/* CHANGES + 0.9.0 -- original version. + 0.9.0a/b -- no changes in this file. + 0.9.0c -- made zero-length BZ_FLUSH work correctly in bzCompress(). + fixed bzWrite/bzRead to ignore zero-length requests. + fixed bzread to correctly handle read requests after EOF. + wrong parameter order in call to bzDecompressInit in + bzBuffToBuffDecompress. Fixed. +*/ + +#include "bzlib_private.h" + + +/*---------------------------------------------------*/ +/*--- Compression stuff ---*/ +/*---------------------------------------------------*/ + + +/*---------------------------------------------------*/ +#ifndef BZ_NO_STDIO +void BZ2_bz__AssertH__fail ( int errcode ) +{ + fprintf(stderr, + "\n\nbzip2/libbzip2: internal error number %d.\n" + "This is a bug in bzip2/libbzip2, %s.\n" + "Please report it to me at: jseward@bzip.org. If this happened\n" + "when you were using some program which uses libbzip2 as a\n" + "component, you should also report this bug to the author(s)\n" + "of that program. Please make an effort to report this bug;\n" + "timely and accurate bug reports eventually lead to higher\n" + "quality software. Thanks. Julian Seward, 10 December 2007.\n\n", + errcode, + BZ2_bzlibVersion() + ); + + if (errcode == 1007) { + fprintf(stderr, + "\n*** A special note about internal error number 1007 ***\n" + "\n" + "Experience suggests that a common cause of i.e. 1007\n" + "is unreliable memory or other hardware. The 1007 assertion\n" + "just happens to cross-check the results of huge numbers of\n" + "memory reads/writes, and so acts (unintendedly) as a stress\n" + "test of your memory system.\n" + "\n" + "I suggest the following: try compressing the file again,\n" + "possibly monitoring progress in detail with the -vv flag.\n" + "\n" + "* If the error cannot be reproduced, and/or happens at different\n" + " points in compression, you may have a flaky memory system.\n" + " Try a memory-test program. I have used Memtest86\n" + " (www.memtest86.com). At the time of writing it is free (GPLd).\n" + " Memtest86 tests memory much more thorougly than your BIOSs\n" + " power-on test, and may find failures that the BIOS doesn't.\n" + "\n" + "* If the error can be repeatably reproduced, this is a bug in\n" + " bzip2, and I would very much like to hear about it. Please\n" + " let me know, and, ideally, save a copy of the file causing the\n" + " problem -- without which I will be unable to investigate it.\n" + "\n" + ); + } + + exit(3); +} +#endif + + +/*---------------------------------------------------*/ +static +int bz_config_ok ( void ) +{ + if (sizeof(int) != 4) return 0; + if (sizeof(short) != 2) return 0; + if (sizeof(char) != 1) return 0; + return 1; +} + + +/*---------------------------------------------------*/ +static +void* default_bzalloc ( void* opaque, Int32 items, Int32 size ) +{ + void* v = malloc ( items * size ); + return v; +} + +static +void default_bzfree ( void* opaque, void* addr ) +{ + if (addr != NULL) free ( addr ); +} + + +/*---------------------------------------------------*/ +static +void prepare_new_block ( EState* s ) +{ + Int32 i; + s->nblock = 0; + s->numZ = 0; + s->state_out_pos = 0; + BZ_INITIALISE_CRC ( s->blockCRC ); + for (i = 0; i < 256; i++) s->inUse[i] = False; + s->blockNo++; +} + + +/*---------------------------------------------------*/ +static +void init_RL ( EState* s ) +{ + s->state_in_ch = 256; + s->state_in_len = 0; +} + + +static +Bool isempty_RL ( EState* s ) +{ + if (s->state_in_ch < 256 && s->state_in_len > 0) + return False; else + return True; +} + + +/*---------------------------------------------------*/ +int BZ_API(BZ2_bzCompressInit) + ( bz_stream* strm, + int blockSize100k, + int verbosity, + int workFactor ) +{ + Int32 n; + EState* s; + + if (!bz_config_ok()) return BZ_CONFIG_ERROR; + + if (strm == NULL || + blockSize100k < 1 || blockSize100k > 9 || + workFactor < 0 || workFactor > 250) + return BZ_PARAM_ERROR; + + if (workFactor == 0) workFactor = 30; + if (strm->bzalloc == NULL) strm->bzalloc = default_bzalloc; + if (strm->bzfree == NULL) strm->bzfree = default_bzfree; + + s = BZALLOC( sizeof(EState) ); + if (s == NULL) return BZ_MEM_ERROR; + s->strm = strm; + + s->arr1 = NULL; + s->arr2 = NULL; + s->ftab = NULL; + + n = 100000 * blockSize100k; + s->arr1 = BZALLOC( n * sizeof(UInt32) ); + s->arr2 = BZALLOC( (n+BZ_N_OVERSHOOT) * sizeof(UInt32) ); + s->ftab = BZALLOC( 65537 * sizeof(UInt32) ); + + if (s->arr1 == NULL || s->arr2 == NULL || s->ftab == NULL) { + if (s->arr1 != NULL) BZFREE(s->arr1); + if (s->arr2 != NULL) BZFREE(s->arr2); + if (s->ftab != NULL) BZFREE(s->ftab); + if (s != NULL) BZFREE(s); + return BZ_MEM_ERROR; + } + + s->blockNo = 0; + s->state = BZ_S_INPUT; + s->mode = BZ_M_RUNNING; + s->combinedCRC = 0; + s->blockSize100k = blockSize100k; + s->nblockMAX = 100000 * blockSize100k - 19; + s->verbosity = verbosity; + s->workFactor = workFactor; + + s->block = (UChar*)s->arr2; + s->mtfv = (UInt16*)s->arr1; + s->zbits = NULL; + s->ptr = (UInt32*)s->arr1; + + strm->state = s; + strm->total_in_lo32 = 0; + strm->total_in_hi32 = 0; + strm->total_out_lo32 = 0; + strm->total_out_hi32 = 0; + init_RL ( s ); + prepare_new_block ( s ); + return BZ_OK; +} + + +/*---------------------------------------------------*/ +static +void add_pair_to_block ( EState* s ) +{ + Int32 i; + UChar ch = (UChar)(s->state_in_ch); + for (i = 0; i < s->state_in_len; i++) { + BZ_UPDATE_CRC( s->blockCRC, ch ); + } + s->inUse[s->state_in_ch] = True; + switch (s->state_in_len) { + case 1: + s->block[s->nblock] = (UChar)ch; s->nblock++; + break; + case 2: + s->block[s->nblock] = (UChar)ch; s->nblock++; + s->block[s->nblock] = (UChar)ch; s->nblock++; + break; + case 3: + s->block[s->nblock] = (UChar)ch; s->nblock++; + s->block[s->nblock] = (UChar)ch; s->nblock++; + s->block[s->nblock] = (UChar)ch; s->nblock++; + break; + default: + s->inUse[s->state_in_len-4] = True; + s->block[s->nblock] = (UChar)ch; s->nblock++; + s->block[s->nblock] = (UChar)ch; s->nblock++; + s->block[s->nblock] = (UChar)ch; s->nblock++; + s->block[s->nblock] = (UChar)ch; s->nblock++; + s->block[s->nblock] = ((UChar)(s->state_in_len-4)); + s->nblock++; + break; + } +} + + +/*---------------------------------------------------*/ +static +void flush_RL ( EState* s ) +{ + if (s->state_in_ch < 256) add_pair_to_block ( s ); + init_RL ( s ); +} + + +/*---------------------------------------------------*/ +#define ADD_CHAR_TO_BLOCK(zs,zchh0) \ +{ \ + UInt32 zchh = (UInt32)(zchh0); \ + /*-- fast track the common case --*/ \ + if (zchh != zs->state_in_ch && \ + zs->state_in_len == 1) { \ + UChar ch = (UChar)(zs->state_in_ch); \ + BZ_UPDATE_CRC( zs->blockCRC, ch ); \ + zs->inUse[zs->state_in_ch] = True; \ + zs->block[zs->nblock] = (UChar)ch; \ + zs->nblock++; \ + zs->state_in_ch = zchh; \ + } \ + else \ + /*-- general, uncommon cases --*/ \ + if (zchh != zs->state_in_ch || \ + zs->state_in_len == 255) { \ + if (zs->state_in_ch < 256) \ + add_pair_to_block ( zs ); \ + zs->state_in_ch = zchh; \ + zs->state_in_len = 1; \ + } else { \ + zs->state_in_len++; \ + } \ +} + + +/*---------------------------------------------------*/ +static +Bool copy_input_until_stop ( EState* s ) +{ + Bool progress_in = False; + + if (s->mode == BZ_M_RUNNING) { + + /*-- fast track the common case --*/ + while (True) { + /*-- block full? --*/ + if (s->nblock >= s->nblockMAX) break; + /*-- no input? --*/ + if (s->strm->avail_in == 0) break; + progress_in = True; + ADD_CHAR_TO_BLOCK ( s, (UInt32)(*((UChar*)(s->strm->next_in))) ); + s->strm->next_in++; + s->strm->avail_in--; + s->strm->total_in_lo32++; + if (s->strm->total_in_lo32 == 0) s->strm->total_in_hi32++; + } + + } else { + + /*-- general, uncommon case --*/ + while (True) { + /*-- block full? --*/ + if (s->nblock >= s->nblockMAX) break; + /*-- no input? --*/ + if (s->strm->avail_in == 0) break; + /*-- flush/finish end? --*/ + if (s->avail_in_expect == 0) break; + progress_in = True; + ADD_CHAR_TO_BLOCK ( s, (UInt32)(*((UChar*)(s->strm->next_in))) ); + s->strm->next_in++; + s->strm->avail_in--; + s->strm->total_in_lo32++; + if (s->strm->total_in_lo32 == 0) s->strm->total_in_hi32++; + s->avail_in_expect--; + } + } + return progress_in; +} + + +/*---------------------------------------------------*/ +static +Bool copy_output_until_stop ( EState* s ) +{ + Bool progress_out = False; + + while (True) { + + /*-- no output space? --*/ + if (s->strm->avail_out == 0) break; + + /*-- block done? --*/ + if (s->state_out_pos >= s->numZ) break; + + progress_out = True; + *(s->strm->next_out) = s->zbits[s->state_out_pos]; + s->state_out_pos++; + s->strm->avail_out--; + s->strm->next_out++; + s->strm->total_out_lo32++; + if (s->strm->total_out_lo32 == 0) s->strm->total_out_hi32++; + } + + return progress_out; +} + + +/*---------------------------------------------------*/ +static +Bool handle_compress ( bz_stream* strm ) +{ + Bool progress_in = False; + Bool progress_out = False; + EState* s = strm->state; + + while (True) { + + if (s->state == BZ_S_OUTPUT) { + progress_out |= copy_output_until_stop ( s ); + if (s->state_out_pos < s->numZ) break; + if (s->mode == BZ_M_FINISHING && + s->avail_in_expect == 0 && + isempty_RL(s)) break; + prepare_new_block ( s ); + s->state = BZ_S_INPUT; + if (s->mode == BZ_M_FLUSHING && + s->avail_in_expect == 0 && + isempty_RL(s)) break; + } + + if (s->state == BZ_S_INPUT) { + progress_in |= copy_input_until_stop ( s ); + if (s->mode != BZ_M_RUNNING && s->avail_in_expect == 0) { + flush_RL ( s ); + BZ2_compressBlock ( s, (Bool)(s->mode == BZ_M_FINISHING) ); + s->state = BZ_S_OUTPUT; + } + else + if (s->nblock >= s->nblockMAX) { + BZ2_compressBlock ( s, False ); + s->state = BZ_S_OUTPUT; + } + else + if (s->strm->avail_in == 0) { + break; + } + } + + } + + return progress_in || progress_out; +} + + +/*---------------------------------------------------*/ +int BZ_API(BZ2_bzCompress) ( bz_stream *strm, int action ) +{ + Bool progress; + EState* s; + if (strm == NULL) return BZ_PARAM_ERROR; + s = strm->state; + if (s == NULL) return BZ_PARAM_ERROR; + if (s->strm != strm) return BZ_PARAM_ERROR; + + preswitch: + switch (s->mode) { + + case BZ_M_IDLE: + return BZ_SEQUENCE_ERROR; + + case BZ_M_RUNNING: + if (action == BZ_RUN) { + progress = handle_compress ( strm ); + return progress ? BZ_RUN_OK : BZ_PARAM_ERROR; + } + else + if (action == BZ_FLUSH) { + s->avail_in_expect = strm->avail_in; + s->mode = BZ_M_FLUSHING; + goto preswitch; + } + else + if (action == BZ_FINISH) { + s->avail_in_expect = strm->avail_in; + s->mode = BZ_M_FINISHING; + goto preswitch; + } + else + return BZ_PARAM_ERROR; + + case BZ_M_FLUSHING: + if (action != BZ_FLUSH) return BZ_SEQUENCE_ERROR; + if (s->avail_in_expect != s->strm->avail_in) + return BZ_SEQUENCE_ERROR; + progress = handle_compress ( strm ); + if (s->avail_in_expect > 0 || !isempty_RL(s) || + s->state_out_pos < s->numZ) return BZ_FLUSH_OK; + s->mode = BZ_M_RUNNING; + return BZ_RUN_OK; + + case BZ_M_FINISHING: + if (action != BZ_FINISH) return BZ_SEQUENCE_ERROR; + if (s->avail_in_expect != s->strm->avail_in) + return BZ_SEQUENCE_ERROR; + progress = handle_compress ( strm ); + if (!progress) return BZ_SEQUENCE_ERROR; + if (s->avail_in_expect > 0 || !isempty_RL(s) || + s->state_out_pos < s->numZ) return BZ_FINISH_OK; + s->mode = BZ_M_IDLE; + return BZ_STREAM_END; + } + return BZ_OK; /*--not reached--*/ +} + + +/*---------------------------------------------------*/ +int BZ_API(BZ2_bzCompressEnd) ( bz_stream *strm ) +{ + EState* s; + if (strm == NULL) return BZ_PARAM_ERROR; + s = strm->state; + if (s == NULL) return BZ_PARAM_ERROR; + if (s->strm != strm) return BZ_PARAM_ERROR; + + if (s->arr1 != NULL) BZFREE(s->arr1); + if (s->arr2 != NULL) BZFREE(s->arr2); + if (s->ftab != NULL) BZFREE(s->ftab); + BZFREE(strm->state); + + strm->state = NULL; + + return BZ_OK; +} + + +/*---------------------------------------------------*/ +/*--- Decompression stuff ---*/ +/*---------------------------------------------------*/ + +/*---------------------------------------------------*/ +int BZ_API(BZ2_bzDecompressInit) + ( bz_stream* strm, + int verbosity, + int small ) +{ + DState* s; + + if (!bz_config_ok()) return BZ_CONFIG_ERROR; + + if (strm == NULL) return BZ_PARAM_ERROR; + if (small != 0 && small != 1) return BZ_PARAM_ERROR; + if (verbosity < 0 || verbosity > 4) return BZ_PARAM_ERROR; + + if (strm->bzalloc == NULL) strm->bzalloc = default_bzalloc; + if (strm->bzfree == NULL) strm->bzfree = default_bzfree; + + s = BZALLOC( sizeof(DState) ); + if (s == NULL) return BZ_MEM_ERROR; + s->strm = strm; + strm->state = s; + s->state = BZ_X_MAGIC_1; + s->bsLive = 0; + s->bsBuff = 0; + s->calculatedCombinedCRC = 0; + strm->total_in_lo32 = 0; + strm->total_in_hi32 = 0; + strm->total_out_lo32 = 0; + strm->total_out_hi32 = 0; + s->smallDecompress = (Bool)small; + s->ll4 = NULL; + s->ll16 = NULL; + s->tt = NULL; + s->currBlockNo = 0; + s->verbosity = verbosity; + + return BZ_OK; +} + + +/*---------------------------------------------------*/ +/* Return True iff data corruption is discovered. + Returns False if there is no problem. +*/ +static +Bool unRLE_obuf_to_output_FAST ( DState* s ) +{ + UChar k1; + + if (s->blockRandomised) { + + while (True) { + /* try to finish existing run */ + while (True) { + if (s->strm->avail_out == 0) return False; + if (s->state_out_len == 0) break; + *( (UChar*)(s->strm->next_out) ) = s->state_out_ch; + BZ_UPDATE_CRC ( s->calculatedBlockCRC, s->state_out_ch ); + s->state_out_len--; + s->strm->next_out++; + s->strm->avail_out--; + s->strm->total_out_lo32++; + if (s->strm->total_out_lo32 == 0) s->strm->total_out_hi32++; + } + + /* can a new run be started? */ + if (s->nblock_used == s->save_nblock+1) return False; + + /* Only caused by corrupt data stream? */ + if (s->nblock_used > s->save_nblock+1) + return True; + + s->state_out_len = 1; + s->state_out_ch = s->k0; + BZ_GET_FAST(k1); BZ_RAND_UPD_MASK; + k1 ^= BZ_RAND_MASK; s->nblock_used++; + if (s->nblock_used == s->save_nblock+1) continue; + if (k1 != s->k0) { s->k0 = k1; continue; }; + + s->state_out_len = 2; + BZ_GET_FAST(k1); BZ_RAND_UPD_MASK; + k1 ^= BZ_RAND_MASK; s->nblock_used++; + if (s->nblock_used == s->save_nblock+1) continue; + if (k1 != s->k0) { s->k0 = k1; continue; }; + + s->state_out_len = 3; + BZ_GET_FAST(k1); BZ_RAND_UPD_MASK; + k1 ^= BZ_RAND_MASK; s->nblock_used++; + if (s->nblock_used == s->save_nblock+1) continue; + if (k1 != s->k0) { s->k0 = k1; continue; }; + + BZ_GET_FAST(k1); BZ_RAND_UPD_MASK; + k1 ^= BZ_RAND_MASK; s->nblock_used++; + s->state_out_len = ((Int32)k1) + 4; + BZ_GET_FAST(s->k0); BZ_RAND_UPD_MASK; + s->k0 ^= BZ_RAND_MASK; s->nblock_used++; + } + + } else { + + /* restore */ + UInt32 c_calculatedBlockCRC = s->calculatedBlockCRC; + UChar c_state_out_ch = s->state_out_ch; + Int32 c_state_out_len = s->state_out_len; + Int32 c_nblock_used = s->nblock_used; + Int32 c_k0 = s->k0; + UInt32* c_tt = s->tt; + UInt32 c_tPos = s->tPos; + char* cs_next_out = s->strm->next_out; + unsigned int cs_avail_out = s->strm->avail_out; + Int32 ro_blockSize100k = s->blockSize100k; + /* end restore */ + + UInt32 avail_out_INIT = cs_avail_out; + Int32 s_save_nblockPP = s->save_nblock+1; + unsigned int total_out_lo32_old; + + while (True) { + + /* try to finish existing run */ + if (c_state_out_len > 0) { + while (True) { + if (cs_avail_out == 0) goto return_notr; + if (c_state_out_len == 1) break; + *( (UChar*)(cs_next_out) ) = c_state_out_ch; + BZ_UPDATE_CRC ( c_calculatedBlockCRC, c_state_out_ch ); + c_state_out_len--; + cs_next_out++; + cs_avail_out--; + } + s_state_out_len_eq_one: + { + if (cs_avail_out == 0) { + c_state_out_len = 1; goto return_notr; + }; + *( (UChar*)(cs_next_out) ) = c_state_out_ch; + BZ_UPDATE_CRC ( c_calculatedBlockCRC, c_state_out_ch ); + cs_next_out++; + cs_avail_out--; + } + } + /* Only caused by corrupt data stream? */ + if (c_nblock_used > s_save_nblockPP) + return True; + + /* can a new run be started? */ + if (c_nblock_used == s_save_nblockPP) { + c_state_out_len = 0; goto return_notr; + }; + c_state_out_ch = c_k0; + BZ_GET_FAST_C(k1); c_nblock_used++; + if (k1 != c_k0) { + c_k0 = k1; goto s_state_out_len_eq_one; + }; + if (c_nblock_used == s_save_nblockPP) + goto s_state_out_len_eq_one; + + c_state_out_len = 2; + BZ_GET_FAST_C(k1); c_nblock_used++; + if (c_nblock_used == s_save_nblockPP) continue; + if (k1 != c_k0) { c_k0 = k1; continue; }; + + c_state_out_len = 3; + BZ_GET_FAST_C(k1); c_nblock_used++; + if (c_nblock_used == s_save_nblockPP) continue; + if (k1 != c_k0) { c_k0 = k1; continue; }; + + BZ_GET_FAST_C(k1); c_nblock_used++; + c_state_out_len = ((Int32)k1) + 4; + BZ_GET_FAST_C(c_k0); c_nblock_used++; + } + + return_notr: + total_out_lo32_old = s->strm->total_out_lo32; + s->strm->total_out_lo32 += (avail_out_INIT - cs_avail_out); + if (s->strm->total_out_lo32 < total_out_lo32_old) + s->strm->total_out_hi32++; + + /* save */ + s->calculatedBlockCRC = c_calculatedBlockCRC; + s->state_out_ch = c_state_out_ch; + s->state_out_len = c_state_out_len; + s->nblock_used = c_nblock_used; + s->k0 = c_k0; + s->tt = c_tt; + s->tPos = c_tPos; + s->strm->next_out = cs_next_out; + s->strm->avail_out = cs_avail_out; + /* end save */ + } + return False; +} + + + +/*---------------------------------------------------*/ +__inline__ Int32 BZ2_indexIntoF ( Int32 indx, Int32 *cftab ) +{ + Int32 nb, na, mid; + nb = 0; + na = 256; + do { + mid = (nb + na) >> 1; + if (indx >= cftab[mid]) nb = mid; else na = mid; + } + while (na - nb != 1); + return nb; +} + + +/*---------------------------------------------------*/ +/* Return True iff data corruption is discovered. + Returns False if there is no problem. +*/ +static +Bool unRLE_obuf_to_output_SMALL ( DState* s ) +{ + UChar k1; + + if (s->blockRandomised) { + + while (True) { + /* try to finish existing run */ + while (True) { + if (s->strm->avail_out == 0) return False; + if (s->state_out_len == 0) break; + *( (UChar*)(s->strm->next_out) ) = s->state_out_ch; + BZ_UPDATE_CRC ( s->calculatedBlockCRC, s->state_out_ch ); + s->state_out_len--; + s->strm->next_out++; + s->strm->avail_out--; + s->strm->total_out_lo32++; + if (s->strm->total_out_lo32 == 0) s->strm->total_out_hi32++; + } + + /* can a new run be started? */ + if (s->nblock_used == s->save_nblock+1) return False; + + /* Only caused by corrupt data stream? */ + if (s->nblock_used > s->save_nblock+1) + return True; + + s->state_out_len = 1; + s->state_out_ch = s->k0; + BZ_GET_SMALL(k1); BZ_RAND_UPD_MASK; + k1 ^= BZ_RAND_MASK; s->nblock_used++; + if (s->nblock_used == s->save_nblock+1) continue; + if (k1 != s->k0) { s->k0 = k1; continue; }; + + s->state_out_len = 2; + BZ_GET_SMALL(k1); BZ_RAND_UPD_MASK; + k1 ^= BZ_RAND_MASK; s->nblock_used++; + if (s->nblock_used == s->save_nblock+1) continue; + if (k1 != s->k0) { s->k0 = k1; continue; }; + + s->state_out_len = 3; + BZ_GET_SMALL(k1); BZ_RAND_UPD_MASK; + k1 ^= BZ_RAND_MASK; s->nblock_used++; + if (s->nblock_used == s->save_nblock+1) continue; + if (k1 != s->k0) { s->k0 = k1; continue; }; + + BZ_GET_SMALL(k1); BZ_RAND_UPD_MASK; + k1 ^= BZ_RAND_MASK; s->nblock_used++; + s->state_out_len = ((Int32)k1) + 4; + BZ_GET_SMALL(s->k0); BZ_RAND_UPD_MASK; + s->k0 ^= BZ_RAND_MASK; s->nblock_used++; + } + + } else { + + while (True) { + /* try to finish existing run */ + while (True) { + if (s->strm->avail_out == 0) return False; + if (s->state_out_len == 0) break; + *( (UChar*)(s->strm->next_out) ) = s->state_out_ch; + BZ_UPDATE_CRC ( s->calculatedBlockCRC, s->state_out_ch ); + s->state_out_len--; + s->strm->next_out++; + s->strm->avail_out--; + s->strm->total_out_lo32++; + if (s->strm->total_out_lo32 == 0) s->strm->total_out_hi32++; + } + + /* can a new run be started? */ + if (s->nblock_used == s->save_nblock+1) return False; + + /* Only caused by corrupt data stream? */ + if (s->nblock_used > s->save_nblock+1) + return True; + + s->state_out_len = 1; + s->state_out_ch = s->k0; + BZ_GET_SMALL(k1); s->nblock_used++; + if (s->nblock_used == s->save_nblock+1) continue; + if (k1 != s->k0) { s->k0 = k1; continue; }; + + s->state_out_len = 2; + BZ_GET_SMALL(k1); s->nblock_used++; + if (s->nblock_used == s->save_nblock+1) continue; + if (k1 != s->k0) { s->k0 = k1; continue; }; + + s->state_out_len = 3; + BZ_GET_SMALL(k1); s->nblock_used++; + if (s->nblock_used == s->save_nblock+1) continue; + if (k1 != s->k0) { s->k0 = k1; continue; }; + + BZ_GET_SMALL(k1); s->nblock_used++; + s->state_out_len = ((Int32)k1) + 4; + BZ_GET_SMALL(s->k0); s->nblock_used++; + } + + } +} + + +/*---------------------------------------------------*/ +int BZ_API(BZ2_bzDecompress) ( bz_stream *strm ) +{ + Bool corrupt; + DState* s; + if (strm == NULL) return BZ_PARAM_ERROR; + s = strm->state; + if (s == NULL) return BZ_PARAM_ERROR; + if (s->strm != strm) return BZ_PARAM_ERROR; + + while (True) { + if (s->state == BZ_X_IDLE) return BZ_SEQUENCE_ERROR; + if (s->state == BZ_X_OUTPUT) { + if (s->smallDecompress) + corrupt = unRLE_obuf_to_output_SMALL ( s ); else + corrupt = unRLE_obuf_to_output_FAST ( s ); + if (corrupt) return BZ_DATA_ERROR; + if (s->nblock_used == s->save_nblock+1 && s->state_out_len == 0) { + BZ_FINALISE_CRC ( s->calculatedBlockCRC ); + if (s->verbosity >= 3) + VPrintf2 ( " {0x%08x, 0x%08x}", s->storedBlockCRC, + s->calculatedBlockCRC ); + if (s->verbosity >= 2) VPrintf0 ( "]" ); + if (s->calculatedBlockCRC != s->storedBlockCRC) + return BZ_DATA_ERROR; + s->calculatedCombinedCRC + = (s->calculatedCombinedCRC << 1) | + (s->calculatedCombinedCRC >> 31); + s->calculatedCombinedCRC ^= s->calculatedBlockCRC; + s->state = BZ_X_BLKHDR_1; + } else { + return BZ_OK; + } + } + if (s->state >= BZ_X_MAGIC_1) { + Int32 r = BZ2_decompress ( s ); + if (r == BZ_STREAM_END) { + if (s->verbosity >= 3) + VPrintf2 ( "\n combined CRCs: stored = 0x%08x, computed = 0x%08x", + s->storedCombinedCRC, s->calculatedCombinedCRC ); + if (s->calculatedCombinedCRC != s->storedCombinedCRC) + return BZ_DATA_ERROR; + return r; + } + if (s->state != BZ_X_OUTPUT) return r; + } + } + + AssertH ( 0, 6001 ); + + return 0; /*NOTREACHED*/ +} + + +/*---------------------------------------------------*/ +int BZ_API(BZ2_bzDecompressEnd) ( bz_stream *strm ) +{ + DState* s; + if (strm == NULL) return BZ_PARAM_ERROR; + s = strm->state; + if (s == NULL) return BZ_PARAM_ERROR; + if (s->strm != strm) return BZ_PARAM_ERROR; + + if (s->tt != NULL) BZFREE(s->tt); + if (s->ll16 != NULL) BZFREE(s->ll16); + if (s->ll4 != NULL) BZFREE(s->ll4); + + BZFREE(strm->state); + strm->state = NULL; + + return BZ_OK; +} + + +#ifndef BZ_NO_STDIO +/*---------------------------------------------------*/ +/*--- File I/O stuff ---*/ +/*---------------------------------------------------*/ + +#define BZ_SETERR(eee) \ +{ \ + if (bzerror != NULL) *bzerror = eee; \ + if (bzf != NULL) bzf->lastErr = eee; \ +} + +typedef + struct { + FILE* handle; + Char buf[BZ_MAX_UNUSED]; + Int32 bufN; + Bool writing; + bz_stream strm; + Int32 lastErr; + Bool initialisedOk; + } + bzFile; + + +/*---------------------------------------------*/ +static Bool myfeof ( FILE* f ) +{ + Int32 c = fgetc ( f ); + if (c == EOF) return True; + ungetc ( c, f ); + return False; +} + + +/*---------------------------------------------------*/ +BZFILE* BZ_API(BZ2_bzWriteOpen) + ( int* bzerror, + FILE* f, + int blockSize100k, + int verbosity, + int workFactor ) +{ + Int32 ret; + bzFile* bzf = NULL; + + BZ_SETERR(BZ_OK); + + if (f == NULL || + (blockSize100k < 1 || blockSize100k > 9) || + (workFactor < 0 || workFactor > 250) || + (verbosity < 0 || verbosity > 4)) + { BZ_SETERR(BZ_PARAM_ERROR); return NULL; }; + + if (ferror(f)) + { BZ_SETERR(BZ_IO_ERROR); return NULL; }; + + bzf = malloc ( sizeof(bzFile) ); + if (bzf == NULL) + { BZ_SETERR(BZ_MEM_ERROR); return NULL; }; + + BZ_SETERR(BZ_OK); + bzf->initialisedOk = False; + bzf->bufN = 0; + bzf->handle = f; + bzf->writing = True; + bzf->strm.bzalloc = NULL; + bzf->strm.bzfree = NULL; + bzf->strm.opaque = NULL; + + if (workFactor == 0) workFactor = 30; + ret = BZ2_bzCompressInit ( &(bzf->strm), blockSize100k, + verbosity, workFactor ); + if (ret != BZ_OK) + { BZ_SETERR(ret); free(bzf); return NULL; }; + + bzf->strm.avail_in = 0; + bzf->initialisedOk = True; + return bzf; +} + + + +/*---------------------------------------------------*/ +void BZ_API(BZ2_bzWrite) + ( int* bzerror, + BZFILE* b, + void* buf, + int len ) +{ + Int32 n, n2, ret; + bzFile* bzf = (bzFile*)b; + + BZ_SETERR(BZ_OK); + if (bzf == NULL || buf == NULL || len < 0) + { BZ_SETERR(BZ_PARAM_ERROR); return; }; + if (!(bzf->writing)) + { BZ_SETERR(BZ_SEQUENCE_ERROR); return; }; + if (ferror(bzf->handle)) + { BZ_SETERR(BZ_IO_ERROR); return; }; + + if (len == 0) + { BZ_SETERR(BZ_OK); return; }; + + bzf->strm.avail_in = len; + bzf->strm.next_in = buf; + + while (True) { + bzf->strm.avail_out = BZ_MAX_UNUSED; + bzf->strm.next_out = bzf->buf; + ret = BZ2_bzCompress ( &(bzf->strm), BZ_RUN ); + if (ret != BZ_RUN_OK) + { BZ_SETERR(ret); return; }; + + if (bzf->strm.avail_out < BZ_MAX_UNUSED) { + n = BZ_MAX_UNUSED - bzf->strm.avail_out; + n2 = fwrite ( (void*)(bzf->buf), sizeof(UChar), + n, bzf->handle ); + if (n != n2 || ferror(bzf->handle)) + { BZ_SETERR(BZ_IO_ERROR); return; }; + } + + if (bzf->strm.avail_in == 0) + { BZ_SETERR(BZ_OK); return; }; + } +} + + +/*---------------------------------------------------*/ +void BZ_API(BZ2_bzWriteClose) + ( int* bzerror, + BZFILE* b, + int abandon, + unsigned int* nbytes_in, + unsigned int* nbytes_out ) +{ + BZ2_bzWriteClose64 ( bzerror, b, abandon, + nbytes_in, NULL, nbytes_out, NULL ); +} + + +void BZ_API(BZ2_bzWriteClose64) + ( int* bzerror, + BZFILE* b, + int abandon, + unsigned int* nbytes_in_lo32, + unsigned int* nbytes_in_hi32, + unsigned int* nbytes_out_lo32, + unsigned int* nbytes_out_hi32 ) +{ + Int32 n, n2, ret; + bzFile* bzf = (bzFile*)b; + + if (bzf == NULL) + { BZ_SETERR(BZ_OK); return; }; + if (!(bzf->writing)) + { BZ_SETERR(BZ_SEQUENCE_ERROR); return; }; + if (ferror(bzf->handle)) + { BZ_SETERR(BZ_IO_ERROR); return; }; + + if (nbytes_in_lo32 != NULL) *nbytes_in_lo32 = 0; + if (nbytes_in_hi32 != NULL) *nbytes_in_hi32 = 0; + if (nbytes_out_lo32 != NULL) *nbytes_out_lo32 = 0; + if (nbytes_out_hi32 != NULL) *nbytes_out_hi32 = 0; + + if ((!abandon) && bzf->lastErr == BZ_OK) { + while (True) { + bzf->strm.avail_out = BZ_MAX_UNUSED; + bzf->strm.next_out = bzf->buf; + ret = BZ2_bzCompress ( &(bzf->strm), BZ_FINISH ); + if (ret != BZ_FINISH_OK && ret != BZ_STREAM_END) + { BZ_SETERR(ret); return; }; + + if (bzf->strm.avail_out < BZ_MAX_UNUSED) { + n = BZ_MAX_UNUSED - bzf->strm.avail_out; + n2 = fwrite ( (void*)(bzf->buf), sizeof(UChar), + n, bzf->handle ); + if (n != n2 || ferror(bzf->handle)) + { BZ_SETERR(BZ_IO_ERROR); return; }; + } + + if (ret == BZ_STREAM_END) break; + } + } + + if ( !abandon && !ferror ( bzf->handle ) ) { + fflush ( bzf->handle ); + if (ferror(bzf->handle)) + { BZ_SETERR(BZ_IO_ERROR); return; }; + } + + if (nbytes_in_lo32 != NULL) + *nbytes_in_lo32 = bzf->strm.total_in_lo32; + if (nbytes_in_hi32 != NULL) + *nbytes_in_hi32 = bzf->strm.total_in_hi32; + if (nbytes_out_lo32 != NULL) + *nbytes_out_lo32 = bzf->strm.total_out_lo32; + if (nbytes_out_hi32 != NULL) + *nbytes_out_hi32 = bzf->strm.total_out_hi32; + + BZ_SETERR(BZ_OK); + BZ2_bzCompressEnd ( &(bzf->strm) ); + free ( bzf ); +} + + +/*---------------------------------------------------*/ +BZFILE* BZ_API(BZ2_bzReadOpen) + ( int* bzerror, + FILE* f, + int verbosity, + int small, + void* unused, + int nUnused ) +{ + bzFile* bzf = NULL; + int ret; + + BZ_SETERR(BZ_OK); + + if (f == NULL || + (small != 0 && small != 1) || + (verbosity < 0 || verbosity > 4) || + (unused == NULL && nUnused != 0) || + (unused != NULL && (nUnused < 0 || nUnused > BZ_MAX_UNUSED))) + { BZ_SETERR(BZ_PARAM_ERROR); return NULL; }; + + if (ferror(f)) + { BZ_SETERR(BZ_IO_ERROR); return NULL; }; + + bzf = malloc ( sizeof(bzFile) ); + if (bzf == NULL) + { BZ_SETERR(BZ_MEM_ERROR); return NULL; }; + + BZ_SETERR(BZ_OK); + + bzf->initialisedOk = False; + bzf->handle = f; + bzf->bufN = 0; + bzf->writing = False; + bzf->strm.bzalloc = NULL; + bzf->strm.bzfree = NULL; + bzf->strm.opaque = NULL; + + while (nUnused > 0) { + bzf->buf[bzf->bufN] = *((UChar*)(unused)); bzf->bufN++; + unused = ((void*)( 1 + ((UChar*)(unused)) )); + nUnused--; + } + + ret = BZ2_bzDecompressInit ( &(bzf->strm), verbosity, small ); + if (ret != BZ_OK) + { BZ_SETERR(ret); free(bzf); return NULL; }; + + bzf->strm.avail_in = bzf->bufN; + bzf->strm.next_in = bzf->buf; + + bzf->initialisedOk = True; + return bzf; +} + + +/*---------------------------------------------------*/ +void BZ_API(BZ2_bzReadClose) ( int *bzerror, BZFILE *b ) +{ + bzFile* bzf = (bzFile*)b; + + BZ_SETERR(BZ_OK); + if (bzf == NULL) + { BZ_SETERR(BZ_OK); return; }; + + if (bzf->writing) + { BZ_SETERR(BZ_SEQUENCE_ERROR); return; }; + + if (bzf->initialisedOk) + (void)BZ2_bzDecompressEnd ( &(bzf->strm) ); + free ( bzf ); +} + + +/*---------------------------------------------------*/ +int BZ_API(BZ2_bzRead) + ( int* bzerror, + BZFILE* b, + void* buf, + int len ) +{ + Int32 n, ret; + bzFile* bzf = (bzFile*)b; + + BZ_SETERR(BZ_OK); + + if (bzf == NULL || buf == NULL || len < 0) + { BZ_SETERR(BZ_PARAM_ERROR); return 0; }; + + if (bzf->writing) + { BZ_SETERR(BZ_SEQUENCE_ERROR); return 0; }; + + if (len == 0) + { BZ_SETERR(BZ_OK); return 0; }; + + bzf->strm.avail_out = len; + bzf->strm.next_out = buf; + + while (True) { + + if (ferror(bzf->handle)) + { BZ_SETERR(BZ_IO_ERROR); return 0; }; + + if (bzf->strm.avail_in == 0 && !myfeof(bzf->handle)) { + n = fread ( bzf->buf, sizeof(UChar), + BZ_MAX_UNUSED, bzf->handle ); + if (ferror(bzf->handle)) + { BZ_SETERR(BZ_IO_ERROR); return 0; }; + bzf->bufN = n; + bzf->strm.avail_in = bzf->bufN; + bzf->strm.next_in = bzf->buf; + } + + ret = BZ2_bzDecompress ( &(bzf->strm) ); + + if (ret != BZ_OK && ret != BZ_STREAM_END) + { BZ_SETERR(ret); return 0; }; + + if (ret == BZ_OK && myfeof(bzf->handle) && + bzf->strm.avail_in == 0 && bzf->strm.avail_out > 0) + { BZ_SETERR(BZ_UNEXPECTED_EOF); return 0; }; + + if (ret == BZ_STREAM_END) + { BZ_SETERR(BZ_STREAM_END); + return len - bzf->strm.avail_out; }; + if (bzf->strm.avail_out == 0) + { BZ_SETERR(BZ_OK); return len; }; + + } + + return 0; /*not reached*/ +} + + +/*---------------------------------------------------*/ +void BZ_API(BZ2_bzReadGetUnused) + ( int* bzerror, + BZFILE* b, + void** unused, + int* nUnused ) +{ + bzFile* bzf = (bzFile*)b; + if (bzf == NULL) + { BZ_SETERR(BZ_PARAM_ERROR); return; }; + if (bzf->lastErr != BZ_STREAM_END) + { BZ_SETERR(BZ_SEQUENCE_ERROR); return; }; + if (unused == NULL || nUnused == NULL) + { BZ_SETERR(BZ_PARAM_ERROR); return; }; + + BZ_SETERR(BZ_OK); + *nUnused = bzf->strm.avail_in; + *unused = bzf->strm.next_in; +} +#endif + + +/*---------------------------------------------------*/ +/*--- Misc convenience stuff ---*/ +/*---------------------------------------------------*/ + +/*---------------------------------------------------*/ +int BZ_API(BZ2_bzBuffToBuffCompress) + ( char* dest, + unsigned int* destLen, + char* source, + unsigned int sourceLen, + int blockSize100k, + int verbosity, + int workFactor ) +{ + bz_stream strm; + int ret; + + if (dest == NULL || destLen == NULL || + source == NULL || + blockSize100k < 1 || blockSize100k > 9 || + verbosity < 0 || verbosity > 4 || + workFactor < 0 || workFactor > 250) + return BZ_PARAM_ERROR; + + if (workFactor == 0) workFactor = 30; + strm.bzalloc = NULL; + strm.bzfree = NULL; + strm.opaque = NULL; + ret = BZ2_bzCompressInit ( &strm, blockSize100k, + verbosity, workFactor ); + if (ret != BZ_OK) return ret; + + strm.next_in = source; + strm.next_out = dest; + strm.avail_in = sourceLen; + strm.avail_out = *destLen; + + ret = BZ2_bzCompress ( &strm, BZ_FINISH ); + if (ret == BZ_FINISH_OK) goto output_overflow; + if (ret != BZ_STREAM_END) goto errhandler; + + /* normal termination */ + *destLen -= strm.avail_out; + BZ2_bzCompressEnd ( &strm ); + return BZ_OK; + + output_overflow: + BZ2_bzCompressEnd ( &strm ); + return BZ_OUTBUFF_FULL; + + errhandler: + BZ2_bzCompressEnd ( &strm ); + return ret; +} + + +/*---------------------------------------------------*/ +int BZ_API(BZ2_bzBuffToBuffDecompress) + ( char* dest, + unsigned int* destLen, + char* source, + unsigned int sourceLen, + int small, + int verbosity ) +{ + bz_stream strm; + int ret; + + if (dest == NULL || destLen == NULL || + source == NULL || + (small != 0 && small != 1) || + verbosity < 0 || verbosity > 4) + return BZ_PARAM_ERROR; + + strm.bzalloc = NULL; + strm.bzfree = NULL; + strm.opaque = NULL; + ret = BZ2_bzDecompressInit ( &strm, verbosity, small ); + if (ret != BZ_OK) return ret; + + strm.next_in = source; + strm.next_out = dest; + strm.avail_in = sourceLen; + strm.avail_out = *destLen; + + ret = BZ2_bzDecompress ( &strm ); + if (ret == BZ_OK) goto output_overflow_or_eof; + if (ret != BZ_STREAM_END) goto errhandler; + + /* normal termination */ + *destLen -= strm.avail_out; + BZ2_bzDecompressEnd ( &strm ); + return BZ_OK; + + output_overflow_or_eof: + if (strm.avail_out > 0) { + BZ2_bzDecompressEnd ( &strm ); + return BZ_UNEXPECTED_EOF; + } else { + BZ2_bzDecompressEnd ( &strm ); + return BZ_OUTBUFF_FULL; + }; + + errhandler: + BZ2_bzDecompressEnd ( &strm ); + return ret; +} + + +/*---------------------------------------------------*/ +/*-- + Code contributed by Yoshioka Tsuneo (tsuneo@rr.iij4u.or.jp) + to support better zlib compatibility. + This code is not _officially_ part of libbzip2 (yet); + I haven't tested it, documented it, or considered the + threading-safeness of it. + If this code breaks, please contact both Yoshioka and me. +--*/ +/*---------------------------------------------------*/ + +/*---------------------------------------------------*/ +/*-- + return version like "0.9.5d, 4-Sept-1999". +--*/ +const char * BZ_API(BZ2_bzlibVersion)(void) +{ + return BZ_VERSION; +} + + +#ifndef BZ_NO_STDIO +/*---------------------------------------------------*/ + +#if defined(_WIN32) || defined(OS2) || defined(MSDOS) +# include +# include +# define SET_BINARY_MODE(file) setmode(fileno(file),O_BINARY) +#else +# define SET_BINARY_MODE(file) +#endif +static +BZFILE * bzopen_or_bzdopen + ( const char *path, /* no use when bzdopen */ + int fd, /* no use when bzdopen */ + const char *mode, + int open_mode) /* bzopen: 0, bzdopen:1 */ +{ + int bzerr; + char unused[BZ_MAX_UNUSED]; + int blockSize100k = 9; + int writing = 0; + char mode2[10] = ""; + FILE *fp = NULL; + BZFILE *bzfp = NULL; + int verbosity = 0; + int workFactor = 30; + int smallMode = 0; + int nUnused = 0; + + if (mode == NULL) return NULL; + while (*mode) { + switch (*mode) { + case 'r': + writing = 0; break; + case 'w': + writing = 1; break; + case 's': + smallMode = 1; break; + default: + if (isdigit((int)(*mode))) { + blockSize100k = *mode-BZ_HDR_0; + } + } + mode++; + } + strcat(mode2, writing ? "w" : "r" ); + strcat(mode2,"b"); /* binary mode */ + + if (open_mode==0) { + if (path==NULL || strcmp(path,"")==0) { + fp = (writing ? stdout : stdin); + SET_BINARY_MODE(fp); + } else { + fp = fopen(path,mode2); + } + } else { +#ifdef BZ_STRICT_ANSI + fp = NULL; +#else + fp = fdopen(fd,mode2); +#endif + } + if (fp == NULL) return NULL; + + if (writing) { + /* Guard against total chaos and anarchy -- JRS */ + if (blockSize100k < 1) blockSize100k = 1; + if (blockSize100k > 9) blockSize100k = 9; + bzfp = BZ2_bzWriteOpen(&bzerr,fp,blockSize100k, + verbosity,workFactor); + } else { + bzfp = BZ2_bzReadOpen(&bzerr,fp,verbosity,smallMode, + unused,nUnused); + } + if (bzfp == NULL) { + if (fp != stdin && fp != stdout) fclose(fp); + return NULL; + } + return bzfp; +} + + +/*---------------------------------------------------*/ +/*-- + open file for read or write. + ex) bzopen("file","w9") + case path="" or NULL => use stdin or stdout. +--*/ +BZFILE * BZ_API(BZ2_bzopen) + ( const char *path, + const char *mode ) +{ + return bzopen_or_bzdopen(path,-1,mode,/*bzopen*/0); +} + + +/*---------------------------------------------------*/ +BZFILE * BZ_API(BZ2_bzdopen) + ( int fd, + const char *mode ) +{ + return bzopen_or_bzdopen(NULL,fd,mode,/*bzdopen*/1); +} + + +/*---------------------------------------------------*/ +int BZ_API(BZ2_bzread) (BZFILE* b, void* buf, int len ) +{ + int bzerr, nread; + if (((bzFile*)b)->lastErr == BZ_STREAM_END) return 0; + nread = BZ2_bzRead(&bzerr,b,buf,len); + if (bzerr == BZ_OK || bzerr == BZ_STREAM_END) { + return nread; + } else { + return -1; + } +} + + +/*---------------------------------------------------*/ +int BZ_API(BZ2_bzwrite) (BZFILE* b, void* buf, int len ) +{ + int bzerr; + + BZ2_bzWrite(&bzerr,b,buf,len); + if(bzerr == BZ_OK){ + return len; + }else{ + return -1; + } +} + + +/*---------------------------------------------------*/ +int BZ_API(BZ2_bzflush) (BZFILE *b) +{ + /* do nothing now... */ + return 0; +} + + +/*---------------------------------------------------*/ +void BZ_API(BZ2_bzclose) (BZFILE* b) +{ + int bzerr; + FILE *fp; + + if (b==NULL) {return;} + fp = ((bzFile *)b)->handle; + if(((bzFile*)b)->writing){ + BZ2_bzWriteClose(&bzerr,b,0,NULL,NULL); + if(bzerr != BZ_OK){ + BZ2_bzWriteClose(NULL,b,1,NULL,NULL); + } + }else{ + BZ2_bzReadClose(&bzerr,b); + } + if(fp!=stdin && fp!=stdout){ + fclose(fp); + } +} + + +/*---------------------------------------------------*/ +/*-- + return last error code +--*/ +static const char *bzerrorstrings[] = { + "OK" + ,"SEQUENCE_ERROR" + ,"PARAM_ERROR" + ,"MEM_ERROR" + ,"DATA_ERROR" + ,"DATA_ERROR_MAGIC" + ,"IO_ERROR" + ,"UNEXPECTED_EOF" + ,"OUTBUFF_FULL" + ,"CONFIG_ERROR" + ,"???" /* for future */ + ,"???" /* for future */ + ,"???" /* for future */ + ,"???" /* for future */ + ,"???" /* for future */ + ,"???" /* for future */ +}; + + +const char * BZ_API(BZ2_bzerror) (BZFILE *b, int *errnum) +{ + int err = ((bzFile *)b)->lastErr; + + if(err>0) err = 0; + *errnum = err; + return bzerrorstrings[err*-1]; +} +#endif + + +/*-------------------------------------------------------------*/ +/*--- end bzlib.c ---*/ +/*-------------------------------------------------------------*/ diff --git a/mk/linux/mojosetup/bzip2/bzlib.h b/mk/linux/mojosetup/bzip2/bzlib.h new file mode 100644 index 00000000..c5b75d6d --- /dev/null +++ b/mk/linux/mojosetup/bzip2/bzlib.h @@ -0,0 +1,282 @@ + +/*-------------------------------------------------------------*/ +/*--- Public header file for the library. ---*/ +/*--- bzlib.h ---*/ +/*-------------------------------------------------------------*/ + +/* ------------------------------------------------------------------ + This file is part of bzip2/libbzip2, a program and library for + lossless, block-sorting data compression. + + bzip2/libbzip2 version 1.0.5 of 10 December 2007 + Copyright (C) 1996-2007 Julian Seward + + Please read the WARNING, DISCLAIMER and PATENTS sections in the + README file. + + This program is released under the terms of the license contained + in the file LICENSE. + ------------------------------------------------------------------ */ + + +#ifndef _BZLIB_H +#define _BZLIB_H + +#ifdef __cplusplus +extern "C" { +#endif + +#define BZ_RUN 0 +#define BZ_FLUSH 1 +#define BZ_FINISH 2 + +#define BZ_OK 0 +#define BZ_RUN_OK 1 +#define BZ_FLUSH_OK 2 +#define BZ_FINISH_OK 3 +#define BZ_STREAM_END 4 +#define BZ_SEQUENCE_ERROR (-1) +#define BZ_PARAM_ERROR (-2) +#define BZ_MEM_ERROR (-3) +#define BZ_DATA_ERROR (-4) +#define BZ_DATA_ERROR_MAGIC (-5) +#define BZ_IO_ERROR (-6) +#define BZ_UNEXPECTED_EOF (-7) +#define BZ_OUTBUFF_FULL (-8) +#define BZ_CONFIG_ERROR (-9) + +typedef + struct { + char *next_in; + unsigned int avail_in; + unsigned int total_in_lo32; + unsigned int total_in_hi32; + + char *next_out; + unsigned int avail_out; + unsigned int total_out_lo32; + unsigned int total_out_hi32; + + void *state; + + void *(*bzalloc)(void *,int,int); + void (*bzfree)(void *,void *); + void *opaque; + } + bz_stream; + + +#ifndef BZ_IMPORT +#define BZ_EXPORT +#endif + +#ifndef BZ_NO_STDIO +/* Need a definitition for FILE */ +#include +#endif + +#ifdef _WIN32 +# include +# ifdef small + /* windows.h define small to char */ +# undef small +# endif +# ifdef BZ_EXPORT +# define BZ_API(func) WINAPI func +# define BZ_EXTERN extern +# else + /* import windows dll dynamically */ +# define BZ_API(func) (WINAPI * func) +# define BZ_EXTERN +# endif +#else +# define BZ_API(func) func +# define BZ_EXTERN extern +#endif + + +/*-- Core (low-level) library functions --*/ + +BZ_EXTERN int BZ_API(BZ2_bzCompressInit) ( + bz_stream* strm, + int blockSize100k, + int verbosity, + int workFactor + ); + +BZ_EXTERN int BZ_API(BZ2_bzCompress) ( + bz_stream* strm, + int action + ); + +BZ_EXTERN int BZ_API(BZ2_bzCompressEnd) ( + bz_stream* strm + ); + +BZ_EXTERN int BZ_API(BZ2_bzDecompressInit) ( + bz_stream *strm, + int verbosity, + int small + ); + +BZ_EXTERN int BZ_API(BZ2_bzDecompress) ( + bz_stream* strm + ); + +BZ_EXTERN int BZ_API(BZ2_bzDecompressEnd) ( + bz_stream *strm + ); + + + +/*-- High(er) level library functions --*/ + +#ifndef BZ_NO_STDIO +#define BZ_MAX_UNUSED 5000 + +typedef void BZFILE; + +BZ_EXTERN BZFILE* BZ_API(BZ2_bzReadOpen) ( + int* bzerror, + FILE* f, + int verbosity, + int small, + void* unused, + int nUnused + ); + +BZ_EXTERN void BZ_API(BZ2_bzReadClose) ( + int* bzerror, + BZFILE* b + ); + +BZ_EXTERN void BZ_API(BZ2_bzReadGetUnused) ( + int* bzerror, + BZFILE* b, + void** unused, + int* nUnused + ); + +BZ_EXTERN int BZ_API(BZ2_bzRead) ( + int* bzerror, + BZFILE* b, + void* buf, + int len + ); + +BZ_EXTERN BZFILE* BZ_API(BZ2_bzWriteOpen) ( + int* bzerror, + FILE* f, + int blockSize100k, + int verbosity, + int workFactor + ); + +BZ_EXTERN void BZ_API(BZ2_bzWrite) ( + int* bzerror, + BZFILE* b, + void* buf, + int len + ); + +BZ_EXTERN void BZ_API(BZ2_bzWriteClose) ( + int* bzerror, + BZFILE* b, + int abandon, + unsigned int* nbytes_in, + unsigned int* nbytes_out + ); + +BZ_EXTERN void BZ_API(BZ2_bzWriteClose64) ( + int* bzerror, + BZFILE* b, + int abandon, + unsigned int* nbytes_in_lo32, + unsigned int* nbytes_in_hi32, + unsigned int* nbytes_out_lo32, + unsigned int* nbytes_out_hi32 + ); +#endif + + +/*-- Utility functions --*/ + +BZ_EXTERN int BZ_API(BZ2_bzBuffToBuffCompress) ( + char* dest, + unsigned int* destLen, + char* source, + unsigned int sourceLen, + int blockSize100k, + int verbosity, + int workFactor + ); + +BZ_EXTERN int BZ_API(BZ2_bzBuffToBuffDecompress) ( + char* dest, + unsigned int* destLen, + char* source, + unsigned int sourceLen, + int small, + int verbosity + ); + + +/*-- + Code contributed by Yoshioka Tsuneo (tsuneo@rr.iij4u.or.jp) + to support better zlib compatibility. + This code is not _officially_ part of libbzip2 (yet); + I haven't tested it, documented it, or considered the + threading-safeness of it. + If this code breaks, please contact both Yoshioka and me. +--*/ + +BZ_EXTERN const char * BZ_API(BZ2_bzlibVersion) ( + void + ); + +#ifndef BZ_NO_STDIO +BZ_EXTERN BZFILE * BZ_API(BZ2_bzopen) ( + const char *path, + const char *mode + ); + +BZ_EXTERN BZFILE * BZ_API(BZ2_bzdopen) ( + int fd, + const char *mode + ); + +BZ_EXTERN int BZ_API(BZ2_bzread) ( + BZFILE* b, + void* buf, + int len + ); + +BZ_EXTERN int BZ_API(BZ2_bzwrite) ( + BZFILE* b, + void* buf, + int len + ); + +BZ_EXTERN int BZ_API(BZ2_bzflush) ( + BZFILE* b + ); + +BZ_EXTERN void BZ_API(BZ2_bzclose) ( + BZFILE* b + ); + +BZ_EXTERN const char * BZ_API(BZ2_bzerror) ( + BZFILE *b, + int *errnum + ); +#endif + +#ifdef __cplusplus +} +#endif + +#endif + +/*-------------------------------------------------------------*/ +/*--- end bzlib.h ---*/ +/*-------------------------------------------------------------*/ diff --git a/mk/linux/mojosetup/bzip2/bzlib_private.h b/mk/linux/mojosetup/bzip2/bzlib_private.h new file mode 100644 index 00000000..23427879 --- /dev/null +++ b/mk/linux/mojosetup/bzip2/bzlib_private.h @@ -0,0 +1,509 @@ + +/*-------------------------------------------------------------*/ +/*--- Private header file for the library. ---*/ +/*--- bzlib_private.h ---*/ +/*-------------------------------------------------------------*/ + +/* ------------------------------------------------------------------ + This file is part of bzip2/libbzip2, a program and library for + lossless, block-sorting data compression. + + bzip2/libbzip2 version 1.0.5 of 10 December 2007 + Copyright (C) 1996-2007 Julian Seward + + Please read the WARNING, DISCLAIMER and PATENTS sections in the + README file. + + This program is released under the terms of the license contained + in the file LICENSE. + ------------------------------------------------------------------ */ + + +#ifndef _BZLIB_PRIVATE_H +#define _BZLIB_PRIVATE_H + +#include + +#ifndef BZ_NO_STDIO +#include +#include +#include +#endif + +#include "bzlib.h" + + + +/*-- General stuff. --*/ + +#define BZ_VERSION "1.0.5, 10-Dec-2007" + +typedef char Char; +typedef unsigned char Bool; +typedef unsigned char UChar; +typedef int Int32; +typedef unsigned int UInt32; +typedef short Int16; +typedef unsigned short UInt16; + +#define True ((Bool)1) +#define False ((Bool)0) + +#ifndef __GNUC__ +#define __inline__ /* */ +#endif + +#ifndef BZ_NO_STDIO + +extern void BZ2_bz__AssertH__fail ( int errcode ); +#define AssertH(cond,errcode) \ + { if (!(cond)) BZ2_bz__AssertH__fail ( errcode ); } + +#if BZ_DEBUG +#define AssertD(cond,msg) \ + { if (!(cond)) { \ + fprintf ( stderr, \ + "\n\nlibbzip2(debug build): internal error\n\t%s\n", msg );\ + exit(1); \ + }} +#else +#define AssertD(cond,msg) /* */ +#endif + +#define VPrintf0(zf) \ + fprintf(stderr,zf) +#define VPrintf1(zf,za1) \ + fprintf(stderr,zf,za1) +#define VPrintf2(zf,za1,za2) \ + fprintf(stderr,zf,za1,za2) +#define VPrintf3(zf,za1,za2,za3) \ + fprintf(stderr,zf,za1,za2,za3) +#define VPrintf4(zf,za1,za2,za3,za4) \ + fprintf(stderr,zf,za1,za2,za3,za4) +#define VPrintf5(zf,za1,za2,za3,za4,za5) \ + fprintf(stderr,zf,za1,za2,za3,za4,za5) + +#else + +extern void bz_internal_error ( int errcode ); +#define AssertH(cond,errcode) \ + { if (!(cond)) bz_internal_error ( errcode ); } +#define AssertD(cond,msg) do { } while (0) +#define VPrintf0(zf) do { } while (0) +#define VPrintf1(zf,za1) do { } while (0) +#define VPrintf2(zf,za1,za2) do { } while (0) +#define VPrintf3(zf,za1,za2,za3) do { } while (0) +#define VPrintf4(zf,za1,za2,za3,za4) do { } while (0) +#define VPrintf5(zf,za1,za2,za3,za4,za5) do { } while (0) + +#endif + + +#define BZALLOC(nnn) (strm->bzalloc)(strm->opaque,(nnn),1) +#define BZFREE(ppp) (strm->bzfree)(strm->opaque,(ppp)) + + +/*-- Header bytes. --*/ + +#define BZ_HDR_B 0x42 /* 'B' */ +#define BZ_HDR_Z 0x5a /* 'Z' */ +#define BZ_HDR_h 0x68 /* 'h' */ +#define BZ_HDR_0 0x30 /* '0' */ + +/*-- Constants for the back end. --*/ + +#define BZ_MAX_ALPHA_SIZE 258 +#define BZ_MAX_CODE_LEN 23 + +#define BZ_RUNA 0 +#define BZ_RUNB 1 + +#define BZ_N_GROUPS 6 +#define BZ_G_SIZE 50 +#define BZ_N_ITERS 4 + +#define BZ_MAX_SELECTORS (2 + (900000 / BZ_G_SIZE)) + + + +/*-- Stuff for randomising repetitive blocks. --*/ + +extern Int32 BZ2_rNums[512]; + +#define BZ_RAND_DECLS \ + Int32 rNToGo; \ + Int32 rTPos \ + +#define BZ_RAND_INIT_MASK \ + s->rNToGo = 0; \ + s->rTPos = 0 \ + +#define BZ_RAND_MASK ((s->rNToGo == 1) ? 1 : 0) + +#define BZ_RAND_UPD_MASK \ + if (s->rNToGo == 0) { \ + s->rNToGo = BZ2_rNums[s->rTPos]; \ + s->rTPos++; \ + if (s->rTPos == 512) s->rTPos = 0; \ + } \ + s->rNToGo--; + + + +/*-- Stuff for doing CRCs. --*/ + +extern UInt32 BZ2_crc32Table[256]; + +#define BZ_INITIALISE_CRC(crcVar) \ +{ \ + crcVar = 0xffffffffL; \ +} + +#define BZ_FINALISE_CRC(crcVar) \ +{ \ + crcVar = ~(crcVar); \ +} + +#define BZ_UPDATE_CRC(crcVar,cha) \ +{ \ + crcVar = (crcVar << 8) ^ \ + BZ2_crc32Table[(crcVar >> 24) ^ \ + ((UChar)cha)]; \ +} + + + +/*-- States and modes for compression. --*/ + +#define BZ_M_IDLE 1 +#define BZ_M_RUNNING 2 +#define BZ_M_FLUSHING 3 +#define BZ_M_FINISHING 4 + +#define BZ_S_OUTPUT 1 +#define BZ_S_INPUT 2 + +#define BZ_N_RADIX 2 +#define BZ_N_QSORT 12 +#define BZ_N_SHELL 18 +#define BZ_N_OVERSHOOT (BZ_N_RADIX + BZ_N_QSORT + BZ_N_SHELL + 2) + + + + +/*-- Structure holding all the compression-side stuff. --*/ + +typedef + struct { + /* pointer back to the struct bz_stream */ + bz_stream* strm; + + /* mode this stream is in, and whether inputting */ + /* or outputting data */ + Int32 mode; + Int32 state; + + /* remembers avail_in when flush/finish requested */ + UInt32 avail_in_expect; + + /* for doing the block sorting */ + UInt32* arr1; + UInt32* arr2; + UInt32* ftab; + Int32 origPtr; + + /* aliases for arr1 and arr2 */ + UInt32* ptr; + UChar* block; + UInt16* mtfv; + UChar* zbits; + + /* for deciding when to use the fallback sorting algorithm */ + Int32 workFactor; + + /* run-length-encoding of the input */ + UInt32 state_in_ch; + Int32 state_in_len; + BZ_RAND_DECLS; + + /* input and output limits and current posns */ + Int32 nblock; + Int32 nblockMAX; + Int32 numZ; + Int32 state_out_pos; + + /* map of bytes used in block */ + Int32 nInUse; + Bool inUse[256]; + UChar unseqToSeq[256]; + + /* the buffer for bit stream creation */ + UInt32 bsBuff; + Int32 bsLive; + + /* block and combined CRCs */ + UInt32 blockCRC; + UInt32 combinedCRC; + + /* misc administratium */ + Int32 verbosity; + Int32 blockNo; + Int32 blockSize100k; + + /* stuff for coding the MTF values */ + Int32 nMTF; + Int32 mtfFreq [BZ_MAX_ALPHA_SIZE]; + UChar selector [BZ_MAX_SELECTORS]; + UChar selectorMtf[BZ_MAX_SELECTORS]; + + UChar len [BZ_N_GROUPS][BZ_MAX_ALPHA_SIZE]; + Int32 code [BZ_N_GROUPS][BZ_MAX_ALPHA_SIZE]; + Int32 rfreq [BZ_N_GROUPS][BZ_MAX_ALPHA_SIZE]; + /* second dimension: only 3 needed; 4 makes index calculations faster */ + UInt32 len_pack[BZ_MAX_ALPHA_SIZE][4]; + + } + EState; + + + +/*-- externs for compression. --*/ + +extern void +BZ2_blockSort ( EState* ); + +extern void +BZ2_compressBlock ( EState*, Bool ); + +extern void +BZ2_bsInitWrite ( EState* ); + +extern void +BZ2_hbAssignCodes ( Int32*, UChar*, Int32, Int32, Int32 ); + +extern void +BZ2_hbMakeCodeLengths ( UChar*, Int32*, Int32, Int32 ); + + + +/*-- states for decompression. --*/ + +#define BZ_X_IDLE 1 +#define BZ_X_OUTPUT 2 + +#define BZ_X_MAGIC_1 10 +#define BZ_X_MAGIC_2 11 +#define BZ_X_MAGIC_3 12 +#define BZ_X_MAGIC_4 13 +#define BZ_X_BLKHDR_1 14 +#define BZ_X_BLKHDR_2 15 +#define BZ_X_BLKHDR_3 16 +#define BZ_X_BLKHDR_4 17 +#define BZ_X_BLKHDR_5 18 +#define BZ_X_BLKHDR_6 19 +#define BZ_X_BCRC_1 20 +#define BZ_X_BCRC_2 21 +#define BZ_X_BCRC_3 22 +#define BZ_X_BCRC_4 23 +#define BZ_X_RANDBIT 24 +#define BZ_X_ORIGPTR_1 25 +#define BZ_X_ORIGPTR_2 26 +#define BZ_X_ORIGPTR_3 27 +#define BZ_X_MAPPING_1 28 +#define BZ_X_MAPPING_2 29 +#define BZ_X_SELECTOR_1 30 +#define BZ_X_SELECTOR_2 31 +#define BZ_X_SELECTOR_3 32 +#define BZ_X_CODING_1 33 +#define BZ_X_CODING_2 34 +#define BZ_X_CODING_3 35 +#define BZ_X_MTF_1 36 +#define BZ_X_MTF_2 37 +#define BZ_X_MTF_3 38 +#define BZ_X_MTF_4 39 +#define BZ_X_MTF_5 40 +#define BZ_X_MTF_6 41 +#define BZ_X_ENDHDR_2 42 +#define BZ_X_ENDHDR_3 43 +#define BZ_X_ENDHDR_4 44 +#define BZ_X_ENDHDR_5 45 +#define BZ_X_ENDHDR_6 46 +#define BZ_X_CCRC_1 47 +#define BZ_X_CCRC_2 48 +#define BZ_X_CCRC_3 49 +#define BZ_X_CCRC_4 50 + + + +/*-- Constants for the fast MTF decoder. --*/ + +#define MTFA_SIZE 4096 +#define MTFL_SIZE 16 + + + +/*-- Structure holding all the decompression-side stuff. --*/ + +typedef + struct { + /* pointer back to the struct bz_stream */ + bz_stream* strm; + + /* state indicator for this stream */ + Int32 state; + + /* for doing the final run-length decoding */ + UChar state_out_ch; + Int32 state_out_len; + Bool blockRandomised; + BZ_RAND_DECLS; + + /* the buffer for bit stream reading */ + UInt32 bsBuff; + Int32 bsLive; + + /* misc administratium */ + Int32 blockSize100k; + Bool smallDecompress; + Int32 currBlockNo; + Int32 verbosity; + + /* for undoing the Burrows-Wheeler transform */ + Int32 origPtr; + UInt32 tPos; + Int32 k0; + Int32 unzftab[256]; + Int32 nblock_used; + Int32 cftab[257]; + Int32 cftabCopy[257]; + + /* for undoing the Burrows-Wheeler transform (FAST) */ + UInt32 *tt; + + /* for undoing the Burrows-Wheeler transform (SMALL) */ + UInt16 *ll16; + UChar *ll4; + + /* stored and calculated CRCs */ + UInt32 storedBlockCRC; + UInt32 storedCombinedCRC; + UInt32 calculatedBlockCRC; + UInt32 calculatedCombinedCRC; + + /* map of bytes used in block */ + Int32 nInUse; + Bool inUse[256]; + Bool inUse16[16]; + UChar seqToUnseq[256]; + + /* for decoding the MTF values */ + UChar mtfa [MTFA_SIZE]; + Int32 mtfbase[256 / MTFL_SIZE]; + UChar selector [BZ_MAX_SELECTORS]; + UChar selectorMtf[BZ_MAX_SELECTORS]; + UChar len [BZ_N_GROUPS][BZ_MAX_ALPHA_SIZE]; + + Int32 limit [BZ_N_GROUPS][BZ_MAX_ALPHA_SIZE]; + Int32 base [BZ_N_GROUPS][BZ_MAX_ALPHA_SIZE]; + Int32 perm [BZ_N_GROUPS][BZ_MAX_ALPHA_SIZE]; + Int32 minLens[BZ_N_GROUPS]; + + /* save area for scalars in the main decompress code */ + Int32 save_i; + Int32 save_j; + Int32 save_t; + Int32 save_alphaSize; + Int32 save_nGroups; + Int32 save_nSelectors; + Int32 save_EOB; + Int32 save_groupNo; + Int32 save_groupPos; + Int32 save_nextSym; + Int32 save_nblockMAX; + Int32 save_nblock; + Int32 save_es; + Int32 save_N; + Int32 save_curr; + Int32 save_zt; + Int32 save_zn; + Int32 save_zvec; + Int32 save_zj; + Int32 save_gSel; + Int32 save_gMinlen; + Int32* save_gLimit; + Int32* save_gBase; + Int32* save_gPerm; + + } + DState; + + + +/*-- Macros for decompression. --*/ + +#define BZ_GET_FAST(cccc) \ + /* c_tPos is unsigned, hence test < 0 is pointless. */ \ + if (s->tPos >= (UInt32)100000 * (UInt32)s->blockSize100k) return True; \ + s->tPos = s->tt[s->tPos]; \ + cccc = (UChar)(s->tPos & 0xff); \ + s->tPos >>= 8; + +#define BZ_GET_FAST_C(cccc) \ + /* c_tPos is unsigned, hence test < 0 is pointless. */ \ + if (c_tPos >= (UInt32)100000 * (UInt32)ro_blockSize100k) return True; \ + c_tPos = c_tt[c_tPos]; \ + cccc = (UChar)(c_tPos & 0xff); \ + c_tPos >>= 8; + +#define SET_LL4(i,n) \ + { if (((i) & 0x1) == 0) \ + s->ll4[(i) >> 1] = (s->ll4[(i) >> 1] & 0xf0) | (n); else \ + s->ll4[(i) >> 1] = (s->ll4[(i) >> 1] & 0x0f) | ((n) << 4); \ + } + +#define GET_LL4(i) \ + ((((UInt32)(s->ll4[(i) >> 1])) >> (((i) << 2) & 0x4)) & 0xF) + +#define SET_LL(i,n) \ + { s->ll16[i] = (UInt16)(n & 0x0000ffff); \ + SET_LL4(i, n >> 16); \ + } + +#define GET_LL(i) \ + (((UInt32)s->ll16[i]) | (GET_LL4(i) << 16)) + +#define BZ_GET_SMALL(cccc) \ + /* c_tPos is unsigned, hence test < 0 is pointless. */ \ + if (s->tPos >= (UInt32)100000 * (UInt32)s->blockSize100k) return True; \ + cccc = BZ2_indexIntoF ( s->tPos, s->cftab ); \ + s->tPos = GET_LL(s->tPos); + + +/*-- externs for decompression. --*/ + +extern Int32 +BZ2_indexIntoF ( Int32, Int32* ); + +extern Int32 +BZ2_decompress ( DState* ); + +extern void +BZ2_hbCreateDecodeTables ( Int32*, Int32*, Int32*, UChar*, + Int32, Int32, Int32 ); + + +#endif + + +/*-- BZ_NO_STDIO seems to make NULL disappear on some platforms. --*/ + +#ifdef BZ_NO_STDIO +#ifndef NULL +#define NULL 0 +#endif +#endif + + +/*-------------------------------------------------------------*/ +/*--- end bzlib_private.h ---*/ +/*-------------------------------------------------------------*/ diff --git a/mk/linux/mojosetup/bzip2/compress.c b/mk/linux/mojosetup/bzip2/compress.c new file mode 100644 index 00000000..8c80a079 --- /dev/null +++ b/mk/linux/mojosetup/bzip2/compress.c @@ -0,0 +1,672 @@ + +/*-------------------------------------------------------------*/ +/*--- Compression machinery (not incl block sorting) ---*/ +/*--- compress.c ---*/ +/*-------------------------------------------------------------*/ + +/* ------------------------------------------------------------------ + This file is part of bzip2/libbzip2, a program and library for + lossless, block-sorting data compression. + + bzip2/libbzip2 version 1.0.5 of 10 December 2007 + Copyright (C) 1996-2007 Julian Seward + + Please read the WARNING, DISCLAIMER and PATENTS sections in the + README file. + + This program is released under the terms of the license contained + in the file LICENSE. + ------------------------------------------------------------------ */ + + +/* CHANGES + 0.9.0 -- original version. + 0.9.0a/b -- no changes in this file. + 0.9.0c -- changed setting of nGroups in sendMTFValues() + so as to do a bit better on small files +*/ + +#include "bzlib_private.h" + + +/*---------------------------------------------------*/ +/*--- Bit stream I/O ---*/ +/*---------------------------------------------------*/ + +/*---------------------------------------------------*/ +void BZ2_bsInitWrite ( EState* s ) +{ + s->bsLive = 0; + s->bsBuff = 0; +} + + +/*---------------------------------------------------*/ +static +void bsFinishWrite ( EState* s ) +{ + while (s->bsLive > 0) { + s->zbits[s->numZ] = (UChar)(s->bsBuff >> 24); + s->numZ++; + s->bsBuff <<= 8; + s->bsLive -= 8; + } +} + + +/*---------------------------------------------------*/ +#define bsNEEDW(nz) \ +{ \ + while (s->bsLive >= 8) { \ + s->zbits[s->numZ] \ + = (UChar)(s->bsBuff >> 24); \ + s->numZ++; \ + s->bsBuff <<= 8; \ + s->bsLive -= 8; \ + } \ +} + + +/*---------------------------------------------------*/ +static +__inline__ +void bsW ( EState* s, Int32 n, UInt32 v ) +{ + bsNEEDW ( n ); + s->bsBuff |= (v << (32 - s->bsLive - n)); + s->bsLive += n; +} + + +/*---------------------------------------------------*/ +static +void bsPutUInt32 ( EState* s, UInt32 u ) +{ + bsW ( s, 8, (u >> 24) & 0xffL ); + bsW ( s, 8, (u >> 16) & 0xffL ); + bsW ( s, 8, (u >> 8) & 0xffL ); + bsW ( s, 8, u & 0xffL ); +} + + +/*---------------------------------------------------*/ +static +void bsPutUChar ( EState* s, UChar c ) +{ + bsW( s, 8, (UInt32)c ); +} + + +/*---------------------------------------------------*/ +/*--- The back end proper ---*/ +/*---------------------------------------------------*/ + +/*---------------------------------------------------*/ +static +void makeMaps_e ( EState* s ) +{ + Int32 i; + s->nInUse = 0; + for (i = 0; i < 256; i++) + if (s->inUse[i]) { + s->unseqToSeq[i] = s->nInUse; + s->nInUse++; + } +} + + +/*---------------------------------------------------*/ +static +void generateMTFValues ( EState* s ) +{ + UChar yy[256]; + Int32 i, j; + Int32 zPend; + Int32 wr; + Int32 EOB; + + /* + After sorting (eg, here), + s->arr1 [ 0 .. s->nblock-1 ] holds sorted order, + and + ((UChar*)s->arr2) [ 0 .. s->nblock-1 ] + holds the original block data. + + The first thing to do is generate the MTF values, + and put them in + ((UInt16*)s->arr1) [ 0 .. s->nblock-1 ]. + Because there are strictly fewer or equal MTF values + than block values, ptr values in this area are overwritten + with MTF values only when they are no longer needed. + + The final compressed bitstream is generated into the + area starting at + (UChar*) (&((UChar*)s->arr2)[s->nblock]) + + These storage aliases are set up in bzCompressInit(), + except for the last one, which is arranged in + compressBlock(). + */ + UInt32* ptr = s->ptr; + UChar* block = s->block; + UInt16* mtfv = s->mtfv; + + makeMaps_e ( s ); + EOB = s->nInUse+1; + + for (i = 0; i <= EOB; i++) s->mtfFreq[i] = 0; + + wr = 0; + zPend = 0; + for (i = 0; i < s->nInUse; i++) yy[i] = (UChar) i; + + for (i = 0; i < s->nblock; i++) { + UChar ll_i; + AssertD ( wr <= i, "generateMTFValues(1)" ); + j = ptr[i]-1; if (j < 0) j += s->nblock; + ll_i = s->unseqToSeq[block[j]]; + AssertD ( ll_i < s->nInUse, "generateMTFValues(2a)" ); + + if (yy[0] == ll_i) { + zPend++; + } else { + + if (zPend > 0) { + zPend--; + while (True) { + if (zPend & 1) { + mtfv[wr] = BZ_RUNB; wr++; + s->mtfFreq[BZ_RUNB]++; + } else { + mtfv[wr] = BZ_RUNA; wr++; + s->mtfFreq[BZ_RUNA]++; + } + if (zPend < 2) break; + zPend = (zPend - 2) / 2; + }; + zPend = 0; + } + { + register UChar rtmp; + register UChar* ryy_j; + register UChar rll_i; + rtmp = yy[1]; + yy[1] = yy[0]; + ryy_j = &(yy[1]); + rll_i = ll_i; + while ( rll_i != rtmp ) { + register UChar rtmp2; + ryy_j++; + rtmp2 = rtmp; + rtmp = *ryy_j; + *ryy_j = rtmp2; + }; + yy[0] = rtmp; + j = ryy_j - &(yy[0]); + mtfv[wr] = j+1; wr++; s->mtfFreq[j+1]++; + } + + } + } + + if (zPend > 0) { + zPend--; + while (True) { + if (zPend & 1) { + mtfv[wr] = BZ_RUNB; wr++; + s->mtfFreq[BZ_RUNB]++; + } else { + mtfv[wr] = BZ_RUNA; wr++; + s->mtfFreq[BZ_RUNA]++; + } + if (zPend < 2) break; + zPend = (zPend - 2) / 2; + }; + zPend = 0; + } + + mtfv[wr] = EOB; wr++; s->mtfFreq[EOB]++; + + s->nMTF = wr; +} + + +/*---------------------------------------------------*/ +#define BZ_LESSER_ICOST 0 +#define BZ_GREATER_ICOST 15 + +static +void sendMTFValues ( EState* s ) +{ + Int32 v, t, i, j, gs, ge, totc, bt, bc, iter; + Int32 nSelectors, alphaSize, minLen, maxLen, selCtr; + Int32 nGroups, nBytes; + + /*-- + UChar len [BZ_N_GROUPS][BZ_MAX_ALPHA_SIZE]; + is a global since the decoder also needs it. + + Int32 code[BZ_N_GROUPS][BZ_MAX_ALPHA_SIZE]; + Int32 rfreq[BZ_N_GROUPS][BZ_MAX_ALPHA_SIZE]; + are also globals only used in this proc. + Made global to keep stack frame size small. + --*/ + + + UInt16 cost[BZ_N_GROUPS]; + Int32 fave[BZ_N_GROUPS]; + + UInt16* mtfv = s->mtfv; + + if (s->verbosity >= 3) + VPrintf3( " %d in block, %d after MTF & 1-2 coding, " + "%d+2 syms in use\n", + s->nblock, s->nMTF, s->nInUse ); + + alphaSize = s->nInUse+2; + for (t = 0; t < BZ_N_GROUPS; t++) + for (v = 0; v < alphaSize; v++) + s->len[t][v] = BZ_GREATER_ICOST; + + /*--- Decide how many coding tables to use ---*/ + AssertH ( s->nMTF > 0, 3001 ); + if (s->nMTF < 200) nGroups = 2; else + if (s->nMTF < 600) nGroups = 3; else + if (s->nMTF < 1200) nGroups = 4; else + if (s->nMTF < 2400) nGroups = 5; else + nGroups = 6; + + /*--- Generate an initial set of coding tables ---*/ + { + Int32 nPart, remF, tFreq, aFreq; + + nPart = nGroups; + remF = s->nMTF; + gs = 0; + while (nPart > 0) { + tFreq = remF / nPart; + ge = gs-1; + aFreq = 0; + while (aFreq < tFreq && ge < alphaSize-1) { + ge++; + aFreq += s->mtfFreq[ge]; + } + + if (ge > gs + && nPart != nGroups && nPart != 1 + && ((nGroups-nPart) % 2 == 1)) { + aFreq -= s->mtfFreq[ge]; + ge--; + } + + if (s->verbosity >= 3) + VPrintf5( " initial group %d, [%d .. %d], " + "has %d syms (%4.1f%%)\n", + nPart, gs, ge, aFreq, + (100.0 * (float)aFreq) / (float)(s->nMTF) ); + + for (v = 0; v < alphaSize; v++) + if (v >= gs && v <= ge) + s->len[nPart-1][v] = BZ_LESSER_ICOST; else + s->len[nPart-1][v] = BZ_GREATER_ICOST; + + nPart--; + gs = ge+1; + remF -= aFreq; + } + } + + /*--- + Iterate up to BZ_N_ITERS times to improve the tables. + ---*/ + for (iter = 0; iter < BZ_N_ITERS; iter++) { + + for (t = 0; t < nGroups; t++) fave[t] = 0; + + for (t = 0; t < nGroups; t++) + for (v = 0; v < alphaSize; v++) + s->rfreq[t][v] = 0; + + /*--- + Set up an auxiliary length table which is used to fast-track + the common case (nGroups == 6). + ---*/ + if (nGroups == 6) { + for (v = 0; v < alphaSize; v++) { + s->len_pack[v][0] = (s->len[1][v] << 16) | s->len[0][v]; + s->len_pack[v][1] = (s->len[3][v] << 16) | s->len[2][v]; + s->len_pack[v][2] = (s->len[5][v] << 16) | s->len[4][v]; + } + } + + nSelectors = 0; + totc = 0; + gs = 0; + while (True) { + + /*--- Set group start & end marks. --*/ + if (gs >= s->nMTF) break; + ge = gs + BZ_G_SIZE - 1; + if (ge >= s->nMTF) ge = s->nMTF-1; + + /*-- + Calculate the cost of this group as coded + by each of the coding tables. + --*/ + for (t = 0; t < nGroups; t++) cost[t] = 0; + + if (nGroups == 6 && 50 == ge-gs+1) { + /*--- fast track the common case ---*/ + register UInt32 cost01, cost23, cost45; + register UInt16 icv; + cost01 = cost23 = cost45 = 0; + +# define BZ_ITER(nn) \ + icv = mtfv[gs+(nn)]; \ + cost01 += s->len_pack[icv][0]; \ + cost23 += s->len_pack[icv][1]; \ + cost45 += s->len_pack[icv][2]; \ + + BZ_ITER(0); BZ_ITER(1); BZ_ITER(2); BZ_ITER(3); BZ_ITER(4); + BZ_ITER(5); BZ_ITER(6); BZ_ITER(7); BZ_ITER(8); BZ_ITER(9); + BZ_ITER(10); BZ_ITER(11); BZ_ITER(12); BZ_ITER(13); BZ_ITER(14); + BZ_ITER(15); BZ_ITER(16); BZ_ITER(17); BZ_ITER(18); BZ_ITER(19); + BZ_ITER(20); BZ_ITER(21); BZ_ITER(22); BZ_ITER(23); BZ_ITER(24); + BZ_ITER(25); BZ_ITER(26); BZ_ITER(27); BZ_ITER(28); BZ_ITER(29); + BZ_ITER(30); BZ_ITER(31); BZ_ITER(32); BZ_ITER(33); BZ_ITER(34); + BZ_ITER(35); BZ_ITER(36); BZ_ITER(37); BZ_ITER(38); BZ_ITER(39); + BZ_ITER(40); BZ_ITER(41); BZ_ITER(42); BZ_ITER(43); BZ_ITER(44); + BZ_ITER(45); BZ_ITER(46); BZ_ITER(47); BZ_ITER(48); BZ_ITER(49); + +# undef BZ_ITER + + cost[0] = cost01 & 0xffff; cost[1] = cost01 >> 16; + cost[2] = cost23 & 0xffff; cost[3] = cost23 >> 16; + cost[4] = cost45 & 0xffff; cost[5] = cost45 >> 16; + + } else { + /*--- slow version which correctly handles all situations ---*/ + for (i = gs; i <= ge; i++) { + UInt16 icv = mtfv[i]; + for (t = 0; t < nGroups; t++) cost[t] += s->len[t][icv]; + } + } + + /*-- + Find the coding table which is best for this group, + and record its identity in the selector table. + --*/ + bc = 999999999; bt = -1; + for (t = 0; t < nGroups; t++) + if (cost[t] < bc) { bc = cost[t]; bt = t; }; + totc += bc; + fave[bt]++; + s->selector[nSelectors] = bt; + nSelectors++; + + /*-- + Increment the symbol frequencies for the selected table. + --*/ + if (nGroups == 6 && 50 == ge-gs+1) { + /*--- fast track the common case ---*/ + +# define BZ_ITUR(nn) s->rfreq[bt][ mtfv[gs+(nn)] ]++ + + BZ_ITUR(0); BZ_ITUR(1); BZ_ITUR(2); BZ_ITUR(3); BZ_ITUR(4); + BZ_ITUR(5); BZ_ITUR(6); BZ_ITUR(7); BZ_ITUR(8); BZ_ITUR(9); + BZ_ITUR(10); BZ_ITUR(11); BZ_ITUR(12); BZ_ITUR(13); BZ_ITUR(14); + BZ_ITUR(15); BZ_ITUR(16); BZ_ITUR(17); BZ_ITUR(18); BZ_ITUR(19); + BZ_ITUR(20); BZ_ITUR(21); BZ_ITUR(22); BZ_ITUR(23); BZ_ITUR(24); + BZ_ITUR(25); BZ_ITUR(26); BZ_ITUR(27); BZ_ITUR(28); BZ_ITUR(29); + BZ_ITUR(30); BZ_ITUR(31); BZ_ITUR(32); BZ_ITUR(33); BZ_ITUR(34); + BZ_ITUR(35); BZ_ITUR(36); BZ_ITUR(37); BZ_ITUR(38); BZ_ITUR(39); + BZ_ITUR(40); BZ_ITUR(41); BZ_ITUR(42); BZ_ITUR(43); BZ_ITUR(44); + BZ_ITUR(45); BZ_ITUR(46); BZ_ITUR(47); BZ_ITUR(48); BZ_ITUR(49); + +# undef BZ_ITUR + + } else { + /*--- slow version which correctly handles all situations ---*/ + for (i = gs; i <= ge; i++) + s->rfreq[bt][ mtfv[i] ]++; + } + + gs = ge+1; + } + if (s->verbosity >= 3) { + VPrintf2 ( " pass %d: size is %d, grp uses are ", + iter+1, totc/8 ); + for (t = 0; t < nGroups; t++) + VPrintf1 ( "%d ", fave[t] ); + VPrintf0 ( "\n" ); + } + + /*-- + Recompute the tables based on the accumulated frequencies. + --*/ + /* maxLen was changed from 20 to 17 in bzip2-1.0.3. See + comment in huffman.c for details. */ + for (t = 0; t < nGroups; t++) + BZ2_hbMakeCodeLengths ( &(s->len[t][0]), &(s->rfreq[t][0]), + alphaSize, 17 /*20*/ ); + } + + + AssertH( nGroups < 8, 3002 ); + AssertH( nSelectors < 32768 && + nSelectors <= (2 + (900000 / BZ_G_SIZE)), + 3003 ); + + + /*--- Compute MTF values for the selectors. ---*/ + { + UChar pos[BZ_N_GROUPS], ll_i, tmp2, tmp; + for (i = 0; i < nGroups; i++) pos[i] = i; + for (i = 0; i < nSelectors; i++) { + ll_i = s->selector[i]; + j = 0; + tmp = pos[j]; + while ( ll_i != tmp ) { + j++; + tmp2 = tmp; + tmp = pos[j]; + pos[j] = tmp2; + }; + pos[0] = tmp; + s->selectorMtf[i] = j; + } + }; + + /*--- Assign actual codes for the tables. --*/ + for (t = 0; t < nGroups; t++) { + minLen = 32; + maxLen = 0; + for (i = 0; i < alphaSize; i++) { + if (s->len[t][i] > maxLen) maxLen = s->len[t][i]; + if (s->len[t][i] < minLen) minLen = s->len[t][i]; + } + AssertH ( !(maxLen > 17 /*20*/ ), 3004 ); + AssertH ( !(minLen < 1), 3005 ); + BZ2_hbAssignCodes ( &(s->code[t][0]), &(s->len[t][0]), + minLen, maxLen, alphaSize ); + } + + /*--- Transmit the mapping table. ---*/ + { + Bool inUse16[16]; + for (i = 0; i < 16; i++) { + inUse16[i] = False; + for (j = 0; j < 16; j++) + if (s->inUse[i * 16 + j]) inUse16[i] = True; + } + + nBytes = s->numZ; + for (i = 0; i < 16; i++) + if (inUse16[i]) bsW(s,1,1); else bsW(s,1,0); + + for (i = 0; i < 16; i++) + if (inUse16[i]) + for (j = 0; j < 16; j++) { + if (s->inUse[i * 16 + j]) bsW(s,1,1); else bsW(s,1,0); + } + + if (s->verbosity >= 3) + VPrintf1( " bytes: mapping %d, ", s->numZ-nBytes ); + } + + /*--- Now the selectors. ---*/ + nBytes = s->numZ; + bsW ( s, 3, nGroups ); + bsW ( s, 15, nSelectors ); + for (i = 0; i < nSelectors; i++) { + for (j = 0; j < s->selectorMtf[i]; j++) bsW(s,1,1); + bsW(s,1,0); + } + if (s->verbosity >= 3) + VPrintf1( "selectors %d, ", s->numZ-nBytes ); + + /*--- Now the coding tables. ---*/ + nBytes = s->numZ; + + for (t = 0; t < nGroups; t++) { + Int32 curr = s->len[t][0]; + bsW ( s, 5, curr ); + for (i = 0; i < alphaSize; i++) { + while (curr < s->len[t][i]) { bsW(s,2,2); curr++; /* 10 */ }; + while (curr > s->len[t][i]) { bsW(s,2,3); curr--; /* 11 */ }; + bsW ( s, 1, 0 ); + } + } + + if (s->verbosity >= 3) + VPrintf1 ( "code lengths %d, ", s->numZ-nBytes ); + + /*--- And finally, the block data proper ---*/ + nBytes = s->numZ; + selCtr = 0; + gs = 0; + while (True) { + if (gs >= s->nMTF) break; + ge = gs + BZ_G_SIZE - 1; + if (ge >= s->nMTF) ge = s->nMTF-1; + AssertH ( s->selector[selCtr] < nGroups, 3006 ); + + if (nGroups == 6 && 50 == ge-gs+1) { + /*--- fast track the common case ---*/ + UInt16 mtfv_i; + UChar* s_len_sel_selCtr + = &(s->len[s->selector[selCtr]][0]); + Int32* s_code_sel_selCtr + = &(s->code[s->selector[selCtr]][0]); + +# define BZ_ITAH(nn) \ + mtfv_i = mtfv[gs+(nn)]; \ + bsW ( s, \ + s_len_sel_selCtr[mtfv_i], \ + s_code_sel_selCtr[mtfv_i] ) + + BZ_ITAH(0); BZ_ITAH(1); BZ_ITAH(2); BZ_ITAH(3); BZ_ITAH(4); + BZ_ITAH(5); BZ_ITAH(6); BZ_ITAH(7); BZ_ITAH(8); BZ_ITAH(9); + BZ_ITAH(10); BZ_ITAH(11); BZ_ITAH(12); BZ_ITAH(13); BZ_ITAH(14); + BZ_ITAH(15); BZ_ITAH(16); BZ_ITAH(17); BZ_ITAH(18); BZ_ITAH(19); + BZ_ITAH(20); BZ_ITAH(21); BZ_ITAH(22); BZ_ITAH(23); BZ_ITAH(24); + BZ_ITAH(25); BZ_ITAH(26); BZ_ITAH(27); BZ_ITAH(28); BZ_ITAH(29); + BZ_ITAH(30); BZ_ITAH(31); BZ_ITAH(32); BZ_ITAH(33); BZ_ITAH(34); + BZ_ITAH(35); BZ_ITAH(36); BZ_ITAH(37); BZ_ITAH(38); BZ_ITAH(39); + BZ_ITAH(40); BZ_ITAH(41); BZ_ITAH(42); BZ_ITAH(43); BZ_ITAH(44); + BZ_ITAH(45); BZ_ITAH(46); BZ_ITAH(47); BZ_ITAH(48); BZ_ITAH(49); + +# undef BZ_ITAH + + } else { + /*--- slow version which correctly handles all situations ---*/ + for (i = gs; i <= ge; i++) { + bsW ( s, + s->len [s->selector[selCtr]] [mtfv[i]], + s->code [s->selector[selCtr]] [mtfv[i]] ); + } + } + + + gs = ge+1; + selCtr++; + } + AssertH( selCtr == nSelectors, 3007 ); + + if (s->verbosity >= 3) + VPrintf1( "codes %d\n", s->numZ-nBytes ); +} + + +/*---------------------------------------------------*/ +void BZ2_compressBlock ( EState* s, Bool is_last_block ) +{ + if (s->nblock > 0) { + + BZ_FINALISE_CRC ( s->blockCRC ); + s->combinedCRC = (s->combinedCRC << 1) | (s->combinedCRC >> 31); + s->combinedCRC ^= s->blockCRC; + if (s->blockNo > 1) s->numZ = 0; + + if (s->verbosity >= 2) + VPrintf4( " block %d: crc = 0x%08x, " + "combined CRC = 0x%08x, size = %d\n", + s->blockNo, s->blockCRC, s->combinedCRC, s->nblock ); + + BZ2_blockSort ( s ); + } + + s->zbits = (UChar*) (&((UChar*)s->arr2)[s->nblock]); + + /*-- If this is the first block, create the stream header. --*/ + if (s->blockNo == 1) { + BZ2_bsInitWrite ( s ); + bsPutUChar ( s, BZ_HDR_B ); + bsPutUChar ( s, BZ_HDR_Z ); + bsPutUChar ( s, BZ_HDR_h ); + bsPutUChar ( s, (UChar)(BZ_HDR_0 + s->blockSize100k) ); + } + + if (s->nblock > 0) { + + bsPutUChar ( s, 0x31 ); bsPutUChar ( s, 0x41 ); + bsPutUChar ( s, 0x59 ); bsPutUChar ( s, 0x26 ); + bsPutUChar ( s, 0x53 ); bsPutUChar ( s, 0x59 ); + + /*-- Now the block's CRC, so it is in a known place. --*/ + bsPutUInt32 ( s, s->blockCRC ); + + /*-- + Now a single bit indicating (non-)randomisation. + As of version 0.9.5, we use a better sorting algorithm + which makes randomisation unnecessary. So always set + the randomised bit to 'no'. Of course, the decoder + still needs to be able to handle randomised blocks + so as to maintain backwards compatibility with + older versions of bzip2. + --*/ + bsW(s,1,0); + + bsW ( s, 24, s->origPtr ); + generateMTFValues ( s ); + sendMTFValues ( s ); + } + + + /*-- If this is the last block, add the stream trailer. --*/ + if (is_last_block) { + + bsPutUChar ( s, 0x17 ); bsPutUChar ( s, 0x72 ); + bsPutUChar ( s, 0x45 ); bsPutUChar ( s, 0x38 ); + bsPutUChar ( s, 0x50 ); bsPutUChar ( s, 0x90 ); + bsPutUInt32 ( s, s->combinedCRC ); + if (s->verbosity >= 2) + VPrintf1( " final combined CRC = 0x%08x\n ", s->combinedCRC ); + bsFinishWrite ( s ); + } +} + + +/*-------------------------------------------------------------*/ +/*--- end compress.c ---*/ +/*-------------------------------------------------------------*/ diff --git a/mk/linux/mojosetup/bzip2/crctable.c b/mk/linux/mojosetup/bzip2/crctable.c new file mode 100644 index 00000000..215687b2 --- /dev/null +++ b/mk/linux/mojosetup/bzip2/crctable.c @@ -0,0 +1,104 @@ + +/*-------------------------------------------------------------*/ +/*--- Table for doing CRCs ---*/ +/*--- crctable.c ---*/ +/*-------------------------------------------------------------*/ + +/* ------------------------------------------------------------------ + This file is part of bzip2/libbzip2, a program and library for + lossless, block-sorting data compression. + + bzip2/libbzip2 version 1.0.5 of 10 December 2007 + Copyright (C) 1996-2007 Julian Seward + + Please read the WARNING, DISCLAIMER and PATENTS sections in the + README file. + + This program is released under the terms of the license contained + in the file LICENSE. + ------------------------------------------------------------------ */ + + +#include "bzlib_private.h" + +/*-- + I think this is an implementation of the AUTODIN-II, + Ethernet & FDDI 32-bit CRC standard. Vaguely derived + from code by Rob Warnock, in Section 51 of the + comp.compression FAQ. +--*/ + +UInt32 BZ2_crc32Table[256] = { + + /*-- Ugly, innit? --*/ + + 0x00000000L, 0x04c11db7L, 0x09823b6eL, 0x0d4326d9L, + 0x130476dcL, 0x17c56b6bL, 0x1a864db2L, 0x1e475005L, + 0x2608edb8L, 0x22c9f00fL, 0x2f8ad6d6L, 0x2b4bcb61L, + 0x350c9b64L, 0x31cd86d3L, 0x3c8ea00aL, 0x384fbdbdL, + 0x4c11db70L, 0x48d0c6c7L, 0x4593e01eL, 0x4152fda9L, + 0x5f15adacL, 0x5bd4b01bL, 0x569796c2L, 0x52568b75L, + 0x6a1936c8L, 0x6ed82b7fL, 0x639b0da6L, 0x675a1011L, + 0x791d4014L, 0x7ddc5da3L, 0x709f7b7aL, 0x745e66cdL, + 0x9823b6e0L, 0x9ce2ab57L, 0x91a18d8eL, 0x95609039L, + 0x8b27c03cL, 0x8fe6dd8bL, 0x82a5fb52L, 0x8664e6e5L, + 0xbe2b5b58L, 0xbaea46efL, 0xb7a96036L, 0xb3687d81L, + 0xad2f2d84L, 0xa9ee3033L, 0xa4ad16eaL, 0xa06c0b5dL, + 0xd4326d90L, 0xd0f37027L, 0xddb056feL, 0xd9714b49L, + 0xc7361b4cL, 0xc3f706fbL, 0xceb42022L, 0xca753d95L, + 0xf23a8028L, 0xf6fb9d9fL, 0xfbb8bb46L, 0xff79a6f1L, + 0xe13ef6f4L, 0xe5ffeb43L, 0xe8bccd9aL, 0xec7dd02dL, + 0x34867077L, 0x30476dc0L, 0x3d044b19L, 0x39c556aeL, + 0x278206abL, 0x23431b1cL, 0x2e003dc5L, 0x2ac12072L, + 0x128e9dcfL, 0x164f8078L, 0x1b0ca6a1L, 0x1fcdbb16L, + 0x018aeb13L, 0x054bf6a4L, 0x0808d07dL, 0x0cc9cdcaL, + 0x7897ab07L, 0x7c56b6b0L, 0x71159069L, 0x75d48ddeL, + 0x6b93dddbL, 0x6f52c06cL, 0x6211e6b5L, 0x66d0fb02L, + 0x5e9f46bfL, 0x5a5e5b08L, 0x571d7dd1L, 0x53dc6066L, + 0x4d9b3063L, 0x495a2dd4L, 0x44190b0dL, 0x40d816baL, + 0xaca5c697L, 0xa864db20L, 0xa527fdf9L, 0xa1e6e04eL, + 0xbfa1b04bL, 0xbb60adfcL, 0xb6238b25L, 0xb2e29692L, + 0x8aad2b2fL, 0x8e6c3698L, 0x832f1041L, 0x87ee0df6L, + 0x99a95df3L, 0x9d684044L, 0x902b669dL, 0x94ea7b2aL, + 0xe0b41de7L, 0xe4750050L, 0xe9362689L, 0xedf73b3eL, + 0xf3b06b3bL, 0xf771768cL, 0xfa325055L, 0xfef34de2L, + 0xc6bcf05fL, 0xc27dede8L, 0xcf3ecb31L, 0xcbffd686L, + 0xd5b88683L, 0xd1799b34L, 0xdc3abdedL, 0xd8fba05aL, + 0x690ce0eeL, 0x6dcdfd59L, 0x608edb80L, 0x644fc637L, + 0x7a089632L, 0x7ec98b85L, 0x738aad5cL, 0x774bb0ebL, + 0x4f040d56L, 0x4bc510e1L, 0x46863638L, 0x42472b8fL, + 0x5c007b8aL, 0x58c1663dL, 0x558240e4L, 0x51435d53L, + 0x251d3b9eL, 0x21dc2629L, 0x2c9f00f0L, 0x285e1d47L, + 0x36194d42L, 0x32d850f5L, 0x3f9b762cL, 0x3b5a6b9bL, + 0x0315d626L, 0x07d4cb91L, 0x0a97ed48L, 0x0e56f0ffL, + 0x1011a0faL, 0x14d0bd4dL, 0x19939b94L, 0x1d528623L, + 0xf12f560eL, 0xf5ee4bb9L, 0xf8ad6d60L, 0xfc6c70d7L, + 0xe22b20d2L, 0xe6ea3d65L, 0xeba91bbcL, 0xef68060bL, + 0xd727bbb6L, 0xd3e6a601L, 0xdea580d8L, 0xda649d6fL, + 0xc423cd6aL, 0xc0e2d0ddL, 0xcda1f604L, 0xc960ebb3L, + 0xbd3e8d7eL, 0xb9ff90c9L, 0xb4bcb610L, 0xb07daba7L, + 0xae3afba2L, 0xaafbe615L, 0xa7b8c0ccL, 0xa379dd7bL, + 0x9b3660c6L, 0x9ff77d71L, 0x92b45ba8L, 0x9675461fL, + 0x8832161aL, 0x8cf30badL, 0x81b02d74L, 0x857130c3L, + 0x5d8a9099L, 0x594b8d2eL, 0x5408abf7L, 0x50c9b640L, + 0x4e8ee645L, 0x4a4ffbf2L, 0x470cdd2bL, 0x43cdc09cL, + 0x7b827d21L, 0x7f436096L, 0x7200464fL, 0x76c15bf8L, + 0x68860bfdL, 0x6c47164aL, 0x61043093L, 0x65c52d24L, + 0x119b4be9L, 0x155a565eL, 0x18197087L, 0x1cd86d30L, + 0x029f3d35L, 0x065e2082L, 0x0b1d065bL, 0x0fdc1becL, + 0x3793a651L, 0x3352bbe6L, 0x3e119d3fL, 0x3ad08088L, + 0x2497d08dL, 0x2056cd3aL, 0x2d15ebe3L, 0x29d4f654L, + 0xc5a92679L, 0xc1683bceL, 0xcc2b1d17L, 0xc8ea00a0L, + 0xd6ad50a5L, 0xd26c4d12L, 0xdf2f6bcbL, 0xdbee767cL, + 0xe3a1cbc1L, 0xe760d676L, 0xea23f0afL, 0xeee2ed18L, + 0xf0a5bd1dL, 0xf464a0aaL, 0xf9278673L, 0xfde69bc4L, + 0x89b8fd09L, 0x8d79e0beL, 0x803ac667L, 0x84fbdbd0L, + 0x9abc8bd5L, 0x9e7d9662L, 0x933eb0bbL, 0x97ffad0cL, + 0xafb010b1L, 0xab710d06L, 0xa6322bdfL, 0xa2f33668L, + 0xbcb4666dL, 0xb8757bdaL, 0xb5365d03L, 0xb1f740b4L +}; + + +/*-------------------------------------------------------------*/ +/*--- end crctable.c ---*/ +/*-------------------------------------------------------------*/ diff --git a/mk/linux/mojosetup/bzip2/decompress.c b/mk/linux/mojosetup/bzip2/decompress.c new file mode 100644 index 00000000..bba5e0fa --- /dev/null +++ b/mk/linux/mojosetup/bzip2/decompress.c @@ -0,0 +1,626 @@ + +/*-------------------------------------------------------------*/ +/*--- Decompression machinery ---*/ +/*--- decompress.c ---*/ +/*-------------------------------------------------------------*/ + +/* ------------------------------------------------------------------ + This file is part of bzip2/libbzip2, a program and library for + lossless, block-sorting data compression. + + bzip2/libbzip2 version 1.0.5 of 10 December 2007 + Copyright (C) 1996-2007 Julian Seward + + Please read the WARNING, DISCLAIMER and PATENTS sections in the + README file. + + This program is released under the terms of the license contained + in the file LICENSE. + ------------------------------------------------------------------ */ + + +#include "bzlib_private.h" + + +/*---------------------------------------------------*/ +static +void makeMaps_d ( DState* s ) +{ + Int32 i; + s->nInUse = 0; + for (i = 0; i < 256; i++) + if (s->inUse[i]) { + s->seqToUnseq[s->nInUse] = i; + s->nInUse++; + } +} + + +/*---------------------------------------------------*/ +#define RETURN(rrr) \ + { retVal = rrr; goto save_state_and_return; }; + +#define GET_BITS(lll,vvv,nnn) \ + case lll: s->state = lll; \ + while (True) { \ + if (s->bsLive >= nnn) { \ + UInt32 v; \ + v = (s->bsBuff >> \ + (s->bsLive-nnn)) & ((1 << nnn)-1); \ + s->bsLive -= nnn; \ + vvv = v; \ + break; \ + } \ + if (s->strm->avail_in == 0) RETURN(BZ_OK); \ + s->bsBuff \ + = (s->bsBuff << 8) | \ + ((UInt32) \ + (*((UChar*)(s->strm->next_in)))); \ + s->bsLive += 8; \ + s->strm->next_in++; \ + s->strm->avail_in--; \ + s->strm->total_in_lo32++; \ + if (s->strm->total_in_lo32 == 0) \ + s->strm->total_in_hi32++; \ + } + +#define GET_UCHAR(lll,uuu) \ + GET_BITS(lll,uuu,8) + +#define GET_BIT(lll,uuu) \ + GET_BITS(lll,uuu,1) + +/*---------------------------------------------------*/ +#define GET_MTF_VAL(label1,label2,lval) \ +{ \ + if (groupPos == 0) { \ + groupNo++; \ + if (groupNo >= nSelectors) \ + RETURN(BZ_DATA_ERROR); \ + groupPos = BZ_G_SIZE; \ + gSel = s->selector[groupNo]; \ + gMinlen = s->minLens[gSel]; \ + gLimit = &(s->limit[gSel][0]); \ + gPerm = &(s->perm[gSel][0]); \ + gBase = &(s->base[gSel][0]); \ + } \ + groupPos--; \ + zn = gMinlen; \ + GET_BITS(label1, zvec, zn); \ + while (1) { \ + if (zn > 20 /* the longest code */) \ + RETURN(BZ_DATA_ERROR); \ + if (zvec <= gLimit[zn]) break; \ + zn++; \ + GET_BIT(label2, zj); \ + zvec = (zvec << 1) | zj; \ + }; \ + if (zvec - gBase[zn] < 0 \ + || zvec - gBase[zn] >= BZ_MAX_ALPHA_SIZE) \ + RETURN(BZ_DATA_ERROR); \ + lval = gPerm[zvec - gBase[zn]]; \ +} + + +/*---------------------------------------------------*/ +Int32 BZ2_decompress ( DState* s ) +{ + UChar uc; + Int32 retVal; + Int32 minLen, maxLen; + bz_stream* strm = s->strm; + + /* stuff that needs to be saved/restored */ + Int32 i; + Int32 j; + Int32 t; + Int32 alphaSize; + Int32 nGroups; + Int32 nSelectors; + Int32 EOB; + Int32 groupNo; + Int32 groupPos; + Int32 nextSym; + Int32 nblockMAX; + Int32 nblock; + Int32 es; + Int32 N; + Int32 curr; + Int32 zt; + Int32 zn; + Int32 zvec; + Int32 zj; + Int32 gSel; + Int32 gMinlen; + Int32* gLimit; + Int32* gBase; + Int32* gPerm; + + if (s->state == BZ_X_MAGIC_1) { + /*initialise the save area*/ + s->save_i = 0; + s->save_j = 0; + s->save_t = 0; + s->save_alphaSize = 0; + s->save_nGroups = 0; + s->save_nSelectors = 0; + s->save_EOB = 0; + s->save_groupNo = 0; + s->save_groupPos = 0; + s->save_nextSym = 0; + s->save_nblockMAX = 0; + s->save_nblock = 0; + s->save_es = 0; + s->save_N = 0; + s->save_curr = 0; + s->save_zt = 0; + s->save_zn = 0; + s->save_zvec = 0; + s->save_zj = 0; + s->save_gSel = 0; + s->save_gMinlen = 0; + s->save_gLimit = NULL; + s->save_gBase = NULL; + s->save_gPerm = NULL; + } + + /*restore from the save area*/ + i = s->save_i; + j = s->save_j; + t = s->save_t; + alphaSize = s->save_alphaSize; + nGroups = s->save_nGroups; + nSelectors = s->save_nSelectors; + EOB = s->save_EOB; + groupNo = s->save_groupNo; + groupPos = s->save_groupPos; + nextSym = s->save_nextSym; + nblockMAX = s->save_nblockMAX; + nblock = s->save_nblock; + es = s->save_es; + N = s->save_N; + curr = s->save_curr; + zt = s->save_zt; + zn = s->save_zn; + zvec = s->save_zvec; + zj = s->save_zj; + gSel = s->save_gSel; + gMinlen = s->save_gMinlen; + gLimit = s->save_gLimit; + gBase = s->save_gBase; + gPerm = s->save_gPerm; + + retVal = BZ_OK; + + switch (s->state) { + + GET_UCHAR(BZ_X_MAGIC_1, uc); + if (uc != BZ_HDR_B) RETURN(BZ_DATA_ERROR_MAGIC); + + GET_UCHAR(BZ_X_MAGIC_2, uc); + if (uc != BZ_HDR_Z) RETURN(BZ_DATA_ERROR_MAGIC); + + GET_UCHAR(BZ_X_MAGIC_3, uc) + if (uc != BZ_HDR_h) RETURN(BZ_DATA_ERROR_MAGIC); + + GET_BITS(BZ_X_MAGIC_4, s->blockSize100k, 8) + if (s->blockSize100k < (BZ_HDR_0 + 1) || + s->blockSize100k > (BZ_HDR_0 + 9)) RETURN(BZ_DATA_ERROR_MAGIC); + s->blockSize100k -= BZ_HDR_0; + + if (s->smallDecompress) { + s->ll16 = BZALLOC( s->blockSize100k * 100000 * sizeof(UInt16) ); + s->ll4 = BZALLOC( + ((1 + s->blockSize100k * 100000) >> 1) * sizeof(UChar) + ); + if (s->ll16 == NULL || s->ll4 == NULL) RETURN(BZ_MEM_ERROR); + } else { + s->tt = BZALLOC( s->blockSize100k * 100000 * sizeof(Int32) ); + if (s->tt == NULL) RETURN(BZ_MEM_ERROR); + } + + GET_UCHAR(BZ_X_BLKHDR_1, uc); + + if (uc == 0x17) goto endhdr_2; + if (uc != 0x31) RETURN(BZ_DATA_ERROR); + GET_UCHAR(BZ_X_BLKHDR_2, uc); + if (uc != 0x41) RETURN(BZ_DATA_ERROR); + GET_UCHAR(BZ_X_BLKHDR_3, uc); + if (uc != 0x59) RETURN(BZ_DATA_ERROR); + GET_UCHAR(BZ_X_BLKHDR_4, uc); + if (uc != 0x26) RETURN(BZ_DATA_ERROR); + GET_UCHAR(BZ_X_BLKHDR_5, uc); + if (uc != 0x53) RETURN(BZ_DATA_ERROR); + GET_UCHAR(BZ_X_BLKHDR_6, uc); + if (uc != 0x59) RETURN(BZ_DATA_ERROR); + + s->currBlockNo++; + if (s->verbosity >= 2) + VPrintf1 ( "\n [%d: huff+mtf ", s->currBlockNo ); + + s->storedBlockCRC = 0; + GET_UCHAR(BZ_X_BCRC_1, uc); + s->storedBlockCRC = (s->storedBlockCRC << 8) | ((UInt32)uc); + GET_UCHAR(BZ_X_BCRC_2, uc); + s->storedBlockCRC = (s->storedBlockCRC << 8) | ((UInt32)uc); + GET_UCHAR(BZ_X_BCRC_3, uc); + s->storedBlockCRC = (s->storedBlockCRC << 8) | ((UInt32)uc); + GET_UCHAR(BZ_X_BCRC_4, uc); + s->storedBlockCRC = (s->storedBlockCRC << 8) | ((UInt32)uc); + + GET_BITS(BZ_X_RANDBIT, s->blockRandomised, 1); + + s->origPtr = 0; + GET_UCHAR(BZ_X_ORIGPTR_1, uc); + s->origPtr = (s->origPtr << 8) | ((Int32)uc); + GET_UCHAR(BZ_X_ORIGPTR_2, uc); + s->origPtr = (s->origPtr << 8) | ((Int32)uc); + GET_UCHAR(BZ_X_ORIGPTR_3, uc); + s->origPtr = (s->origPtr << 8) | ((Int32)uc); + + if (s->origPtr < 0) + RETURN(BZ_DATA_ERROR); + if (s->origPtr > 10 + 100000*s->blockSize100k) + RETURN(BZ_DATA_ERROR); + + /*--- Receive the mapping table ---*/ + for (i = 0; i < 16; i++) { + GET_BIT(BZ_X_MAPPING_1, uc); + if (uc == 1) + s->inUse16[i] = True; else + s->inUse16[i] = False; + } + + for (i = 0; i < 256; i++) s->inUse[i] = False; + + for (i = 0; i < 16; i++) + if (s->inUse16[i]) + for (j = 0; j < 16; j++) { + GET_BIT(BZ_X_MAPPING_2, uc); + if (uc == 1) s->inUse[i * 16 + j] = True; + } + makeMaps_d ( s ); + if (s->nInUse == 0) RETURN(BZ_DATA_ERROR); + alphaSize = s->nInUse+2; + + /*--- Now the selectors ---*/ + GET_BITS(BZ_X_SELECTOR_1, nGroups, 3); + if (nGroups < 2 || nGroups > 6) RETURN(BZ_DATA_ERROR); + GET_BITS(BZ_X_SELECTOR_2, nSelectors, 15); + if (nSelectors < 1) RETURN(BZ_DATA_ERROR); + for (i = 0; i < nSelectors; i++) { + j = 0; + while (True) { + GET_BIT(BZ_X_SELECTOR_3, uc); + if (uc == 0) break; + j++; + if (j >= nGroups) RETURN(BZ_DATA_ERROR); + } + s->selectorMtf[i] = j; + } + + /*--- Undo the MTF values for the selectors. ---*/ + { + UChar pos[BZ_N_GROUPS], tmp, v; + for (v = 0; v < nGroups; v++) pos[v] = v; + + for (i = 0; i < nSelectors; i++) { + v = s->selectorMtf[i]; + tmp = pos[v]; + while (v > 0) { pos[v] = pos[v-1]; v--; } + pos[0] = tmp; + s->selector[i] = tmp; + } + } + + /*--- Now the coding tables ---*/ + for (t = 0; t < nGroups; t++) { + GET_BITS(BZ_X_CODING_1, curr, 5); + for (i = 0; i < alphaSize; i++) { + while (True) { + if (curr < 1 || curr > 20) RETURN(BZ_DATA_ERROR); + GET_BIT(BZ_X_CODING_2, uc); + if (uc == 0) break; + GET_BIT(BZ_X_CODING_3, uc); + if (uc == 0) curr++; else curr--; + } + s->len[t][i] = curr; + } + } + + /*--- Create the Huffman decoding tables ---*/ + for (t = 0; t < nGroups; t++) { + minLen = 32; + maxLen = 0; + for (i = 0; i < alphaSize; i++) { + if (s->len[t][i] > maxLen) maxLen = s->len[t][i]; + if (s->len[t][i] < minLen) minLen = s->len[t][i]; + } + BZ2_hbCreateDecodeTables ( + &(s->limit[t][0]), + &(s->base[t][0]), + &(s->perm[t][0]), + &(s->len[t][0]), + minLen, maxLen, alphaSize + ); + s->minLens[t] = minLen; + } + + /*--- Now the MTF values ---*/ + + EOB = s->nInUse+1; + nblockMAX = 100000 * s->blockSize100k; + groupNo = -1; + groupPos = 0; + + for (i = 0; i <= 255; i++) s->unzftab[i] = 0; + + /*-- MTF init --*/ + { + Int32 ii, jj, kk; + kk = MTFA_SIZE-1; + for (ii = 256 / MTFL_SIZE - 1; ii >= 0; ii--) { + for (jj = MTFL_SIZE-1; jj >= 0; jj--) { + s->mtfa[kk] = (UChar)(ii * MTFL_SIZE + jj); + kk--; + } + s->mtfbase[ii] = kk + 1; + } + } + /*-- end MTF init --*/ + + nblock = 0; + GET_MTF_VAL(BZ_X_MTF_1, BZ_X_MTF_2, nextSym); + + while (True) { + + if (nextSym == EOB) break; + + if (nextSym == BZ_RUNA || nextSym == BZ_RUNB) { + + es = -1; + N = 1; + do { + if (nextSym == BZ_RUNA) es = es + (0+1) * N; else + if (nextSym == BZ_RUNB) es = es + (1+1) * N; + N = N * 2; + GET_MTF_VAL(BZ_X_MTF_3, BZ_X_MTF_4, nextSym); + } + while (nextSym == BZ_RUNA || nextSym == BZ_RUNB); + + es++; + uc = s->seqToUnseq[ s->mtfa[s->mtfbase[0]] ]; + s->unzftab[uc] += es; + + if (s->smallDecompress) + while (es > 0) { + if (nblock >= nblockMAX) RETURN(BZ_DATA_ERROR); + s->ll16[nblock] = (UInt16)uc; + nblock++; + es--; + } + else + while (es > 0) { + if (nblock >= nblockMAX) RETURN(BZ_DATA_ERROR); + s->tt[nblock] = (UInt32)uc; + nblock++; + es--; + }; + + continue; + + } else { + + if (nblock >= nblockMAX) RETURN(BZ_DATA_ERROR); + + /*-- uc = MTF ( nextSym-1 ) --*/ + { + Int32 ii, jj, kk, pp, lno, off; + UInt32 nn; + nn = (UInt32)(nextSym - 1); + + if (nn < MTFL_SIZE) { + /* avoid general-case expense */ + pp = s->mtfbase[0]; + uc = s->mtfa[pp+nn]; + while (nn > 3) { + Int32 z = pp+nn; + s->mtfa[(z) ] = s->mtfa[(z)-1]; + s->mtfa[(z)-1] = s->mtfa[(z)-2]; + s->mtfa[(z)-2] = s->mtfa[(z)-3]; + s->mtfa[(z)-3] = s->mtfa[(z)-4]; + nn -= 4; + } + while (nn > 0) { + s->mtfa[(pp+nn)] = s->mtfa[(pp+nn)-1]; nn--; + }; + s->mtfa[pp] = uc; + } else { + /* general case */ + lno = nn / MTFL_SIZE; + off = nn % MTFL_SIZE; + pp = s->mtfbase[lno] + off; + uc = s->mtfa[pp]; + while (pp > s->mtfbase[lno]) { + s->mtfa[pp] = s->mtfa[pp-1]; pp--; + }; + s->mtfbase[lno]++; + while (lno > 0) { + s->mtfbase[lno]--; + s->mtfa[s->mtfbase[lno]] + = s->mtfa[s->mtfbase[lno-1] + MTFL_SIZE - 1]; + lno--; + } + s->mtfbase[0]--; + s->mtfa[s->mtfbase[0]] = uc; + if (s->mtfbase[0] == 0) { + kk = MTFA_SIZE-1; + for (ii = 256 / MTFL_SIZE-1; ii >= 0; ii--) { + for (jj = MTFL_SIZE-1; jj >= 0; jj--) { + s->mtfa[kk] = s->mtfa[s->mtfbase[ii] + jj]; + kk--; + } + s->mtfbase[ii] = kk + 1; + } + } + } + } + /*-- end uc = MTF ( nextSym-1 ) --*/ + + s->unzftab[s->seqToUnseq[uc]]++; + if (s->smallDecompress) + s->ll16[nblock] = (UInt16)(s->seqToUnseq[uc]); else + s->tt[nblock] = (UInt32)(s->seqToUnseq[uc]); + nblock++; + + GET_MTF_VAL(BZ_X_MTF_5, BZ_X_MTF_6, nextSym); + continue; + } + } + + /* Now we know what nblock is, we can do a better sanity + check on s->origPtr. + */ + if (s->origPtr < 0 || s->origPtr >= nblock) + RETURN(BZ_DATA_ERROR); + + /*-- Set up cftab to facilitate generation of T^(-1) --*/ + s->cftab[0] = 0; + for (i = 1; i <= 256; i++) s->cftab[i] = s->unzftab[i-1]; + for (i = 1; i <= 256; i++) s->cftab[i] += s->cftab[i-1]; + for (i = 0; i <= 256; i++) { + if (s->cftab[i] < 0 || s->cftab[i] > nblock) { + /* s->cftab[i] can legitimately be == nblock */ + RETURN(BZ_DATA_ERROR); + } + } + + s->state_out_len = 0; + s->state_out_ch = 0; + BZ_INITIALISE_CRC ( s->calculatedBlockCRC ); + s->state = BZ_X_OUTPUT; + if (s->verbosity >= 2) VPrintf0 ( "rt+rld" ); + + if (s->smallDecompress) { + + /*-- Make a copy of cftab, used in generation of T --*/ + for (i = 0; i <= 256; i++) s->cftabCopy[i] = s->cftab[i]; + + /*-- compute the T vector --*/ + for (i = 0; i < nblock; i++) { + uc = (UChar)(s->ll16[i]); + SET_LL(i, s->cftabCopy[uc]); + s->cftabCopy[uc]++; + } + + /*-- Compute T^(-1) by pointer reversal on T --*/ + i = s->origPtr; + j = GET_LL(i); + do { + Int32 tmp = GET_LL(j); + SET_LL(j, i); + i = j; + j = tmp; + } + while (i != s->origPtr); + + s->tPos = s->origPtr; + s->nblock_used = 0; + if (s->blockRandomised) { + BZ_RAND_INIT_MASK; + BZ_GET_SMALL(s->k0); s->nblock_used++; + BZ_RAND_UPD_MASK; s->k0 ^= BZ_RAND_MASK; + } else { + BZ_GET_SMALL(s->k0); s->nblock_used++; + } + + } else { + + /*-- compute the T^(-1) vector --*/ + for (i = 0; i < nblock; i++) { + uc = (UChar)(s->tt[i] & 0xff); + s->tt[s->cftab[uc]] |= (i << 8); + s->cftab[uc]++; + } + + s->tPos = s->tt[s->origPtr] >> 8; + s->nblock_used = 0; + if (s->blockRandomised) { + BZ_RAND_INIT_MASK; + BZ_GET_FAST(s->k0); s->nblock_used++; + BZ_RAND_UPD_MASK; s->k0 ^= BZ_RAND_MASK; + } else { + BZ_GET_FAST(s->k0); s->nblock_used++; + } + + } + + RETURN(BZ_OK); + + + + endhdr_2: + + GET_UCHAR(BZ_X_ENDHDR_2, uc); + if (uc != 0x72) RETURN(BZ_DATA_ERROR); + GET_UCHAR(BZ_X_ENDHDR_3, uc); + if (uc != 0x45) RETURN(BZ_DATA_ERROR); + GET_UCHAR(BZ_X_ENDHDR_4, uc); + if (uc != 0x38) RETURN(BZ_DATA_ERROR); + GET_UCHAR(BZ_X_ENDHDR_5, uc); + if (uc != 0x50) RETURN(BZ_DATA_ERROR); + GET_UCHAR(BZ_X_ENDHDR_6, uc); + if (uc != 0x90) RETURN(BZ_DATA_ERROR); + + s->storedCombinedCRC = 0; + GET_UCHAR(BZ_X_CCRC_1, uc); + s->storedCombinedCRC = (s->storedCombinedCRC << 8) | ((UInt32)uc); + GET_UCHAR(BZ_X_CCRC_2, uc); + s->storedCombinedCRC = (s->storedCombinedCRC << 8) | ((UInt32)uc); + GET_UCHAR(BZ_X_CCRC_3, uc); + s->storedCombinedCRC = (s->storedCombinedCRC << 8) | ((UInt32)uc); + GET_UCHAR(BZ_X_CCRC_4, uc); + s->storedCombinedCRC = (s->storedCombinedCRC << 8) | ((UInt32)uc); + + s->state = BZ_X_IDLE; + RETURN(BZ_STREAM_END); + + default: AssertH ( False, 4001 ); + } + + AssertH ( False, 4002 ); + + save_state_and_return: + + s->save_i = i; + s->save_j = j; + s->save_t = t; + s->save_alphaSize = alphaSize; + s->save_nGroups = nGroups; + s->save_nSelectors = nSelectors; + s->save_EOB = EOB; + s->save_groupNo = groupNo; + s->save_groupPos = groupPos; + s->save_nextSym = nextSym; + s->save_nblockMAX = nblockMAX; + s->save_nblock = nblock; + s->save_es = es; + s->save_N = N; + s->save_curr = curr; + s->save_zt = zt; + s->save_zn = zn; + s->save_zvec = zvec; + s->save_zj = zj; + s->save_gSel = gSel; + s->save_gMinlen = gMinlen; + s->save_gLimit = gLimit; + s->save_gBase = gBase; + s->save_gPerm = gPerm; + + return retVal; +} + + +/*-------------------------------------------------------------*/ +/*--- end decompress.c ---*/ +/*-------------------------------------------------------------*/ diff --git a/mk/linux/mojosetup/bzip2/huffman.c b/mk/linux/mojosetup/bzip2/huffman.c new file mode 100644 index 00000000..87e79e38 --- /dev/null +++ b/mk/linux/mojosetup/bzip2/huffman.c @@ -0,0 +1,205 @@ + +/*-------------------------------------------------------------*/ +/*--- Huffman coding low-level stuff ---*/ +/*--- huffman.c ---*/ +/*-------------------------------------------------------------*/ + +/* ------------------------------------------------------------------ + This file is part of bzip2/libbzip2, a program and library for + lossless, block-sorting data compression. + + bzip2/libbzip2 version 1.0.5 of 10 December 2007 + Copyright (C) 1996-2007 Julian Seward + + Please read the WARNING, DISCLAIMER and PATENTS sections in the + README file. + + This program is released under the terms of the license contained + in the file LICENSE. + ------------------------------------------------------------------ */ + + +#include "bzlib_private.h" + +/*---------------------------------------------------*/ +#define WEIGHTOF(zz0) ((zz0) & 0xffffff00) +#define DEPTHOF(zz1) ((zz1) & 0x000000ff) +#define MYMAX(zz2,zz3) ((zz2) > (zz3) ? (zz2) : (zz3)) + +#define ADDWEIGHTS(zw1,zw2) \ + (WEIGHTOF(zw1)+WEIGHTOF(zw2)) | \ + (1 + MYMAX(DEPTHOF(zw1),DEPTHOF(zw2))) + +#define UPHEAP(z) \ +{ \ + Int32 zz, tmp; \ + zz = z; tmp = heap[zz]; \ + while (weight[tmp] < weight[heap[zz >> 1]]) { \ + heap[zz] = heap[zz >> 1]; \ + zz >>= 1; \ + } \ + heap[zz] = tmp; \ +} + +#define DOWNHEAP(z) \ +{ \ + Int32 zz, yy, tmp; \ + zz = z; tmp = heap[zz]; \ + while (True) { \ + yy = zz << 1; \ + if (yy > nHeap) break; \ + if (yy < nHeap && \ + weight[heap[yy+1]] < weight[heap[yy]]) \ + yy++; \ + if (weight[tmp] < weight[heap[yy]]) break; \ + heap[zz] = heap[yy]; \ + zz = yy; \ + } \ + heap[zz] = tmp; \ +} + + +/*---------------------------------------------------*/ +void BZ2_hbMakeCodeLengths ( UChar *len, + Int32 *freq, + Int32 alphaSize, + Int32 maxLen ) +{ + /*-- + Nodes and heap entries run from 1. Entry 0 + for both the heap and nodes is a sentinel. + --*/ + Int32 nNodes, nHeap, n1, n2, i, j, k; + Bool tooLong; + + Int32 heap [ BZ_MAX_ALPHA_SIZE + 2 ]; + Int32 weight [ BZ_MAX_ALPHA_SIZE * 2 ]; + Int32 parent [ BZ_MAX_ALPHA_SIZE * 2 ]; + + for (i = 0; i < alphaSize; i++) + weight[i+1] = (freq[i] == 0 ? 1 : freq[i]) << 8; + + while (True) { + + nNodes = alphaSize; + nHeap = 0; + + heap[0] = 0; + weight[0] = 0; + parent[0] = -2; + + for (i = 1; i <= alphaSize; i++) { + parent[i] = -1; + nHeap++; + heap[nHeap] = i; + UPHEAP(nHeap); + } + + AssertH( nHeap < (BZ_MAX_ALPHA_SIZE+2), 2001 ); + + while (nHeap > 1) { + n1 = heap[1]; heap[1] = heap[nHeap]; nHeap--; DOWNHEAP(1); + n2 = heap[1]; heap[1] = heap[nHeap]; nHeap--; DOWNHEAP(1); + nNodes++; + parent[n1] = parent[n2] = nNodes; + weight[nNodes] = ADDWEIGHTS(weight[n1], weight[n2]); + parent[nNodes] = -1; + nHeap++; + heap[nHeap] = nNodes; + UPHEAP(nHeap); + } + + AssertH( nNodes < (BZ_MAX_ALPHA_SIZE * 2), 2002 ); + + tooLong = False; + for (i = 1; i <= alphaSize; i++) { + j = 0; + k = i; + while (parent[k] >= 0) { k = parent[k]; j++; } + len[i-1] = j; + if (j > maxLen) tooLong = True; + } + + if (! tooLong) break; + + /* 17 Oct 04: keep-going condition for the following loop used + to be 'i < alphaSize', which missed the last element, + theoretically leading to the possibility of the compressor + looping. However, this count-scaling step is only needed if + one of the generated Huffman code words is longer than + maxLen, which up to and including version 1.0.2 was 20 bits, + which is extremely unlikely. In version 1.0.3 maxLen was + changed to 17 bits, which has minimal effect on compression + ratio, but does mean this scaling step is used from time to + time, enough to verify that it works. + + This means that bzip2-1.0.3 and later will only produce + Huffman codes with a maximum length of 17 bits. However, in + order to preserve backwards compatibility with bitstreams + produced by versions pre-1.0.3, the decompressor must still + handle lengths of up to 20. */ + + for (i = 1; i <= alphaSize; i++) { + j = weight[i] >> 8; + j = 1 + (j / 2); + weight[i] = j << 8; + } + } +} + + +/*---------------------------------------------------*/ +void BZ2_hbAssignCodes ( Int32 *code, + UChar *length, + Int32 minLen, + Int32 maxLen, + Int32 alphaSize ) +{ + Int32 n, vec, i; + + vec = 0; + for (n = minLen; n <= maxLen; n++) { + for (i = 0; i < alphaSize; i++) + if (length[i] == n) { code[i] = vec; vec++; }; + vec <<= 1; + } +} + + +/*---------------------------------------------------*/ +void BZ2_hbCreateDecodeTables ( Int32 *limit, + Int32 *base, + Int32 *perm, + UChar *length, + Int32 minLen, + Int32 maxLen, + Int32 alphaSize ) +{ + Int32 pp, i, j, vec; + + pp = 0; + for (i = minLen; i <= maxLen; i++) + for (j = 0; j < alphaSize; j++) + if (length[j] == i) { perm[pp] = j; pp++; }; + + for (i = 0; i < BZ_MAX_CODE_LEN; i++) base[i] = 0; + for (i = 0; i < alphaSize; i++) base[length[i]+1]++; + + for (i = 1; i < BZ_MAX_CODE_LEN; i++) base[i] += base[i-1]; + + for (i = 0; i < BZ_MAX_CODE_LEN; i++) limit[i] = 0; + vec = 0; + + for (i = minLen; i <= maxLen; i++) { + vec += (base[i+1] - base[i]); + limit[i] = vec-1; + vec <<= 1; + } + for (i = minLen + 1; i <= maxLen; i++) + base[i] = ((limit[i-1] + 1) << 1) - base[i]; +} + + +/*-------------------------------------------------------------*/ +/*--- end huffman.c ---*/ +/*-------------------------------------------------------------*/ diff --git a/mk/linux/mojosetup/bzip2/randtable.c b/mk/linux/mojosetup/bzip2/randtable.c new file mode 100644 index 00000000..068b7636 --- /dev/null +++ b/mk/linux/mojosetup/bzip2/randtable.c @@ -0,0 +1,84 @@ + +/*-------------------------------------------------------------*/ +/*--- Table for randomising repetitive blocks ---*/ +/*--- randtable.c ---*/ +/*-------------------------------------------------------------*/ + +/* ------------------------------------------------------------------ + This file is part of bzip2/libbzip2, a program and library for + lossless, block-sorting data compression. + + bzip2/libbzip2 version 1.0.5 of 10 December 2007 + Copyright (C) 1996-2007 Julian Seward + + Please read the WARNING, DISCLAIMER and PATENTS sections in the + README file. + + This program is released under the terms of the license contained + in the file LICENSE. + ------------------------------------------------------------------ */ + + +#include "bzlib_private.h" + + +/*---------------------------------------------*/ +Int32 BZ2_rNums[512] = { + 619, 720, 127, 481, 931, 816, 813, 233, 566, 247, + 985, 724, 205, 454, 863, 491, 741, 242, 949, 214, + 733, 859, 335, 708, 621, 574, 73, 654, 730, 472, + 419, 436, 278, 496, 867, 210, 399, 680, 480, 51, + 878, 465, 811, 169, 869, 675, 611, 697, 867, 561, + 862, 687, 507, 283, 482, 129, 807, 591, 733, 623, + 150, 238, 59, 379, 684, 877, 625, 169, 643, 105, + 170, 607, 520, 932, 727, 476, 693, 425, 174, 647, + 73, 122, 335, 530, 442, 853, 695, 249, 445, 515, + 909, 545, 703, 919, 874, 474, 882, 500, 594, 612, + 641, 801, 220, 162, 819, 984, 589, 513, 495, 799, + 161, 604, 958, 533, 221, 400, 386, 867, 600, 782, + 382, 596, 414, 171, 516, 375, 682, 485, 911, 276, + 98, 553, 163, 354, 666, 933, 424, 341, 533, 870, + 227, 730, 475, 186, 263, 647, 537, 686, 600, 224, + 469, 68, 770, 919, 190, 373, 294, 822, 808, 206, + 184, 943, 795, 384, 383, 461, 404, 758, 839, 887, + 715, 67, 618, 276, 204, 918, 873, 777, 604, 560, + 951, 160, 578, 722, 79, 804, 96, 409, 713, 940, + 652, 934, 970, 447, 318, 353, 859, 672, 112, 785, + 645, 863, 803, 350, 139, 93, 354, 99, 820, 908, + 609, 772, 154, 274, 580, 184, 79, 626, 630, 742, + 653, 282, 762, 623, 680, 81, 927, 626, 789, 125, + 411, 521, 938, 300, 821, 78, 343, 175, 128, 250, + 170, 774, 972, 275, 999, 639, 495, 78, 352, 126, + 857, 956, 358, 619, 580, 124, 737, 594, 701, 612, + 669, 112, 134, 694, 363, 992, 809, 743, 168, 974, + 944, 375, 748, 52, 600, 747, 642, 182, 862, 81, + 344, 805, 988, 739, 511, 655, 814, 334, 249, 515, + 897, 955, 664, 981, 649, 113, 974, 459, 893, 228, + 433, 837, 553, 268, 926, 240, 102, 654, 459, 51, + 686, 754, 806, 760, 493, 403, 415, 394, 687, 700, + 946, 670, 656, 610, 738, 392, 760, 799, 887, 653, + 978, 321, 576, 617, 626, 502, 894, 679, 243, 440, + 680, 879, 194, 572, 640, 724, 926, 56, 204, 700, + 707, 151, 457, 449, 797, 195, 791, 558, 945, 679, + 297, 59, 87, 824, 713, 663, 412, 693, 342, 606, + 134, 108, 571, 364, 631, 212, 174, 643, 304, 329, + 343, 97, 430, 751, 497, 314, 983, 374, 822, 928, + 140, 206, 73, 263, 980, 736, 876, 478, 430, 305, + 170, 514, 364, 692, 829, 82, 855, 953, 676, 246, + 369, 970, 294, 750, 807, 827, 150, 790, 288, 923, + 804, 378, 215, 828, 592, 281, 565, 555, 710, 82, + 896, 831, 547, 261, 524, 462, 293, 465, 502, 56, + 661, 821, 976, 991, 658, 869, 905, 758, 745, 193, + 768, 550, 608, 933, 378, 286, 215, 979, 792, 961, + 61, 688, 793, 644, 986, 403, 106, 366, 905, 644, + 372, 567, 466, 434, 645, 210, 389, 550, 919, 135, + 780, 773, 635, 389, 707, 100, 626, 958, 165, 504, + 920, 176, 193, 713, 857, 265, 203, 50, 668, 108, + 645, 990, 626, 197, 510, 357, 358, 850, 858, 364, + 936, 638 +}; + + +/*-------------------------------------------------------------*/ +/*--- end randtable.c ---*/ +/*-------------------------------------------------------------*/ diff --git a/mk/linux/mojosetup/bzip2/version.txt b/mk/linux/mojosetup/bzip2/version.txt new file mode 100644 index 00000000..db284dad --- /dev/null +++ b/mk/linux/mojosetup/bzip2/version.txt @@ -0,0 +1 @@ +bzip2-1.0.5 diff --git a/mk/linux/mojosetup/checksum_crc32.c b/mk/linux/mojosetup/checksum_crc32.c new file mode 100644 index 00000000..7bd18882 --- /dev/null +++ b/mk/linux/mojosetup/checksum_crc32.c @@ -0,0 +1,81 @@ +#include "universal.h" + +#if SUPPORT_CRC32 + +void MojoCrc32_init(MojoCrc32 *context) +{ + *context = (MojoCrc32) 0xFFFFFFFF; +} // MojoCrc32_init + + +void MojoCrc32_append(MojoCrc32 *_crc, const uint8 *buf, uint32 len) +{ + uint32 crc = (uint32) *_crc; + + uint32 n; + for (n = 0; n < len; n++) + { + uint32 xorval = (uint32) ((crc ^ buf[n]) & 0xFF); + xorval = ((xorval & 1) ? (0xEDB88320 ^ (xorval >> 1)) : (xorval >> 1)); + xorval = ((xorval & 1) ? (0xEDB88320 ^ (xorval >> 1)) : (xorval >> 1)); + xorval = ((xorval & 1) ? (0xEDB88320 ^ (xorval >> 1)) : (xorval >> 1)); + xorval = ((xorval & 1) ? (0xEDB88320 ^ (xorval >> 1)) : (xorval >> 1)); + xorval = ((xorval & 1) ? (0xEDB88320 ^ (xorval >> 1)) : (xorval >> 1)); + xorval = ((xorval & 1) ? (0xEDB88320 ^ (xorval >> 1)) : (xorval >> 1)); + xorval = ((xorval & 1) ? (0xEDB88320 ^ (xorval >> 1)) : (xorval >> 1)); + xorval = ((xorval & 1) ? (0xEDB88320 ^ (xorval >> 1)) : (xorval >> 1)); + crc = xorval ^ (crc >> 8); + } // for + + *_crc = (MojoCrc32) crc; +} // MojoCrc32_append + + +void MojoCrc32_finish(MojoCrc32 *context, uint32 *digest) +{ + *digest = (*context ^ 0xFFFFFFFF); +} // MojoCrc32_finish + + +#endif // SUPPORT_CRC32 + +#if TEST_CRC32 +int main(int argc, char **argv) +{ + int i = 0; + for (i = 1; i < argc; i++) + { + FILE *in = NULL; + MojoCrc32 ctx; + MojoCrc32_init(&ctx); + in = fopen(argv[i], "rb"); + if (!in) + perror("fopen"); + else + { + uint32 digest = 0; + int err = 0; + while ( (!err) && (!feof(in)) ) + { + uint8 buf[1024]; + size_t rc = fread(buf, 1, sizeof (buf), in); + if (rc > 0) + MojoCrc32_append(&ctx, buf, rc); + err = ferror(in); + } // while + + if (err) + perror("fread"); + fclose(in); + MojoCrc32_finish(&ctx, &digest); + if (!err) + printf("%s: %X\n", argv[i], (unsigned int) digest); + } // else + } // for + + return 0; +} // main +#endif + +// end of checksum_crc32.c ... + diff --git a/mk/linux/mojosetup/checksum_md5.c b/mk/linux/mojosetup/checksum_md5.c new file mode 100644 index 00000000..bb940be1 --- /dev/null +++ b/mk/linux/mojosetup/checksum_md5.c @@ -0,0 +1,441 @@ +#include "universal.h" + +#if SUPPORT_MD5 + +// MD5 code originally from http://sourceforge.net/projects/libmd5-rfc/ +// License: zlib. +// I cleaned it up a little for MojoSetup's specific purposes. --ryan. + +/* + Copyright (C) 1999, 2000, 2002 Aladdin Enterprises. All rights reserved. + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. + + L. Peter Deutsch + ghost@aladdin.com + + */ +/* $Id: md5.c,v 1.6 2002/04/13 19:20:28 lpd Exp $ */ +/* + Independent implementation of MD5 (RFC 1321). + + This code implements the MD5 Algorithm defined in RFC 1321, whose + text is available at + http://www.ietf.org/rfc/rfc1321.txt + The code is derived from the text of the RFC, including the test suite + (section A.5) but excluding the rest of Appendix A. It does not include + any code or documentation that is identified in the RFC as being + copyrighted. + + The original and principal author of md5.c is L. Peter Deutsch + . Other authors are noted in the change history + that follows (in reverse chronological order): + + 2002-04-13 lpd Clarified derivation from RFC 1321; now handles byte order + either statically or dynamically; added missing #include + in library. + 2002-03-11 lpd Corrected argument list for main(), and added int return + type, in test program and T value program. + 2002-02-21 lpd Added missing #include in test program. + 2000-07-03 lpd Patched to eliminate warnings about "constant is + unsigned in ANSI C, signed in traditional"; made test program + self-checking. + 1999-11-04 lpd Edited comments slightly for automatic TOC extraction. + 1999-10-18 lpd Fixed typo in header comment (ansi2knr rather than md5). + 1999-05-03 lpd Original version. + */ + +#undef BYTE_ORDER /* 1 = big-endian, -1 = little-endian, 0 = unknown */ +//#ifdef ARCH_IS_BIG_ENDIAN +//# define BYTE_ORDER (ARCH_IS_BIG_ENDIAN ? 1 : -1) +//#else +//# define BYTE_ORDER 0 +//#endif +#if PLATFORM_BIGENDIAN +# define BYTE_ORDER 1 +#else +# define BYTE_ORDER -1 +#endif + +#define T_MASK ((uint32)~0) +#define T1 /* 0xd76aa478 */ (T_MASK ^ 0x28955b87) +#define T2 /* 0xe8c7b756 */ (T_MASK ^ 0x173848a9) +#define T3 0x242070db +#define T4 /* 0xc1bdceee */ (T_MASK ^ 0x3e423111) +#define T5 /* 0xf57c0faf */ (T_MASK ^ 0x0a83f050) +#define T6 0x4787c62a +#define T7 /* 0xa8304613 */ (T_MASK ^ 0x57cfb9ec) +#define T8 /* 0xfd469501 */ (T_MASK ^ 0x02b96afe) +#define T9 0x698098d8 +#define T10 /* 0x8b44f7af */ (T_MASK ^ 0x74bb0850) +#define T11 /* 0xffff5bb1 */ (T_MASK ^ 0x0000a44e) +#define T12 /* 0x895cd7be */ (T_MASK ^ 0x76a32841) +#define T13 0x6b901122 +#define T14 /* 0xfd987193 */ (T_MASK ^ 0x02678e6c) +#define T15 /* 0xa679438e */ (T_MASK ^ 0x5986bc71) +#define T16 0x49b40821 +#define T17 /* 0xf61e2562 */ (T_MASK ^ 0x09e1da9d) +#define T18 /* 0xc040b340 */ (T_MASK ^ 0x3fbf4cbf) +#define T19 0x265e5a51 +#define T20 /* 0xe9b6c7aa */ (T_MASK ^ 0x16493855) +#define T21 /* 0xd62f105d */ (T_MASK ^ 0x29d0efa2) +#define T22 0x02441453 +#define T23 /* 0xd8a1e681 */ (T_MASK ^ 0x275e197e) +#define T24 /* 0xe7d3fbc8 */ (T_MASK ^ 0x182c0437) +#define T25 0x21e1cde6 +#define T26 /* 0xc33707d6 */ (T_MASK ^ 0x3cc8f829) +#define T27 /* 0xf4d50d87 */ (T_MASK ^ 0x0b2af278) +#define T28 0x455a14ed +#define T29 /* 0xa9e3e905 */ (T_MASK ^ 0x561c16fa) +#define T30 /* 0xfcefa3f8 */ (T_MASK ^ 0x03105c07) +#define T31 0x676f02d9 +#define T32 /* 0x8d2a4c8a */ (T_MASK ^ 0x72d5b375) +#define T33 /* 0xfffa3942 */ (T_MASK ^ 0x0005c6bd) +#define T34 /* 0x8771f681 */ (T_MASK ^ 0x788e097e) +#define T35 0x6d9d6122 +#define T36 /* 0xfde5380c */ (T_MASK ^ 0x021ac7f3) +#define T37 /* 0xa4beea44 */ (T_MASK ^ 0x5b4115bb) +#define T38 0x4bdecfa9 +#define T39 /* 0xf6bb4b60 */ (T_MASK ^ 0x0944b49f) +#define T40 /* 0xbebfbc70 */ (T_MASK ^ 0x4140438f) +#define T41 0x289b7ec6 +#define T42 /* 0xeaa127fa */ (T_MASK ^ 0x155ed805) +#define T43 /* 0xd4ef3085 */ (T_MASK ^ 0x2b10cf7a) +#define T44 0x04881d05 +#define T45 /* 0xd9d4d039 */ (T_MASK ^ 0x262b2fc6) +#define T46 /* 0xe6db99e5 */ (T_MASK ^ 0x1924661a) +#define T47 0x1fa27cf8 +#define T48 /* 0xc4ac5665 */ (T_MASK ^ 0x3b53a99a) +#define T49 /* 0xf4292244 */ (T_MASK ^ 0x0bd6ddbb) +#define T50 0x432aff97 +#define T51 /* 0xab9423a7 */ (T_MASK ^ 0x546bdc58) +#define T52 /* 0xfc93a039 */ (T_MASK ^ 0x036c5fc6) +#define T53 0x655b59c3 +#define T54 /* 0x8f0ccc92 */ (T_MASK ^ 0x70f3336d) +#define T55 /* 0xffeff47d */ (T_MASK ^ 0x00100b82) +#define T56 /* 0x85845dd1 */ (T_MASK ^ 0x7a7ba22e) +#define T57 0x6fa87e4f +#define T58 /* 0xfe2ce6e0 */ (T_MASK ^ 0x01d3191f) +#define T59 /* 0xa3014314 */ (T_MASK ^ 0x5cfebceb) +#define T60 0x4e0811a1 +#define T61 /* 0xf7537e82 */ (T_MASK ^ 0x08ac817d) +#define T62 /* 0xbd3af235 */ (T_MASK ^ 0x42c50dca) +#define T63 0x2ad7d2bb +#define T64 /* 0xeb86d391 */ (T_MASK ^ 0x14792c6e) + + +static void +MojoMd5_process(MojoMd5 *pms, const uint8 *data /*[64]*/) +{ + uint32 + a = pms->abcd[0], b = pms->abcd[1], + c = pms->abcd[2], d = pms->abcd[3]; + uint32 t; +#if BYTE_ORDER > 0 + /* Define storage only for big-endian CPUs. */ + uint32 X[16]; +#else + /* Define storage for little-endian or both types of CPUs. */ + uint32 xbuf[16]; + const uint32 *X; +#endif + + { +#if BYTE_ORDER == 0 + /* + * Determine dynamically whether this is a big-endian or + * little-endian machine, since we can use a more efficient + * algorithm on the latter. + */ + static const int w = 1; + + if (*((const uint8 *)&w)) /* dynamic little-endian */ +#endif +#if BYTE_ORDER <= 0 /* little-endian */ + { + /* + * On little-endian machines, we can process properly aligned + * data without copying it. + */ + if (!((data - (const uint8 *)0) & 3)) { + /* data are properly aligned */ + X = (const uint32 *)data; + } else { + /* not aligned */ + memcpy(xbuf, data, 64); + X = xbuf; + } + } +#endif +#if BYTE_ORDER == 0 + else /* dynamic big-endian */ +#endif +#if BYTE_ORDER >= 0 /* big-endian */ + { + /* + * On big-endian machines, we must arrange the bytes in the + * right order. + */ + const uint8 *xp = data; + int i; + +# if BYTE_ORDER == 0 + X = xbuf; /* (dynamic only) */ +# else +# define xbuf X /* (static only) */ +# endif + for (i = 0; i < 16; ++i, xp += 4) + xbuf[i] = xp[0] + (xp[1] << 8) + (xp[2] << 16) + (xp[3] << 24); + } +#endif + } + +#define ROTATE_LEFT(x, n) (((x) << (n)) | ((x) >> (32 - (n)))) + + /* Round 1. */ + /* Let [abcd k s i] denote the operation + a = b + ((a + F(b,c,d) + X[k] + T[i]) <<< s). */ +#define F(x, y, z) (((x) & (y)) | (~(x) & (z))) +#define SET(a, b, c, d, k, s, Ti)\ + t = a + F(b,c,d) + X[k] + Ti;\ + a = ROTATE_LEFT(t, s) + b + /* Do the following 16 operations. */ + SET(a, b, c, d, 0, 7, T1); + SET(d, a, b, c, 1, 12, T2); + SET(c, d, a, b, 2, 17, T3); + SET(b, c, d, a, 3, 22, T4); + SET(a, b, c, d, 4, 7, T5); + SET(d, a, b, c, 5, 12, T6); + SET(c, d, a, b, 6, 17, T7); + SET(b, c, d, a, 7, 22, T8); + SET(a, b, c, d, 8, 7, T9); + SET(d, a, b, c, 9, 12, T10); + SET(c, d, a, b, 10, 17, T11); + SET(b, c, d, a, 11, 22, T12); + SET(a, b, c, d, 12, 7, T13); + SET(d, a, b, c, 13, 12, T14); + SET(c, d, a, b, 14, 17, T15); + SET(b, c, d, a, 15, 22, T16); +#undef SET + + /* Round 2. */ + /* Let [abcd k s i] denote the operation + a = b + ((a + G(b,c,d) + X[k] + T[i]) <<< s). */ +#define G(x, y, z) (((x) & (z)) | ((y) & ~(z))) +#define SET(a, b, c, d, k, s, Ti)\ + t = a + G(b,c,d) + X[k] + Ti;\ + a = ROTATE_LEFT(t, s) + b + /* Do the following 16 operations. */ + SET(a, b, c, d, 1, 5, T17); + SET(d, a, b, c, 6, 9, T18); + SET(c, d, a, b, 11, 14, T19); + SET(b, c, d, a, 0, 20, T20); + SET(a, b, c, d, 5, 5, T21); + SET(d, a, b, c, 10, 9, T22); + SET(c, d, a, b, 15, 14, T23); + SET(b, c, d, a, 4, 20, T24); + SET(a, b, c, d, 9, 5, T25); + SET(d, a, b, c, 14, 9, T26); + SET(c, d, a, b, 3, 14, T27); + SET(b, c, d, a, 8, 20, T28); + SET(a, b, c, d, 13, 5, T29); + SET(d, a, b, c, 2, 9, T30); + SET(c, d, a, b, 7, 14, T31); + SET(b, c, d, a, 12, 20, T32); +#undef SET + + /* Round 3. */ + /* Let [abcd k s t] denote the operation + a = b + ((a + H(b,c,d) + X[k] + T[i]) <<< s). */ +#define H(x, y, z) ((x) ^ (y) ^ (z)) +#define SET(a, b, c, d, k, s, Ti)\ + t = a + H(b,c,d) + X[k] + Ti;\ + a = ROTATE_LEFT(t, s) + b + /* Do the following 16 operations. */ + SET(a, b, c, d, 5, 4, T33); + SET(d, a, b, c, 8, 11, T34); + SET(c, d, a, b, 11, 16, T35); + SET(b, c, d, a, 14, 23, T36); + SET(a, b, c, d, 1, 4, T37); + SET(d, a, b, c, 4, 11, T38); + SET(c, d, a, b, 7, 16, T39); + SET(b, c, d, a, 10, 23, T40); + SET(a, b, c, d, 13, 4, T41); + SET(d, a, b, c, 0, 11, T42); + SET(c, d, a, b, 3, 16, T43); + SET(b, c, d, a, 6, 23, T44); + SET(a, b, c, d, 9, 4, T45); + SET(d, a, b, c, 12, 11, T46); + SET(c, d, a, b, 15, 16, T47); + SET(b, c, d, a, 2, 23, T48); +#undef SET + + /* Round 4. */ + /* Let [abcd k s t] denote the operation + a = b + ((a + I(b,c,d) + X[k] + T[i]) <<< s). */ +#define I(x, y, z) ((y) ^ ((x) | ~(z))) +#define SET(a, b, c, d, k, s, Ti)\ + t = a + I(b,c,d) + X[k] + Ti;\ + a = ROTATE_LEFT(t, s) + b + /* Do the following 16 operations. */ + SET(a, b, c, d, 0, 6, T49); + SET(d, a, b, c, 7, 10, T50); + SET(c, d, a, b, 14, 15, T51); + SET(b, c, d, a, 5, 21, T52); + SET(a, b, c, d, 12, 6, T53); + SET(d, a, b, c, 3, 10, T54); + SET(c, d, a, b, 10, 15, T55); + SET(b, c, d, a, 1, 21, T56); + SET(a, b, c, d, 8, 6, T57); + SET(d, a, b, c, 15, 10, T58); + SET(c, d, a, b, 6, 15, T59); + SET(b, c, d, a, 13, 21, T60); + SET(a, b, c, d, 4, 6, T61); + SET(d, a, b, c, 11, 10, T62); + SET(c, d, a, b, 2, 15, T63); + SET(b, c, d, a, 9, 21, T64); +#undef SET + + /* Then perform the following additions. (That is increment each + of the four registers by the value it had before this block + was started.) */ + pms->abcd[0] += a; + pms->abcd[1] += b; + pms->abcd[2] += c; + pms->abcd[3] += d; +} + +void +MojoMd5_init(MojoMd5 *pms) +{ + pms->count[0] = pms->count[1] = 0; + pms->abcd[0] = 0x67452301; + pms->abcd[1] = /*0xefcdab89*/ T_MASK ^ 0x10325476; + pms->abcd[2] = /*0x98badcfe*/ T_MASK ^ 0x67452301; + pms->abcd[3] = 0x10325476; +} + +void +MojoMd5_append(MojoMd5 *pms, const uint8 *data, int nbytes) +{ + const uint8 *p = data; + int left = nbytes; + int offset = (pms->count[0] >> 3) & 63; + uint32 nbits = (uint32)(nbytes << 3); + + if (nbytes <= 0) + return; + + /* Update the message length. */ + pms->count[1] += nbytes >> 29; + pms->count[0] += nbits; + if (pms->count[0] < nbits) + pms->count[1]++; + + /* Process an initial partial block. */ + if (offset) { + int copy = (offset + nbytes > 64 ? 64 - offset : nbytes); + + memcpy(pms->buf + offset, p, copy); + if (offset + copy < 64) + return; + p += copy; + left -= copy; + MojoMd5_process(pms, pms->buf); + } + + /* Process full blocks. */ + for (; left >= 64; p += 64, left -= 64) + MojoMd5_process(pms, p); + + /* Process a final partial block. */ + if (left) + memcpy(pms->buf, p, left); +} + +void +MojoMd5_finish(MojoMd5 *pms, uint8 digest[16]) +{ + const uint8 pad[64] = { + 0x80, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 + }; + uint8 data[8]; + int i; + + /* Save the length before padding. */ + for (i = 0; i < 8; ++i) + data[i] = (uint8)(pms->count[i >> 2] >> ((i & 3) << 3)); + /* Pad to 56 bytes mod 64. */ + MojoMd5_append(pms, pad, ((55 - (pms->count[0] >> 3)) & 63) + 1); + /* Append the length. */ + MojoMd5_append(pms, data, 8); + for (i = 0; i < 16; ++i) + digest[i] = (uint8)(pms->abcd[i >> 2] >> ((i & 3) << 3)); +} + +#endif // SUPPORT_MD5 + +#if TEST_MD5 +int main(int argc, char **argv) +{ + int i = 0; + for (i = 1; i < argc; i++) + { + FILE *in = NULL; + MojoMd5 ctx; + MojoMd5_init(&ctx); + in = fopen(argv[i], "rb"); + if (!in) + perror("fopen"); + else + { + uint8 dig[16]; + int err = 0; + while ( (!err) && (!feof(in)) ) + { + uint8 buf[1024]; + size_t rc = fread(buf, 1, sizeof (buf), in); + if (rc > 0) + MojoMd5_append(&ctx, buf, rc); + err = ferror(in); + } // while + + if (err) + perror("fread"); + fclose(in); + MojoMd5_finish(&ctx, dig); + + if (!err) + { + printf("%s: %x%x%x%x%x%x%x%x%x%x%x%x%x%x%x%x\n", argv[i], + (int) dig[0], (int) dig[1], (int) dig[2], (int) dig[3], + (int) dig[4], (int) dig[5], (int) dig[6], (int) dig[7], + (int) dig[8], (int) dig[9], (int) dig[10], (int) dig[11], + (int) dig[12], (int) dig[13], (int) dig[14], (int) dig[15]); + } // if + } // else + } // for + + return 0; +} // main +#endif + +// end of checksum_md5.c ... + diff --git a/mk/linux/mojosetup/checksum_sha1.c b/mk/linux/mojosetup/checksum_sha1.c new file mode 100644 index 00000000..ea9e18cd --- /dev/null +++ b/mk/linux/mojosetup/checksum_sha1.c @@ -0,0 +1,210 @@ +#include "universal.h" + +#if SUPPORT_SHA1 + +// SHA-1 code originally from ftp://ftp.funet.fi/pub/crypt/hash/sha/sha1.c +// License: public domain. +// I cleaned it up a little for MojoSetup's specific purposes. --ryan. + +/* +SHA-1 in C +By Steve Reid +100% Public Domain + +Test Vectors (from FIPS PUB 180-1) +"abc" + A9993E36 4706816A BA3E2571 7850C26C 9CD0D89D +"abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq" + 84983E44 1C3BD26E BAAE4AA1 F95129E5 E54670F1 +A million repetitions of "a" + 34AA973C D4C4DAA4 F61EEB2B DBAD2731 6534016F +*/ + +#define rol(value, bits) (((value) << (bits)) | ((value) >> (32 - (bits)))) + +/* blk0() and blk() perform the initial expand. */ +/* I got the idea of expanding during the round function from SSLeay */ +#if PLATFORM_LITTLEENDIAN +#define blk0(i) (block->l[i] = (rol(block->l[i],24)&0xFF00FF00) \ + |(rol(block->l[i],8)&0x00FF00FF)) +#else +#define blk0(i) block->l[i] +#endif +#define blk(i) (block->l[i&15] = rol(block->l[(i+13)&15]^block->l[(i+8)&15] \ + ^block->l[(i+2)&15]^block->l[i&15],1)) + +/* (R0+R1), R2, R3, R4 are the different operations used in SHA1 */ +#define R0(v,w,x,y,z,i) z+=((w&(x^y))^y)+blk0(i)+0x5A827999+rol(v,5);w=rol(w,30); +#define R1(v,w,x,y,z,i) z+=((w&(x^y))^y)+blk(i)+0x5A827999+rol(v,5);w=rol(w,30); +#define R2(v,w,x,y,z,i) z+=(w^x^y)+blk(i)+0x6ED9EBA1+rol(v,5);w=rol(w,30); +#define R3(v,w,x,y,z,i) z+=(((w|x)&y)|(w&x))+blk(i)+0x8F1BBCDC+rol(v,5);w=rol(w,30); +#define R4(v,w,x,y,z,i) z+=(w^x^y)+blk(i)+0xCA62C1D6+rol(v,5);w=rol(w,30); + + +/* Hash a single 512-bit block. This is the core of the algorithm. */ + +static void MojoSha1_transform(uint32 state[5], const uint8 buffer[64]) +{ + uint32 a, b, c, d, e; + typedef union { + uint8 c[64]; + uint32 l[16]; + } CHAR64LONG16; + CHAR64LONG16* block; + static uint8 workspace[64]; + block = (CHAR64LONG16*)workspace; + memcpy(block, buffer, 64); + /* Copy context->state[] to working vars */ + a = state[0]; + b = state[1]; + c = state[2]; + d = state[3]; + e = state[4]; + /* 4 rounds of 20 operations each. Loop unrolled. */ + R0(a,b,c,d,e, 0); R0(e,a,b,c,d, 1); R0(d,e,a,b,c, 2); R0(c,d,e,a,b, 3); + R0(b,c,d,e,a, 4); R0(a,b,c,d,e, 5); R0(e,a,b,c,d, 6); R0(d,e,a,b,c, 7); + R0(c,d,e,a,b, 8); R0(b,c,d,e,a, 9); R0(a,b,c,d,e,10); R0(e,a,b,c,d,11); + R0(d,e,a,b,c,12); R0(c,d,e,a,b,13); R0(b,c,d,e,a,14); R0(a,b,c,d,e,15); + R1(e,a,b,c,d,16); R1(d,e,a,b,c,17); R1(c,d,e,a,b,18); R1(b,c,d,e,a,19); + R2(a,b,c,d,e,20); R2(e,a,b,c,d,21); R2(d,e,a,b,c,22); R2(c,d,e,a,b,23); + R2(b,c,d,e,a,24); R2(a,b,c,d,e,25); R2(e,a,b,c,d,26); R2(d,e,a,b,c,27); + R2(c,d,e,a,b,28); R2(b,c,d,e,a,29); R2(a,b,c,d,e,30); R2(e,a,b,c,d,31); + R2(d,e,a,b,c,32); R2(c,d,e,a,b,33); R2(b,c,d,e,a,34); R2(a,b,c,d,e,35); + R2(e,a,b,c,d,36); R2(d,e,a,b,c,37); R2(c,d,e,a,b,38); R2(b,c,d,e,a,39); + R3(a,b,c,d,e,40); R3(e,a,b,c,d,41); R3(d,e,a,b,c,42); R3(c,d,e,a,b,43); + R3(b,c,d,e,a,44); R3(a,b,c,d,e,45); R3(e,a,b,c,d,46); R3(d,e,a,b,c,47); + R3(c,d,e,a,b,48); R3(b,c,d,e,a,49); R3(a,b,c,d,e,50); R3(e,a,b,c,d,51); + R3(d,e,a,b,c,52); R3(c,d,e,a,b,53); R3(b,c,d,e,a,54); R3(a,b,c,d,e,55); + R3(e,a,b,c,d,56); R3(d,e,a,b,c,57); R3(c,d,e,a,b,58); R3(b,c,d,e,a,59); + R4(a,b,c,d,e,60); R4(e,a,b,c,d,61); R4(d,e,a,b,c,62); R4(c,d,e,a,b,63); + R4(b,c,d,e,a,64); R4(a,b,c,d,e,65); R4(e,a,b,c,d,66); R4(d,e,a,b,c,67); + R4(c,d,e,a,b,68); R4(b,c,d,e,a,69); R4(a,b,c,d,e,70); R4(e,a,b,c,d,71); + R4(d,e,a,b,c,72); R4(c,d,e,a,b,73); R4(b,c,d,e,a,74); R4(a,b,c,d,e,75); + R4(e,a,b,c,d,76); R4(d,e,a,b,c,77); R4(c,d,e,a,b,78); R4(b,c,d,e,a,79); + /* Add the working vars back into context.state[] */ + state[0] += a; + state[1] += b; + state[2] += c; + state[3] += d; + state[4] += e; + /* Wipe variables */ + a = b = c = d = e = 0; +} + + +/* MojoSha1_init - Initialize new context */ + +void MojoSha1_init(MojoSha1 *context) +{ + /* SHA1 initialization constants */ + context->state[0] = 0x67452301; + context->state[1] = 0xEFCDAB89; + context->state[2] = 0x98BADCFE; + context->state[3] = 0x10325476; + context->state[4] = 0xC3D2E1F0; + context->count[0] = context->count[1] = 0; +} + + +/* Run your data through this. */ + +void MojoSha1_append(MojoSha1 *context, const uint8 *data, uint32 len) +{ + uint32 i, j; + + j = (context->count[0] >> 3) & 63; + if ((context->count[0] += len << 3) < (len << 3)) context->count[1]++; + context->count[1] += (len >> 29); + if ((j + len) > 63) { + memcpy(&context->buffer[j], data, (i = 64-j)); + MojoSha1_transform(context->state, context->buffer); + for ( ; i + 63 < len; i += 64) { + MojoSha1_transform(context->state, &data[i]); + } + j = 0; + } + else i = 0; + memcpy(&context->buffer[j], &data[i], len - i); +} + + +/* Add padding and return the message digest. */ + +void MojoSha1_finish(MojoSha1 *context, uint8 digest[20]) +{ + uint32 i, j; + uint8 finalcount[8]; + + for (i = 0; i < 8; i++) { + finalcount[i] = (uint8)((context->count[(i >= 4 ? 0 : 1)] + >> ((3-(i & 3)) * 8) ) & 255); /* Endian independent */ + } + MojoSha1_append(context, (uint8 *)"\200", 1); + while ((context->count[0] & 504) != 448) { + MojoSha1_append(context, (uint8 *)"\0", 1); + } + MojoSha1_append(context, finalcount, 8); /* Should cause a MojoSha1_transform() */ + for (i = 0; i < 20; i++) { + digest[i] = (uint8) + ((context->state[i>>2] >> ((3-(i & 3)) * 8) ) & 255); + } + /* Wipe variables */ + i = j = 0; + memset(context->buffer, 0, 64); + memset(context->state, 0, 20); + memset(context->count, 0, 8); + memset(&finalcount, 0, 8); + MojoSha1_transform(context->state, context->buffer); +} + +#endif // SUPPORT_SHA1 + +#if TEST_SHA1 +int main(int argc, char **argv) +{ + int i = 0; + for (i = 1; i < argc; i++) + { + FILE *in = NULL; + MojoSha1 ctx; + MojoSha1_init(&ctx); + in = fopen(argv[i], "rb"); + if (!in) + perror("fopen"); + else + { + uint8 dig[20]; + int err = 0; + while ( (!err) && (!feof(in)) ) + { + uint8 buf[1024]; + size_t rc = fread(buf, 1, sizeof (buf), in); + if (rc > 0) + MojoSha1_append(&ctx, buf, rc); + err = ferror(in); + } // while + + if (err) + perror("fread"); + fclose(in); + MojoSha1_finish(&ctx, dig); + + if (!err) + { + printf("%s: %x%x%x%x%x%x%x%x%x%x%x%x%x%x%x%x%x%x%x%x\n", + argv[i], + (int) dig[0], (int) dig[1], (int) dig[2], (int) dig[3], + (int) dig[4], (int) dig[5], (int) dig[6], (int) dig[7], + (int) dig[8], (int) dig[9], (int) dig[10], (int) dig[11], + (int) dig[12], (int) dig[13], (int) dig[14], (int) dig[15], + (int) dig[16], (int) dig[17], (int) dig[18], (int) dig[19]); + } // if + } // else + } // for + + return 0; +} // main +#endif + +// end of checksum_sha1.c ... + diff --git a/mk/linux/mojosetup/docs.txt b/mk/linux/mojosetup/docs.txt new file mode 100644 index 00000000..7c86c5a8 --- /dev/null +++ b/mk/linux/mojosetup/docs.txt @@ -0,0 +1,1405 @@ + +Using MojoSetup. + +If there are gaps in this documentation, please ask on the MojoSetup mailing + list. To subscribe to the list, go here... + + http://icculus.org/mailman/listinfo/mojosetup + + ...and then questions can go to mojosetup@icculus.org. This document will + be updated as we see what parts are confusing, so feedback is appreciated. + + +Putting together a MojoSetup installer involves five general steps: +1) Compile the software. +2) Set up the installer filesystem structure. +3) Write a config file. +4) Add any localized strings. +5) Package up the final file for distribution. + +Each step has a lot of details, but all installers basically follow those same + basic development steps. + + +Compile the software: + +You will need some tools. First, you'll need your platform's favorite build + tools. You'll also need CMake (http://www.cmake.org/), and a Mercurial + (http://www.selenic.com/mercurial/) client. These are all available for most + popular operating systems, and some not-so-popular ones. + +Get the latest version of MojoSetup from Mercurial: + + hg clone http://hg.icculus.org/icculus/mojosetup + + +Then you'll need to point CMake at it: + + cd mojosetup + mkdir cmake-build + cd cmake-build + ccmake .. + +Tweak the build settings to your liking. You'll want to set CMAKE_BUILD_TYPE + to MinSizeRel, to make the compiled binary be as small as possible, and + then trim out features you don't need. For example, you can drop the + HTTP and FTP support to save about 25 kilobytes on the binary. You can also + drop support for various archive types, pieces of Lua you don't plan to use, + etc. + +CMake will get you project files for whatever development environment you use + (Makefiles, XCode, Visual Studio, etc). Build the project. You should end + up with some shared libraries for whatever GUIs you left enabled, and + a mojsetup binary. Strip the debug symbols and put these aside for later. + +If you are building MojoSetup without the Lua parser, you'll want to build + the separate Lua compiler (MOJOSETUP_BUILD_LUAC in ccmake). That will produce + a "mojoluac" binary. Put that aside for later, too. + + +Set up the installer filesystem structure: + +This is fairly easy. The installer eventually wants to see a directory + tree like this: + + data/ + scripts/ + guis/ + meta/ + +This is called the "Base Archive," even if it's a real directory tree in the + physical filesystem and not in an actual archive, such as a .zip file. + +"data" is where the installer looks for files included in the installer itself + that need installation (as opposed to those being read from the network + or a CD-ROM, etc). READMEs and EULAs go in here, too. The installer + doesn't care how things under data/ are arranged. + +"guis" is where the installer looks for those shared libraries that got + built in the first step. Copy them in here, if you built any. + +"meta" contains installer metadata: graphics for splash screens, etc. It's sort + of a catch-all for things that don't fit elsewhere. + +"scripts" is where Lua scripts go. You'll put your config file in here + (config.lua), the translation table (localizations.lua), and whatever other + scripts come with MojoSetup, which are required application logic. The + installer will not work if you don't include all these files! This + directory can hold either .lua files (source code), or their .luac + equivalents. If you built MojoSetup without the Lua parser to save space, + you'll need to compile the .lua sources into .luac objects now, or the + installer won't know what to do with them. It's safe to compile them even + if you include the parser. + + cd scripts + ../mojoluac -o config.luac config.lua + cd .. + +You can strip debug symbols from the compiled scripts to save more space, + but you'll get less useful information if there's a script error: + + cd scripts + ../mojoluac -s -o config.luac config.lua + cd .. + +Once you finish constructing this directory tree, put it aside for later. + + +Write a config file: + +This is the complicated part, and where most of your effort will be spent. + This document will try to cover all the provided facilities, but as the + configuration file also provides a robust programming language, not only + is the full scope beyond this document, you can also accomplish all sorts + of things we haven't even considered yet. + +Configuration files are Lua scripts. The Lua language and runtime library is + documented at http://www.lua.org/, and they sell an excellent book called + "Programming in Lua" which is a fast read and will demonstrate all manners + of wild and interesting features of the language. That being said, most + people rolling config files don't need any significant Lua expertise, and + basic config files don't need any programming experience at all. + +MojoSetup provides some functions for your benefit, if you want to add any + programming logic to your config. These are documented below. + +The config file is named config.lua, and it must be a text file in UTF-8 + encoding. If you are doing any programming, you may use any symbol you like, + so long as the name isn't "Setup", "MojoSetup", or any of the standard Lua + runtime names like "string" or "table". + +Configuration files are a hierarchy of elements that take this form: + + Setup.DataType + { + someattribute = value1, + someotherattribute = value2, + } + +Elements can nest: + + Setup.DataType + { + someattribute = value1, + someotherattribute = value2, + Setup.AnotherDataType + { + something = value3, + } + } + + +Case is important! Setup.Option and Setup.option are NOT the same thing! + + +Here are the elements, and the attributes they can possess. + + There are some specifiers by the attributes: + mustExist: Error if is nil (usually if you don't specify it). The other + "mustBe" descriptions consider nil to be valid when mustExist + isn't explicitly mentioned. + no default: This attribute will not have a default if not specified. + default X: This attribute defaults to X if not specified. + mustBeString: Error if isn't a string. + cantBeEmpty: Error is this string is "". String can be nil, though. + mustBeBool: Error if isn't true, false, or nil. + mustBeFunction: Error if isn't a function (can be C or Lua). + mustBeNumber: Error if isn't a number. + mustBeUrl: Error if isn't a string that matches the regexp "^.+://.-/.*". + mustBePerms: Error if isn't a valid permissions string for the platform. + mustBeStringOrTableOfStrings: Error if isn't a string or an array of strings. + mustBeSplashPosition: Error if isn't a string in the set of "top", + "left", "bottom", "right", or "background". + + Attributes that aren't explicitly specified take on their default value. In + cases without a default, they are effectively set to Lua's "nil" value. + This makes boolean values be treated as "false." Plan accordingly. + + + Setup.Package: + + All configurations need at least one Setup.Package element. Every other + element is added under Setup.Package. One full run of the installer is + done for each Setup.Package. You can have multiple packages in one file, and + the installer will run through for each one as if the program was started + multiple times. If there are multiple packages and an installation failure + occurs, all successfully-installed packages will remain. In most cases, you + only want one Setup.Package and should use Setup.Option to cull pieces + of the package. + + Setup.Package attributes: + + vendor (no default, mustExist, mustBeString, cantBeEmpty) + + This is a unique identifier for your organization. This should be in the + format "companyname.dom" ... the hope is that your primary website is + a unique identifier for your company. If your website is www.icculus.org, + you'd enter your vendor setting as "icculus.org" ... just the hostname and + top-level domain. This is used largely by the OS to maintain packages + (Mac OS X application bundles, vendor IDs for Unix desktop menus, etc). + This is, in theory, never shown to the user, so you don't need this to + actually exist as a website with meaningful content, so long as you can + reasonably assure that the string is unique and follows the "host.dom" + format. + + + id (no default, mustExist, mustBeString, cantBeEmpty) + + This is a unique identifier for your package. Currently it is used as + the base of the install path, but future features may use it for other + things. Set this to something short, unique, and human-readable, like + "mygame". + + + disabled (no default, mustBeBool) + + If this is true, the entire package will be skipped by the installer. You + probably want this to be true, but you might need to programmatically shut + off a whole package. + + + description (no default, mustExist, mustBeString, cantBeEmpty) + + This is your product's name. This will be displayed in the title bar, and + other locations during installation. + + + version (no default, mustExist, mustBeString, cantBeEmpty) + + This is the version of this package. This is arbitrary, and doesn't matter + to the installer what you specify. It's usually a value like "1.0" or + "beta3" + + The installer may use this for future features, like upgrading previous + installations. + + + destination (no default, mustBeString, cantBeEmpty) + + This attribute can be used to force the installation into a specific + location in the physical filesystem. Unless you are building something + very specific (like device drivers for a well-defined platform), you + probably should not use this attribute. If destination isn't forced, + the installer will prompt the user, possibly recommmending locations + to him. + + + recommended_destinations (no default, mustBeStringOrTableOfStrings) + + This attribute lets you define some favorable places to install the + package. You can have a table of strings or a single string: + + recommended_destinations = MojoSetup.info.homedir, + ...or... + recommended_destinations = { "/usr/local/games", "/opt/games" }, + + These strings are presented in the UI to the user when selecting a + install destination, but they can override them with their own choice. + The "id" attribute is appended to these before displaying to the end + user, so they'll see, for example, "/usr/local/games/mygame" and + "/opt/games/mygame" ... if a listed directory is determined to be + unwritable to the user (lack of permissions), it will be removed from the + list before presentation to the user. + + + precheck (no default, mustBeFunction) + + If this attribute is defined, it is called by the installer after the + configuration is parsed and the GUI has started, but before the user has + interacted with the installer at all. It passes the finalized + Setup.Package table as a parameter. + + + preflight (no default, mustBeFunction) + + If this attribute is defined, it is called by the installer after the + user has chosen options to install. The heavy-lifting of the installer + is about to begin: downloading files and installing the Package. It + passes the finalized Setup.Package table as a parameter. + + + preinstall (no default, mustBeFunction) + + If this attribute is defined, it is called by the installer after all + needed external files are downloaded and installation of files is about + to begin. It passes the finalized Setup.Package table as a parameter. + + + postinstall (no default, mustBeFunction) + + If this attribute is defined, it is called by the installer after the + entire package was successfully installed to disk. It passes the finalized + Setup.Package table as a parameter. + + + preuninstall (no default, mustBeFunction) + + If this attribute is defined, it is called by the uninstaller after the + user confirms that uninstallation is acceptable and deletion of + files is about to begin. It passes something like the finalized + Setup.Package table as a parameter. This function is serialized for later + use, in a different program running in a different context: it may NOT use + any Lua upvalues (they will be local variables set to nil when the function + runs) and any globals you reference may or may not exist when the + function runs. Try to do the bare minimum here if you must use this hook. + + + postuninstall (no default, mustBeFunction) + + If this attribute is defined, it is called by the uninstaller after the + uninstallation has successfully finished. It passes something like the + finalized Setup.Package table as a parameter. This function is serialized + for later use, in a different program running in a different context: it + may NOT use any Lua upvalues (they will be local variables set to nil when + the function runs) and any globals you reference may or may not exist when + the function runs. Try to do the bare minimum here if you must use this + hook. + + + updateurl (no default, mustBeUrl) + + This is written to the manifest files for the aid of external tools, but + isn't currently used by MojoSetup itself. + + + splash (no default, mustBeString, cantBeEmpty) + + This is the filename of an image file that will be used in the GUI. + The file should be placed in the "meta" directory (but you should omit + "meta" from this string). Please note that not all GUIs can show graphics, + and you must build MojoSetup with support for whatever image format you + used for the file. + + + splashpos (no default, mustBeSplashPosition) + + This is the location of the splash image that will be used in the GUI. + Please note that not all GUIs can show graphics, or handle the position + requested, but this makes a best effort. If you specify a splash and no + position, the GUI is free to place it wherever it thinks is best. + + + url (no default, mustBeString, cantBeEmpty) + + (!!! FIXME) This attribute is for future expansion. + + + once (default true, mustBeBool) + + (!!! FIXME) This attribute is for future expansion. + + + category (default "Games", mustBeString, cantBeEmpty) + + (!!! FIXME) This attribute is for future expansion. + + + promptoverwrite (default true, mustBeBool) + + (!!! FIXME) This attribute is for future expansion. + Please refer to Setup.File.allowoverwrite for now. + + + binarypath (no default, mustBeString, cantBeEmpty) + + (!!! FIXME) This attribute is for future expansion. + + + superuser (default false, mustBeBool) + + (!!! FIXME) This attribute is for future expansion. + + + write_manifest (default true, mustBeBool) + + If true, MojoSetup will create a hidden metadata directory in the + destination folder with lists of all files installed and some other + pertinent facts about the installed package. This allows other tools to + operate on the installation later, such as a software updater program or + an uninstaller. MojoSetup will also install tools in the metadata + directory to aid in manifest management and uninstallation. + + Unless your package is a well-defined, static installation, you probably + want this. It adds a couple hundred kilobytes to the final install in the + filesystem (but not your download package), and puts an extra directory + in there (Usually called ".mojosetup", and hidden from the end-user). + + + support_uninstall (default true, mustBeBool) + + If true, MojoSetup will include a means for the end-user to uninstall + this package. On Unix, this takes the form of a shell script in the + destination folder, on Windows, this hooks your package into the + "Add/Remove Programs" control panel. + + If you enable support_uninstall, you must enable write_manifest, or the + installer will refuse to run to alert you to the problem immediately. + + Please note that if you haven't anything outside the destination folder + to clean up, uninstall is merely a user-friendly formality; MojoSetup + doesn't implicitly write anything to the system outside this folder, so + the user can just drag it to the trash in the basic usage scenario. Indeed, + on Mac OS X, this is Apple's recommended "uninstall" procedure. On Windows, + hooking into Add/Remove Programs is probably desirable in all cases. + + Enabling this option adds very little overhead to the normal install, once + you swallow the cost from write_manifest. + + + Setup.Eula: + + This element can be a child of Setup.Package or Setup.Option. It can be + used to display a license agreement to the end user, which they must agree + to before installation can proceed. If they refuse the license, the installer + terminates without installing anything (or, in the Setup.Option case, steps + back in the installation to let them change options, so they can disable the + installation of whatever they disagree with). There can be multiple + Setup.Eula elements listed, in which case the end user will be asked to + agree to each license individually before installation may proceed. The + Setup.Package licenses are shown first before any other interaction occurs, + and the Setup.Option licenses are shown after the user selects her install + options. + + Setup.Eula attributes: + + description (no default, mustExist, mustBeString, cantBeEmpty) + + This is a brief description of the license, used for title bars and such. + + + source (no default, mustExist, mustBeString, cantBeEmpty) + + This is a filename in the Base Archive's "data" directory that contains + the license text. Currently this must be a text file in UTF-8 encoding. + + + Setup.Readme: + + This element is a child of Setup.Package. It can be used to display a + information about the package to the end user, such as a welcome message, + FAQs, or other orientation information. There can be multiple Setup.Readme + elements listed, in which case the end user will be shown each readme + individually before installation may proceed. The readmes are shown after + any EULA elements in the Setup.Package. EULA elements in a Setup.Option + are shown later, however. + + Setup.Readme attributes: + + description (no default, mustExist, mustBeString, cantBeEmpty) + + This is a brief description of the Readme, used for title bars and such. + + + source (no default, mustExist, mustBeString, cantBeEmpty) + + This is a filename in the Base Archive's "data" directory that contains + the readme text. Currently this must be a text file in UTF-8 encoding. + + + Setup.ProductKey: + + This element can be a child of Setup.Package or Setup.Option. It can be + used to prompt the user for a "CD key" or some other sort of code that + is required to install the product. If they can't enter a valid key, + the installer terminates without installing anything (or, in the + Setup.Option case, steps back in the installation to let them change options, + so they can disable the installation of whatever they don't have keys for). + There can be multiple Setup.ProductKey elements listed, in which case the + end user will be asked to enter each key individually before installation + may proceed. The Setup.Package keys are requested after any global EULAs are + agreed to, and the Setup.Option keys are requested after any per-option + EULAs. + + Setup.ProductKey attributes: + + description (no default, mustExist, mustBeString, cantBeEmpty) + + This is a brief description of the key being requested, used for + title bars and such. + + + format (no default, mustBeString, cantBeEmpty) + + This specifies the exact format a key must be. This is a string of + characters. The GUI will not allow the user to continue until they either + enter a string that matches this format or abort entry. + + The following characters are acceptable in a format string: + 'X', '#', ' ', '-', '?', '*' + + 'X' means "any letter." + '#' means "any number." + '?' means "any letter or number." + '*' means "any character." + ' ' and '-' specify new blocks of text. + + Obviously, these are not regular expressions, or filename-style wildcards. + + For example, if you expect a valid product key to be four segments of + four numbers, followed by two letters, your format would be this: + + ####-####-####-#### XX + + '-' and ' ' are optional. The GUI may be able to optimize for these cases, + such as splitting input into separate text boxes. Users won't have to + enter these characters; MojoSetup will fill them in if they are missing. + + If no format is specified, the user may enter any string. + + + verify (no default, nil, mustBeFunction) + + This function is called after the user finishes typing in their key. It + allows the installer to verify that the key is valid before continuing. + The function returns true or false, and maybe optionally return a second + value that transforms the key, perhaps to encrypt it before writing it + to disk. + + Here is a very basic example function in Lua: + + local function verify_cdkey(key) + if key == "this-is-a-valid-cdkey" then + -- You could just "return true" too, to not change the key. + return true, key .. "-some-extra-junk-on-the-end" + end + return false + end + + One could also call into a C function, which can be handy to reuse the + same key validation routines that your installed application would use. + MojoSetup's license allows for you to statically link such code without + releasing the source code to it. To do so, please see the function + luahook_verifyproductkey() in lua_glue.c, and change it to fit your needs. + + If no verify function is specified, no verification occurs; MojoSetup + assumes that whatever the user entered is okay, only making sure it + matched the specified format. + + In the case of a successful verification, MojoSetup will quietly continue + on. If you wish to say something to the user here, such as: "don't tell + anyone your CD key, we will never ask you for it," then you should call + MojoSetup.msgbox() before returning from your verify function (or, in C + code: GGui->msgbox("window title", "message to show"). + + + destination (no default, nil, mustBeString, cantBeEmpty) + + This is where MojoSetup should write the product key. It will be a text + file with the final ASCII key string. + + If no destination is specified, the product key is not written to disk. + This may be desirable if the installer just needs to make sure a key is + available and valid. + + On Windows, the destination is allowed to use a magic format for targeting + a specific key in the Windows Registry instead of a file, such as: + + "$WINDOWSREGISTRY/HKEY_LOCAL_MACHINE/Software/MyApp/ProductKey" + + + Setup.Media: + + This element is required if you need to install data from removable media, + such as a DVD-ROM drive. The installer needs a means to identify the + media as the correct source when it is connected to the system. + + Setup.Media attributes: + + id (no default, mustExist, mustBeString, cantBeEmpty) + + A unique specifier for this media, such as "disc1" or "game-disc". This + will be used for Setup.File.source: "media://game-disc/path/filename.zip" + + + description (no default, mustExist, mustBeString, cantBeEmpty) + + A human-readable description of this media, such as "MyGame Disc 2". This + string will be used when the end user must be prompted to insert a new + piece of media to continue the installation. + + + uniquefile (no default, mustExist, mustBeString, cantBeEmpty) + + This is a path that is unique to this media, relative to its root + directory, such as "sounds/guitar.wav". The installer looks at all + media available to the system until it finds this path exists, to + determine if the correct media has been made available by the end user. + + + Setup.Option: + + This element defines an optional section of the install, and is a child + of Setup.Package. You must have at least one Setup.Option in your + configuration, but you can make it mandatory with the "required" attribute + if you don't want it to be actually optional. + + The GUI will show all selectable options to the end user, and they can + pick and choose the parts they want. If there are no optional portions of + the install, the GUI will skip the option selection screen. + + Setup.Options can nest. If a parent option is unchecked in the GUI, its + child options become disabled and will be considered unchecked also when + installation proceeds. + + Setup.Option + { + description = "Wing Commander 1" + source = "base:///wc1.zip", + + -- This option can only install if "Wing Commander 1" is checked too. + Setup.Option + { + description = "WC1 Speech Pack", + source = "base:///wc1sp.zip", + }, + }, + + + Setup.Option attributes: + + disabled (default false, mustBeBool) + + If true, this whole group (including all children) will be removed from + the GUI, and the installer will treat all the child options as unchecked. + If an option has both "required" and "disabled" set to true, then + "disabled" takes precedence. + + + value (default false, mustBeBool) + + If true, the checkbox will be checked by default in the GUI. Checked + options are installed. + + + required (default false, mustBeBool) + + If true, the option won't be shown to the end user, but will just be + treated as if it was checked when installation proceeds. If an option + has both "required" and "disabled" set to true, then "disabled" takes + precedence. + + + bytes (no default, mustExist, mustBeNumber) + + This is the size, in bytes, of files this option will write to disk. The + installer uses this to determine space requirements for the total install. + If you don't know the size, you should set this to -1, but this will + disable some functionality. + + + description (no default, mustExist, mustBeString, cantBeEmpty) + + This string will be shown to the end user, as a label with the GUI's + checkbox. + + + tooltip (no default, mustBeString, cantBeEmpty) + + This string will be used in mouseover "tooltips" in GUI environments for + this option's UI widget. There is no guarantee that they will be shown to + a user in any GUI target, so don't rely on them! + + + Setup.OptionGroup: + + This element can be the parent or child of Setup.Option, or a child of + Setup.Package. It contains of a collection of Setup.Option elements. + The children Setup.Options will be grouped radio buttons in the GUI instead + of individual checkboxes. As such, only one child Setup.Option in an + Setup.OptionGroup will be checked in the GUI. + + Setup.OptionGroup + { + description = "Language", + Setup.Option { description = "English", source = "base:///en.zip" }, + Setup.Option { description = "French", source = "base:///fr.zip" }, + Setup.Option { description = "German", source = "base:///fr.zip" }, + }, + + Setup.OptionGroup attributes: + + disabled (no default, mustBeBool) + + If true, this option (including all children) will be removed from + the GUI, and the installer will treat this and all child options as + unchecked. + + + description (no default, mustExist, mustBeString, cantBeEmpty) + + This string will be shown to the end user, as a label with the GUI's + radio button group. + + + tooltip (no default, mustBeString, cantBeEmpty) + + This string will be used in mouseover "tooltips" in GUI environments for + this option's UI widget. There is no guarantee that they will be shown to + a user in any GUI target, so don't rely on them! + + + Setup.File: + + This element specifies a fileset, a collection of files, to install. These + are children of Setup.Option, and you can specify as many as you like per + option. Each Setup.File represents an "archive," that is, some set of files, + such as a .zip file or a directory. + + Setup.File attributes: + + source (no default, mustBeUrl) + + This is a URL that provides the source for this fileset. You can only + specify archives (directories and files like .zip, .tar, etc), not + specific individual files. If you need a specific file, use its parent + directory here and a "wildcards" attribute. + + There are some standard and non-standard URL handlers you can specify: + + base:///path/file.ext + + This references an archive in the Base Archive, where the "data" + directory is the root...so the above looks for data/path/file.ext in + the Base Archive. + + This can install from an archive inside an archive, like this: + + base:///mydir/outside.zip/internalpath/inside.tar + + + media://id/path/file.ext + + This references a file on an external media with a specific id, + as defined in a Setup.Media element. The user will be prompted for + the correct media if the installer can't find it. This can install + archives-in-archives, like the base:/// version can. + + + ftp://hostname.dom/path/file.ext + http://hostname.dom/path/file.ext + + The references a file on an FTP or web server. These files will all be + downloaded before local files are installed. You may only specify + archives at this time, not individual files or directories. + MojoSetup must be built with support for the proper network protocol. + + + destination (no default, mustBeString, cantBeEmpty) + + This attribute lets you, across the board, redirect files in this archive + to a specific destination. This is a path relative to the base of the + installation destination path. If the user specified an installation + destination of "/games/mygame", this attribute is "gamemod", and the + source produces a file "maps/level1.map", then the final file written to + disk would be "/games/mygame/gamemod/maps/level1.map". + + After the path is prepared with this attribute, it is tested against the + "wildcards" attribute, and if it passes there, it is pushed through the + "filter" attribute. + + + wildcards (no default, mustBeStringOrTableOfStrings) + + This is the first step to culling files from an archive or directory. + Files are only installed if they match a specified wildcard. + Wildcards are simple to use: they only allow '?' for single character + matches and '*' to match a sequence of characters. You may specify a + single string, or a list of wildcards, like this: + + -- matches sounds/heroes/laser13.wav and sounds/villians/laser02.wav + wildcards = "sounds/*/laser??.wav" + + ...or... + + -- everything in the maps, sounds, and graphics directories. + -- (this includes subdirs! '*' matches past '/' separators!) + wildcards = { "maps/*", "sounds/*", "graphics/*" } + + + filter (no default, mustBeFunction) + + This is a function that takes one argument, a string that represents the + path of a single file relative to the root of the installation destination. + This function may return nil to choose not to install this file, which is + useful for culling files from an archive, or a string that represents a + new destination for the file, which is useful for renaming some files + on-the-fly: + + filter = function(dest) + if string.match(dest, ".exe$") then + return nil -- skip Windows .exe files on Unix. + end + if dest == "SOMEFILE.TXT" then + return "somefile.txt" -- force this to lowercase. + end + return dest -- everything else can go through as-is. + end + + Filters can optionally return a second argument, a string, that defines + the destination file's permissions. This can be omitted, or nil, to use + the default permissions: + + filter = function(dest) + if dest == "mygame-binary" then + return dest, "0755" -- make sure it's executable. + end + return dest -- everything else just goes through as-is. + end + + Please see the documentation for Setup.File's "permissions" attribute for + further discussion. + + + allowoverwrite (no default, mustBeBool) + + If true, the installer will overwrite existing files without warning. If + false, the user will be prompted before overwriting each file. + + Files are actually moved out of the way instead of overwritten, so the + installer can restore them if the install is cancelled or fails mid-way. + They are deleted only after a successful install. + + + permissions (no default, mustBePerms) + + Override the permissions with which the files will be created. This is + a string, not a number...this allows both for future expansion (non-Unix + systems, extended attributes, etc), and works around the fact that Lua + does not have syntax for specifying octal numbers directly. + + Currently this string maps to Unix permissions as an octal number: + "0644" would be read/write access for the user, and read-only for the + group and everyone else. + + If set to nil or not specified, the new file's permissions will be + whatever is already associated with the file (such as the Unix permissions + in a .tar file's entry). + + Please note that files coming from a real filesystem will have their + defaults overridden by MojoSetup (to "0644"), since many operating systems + tend to report every file on a CD-ROM as read-only and executable, which + is frequently not what you want in the installed copy. Plan accordingly. + + You can return a permissions string as the second value from your filter + function as well, which may be more efficient if you only need to change + a few files, (each Setup.File has to iterate the whole archive, so you + want to avoid specifying multiple Setup.Files for one archive when + possible), or need to adjust permissions in only a portion of a downloaded + archive. This attribute applies permissions to every file installed + through this element. If this attribute is set and the filter returns a + non-nil permission, the filter takes precedence. + + + Setup.DesktopMenuItem: + + This element specifies a menu item that will be installed in the system + desktop menu: this might be the "Applications" dropdown in the Gnome panel, + or the "Start" bar on Windows, for example. This can be a child of + Setup.Option (in which case it is only considered for installation if the + option itself is too), or Setup.Package (in which case it is always + considered for installation). Some of this element's properties are ignored + on some operating systems, but they are still required both for + cross-platform safety and future expansion. + + Setup.DesktopMenuItem attributes: + + disabled (no default, mustBeBool) + + If this is true, the menu item will be skipped by the installer. You + probably want this to be true, but you might need to programmatically shut + off specific menu items. + + + name (no default, mustExist, mustBeString, cantBeEmpty) + + This is the proper name of the item to be installed ("Firefox"). + + + genericname (no default, mustExist, mustBeString, cantBeEmpty) + + This is a generic name for the item to be installed ("Web Browser"). + + + tooltip (no default, mustExist, mustBeString, cantBeEmpty) + + This is used as a tooltip for the item by the OS when the user hovers + the mouse pointer over it. + + builtin_icon (no default, mustBeBool) + + If this is true, then "icon" refers to a platform-dependent standard + icon. Currently, this only makes sense on Unix systems that follow + the freedesktop.org standards. If this is false, then "icon" refers + to a file, relative to the installation's destination directory, which + the must be installed through a Setup.File. Most installers should set + this to false (the default) unless they know what they are doing. + + icon (no default, mustExist, mustBeString, cantBeEmpty) + + The icon to use with this menu item. Please see builtin_icon for info + on what this string means. The format of files that may be used as icons + varies from platform to platform; you may need to install a different + file programmatically, based on the value of MojoSetup.info.platform. + + commandline (no default, mustExist, mustBeString, cantBeEmpty) + + This is the command line that will be used to launch the application + when the end user clicks on the desktop menu item. The string "%0" is + replaced with the install destination, so if you need an absolute path + to mygame.exe, and the user is installing to /home/user/mygame, you should + specify "%0/mygame.exe" to get "/home/user/mygame/mygame.exe". + + category (no default, mustExist, mustBeStringOrTableOfStrings) + + This is a category (or array of categories) that the menu item applies + to. You can choose several, but one is usually less confusing. Valid + choices are currently: AudioVideo, Development, Education, Game, Graphics, Network, + Office, Settings, System, Utility. + + mimetype (no default, mustBeStringOrTableOfStrings) + + This is a MIME type (or array of MIME types) that the menu item can handle. + For example, if you are installing an image viewer, you might specify: + mimetype={"image/jpeg", "image/png"}; ... this is optional, you don't + have to specify any mimetypes at all. + + !!! FIXME: there is currently no way for an installer to inform the system + !!! FIXME: of associations between new file extensions and mimetypes. + !!! FIXME: Things that collect mime info themselves, like web browsers + !!! FIXME: and email clients, can use new apps this way, however. + + !!! FIXME: there is currently no way for an installer to add submenus. + + + +Add any localized strings: + +If you added strings to the installer or your config file that you want + translated at runtime, you need to add them to scripts/app_localization.lua. + This is a Lua script, too, of course, but you really should treat it like a + basic config file. + +The format looks something like this: + + ["Yes"] = { + es = "Si"; + fr = "Oui"; + }; + +As you can see, the ["Yes"] is a string to translate. These are always English + by convention, but this is whatever the string you wish to translate. Please + note that the brackets are important, and only used on this specific string. + +The fields in this structure are language abbreviations that match a user's + locale and the string of translated text. + +Please note that you can do locale-specific translations, too: + + ["colors"] = { + en_UK = "colours"; + }; + +All strings in this file (and all Lua scripts) are UTF-8 encoded. Using a + high-ASCII character will not work like you expect at runtime! + +These lookup tables are used at runtime to translate strings, both by you and + internally by MojoSetup. You can do a translation by calling: + + MojoSetup.translate("colors") + +We recommend making a convenience function like this at the top of your + config.lua... + + local function _ = MojoSetup.translate + +...so that you have a convention for translations that cause minimal clutter: + + Setup.Option { + description = _("Level editor utility"), + -- ...etc... + } + +A detailed example of how to do this is scripts/localization.lua, which you + should ship with your installer. You probably shouldn't add your strings to + localization.lua directly, though. MojoSetup uses this file for text it uses + internally, and the file changes a lot. Using app_localization.lua allows + your translations to live separately from MojoSetup's, which has two benefits. + First, you don't have to merge your translation work with MojoSetup's every + time you upgrade. Second, you can override default translations, like this: + + ["Uninstall complete"] = { + en = "Uninstall complete. You may also delete '.MyGame' in your home directory to remove personal savegames and settings.", + it = "Disinstallazione completata. Se desideri cancellare i salvataggi e le impostazione cancella '.MyGame' nella tua directory home.", + -- ...other languages here... + }; + +app_localization.lua's translations will be favored over localization.lua's. + In the above example, a language that doesn't have an override may still get + a correctly translated "Uninstall complete" without the extras from the base + file. + + +Package up the final file for distribution: + +Now you have a MojoSetup binary and a directory tree containing your data, GUI + plugins, and scripts (including the config.lua you just wrote). Now you just + need to glue them together. MojoSetup will attempt to look at itself as an + archive on startup, which works in the same way "self-extracting" exe files + worked on other operating systems. If you want MojoSetup to be + self-extracting, zip your directory tree up and append it to the binary: + + zip -9r mydata.zip data guis scripts + cat mydata.zip >> mojosetup + +Now rename "mojosetup" to something meaningful (mygame-1.0-linux-x86.bin or + whatever), and you've got an installer. + +If you have the luxury of a real filesystem (inside a disk image or on a CD + you are shipping, for example), MojoSetup will use the binary's directory + if it doesn't find a zipfile appended to the binary itself, so you can just + have "data", "scripts" and "guis" in the same directory as "mojosetup" to + have it work, too. + + +Now you're done! Give your installer to the public. + + + +MojoSetup-provided globals: + +Your config file is a Lua script, and as such, has access to all of Lua's + runtime library (presuming you didn't disable it when building MojoSetup) + and several other bits of MojoSetup-specific functionality. Everything the + installer provides to your script is under the "MojoSetup" table, so as not + to pollute the namespace. Also, the config files use the "Setup" table for + the basic config schema. Everything else is free game. Here are the globals + that MojoSetup provides: + + MojoSetup.format(fmt, ...) + + Format a string, sort of (but not exactly!) like sprintf(). + The only formatters accepted are %0 through %9 (and %%), which do not + have to appear in order in the string, but match the varargs in the + order they are passed to the function. + + format('%1 %0 %1 %%', 'X', 'Y', 'Z') will return the string: 'Y X Y %' + + + MojoSetup.fatal(errstr) + + Display (errstr) to the end user and stop the installation. The installer + will attempt to clean up any half-finished installation, including rolling + back any files that would have been replaced had the installation succeeded. + You should never use error() in the standard Lua runtime; use this instead. + + + MojoSetup.runfile(script) + + Run the code in a given Lua file. This is JUST the base filename. MojoSetup + will look for it in the Base Archive in the scripts/ directory, both as + script.luac and script.lua. This code chunk will accept no arguments, and + return no results, but it can change the global state and alter tables, + etc, so it can have lasting side effects. Will return false if the file + couldn't be loaded, or true if the chunk successfully ran. Will not return + if there's a runtime error in the chunk, as it will call MojoSetup.fatal() + instead. You should use this instead of the "require" function in the Lua + runtime, as require() won't respect the Base Archive. + + + MojoSetup.translate(str) + + Find the proper translation for the end user's locale in the localization + table. Returns the translation, or the original string if no translation + was available. It's common to use this for shorthand: + + local function _ = MojoSetup.translate + + ...so you can be less verbose: print(_("translate this string")) + + + MojoSetup.ticks() + + Return the time, in milliseconds, that the process has been running. + + + MojoSetup.logwarning(str) + + Write a warning to the installation log, if logging settings permit. + + + MojoSetup.logerror(str) + + Write an error to the installation log, if logging settings permit. + + + MojoSetup.loginfo(str) + + Write an info string to the installation log, if logging settings permit. + + + MojoSetup.logdebug(str) + + Write debug info to the installation log, if logging settings permit. + + + MojoSetup.launchbrowser(url) + + Launch a web browser to view the URL (url). This will try to launch a + new window/tab of the user's preferred handler for the url. Launching + "http://" URLs are probably always safe, other protocols, like "ftp://" + may or may not work, depending on what the platform offers. + + Returns true if the browser launched, false otherwise. We can't know + if the URL actually loaded or rendered, just if the browser launched. + The hope is that the browser will inform the user if there's a problem + loading the URL. + + + MojoSetup.msgbox(title, str) + + Show (str) to the user with a GUI message box, and wait until they click + an "OK" button. (title) is the message box's title. + + + MojoSetup.promptyn(title, str, defval) + + Show (str) to the user with a GUI message box, and wait until they click + either a "YES" or "NO" button. Returns true if they clicked YES, false + if they clicked "NO". (title) is the message box's title. + (defval) is an optional boolean value: whether the default action should + be "YES" or "NO". If (defval) isn't specified, it defaults to false. + + + MojoSetup.promptynan(title, str, defval) + + Show (str) to the user with a GUI message box, and wait until they click + either a "YES", "NO", "ALWAYS" or "NEVER" button. Returns the string + "yes", "no", "always", or "never". (title) is the message box's title. + (defval) is an optional boolean value: whether the default action should + be "YES" or "NO" ... "always" and "never" can not be the default, since + these tend to be destructive actions that the user should consciously + choose to do. If (defval) isn't specified, it defaults to false. + + + MojoSetup.stackwalk() + + This writes a backtrace of the current Lua callstack to the installation + log, if logging settings permit debug-level logging. + + + MojoSetup.cmdline(flag) + + See if a given flag was on the command line for the process. + MojoSetup.cmdline("nosound") will return true if "-nosound", "--nosound", + etc was on the command line. The option must start with a '-' on the + command line to be noticed by this function. Returns true if flag was on + the command line, false otherwise. + + + MojoSetup.cmdlinestr(flag, envr, deflt) + + Get robust command line options, with optional default for missing ones. + + If the command line was ./myapp --a=b -c=d ----e f + - cmdlinestr("a") will return "b" + - cmdlinestr("c") will return "d" + - cmdlinestr("e") will return "f" + - cmdlinestr("g") will return the default string. + + Like MojoSetup.cmdline(), the option must start with a '-'. + + (envr) is an optional environment var to check if command line wasn't + found. You can call this function without specifying this parameter, or + pass a nil here. + (deflt) is the return value if (flag) isn't on the command line. + + + MojoSetup.collectgarbage() + + Do a complete run of the Lua garbage collector. Use this instead of the + version in the Lua standard runtime, since this version does better debug + logging. + + + MojoSetup.date() + + Return a string of the current date. This is roughly the same as os.date() + in the standard Lua runtime, but we didn't want to add the os table + dependencies just to write this string into the log. + + + MojoSetup.info.uid + + This is a number (not a function!) that lists the user id of the person + running the installer. On Unix, this is what getuid() reports (and zero + would be the root user). + + + MojoSetup.info.euid + + This is a number (not a function!) that lists the EFFECTIVE user id of the + person running the installer. On Unix, this is what geteuid() reports (and + zero would be the root user). + + + MojoSetup.info.gid + + This is a number (not a function!) that lists the group id of the person + running the installer. On Unix, this is what getgid() reports. + + + MojoSetup.info.locale + + This is a string (not a function!) of the current locale, in the format + xx_YY, where "xx" is the language code (en for english, de for German, etc) + and "YY" is the country code: "en_US" for American English, fr_CA for + Canadian French, etc. + + If MojoSetup can't determine the user's locale, this string is "???". + + + MojoSetup.info.platform + + This is a string (not a function!) of the current platform. This is + currently one of "macosx", "unix", "windows", or "beos", or one of several + others, depending on your build and target platform. + + + MojoSetup.info.arch + + This is a string (not a function!) of the current platform's CPU type. + This is currently one of "x86", "x86-64", "powerpc", "powerpc64", + or one of several others, depending on your build and target platform. + + Please note that this is the arch of the installer binary...you can run + a 32-bit binary on an amd64 chip, in which case it will report "x86"! + + + MojoSetup.info.ostype + + This is a string (not a function!) of the current platform's operating + system. This is currently one of "macosx", "beos", "linux", "freebsd", + "netbsd", "openbsd", "bsdi", "aix", "hpux", "irix", or "solaris". + + Please note that this is the OS target of the installer binary...you can + run a Linux binary on FreeBSD through the binary compatibility layer, + in which case it will still report "linux"! + + On Windows, this is currently either "win9x" or "winnt" to differentiate + Windows 95/98/ME from NT/XP/Vista/etc, since their version numbers can + overlap. Installers should not rely on there never being a third string + some day in the distant future, though. + + + MojoSetup.info.osversion + + This is a string (not a function!) of the current platform's operating + system version. This may not be useful information on many platforms. + On Mac OS X, it's the system version (So it might be 10.4.9 on a Tiger + install, 10.3.8 on a Panther install, etc). + + On other Unixes, it's the "release" field from uname(), which on Linux + gives you the kernel version, which is usually not helpful, but could be + on, say, BeOS. + + On Windows, it'll be the Major.Minor.Build version for the OS. This is the + same information that the win32 OSVERSIONINFO structure supplies: + + http://msdn2.microsoft.com/en-us/library/ms724834.aspx + + So "5.1.2600" might mean "Windows XP, service pack 1" ... relying on the + build number can be very dangerous if you don't know what you're doing, + but the major/minor values appear to be reliable to differentiate various + flavors of Windows (and MojoSetup.info.ostype can differentiate between + the Win95-based and WinNT-based versions). + + On any platform, it would be wise to not rely too heavily on this data: + it's frequently better to check for the specific thing you want to know + about ("Is DirectX 9 installed?") rather than ask a general question ("Is + this Windows XP?"). This prevents problems when unexpected values arise in + situations you never expected to handle (for example, if you ran the + Windows installer under Wine, it could report that its Windows XP, but + there's no DirectX 9 support). Knowing what you really want to know is + half the battle. + + + MojoSetup.info.ui + + This is a string (not a function!) of the UI plugin that MojoSetup chose. + This is currently one of "stdio", "ncurses", "macosx", "gtkplus2", "www", + or one of several others, depending on your build and target platform. + It's best to not rely on this being within a specific set of values. + + + MojoSetup.info.buildver + + This is a string (not a function!) of the build identifier for this binary. + You can print this string to stdout by running ./mojosetup --buildver + at the command line. + + + MojoSetup.info.loglevel + + This is a string (not a function!) of the logging level that MojoSetup + is enforcing. This is currently one of "nothing", "errors", "warnings", + "info", "debug", or "everything" ... each level includes the previous + level, so "warnings" will also log error messages, but not info or debug + messages. + + + MojoSetup.info.homedir + + This is a string (not a function!) of the "home directory" of the end-user + in the physical filesystem. This is useful if you want to determine a sane + default location to write files. + + + MojoSetup.info.argv + + This is a string array (not a function!) of the installer process's + command line arguments. You might find MojoSetup.cmdline() or + MojoSetup.cmdlinestr() to be more useful. + + + MojoSetup.info.supportedurls + + This is a string array (not a function!) of URL types the installer + supports. You can either iterate it... + + for k,v in pairs(MojoSetup.info.supportedurls) do + print("installer supports " .. v .. ":// URLs") + end + + ...or you can query it... + + if MojoSetup.info.supportedurls["http"] ~= nil then + print("installer supports http:// URLs") + end + + "base" and "media" are included in the list, always. The rest are + compile-time options. + + + MojoSetup.destination + + This is a string (not a function!) of the path on the physical filesystem + where the package is being installed. This is not available until the + user has selected a destination, but could be useful in your postinstall + script. + + + MojoSetup.manifest + + This is a table of tables (not a function!) that is built during the + course of the installation. As changes are made to the destination + filesystem, they are noted in MojoSetup.manifest, so this will be + complete and most useful during a postinstall hook in your config file. + + As with most other globals listed here, MojoSetup depends on this data, + so you should treat it as read-only. Modifying this table from your config + script will result in undefined (but probably bad) behaviour. + + There is one element in the array for each Setup.Option that generated + a change to the filesystem. Each of these elements is an array of tables. + + for option,items in pairs(MojoSetup.manifest) do + local desc = option + if type(desc) == "table" then -- could be a string in some cases! + desc = desc.description + end + print("Option: " .. desc) + for i,item in ipairs(items) do + -- ... do stuff with "item" here ... + end + end + + The format of the item tables vary depending on type. They all have a + "type" field, which is a string. Based on the type, different fields are + available: + + if item.type == "file" then + print("file created at " .. item.path) + print("with permissions" .. item.mode) -- This is a string! + + -- Checksums may or may not exist in this table, depending on how + -- MojoSetup was compiled. You can iterate to find out what's there: + print("checksums:") + if item.checksums ~= nil then + for k,v in pairs(item.checksums) do + print(" " .. k .. ": " .. v) -- "crc32: 92FAB211E", etc. + end + end + end + + if item.type == "dir" then + print("directory created at " .. item.path) + print("with permissions" .. item.mode) -- This is a string! + end + + if item.type == "symlink" then + print("symbolic link created at " .. item.path) + print("pointing to " .. item.linkdest) + end + +// end of docs.txt ... + diff --git a/mk/linux/mojosetup/fileio.c b/mk/linux/mojosetup/fileio.c new file mode 100644 index 00000000..73312778 --- /dev/null +++ b/mk/linux/mojosetup/fileio.c @@ -0,0 +1,1157 @@ +/** + * MojoSetup; a portable, flexible installation application. + * + * Please see the file LICENSE.txt in the source's root directory. + * + * This file written by Ryan C. Gordon. + */ + +#include "fileio.h" +#include "platform.h" + +typedef MojoArchive* (*MojoArchiveCreateEntryPoint)(MojoInput *io); + +MojoArchive *MojoArchive_createZIP(MojoInput *io); +MojoArchive *MojoArchive_createTAR(MojoInput *io); +MojoArchive *MojoArchive_createUZ2(MojoInput *io); +MojoArchive *MojoArchive_createPCK(MojoInput *io); + +typedef struct +{ + const char *ext; + MojoArchiveCreateEntryPoint create; + boolean hasMagic; // can determine file type from contents? +} MojoArchiveType; + +static const MojoArchiveType archives[] = +{ + { "zip", MojoArchive_createZIP, true }, + { "tar", MojoArchive_createTAR, true }, + { "tar.gz", MojoArchive_createTAR, true }, + { "tar.bz2", MojoArchive_createTAR, true }, + { "tgz", MojoArchive_createTAR, true }, + { "tbz2", MojoArchive_createTAR, true }, + { "tb2", MojoArchive_createTAR, true }, + { "tbz", MojoArchive_createTAR, true }, + { "uz2", MojoArchive_createUZ2, false }, + { "pck", MojoArchive_createPCK, true }, +}; + + +#if SUPPORT_GZIP + +#include "zlib/zlib.h" + +#define GZIP_READBUFSIZE (128 * 1024) + +static MojoInput *make_gzip_input(MojoInput *origio); + +typedef struct GZIPinfo +{ + MojoInput *origio; + uint64 uncompressed_position; + uint8 *buffer; + z_stream stream; +} GZIPinfo; + +static voidpf mojoZlibAlloc(voidpf opaque, uInt items, uInt size) +{ + return xmalloc(items * size); +} // mojoZlibAlloc + +static void mojoZlibFree(voidpf opaque, voidpf address) +{ + free(address); +} // mojoZlibFree + +static void initializeZStream(z_stream *pstr) +{ + memset(pstr, '\0', sizeof (z_stream)); + pstr->zalloc = mojoZlibAlloc; + pstr->zfree = mojoZlibFree; +} // initializeZStream + +static boolean MojoInput_gzip_ready(MojoInput *io) +{ + return true; // !!! FIXME: ready if there are bytes uncompressed. +} // MojoInput_gzip_ready + +static boolean MojoInput_gzip_seek(MojoInput *io, uint64 offset) +{ + // This is all really expensive. + GZIPinfo *info = (GZIPinfo *) io->opaque; + + /* + * If seeking backwards, we need to redecode the file + * from the start and throw away the compressed bits until we hit + * the offset we need. If seeking forward, we still need to + * decode, but we don't rewind first. + */ + if (offset < info->uncompressed_position) + { + if (!info->origio->seek(info->origio, 0)) + return false; + inflateEnd(&info->stream); + initializeZStream(&info->stream); + if (inflateInit2(&info->stream, 31) != Z_OK) + return false; + info->uncompressed_position = 0; + } // if + + while (info->uncompressed_position != offset) + { + uint8 buf[512]; + uint32 maxread; + int64 br; + + maxread = (uint32) (offset - info->uncompressed_position); + if (maxread > sizeof (buf)) + maxread = sizeof (buf); + + br = io->read(io, buf, maxread); + if (br != maxread) + return false; + } /* while */ + + return true; +} // MojoInput_gzip_seek + +static int64 MojoInput_gzip_tell(MojoInput *io) +{ + return (((GZIPinfo *) io->opaque)->uncompressed_position); +} // MojoInput_gzip_tell + +static int64 MojoInput_gzip_length(MojoInput *io) +{ + return -1; +} // MojoInput_gzip_length + +static int64 MojoInput_gzip_read(MojoInput *io, void *buf, uint32 bufsize) +{ + GZIPinfo *info = (GZIPinfo *) io->opaque; + MojoInput *origio = info->origio; + int64 retval = 0; + + if (bufsize == 0) + return 0; // quick rejection. + else + { + info->stream.next_out = buf; + info->stream.avail_out = bufsize; + + while (retval < ((int64) bufsize)) + { + const uint32 before = info->stream.total_out; + int rc; + + if (info->stream.avail_in == 0) + { + int64 br; + + br = origio->length(origio) - origio->tell(origio); + if (br > 0) + { + if (br > GZIP_READBUFSIZE) + br = GZIP_READBUFSIZE; + + br = origio->read(origio, info->buffer, (uint32) br); + if (br <= 0) + return -1; + + info->stream.next_in = info->buffer; + info->stream.avail_in = (uint32) br; + } // if + } // if + + rc = inflate(&info->stream, Z_SYNC_FLUSH); + retval += (info->stream.total_out - before); + + if (rc != Z_OK) + return -1; + } // while + } // else + + if (retval > 0) + info->uncompressed_position += (uint32) retval; + + return retval; +} // MojoInput_gzip_read + +static MojoInput* MojoInput_gzip_duplicate(MojoInput *io) +{ + GZIPinfo *info = (GZIPinfo *) io->opaque; + MojoInput *retval = NULL; + MojoInput *newio = info->origio->duplicate(info->origio); + if (newio != NULL) + { + retval = make_gzip_input(newio); + if (retval != NULL) + retval->seek(retval, io->tell(io)); // slow, slow, slow... + } // if + return retval; +} // MojoInput_gzip_duplicate + +static void MojoInput_gzip_close(MojoInput *io) +{ + GZIPinfo *info = (GZIPinfo *) io->opaque; + if (info->origio != NULL) + info->origio->close(info->origio); + inflateEnd(&info->stream); + free(info->buffer); + free(info); + free(io); +} // MojoInput_gzip_close + +static MojoInput *make_gzip_input(MojoInput *origio) +{ + MojoInput *io = NULL; + GZIPinfo *info = (GZIPinfo *) xmalloc(sizeof (GZIPinfo)); + + initializeZStream(&info->stream); + if (inflateInit2(&info->stream, 31) != Z_OK) + { + free(info); + return NULL; + } // if + + info->origio = origio; + info->buffer = (uint8 *) xmalloc(GZIP_READBUFSIZE); + + io = (MojoInput *) xmalloc(sizeof (MojoInput)); + io->ready = MojoInput_gzip_ready; + io->read = MojoInput_gzip_read; + io->seek = MojoInput_gzip_seek; + io->tell = MojoInput_gzip_tell; + io->length = MojoInput_gzip_length; + io->duplicate = MojoInput_gzip_duplicate; + io->close = MojoInput_gzip_close; + io->opaque = info; + return io; +} // make_gzip_input + +#endif // SUPPORT_GZIP + + +#if SUPPORT_BZIP2 + +#include "bzip2/bzlib.h" + +#define BZIP2_READBUFSIZE (128 * 1024) + +static MojoInput *make_bzip2_input(MojoInput *origio); + +typedef struct BZIP2info +{ + MojoInput *origio; + uint64 uncompressed_position; + uint8 *buffer; + bz_stream stream; +} BZIP2info; + +static void *mojoBzlib2Alloc(void *opaque, int items, int size) +{ + return xmalloc(items * size); +} // mojoBzlib2Alloc + +static void mojoBzlib2Free(void *opaque, void *address) +{ + free(address); +} // mojoBzlib2Free + +static void initializeBZ2Stream(bz_stream *pstr) +{ + memset(pstr, '\0', sizeof (bz_stream)); + pstr->bzalloc = mojoBzlib2Alloc; + pstr->bzfree = mojoBzlib2Free; +} // initializeBZ2Stream + +static boolean MojoInput_bzip2_ready(MojoInput *io) +{ + return true; // !!! FIXME: ready if there are bytes uncompressed. +} // MojoInput_bzip2_ready + +static boolean MojoInput_bzip2_seek(MojoInput *io, uint64 offset) +{ + // This is all really expensive. + BZIP2info *info = (BZIP2info *) io->opaque; + + /* + * If seeking backwards, we need to redecode the file + * from the start and throw away the compressed bits until we hit + * the offset we need. If seeking forward, we still need to + * decode, but we don't rewind first. + */ + if (offset < info->uncompressed_position) + { +#if 0 + /* we do a copy so state is sane if inflateInit2() fails. */ + bz_stream str; + initializeBZ2Stream(&str); + if (BZ2_bzDecompressInit(&str, 0, 0) != BZ_OK) + return false; + + if (!info->origio->seek(info->origio, 0)) + return false; // !!! FIXME: leaking (str)? + + BZ2_bzDecompressEnd(&info->stream); + memcpy(&info->stream, &str, sizeof (bz_stream)); +#endif + + if (!info->origio->seek(info->origio, 0)) + return false; + BZ2_bzDecompressEnd(&info->stream); + initializeBZ2Stream(&info->stream); + if (BZ2_bzDecompressInit(&info->stream, 0, 0) != BZ_OK) + return false; + info->uncompressed_position = 0; + } // if + + while (info->uncompressed_position != offset) + { + uint8 buf[512]; + uint32 maxread; + int64 br; + + maxread = (uint32) (offset - info->uncompressed_position); + if (maxread > sizeof (buf)) + maxread = sizeof (buf); + + br = io->read(io, buf, maxread); + if (br != maxread) + return false; + } /* while */ + + return true; +} // MojoInput_bzip2_seek + +static int64 MojoInput_bzip2_tell(MojoInput *io) +{ + return (((BZIP2info *) io->opaque)->uncompressed_position); +} // MojoInput_bzip2_tell + +static int64 MojoInput_bzip2_length(MojoInput *io) +{ + return -1; +} // MojoInput_bzip2_length + +static int64 MojoInput_bzip2_read(MojoInput *io, void *buf, uint32 bufsize) +{ + BZIP2info *info = (BZIP2info *) io->opaque; + MojoInput *origio = info->origio; + int64 retval = 0; + + if (bufsize == 0) + return 0; // quick rejection. + else + { + info->stream.next_out = buf; + info->stream.avail_out = bufsize; + + while (retval < ((int64) bufsize)) + { + const uint32 before = info->stream.total_out_lo32; + int rc; + + if (info->stream.avail_in == 0) + { + int64 br; + + br = origio->length(origio) - origio->tell(origio); + if (br > 0) + { + if (br > BZIP2_READBUFSIZE) + br = BZIP2_READBUFSIZE; + + br = origio->read(origio, info->buffer, (uint32) br); + if (br <= 0) + return -1; + + info->stream.next_in = (char *) info->buffer; + info->stream.avail_in = (uint32) br; + } // if + } // if + + rc = BZ2_bzDecompress(&info->stream); + retval += (info->stream.total_out_lo32 - before); + if (rc != BZ_OK) + return -1; + } // while + } // else + + if (retval > 0) + info->uncompressed_position += (uint32) retval; + + return retval; +} // MojoInput_bzip2_read + +static MojoInput* MojoInput_bzip2_duplicate(MojoInput *io) +{ + BZIP2info *info = (BZIP2info *) io->opaque; + MojoInput *retval = NULL; + MojoInput *newio = info->origio->duplicate(info->origio); + if (newio != NULL) + { + retval = make_bzip2_input(newio); + if (retval != NULL) + retval->seek(retval, io->tell(io)); // slow, slow, slow... + } // if + return retval; +} // MojoInput_bzip2_duplicate + +static void MojoInput_bzip2_close(MojoInput *io) +{ + BZIP2info *info = (BZIP2info *) io->opaque; + if (info->origio != NULL) + info->origio->close(info->origio); + BZ2_bzDecompressEnd(&info->stream); + free(info->buffer); + free(info); + free(io); +} // MojoInput_bzip2_close + +static MojoInput *make_bzip2_input(MojoInput *origio) +{ + MojoInput *io = NULL; + BZIP2info *info = (BZIP2info *) xmalloc(sizeof (BZIP2info)); + + initializeBZ2Stream(&info->stream); + if (BZ2_bzDecompressInit(&info->stream, 0, 0) != BZ_OK) + { + free(info); + return NULL; + } // if + + info->origio = origio; + info->buffer = (uint8 *) xmalloc(BZIP2_READBUFSIZE); + + io = (MojoInput *) xmalloc(sizeof (MojoInput)); + io->ready = MojoInput_bzip2_ready; + io->read = MojoInput_bzip2_read; + io->seek = MojoInput_bzip2_seek; + io->tell = MojoInput_bzip2_tell; + io->length = MojoInput_bzip2_length; + io->duplicate = MojoInput_bzip2_duplicate; + io->close = MojoInput_bzip2_close; + io->opaque = info; + return io; +} // make_bzip2_input + +#endif // SUPPORT_BZIP2 + + +MojoInput *MojoInput_newCompressedStream(MojoInput *origio) +{ +#if SUPPORT_GZIP || SUPPORT_BZIP2 + // Look at the first piece of the file to decide if it is compressed + // by a general compression algorithm, and if so, wrap the MojoInput + // in a decompressor. + uint8 magic[4]; + const int64 br = origio->read(origio, magic, sizeof (magic)); + if ((origio->seek(origio, 0)) && (br == sizeof (magic))) + { + #if SUPPORT_GZIP + if ((magic[0] == 0x1F) && (magic[1] == 0x8B) && (magic[2] == 0x08)) + return make_gzip_input(origio); + #endif + + #if SUPPORT_BZIP2 + if ((magic[0] == 0x42) && (magic[1] == 0x5A)) + return make_bzip2_input(origio); + #endif + } // if +#endif + + return NULL; +} // MojoInput_newCompressedStream + + +MojoArchive *MojoArchive_newFromInput(MojoInput *_io, const char *origfname) +{ + int i; + MojoArchive *retval = NULL; + const char *ext = NULL; + MojoInput *io = MojoInput_newCompressedStream(_io); + if (io == NULL) + io = _io; + + if (origfname != NULL) + { + ext = strrchr(origfname, '/'); + if (ext == NULL) + ext = strchr(origfname, '.'); + else + ext = strchr(ext+1, '.'); + } // if + + while (ext != NULL) + { + // Try for an exact match by filename extension. + ext++; // skip that '.' + for (i = 0; i < STATICARRAYLEN(archives); i++) + { + const MojoArchiveType *arc = &archives[i]; + if (strcasecmp(ext, arc->ext) == 0) + return arc->create(io); + } // for + ext = strchr(ext, '.'); + } // while + + // Try any that could be determined without the file extension... + for (i = 0; i < STATICARRAYLEN(archives); i++) + { + const MojoArchiveType *arc = &archives[i]; + if ((arc->hasMagic) && ((retval = arc->create(io)) != NULL)) + return retval; + } // for + + io->close(io); + return NULL; // nothing can handle this data. +} // MojoArchive_newFromInput + + +void MojoArchive_resetEntry(MojoArchiveEntry *info) +{ + free(info->filename); + free(info->linkdest); + memset(info, '\0', sizeof (MojoArchiveEntry)); +} // MojoArchive_resetEntry + + +// !!! FIXME: I'd rather not use a callback here, but I can't see a cleaner +// !!! FIXME: way right now... +boolean MojoInput_toPhysicalFile(MojoInput *in, const char *fname, uint16 perms, + MojoChecksums *checksums, int64 maxbytes, + MojoInput_FileCopyCallback cb, void *data) +{ + boolean retval = false; + uint32 start = MojoPlatform_ticks(); + void *out = NULL; + boolean iofailure = false; + int64 flen = 0; + int64 bw = 0; + MojoChecksumContext sumctx; + + if (in == NULL) + return false; + + if (checksums != NULL) + { + memset(checksums, '\0', sizeof (MojoChecksums)); + MojoChecksum_init(&sumctx); + } // if + + // Wait for a ready(), so length() can be meaningful on network streams. + while ((!in->ready(in)) && (!iofailure)) + { + MojoPlatform_sleep(100); + if (cb != NULL) + { + if (!cb(MojoPlatform_ticks() - start, 0, 0, -1, data)) + iofailure = true; + } // if + } // while + + flen = in->length(in); + if ((maxbytes >= 0) && (flen > maxbytes)) + flen = maxbytes; + + MojoPlatform_unlink(fname); + if (!iofailure) + { + const uint32 flags = MOJOFILE_WRITE|MOJOFILE_CREATE|MOJOFILE_TRUNCATE; + const uint16 mode = MojoPlatform_defaultFilePerms(); + out = MojoPlatform_open(fname, flags, mode); + } // if + + if (out != NULL) + { + while (!iofailure) + { + int64 br = 0; + int64 maxread = sizeof (scratchbuf_128k); + + // see if we need to clamp to eof or maxbytes... + if (flen >= 0) + { + const int64 avail = flen - bw; + if (avail < maxread) + { + maxread = avail; + if (maxread == 0) + break; // nothing left to do, break out. + } // if + } // if + + // If there's a callback, then poll. Otherwise, just block on + // the reads from the MojoInput. + if ((cb != NULL) && (!in->ready(in))) + MojoPlatform_sleep(100); + else + { + br = in->read(in, scratchbuf_128k, (uint32) maxread); + if (br == 0) // we're done! + break; + else if (br < 0) + iofailure = true; + else + { + if (MojoPlatform_write(out, scratchbuf_128k, (uint32) br) != br) + iofailure = true; + else + { + if (checksums != NULL) + MojoChecksum_append(&sumctx, scratchbuf_128k, (uint32) br); + bw += br; + } // else + } // else + } // else + + if (cb != NULL) + { + if (!cb(MojoPlatform_ticks() - start, br, bw, flen, data)) + iofailure = true; + } // if + } // while + + if (MojoPlatform_close(out) != 0) + iofailure = true; + else if (bw != flen) + iofailure = true; + + if (iofailure) + MojoPlatform_unlink(fname); + else + { + MojoPlatform_chmod(fname, perms); + if (checksums != NULL) + MojoChecksum_finish(&sumctx, checksums); + retval = true; + } // else + } // if + + in->close(in); + return retval; +} // MojoInput_toPhysicalFile + + +MojoInput *MojoInput_newFromArchivePath(MojoArchive *ar, const char *fname) +{ + MojoInput *retval = NULL; + if (ar->enumerate(ar)) + { + const MojoArchiveEntry *entinfo; + while ((entinfo = ar->enumNext(ar)) != NULL) + { + if (strcmp(entinfo->filename, fname) == 0) + { + if (entinfo->type == MOJOARCHIVE_ENTRY_FILE) + retval = ar->openCurrentEntry(ar); + break; + } // if + } // while + } // if + + return retval; +} // MojoInput_newFromArchivePath + + + +// MojoInputs from files on the OS filesystem. + +typedef struct +{ + void *handle; + char *path; +} MojoInputFileInstance; + +static boolean MojoInput_file_ready(MojoInput *io) +{ + // !!! FIXME: select()? Does that help with network filesystems? + return true; +} // MojoInput_file_ready + +static int64 MojoInput_file_read(MojoInput *io, void *buf, uint32 bufsize) +{ + MojoInputFileInstance *inst = (MojoInputFileInstance *) io->opaque; + return MojoPlatform_read(inst->handle, buf, bufsize); +} // MojoInput_file_read + +static boolean MojoInput_file_seek(MojoInput *io, uint64 pos) +{ + MojoInputFileInstance *inst = (MojoInputFileInstance *) io->opaque; + return (MojoPlatform_seek(inst->handle, pos, MOJOSEEK_SET) == pos); +} // MojoInput_file_seek + +static int64 MojoInput_file_tell(MojoInput *io) +{ + MojoInputFileInstance *inst = (MojoInputFileInstance *) io->opaque; + return MojoPlatform_tell(inst->handle); +} // MojoInput_file_tell + +static int64 MojoInput_file_length(MojoInput *io) +{ + MojoInputFileInstance *inst = (MojoInputFileInstance *) io->opaque; + return MojoPlatform_flen(inst->handle); +} // MojoInput_file_length + +static MojoInput *MojoInput_file_duplicate(MojoInput *io) +{ + MojoInputFileInstance *inst = (MojoInputFileInstance *) io->opaque; + return MojoInput_newFromFile(inst->path); +} // MojoInput_file_duplicate + +static void MojoInput_file_close(MojoInput *io) +{ + MojoInputFileInstance *inst = (MojoInputFileInstance *) io->opaque; + MojoPlatform_close(inst->handle); + free(inst->path); + free(inst); + free(io); +} // MojoInput_file_close + +MojoInput *MojoInput_newFromFile(const char *path) +{ + MojoInput *io = NULL; + void *f = NULL; + + f = MojoPlatform_open(path, MOJOFILE_READ, 0); + if (f != NULL) + { + MojoInputFileInstance *inst; + inst = (MojoInputFileInstance *) xmalloc(sizeof (MojoInputFileInstance)); + inst->path = xstrdup(path); + inst->handle = f; + + io = (MojoInput *) xmalloc(sizeof (MojoInput)); + io->ready = MojoInput_file_ready; + io->read = MojoInput_file_read; + io->seek = MojoInput_file_seek; + io->tell = MojoInput_file_tell; + io->length = MojoInput_file_length; + io->duplicate = MojoInput_file_duplicate; + io->close = MojoInput_file_close; + io->opaque = inst; + } // if + + return io; +} // MojoInput_newFromFile + + + +// MojoInputs from blocks of memory. + +typedef struct +{ + void *ptr; // original pointer from xmalloc() + uint32 *refcount; // address in xmalloc()'d block for reference count. + const uint8 *data; // base of actual "file" data in xmalloc()'d block. + uint32 len; // size, in bytes, of "file" data. + uint32 pos; // current read position. +} MojoInputMemInstance; + +static boolean MojoInput_memory_ready(MojoInput *io) +{ + return true; // always ready! +} // MojoInput_memory_ready + +static int64 MojoInput_memory_read(MojoInput *io, void *buf, uint32 bufsize) +{ + MojoInputMemInstance *inst = (MojoInputMemInstance *) io->opaque; + const uint32 avail = inst->len - inst->pos; + if (bufsize > avail) + bufsize = avail; + memcpy(buf, inst->data + inst->pos, bufsize); + inst->pos += bufsize; + return bufsize; +} // MojoInput_memory_read + +static boolean MojoInput_memory_seek(MojoInput *io, uint64 pos) +{ + MojoInputMemInstance *inst = (MojoInputMemInstance *) io->opaque; + if (pos > (uint64) inst->len) + return false; + inst->pos = (uint32) pos; + return true; +} // MojoInput_memory_seek + +static int64 MojoInput_memory_tell(MojoInput *io) +{ + MojoInputMemInstance *inst = (MojoInputMemInstance *) io->opaque; + return (int64) inst->pos; +} // MojoInput_memory_tell + +static int64 MojoInput_memory_length(MojoInput *io) +{ + MojoInputMemInstance *inst = (MojoInputMemInstance *) io->opaque; + return (int64) inst->len; +} // MojoInput_memory_length + +static MojoInput *MojoInput_memory_duplicate(MojoInput *io) +{ + MojoInputMemInstance *srcinst = (MojoInputMemInstance *) io->opaque; + MojoInput *retval = NULL; + MojoInputMemInstance *inst = NULL; + + if (srcinst->refcount != NULL) + { + // we don't copy the data for each duplicate; we just bump a reference + // counter. We free the data when all referencers are closed. + (*srcinst->refcount)++; // !!! FIXME: not thread safe! + } // if + + inst = (MojoInputMemInstance*) xmalloc(sizeof (MojoInputMemInstance)); + memcpy(inst, srcinst, sizeof (MojoInputMemInstance)); + inst->pos = 0; + + retval = (MojoInput *) xmalloc(sizeof (MojoInput)); + memcpy(retval, io, sizeof (MojoInput)); + retval->opaque = inst; + + return retval; +} // MojoInput_memory_duplicate + +static void MojoInput_memory_close(MojoInput *io) +{ + MojoInputMemInstance *inst = (MojoInputMemInstance *) io->opaque; + + if (inst->refcount != NULL) // memory we have to free? + { + assert(*inst->refcount > 0); + if (--(*inst->refcount) == 0) // !!! FIXME: not thread safe! + free(inst->ptr); + } // if + + free(inst); + free(io); +} // MojoInput_memory_close + +MojoInput *MojoInput_newFromMemory(const uint8 *ptr, uint32 len, int constant) +{ + MojoInput *io = (MojoInput *) xmalloc(sizeof (MojoInput)); + MojoInputMemInstance *inst = (MojoInputMemInstance*) + xmalloc(sizeof (MojoInputMemInstance)); + + if (constant) + inst->data = ptr; + else + { + inst->ptr = xmalloc(len + sizeof (uint32)); + inst->refcount = (uint32 *) inst->ptr; + inst->data = ((const uint8 *) inst->ptr) + sizeof (uint32); + *inst->refcount = 1; + memcpy((void *) inst->data, ptr, len); + } // else + + inst->len = len; + + io->ready = MojoInput_memory_ready; + io->read = MojoInput_memory_read; + io->seek = MojoInput_memory_seek; + io->tell = MojoInput_memory_tell; + io->length = MojoInput_memory_length; + io->duplicate = MojoInput_memory_duplicate; + io->close = MojoInput_memory_close; + io->opaque = inst; + + return io; +} // MojoInput_newFromMemory + + + + +// MojoArchives from directories on the OS filesystem. + +typedef struct DirStack +{ + void *dir; + char *basepath; + struct DirStack *next; +} DirStack; + +static void pushDirStack(DirStack **_stack, const char *basepath, void *dir) +{ + DirStack *stack = (DirStack *) xmalloc(sizeof (DirStack)); + stack->dir = dir; + stack->basepath = xstrdup(basepath); + stack->next = *_stack; + *_stack = stack; +} // pushDirStack + +static void popDirStack(DirStack **_stack) +{ + DirStack *stack = *_stack; + if (stack != NULL) + { + DirStack *next = stack->next; + if (stack->dir) + MojoPlatform_closedir(stack->dir); + free(stack->basepath); + free(stack); + *_stack = next; + } // if +} // popDirStack + +static void freeDirStack(DirStack **_stack) +{ + while (*_stack) + popDirStack(_stack); +} // freeDirStack + + +typedef struct +{ + DirStack *dirs; + char *base; +} MojoArchiveDirInstance; + +static boolean MojoArchive_dir_enumerate(MojoArchive *ar) +{ + MojoArchiveDirInstance *inst = (MojoArchiveDirInstance *) ar->opaque; + void *dir = NULL; + + freeDirStack(&inst->dirs); + MojoArchive_resetEntry(&ar->prevEnum); + + dir = MojoPlatform_opendir(inst->base); + if (dir != NULL) + pushDirStack(&inst->dirs, inst->base, dir); + + return (dir != NULL); +} // MojoArchive_dir_enumerate + + +static const MojoArchiveEntry *MojoArchive_dir_enumNext(MojoArchive *ar) +{ + uint16 perms = 0644; //(S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH); + char *fullpath = NULL; + char *dent = NULL; // "dent" == "directory entry" + MojoArchiveDirInstance *inst = (MojoArchiveDirInstance *) ar->opaque; + const char *basepath; + + MojoArchive_resetEntry(&ar->prevEnum); + + if (inst->dirs == NULL) + return NULL; + + basepath = inst->dirs->basepath; + + // if readdir fails, it's end of dir (!!! FIXME: what about i/o failures?) + dent = MojoPlatform_readdir(inst->dirs->dir); + if (dent == NULL) // end of dir? + { + popDirStack(&inst->dirs); + return MojoArchive_dir_enumNext(ar); // try higher level in tree. + } // if + + // MojoPlatform layer shouldn't return "." or ".." paths. + assert((strcmp(dent, ".") != 0) && (strcmp(dent, "..") != 0)); + + fullpath = (char *) xmalloc(strlen(basepath) + strlen(dent) + 2); + sprintf(fullpath, "%s/%s", basepath, dent); + free(dent); + + ar->prevEnum.filename = xstrdup(fullpath + strlen(inst->base) + 1); + ar->prevEnum.filesize = 0; + ar->prevEnum.type = MOJOARCHIVE_ENTRY_UNKNOWN; + + // We currently force the perms from physical files, since CDs on + // Linux tend to mark every files as executable and read-only. If you + // want to install something with specific permissions, wrap it in a + // tarball, or use Setup.File.permissions, or return a permissions + // string from Setup.File.filter. + //MojoPlatform_perms(fullpath, &perms); + ar->prevEnum.perms = perms; + + if (MojoPlatform_isfile(fullpath)) + { + ar->prevEnum.type = MOJOARCHIVE_ENTRY_FILE; + ar->prevEnum.filesize = MojoPlatform_filesize(fullpath); + } // if + + else if (MojoPlatform_issymlink(fullpath)) + { + ar->prevEnum.type = MOJOARCHIVE_ENTRY_SYMLINK; + ar->prevEnum.linkdest = MojoPlatform_readlink(fullpath); + if (ar->prevEnum.linkdest == NULL) + { + free(fullpath); + return MojoArchive_dir_enumNext(ar); + } // if + } // else if + + else if (MojoPlatform_isdir(fullpath)) + { + void *dir = MojoPlatform_opendir(fullpath); + ar->prevEnum.type = MOJOARCHIVE_ENTRY_DIR; + if (dir == NULL) + { + free(fullpath); + return MojoArchive_dir_enumNext(ar); + } // if + + // push this dir on the stack. Next enum will start there. + pushDirStack(&inst->dirs, fullpath, dir); + } // else if + + else + { + assert(false && "possible file i/o error?"); + } // else + + free(fullpath); + return &ar->prevEnum; +} // MojoArchive_dir_enumNext + + +static MojoInput *MojoArchive_dir_openCurrentEntry(MojoArchive *ar) +{ + MojoInput *retval = NULL; + MojoArchiveDirInstance *inst = (MojoArchiveDirInstance *) ar->opaque; + + if ((inst->dirs != NULL) && (ar->prevEnum.type == MOJOARCHIVE_ENTRY_FILE)) + { + char *fullpath = (char *) xmalloc(strlen(inst->base) + + strlen(ar->prevEnum.filename) + 2); + sprintf(fullpath, "%s/%s", inst->base, ar->prevEnum.filename); + retval = MojoInput_newFromFile(fullpath); + free(fullpath); + } // if + + return retval; +} // MojoArchive_dir_openCurrentEntry + + +static void MojoArchive_dir_close(MojoArchive *ar) +{ + MojoArchiveDirInstance *inst = (MojoArchiveDirInstance *) ar->opaque; + freeDirStack(&inst->dirs); + free(inst->base); + free(inst); + MojoArchive_resetEntry(&ar->prevEnum); + free(ar); +} // MojoArchive_dir_close + + +MojoArchive *MojoArchive_newFromDirectory(const char *dirname) +{ + MojoArchive *ar = NULL; + MojoArchiveDirInstance *inst; + char *real = MojoPlatform_realpath(dirname); + + if (real == NULL) + return NULL; + + if (!MojoPlatform_exists(real, NULL)) + return NULL; + + if (!MojoPlatform_isdir(real)) + return NULL; + + inst = (MojoArchiveDirInstance *) xmalloc(sizeof (MojoArchiveDirInstance)); + inst->base = real; + ar = (MojoArchive *) xmalloc(sizeof (MojoArchive)); + ar->enumerate = MojoArchive_dir_enumerate; + ar->enumNext = MojoArchive_dir_enumNext; + ar->openCurrentEntry = MojoArchive_dir_openCurrentEntry; + ar->close = MojoArchive_dir_close; + ar->offsetOfStart = -1; // doesn't mean anything here. + ar->opaque = inst; + return ar; +} // MojoArchive_newFromDirectory + + + + +MojoArchive *GBaseArchive = NULL; +const char *GBaseArchivePath = NULL; + +MojoArchive *MojoArchive_initBaseArchive(void) +{ + char *basepath = NULL; + const char *cmd = NULL; + MojoInput *io = NULL; + + if (GBaseArchive != NULL) + return GBaseArchive; // already initialized. + + if ((cmd = cmdlinestr("base", "MOJOSETUP_BASE", NULL)) != NULL) + { + char *real = MojoPlatform_realpath(cmd); + if (real != NULL) + { + if (MojoPlatform_isdir(real)) + GBaseArchive = MojoArchive_newFromDirectory(real); + else + { + io = MojoInput_newFromFile(real); + if (io != NULL) + GBaseArchive = MojoArchive_newFromInput(io, real); + } // else + + if (GBaseArchive != NULL) + basepath = real; + else + free(real); + } // if + } // else if + + else + { + basepath = MojoPlatform_appBinaryPath(); + io = MojoInput_newFromFile(basepath); + + if (io != NULL) + GBaseArchive = MojoArchive_newFromInput(io, basepath); + + if (GBaseArchive == NULL) + { + // Just use the same directory as the binary instead. + char *ptr = strrchr(basepath, '/'); + if (ptr != NULL) + *ptr = '\0'; + else + { + free(basepath); // oh well, try cwd. + basepath = MojoPlatform_currentWorkingDir(); + } // else + GBaseArchive = MojoArchive_newFromDirectory(basepath); + + // !!! FIXME: failing this, maybe default.mojosetup? + } // if + } // else + + if (GBaseArchive == NULL) + { + free(basepath); + basepath = NULL; + } // if + GBaseArchivePath = basepath; + + return GBaseArchive; +} // MojoArchive_initBaseArchive + + +void MojoArchive_deinitBaseArchive(void) +{ + if (GBaseArchive != NULL) + { + GBaseArchive->close(GBaseArchive); + GBaseArchive = NULL; + } // if + + free((void *) GBaseArchivePath); + GBaseArchivePath = NULL; +} // MojoArchive_deinitBaseArchive + + +// This stub is here if we didn't compile in libfetch... +#if !SUPPORT_URL_HTTP && !SUPPORT_URL_FTP +MojoInput *MojoInput_newFromURL(const char *url) +{ + logError("No networking support in this build."); + return NULL; +} // MojoInput_newFromURL +#endif + +// end of fileio.c ... + diff --git a/mk/linux/mojosetup/fileio.h b/mk/linux/mojosetup/fileio.h new file mode 100644 index 00000000..32b866c5 --- /dev/null +++ b/mk/linux/mojosetup/fileio.h @@ -0,0 +1,128 @@ +/** + * MojoSetup; a portable, flexible installation application. + * + * Please see the file LICENSE.txt in the source's root directory. + * + * This file written by Ryan C. Gordon. + */ + +#ifndef _INCL_FILEIO_H_ +#define _INCL_FILEIO_H_ + +#include "universal.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * File i/o may go through multiple layers: the archive attached to the binary, + * then an archive in there that's being read entirely out of memory that's + * being uncompressed to on the fly, or it might be a straight read from a + * regular uncompressed file on physical media. It might be a single file + * compressed with bzip2. As such, we have to have an abstraction over the + * usual channels...basically what we need here is archives-within-archives, + * done transparently and with arbitrary depth, although usually not more + * than one deep. This also works as a general transport layer, so the + * abstraction could be extended to network connections and such, too. + */ + +// Abstract input interface. Files, memory, archive entries, etc. +typedef struct MojoInput MojoInput; +struct MojoInput +{ + // public + boolean (*ready)(MojoInput *io); + int64 (*read)(MojoInput *io, void *buf, uint32 bufsize); + boolean (*seek)(MojoInput *io, uint64 pos); + int64 (*tell)(MojoInput *io); + int64 (*length)(MojoInput *io); + MojoInput* (*duplicate)(MojoInput *io); + void (*close)(MojoInput *io); + + // private + void *opaque; +}; + +// This copies the memory, so you may free (ptr) after this function returns. +MojoInput *MojoInput_newFromMemory(const uint8 *ptr, uint32 len, int constant); +MojoInput *MojoInput_newFromFile(const char *fname); + + +typedef enum +{ + MOJOARCHIVE_ENTRY_UNKNOWN = 0, + MOJOARCHIVE_ENTRY_FILE, + MOJOARCHIVE_ENTRY_DIR, + MOJOARCHIVE_ENTRY_SYMLINK, +} MojoArchiveEntryType; + +// Abstract archive interface. Archives, directories, etc. +typedef struct MojoArchiveEntry +{ + char *filename; + char *linkdest; + MojoArchiveEntryType type; + int64 filesize; + uint16 perms; +} MojoArchiveEntry; + +void MojoArchive_resetEntry(MojoArchiveEntry *info); + + +typedef struct MojoArchive MojoArchive; +struct MojoArchive +{ + // public + boolean (*enumerate)(MojoArchive *ar); + const MojoArchiveEntry* (*enumNext)(MojoArchive *ar); + MojoInput* (*openCurrentEntry)(MojoArchive *ar); + void (*close)(MojoArchive *ar); + + // private + MojoInput *io; + MojoArchiveEntry prevEnum; + int64 offsetOfStart; // byte offset in MojoInput where archive starts. + void *opaque; +}; + +MojoArchive *MojoArchive_newFromDirectory(const char *dirname); +MojoArchive *MojoArchive_newFromInput(MojoInput *io, const char *origfname); + +// This will reset enumeration in the archive, don't use it while iterating! +// Also, this can be very slow depending on the archive in question, so +// try to limit your random access filename lookups to known-fast quantities +// (like directories on the physical filesystem or a zipfile...tarballs and +// zipfiles-in-zipfiles will bog down here, for example). +MojoInput *MojoInput_newFromArchivePath(MojoArchive *ar, const char *fname); + +// Wrap (origio) in a new MojoInput that decompresses a compressed stream +// on the fly. Returns NULL on error or if (origio) isn't a supported +// compressed format. The returned MojoInput wraps the original input; +// closing the returned MojoInput will close (origio), too, and you should +// consider origio lost. If this function returns non-NULL, you should not, +// under any circumstances, interact directly with origio again, as the +// new MojoInput now owns it. +MojoInput *MojoInput_newCompressedStream(MojoInput *origio); + +extern MojoArchive *GBaseArchive; +extern const char *GBaseArchivePath; +MojoArchive *MojoArchive_initBaseArchive(void); +void MojoArchive_deinitBaseArchive(void); + +typedef boolean (*MojoInput_FileCopyCallback)(uint32 ticks, int64 justwrote, + int64 bw, int64 total, void *data); +boolean MojoInput_toPhysicalFile(MojoInput *in, const char *fname, uint16 perms, + MojoChecksums *checksums, int64 maxbytes, + MojoInput_FileCopyCallback cb, void *data); + +MojoInput *MojoInput_newFromURL(const char *url); + +#ifdef __cplusplus +} +#endif + +#endif + +// end of fileio.h ... + diff --git a/mk/linux/mojosetup/gui.c b/mk/linux/mojosetup/gui.c new file mode 100644 index 00000000..f4d1b959 --- /dev/null +++ b/mk/linux/mojosetup/gui.c @@ -0,0 +1,220 @@ +/** + * MojoSetup; a portable, flexible installation application. + * + * Please see the file LICENSE.txt in the source's root directory. + * + * This file written by Ryan C. Gordon. + */ + +#include "gui.h" +#include "platform.h" +#include "fileio.h" + +typedef struct S_PLUGINLIST +{ + void *lib; + const MojoGui *gui; + MojoGuiPluginPriority priority; + struct S_PLUGINLIST *next; +} PluginList; + +const MojoGui *GGui = NULL; +static PluginList *pluginDetails = NULL; + +static const MojoGuiEntryPoint staticGui[] = +{ +#if GUI_STATIC_LINK_STDIO + MojoGuiPlugin_stdio, +#endif +#if GUI_STATIC_LINK_COCOA + MojoGuiPlugin_cocoa, +#endif +#if GUI_STATIC_LINK_GTKPLUS2 + MojoGuiPlugin_gtkplus2, +#endif +#if GUI_STATIC_LINK_WWW + MojoGuiPlugin_www, +#endif +#if GUI_STATIC_LINK_NCURSES + MojoGuiPlugin_ncurses, +#endif + NULL +}; + + +static MojoGuiPluginPriority calcGuiPriority(const MojoGui *gui) +{ + MojoGuiPluginPriority retval; + + retval = gui->priority(MojoPlatform_istty()); + + // If the plugin isn't saying "don't try me at all" then see if the + // user explicitly wants this one. + if (retval != MOJOGUI_PRIORITY_NEVER_TRY) + { + static const char *envr = NULL; + if (envr == NULL) + envr = cmdlinestr("ui", "MOJOSETUP_UI", NULL); + if ((envr != NULL) && (strcasecmp(envr, gui->name()) == 0)) + retval = MOJOGUI_PRIORITY_USER_REQUESTED; + } // if + + return retval; +} // calcGuiPriority + + +static PluginList *initGuiPluginsByPriority(PluginList *plugins) +{ + MojoGuiPluginPriority p; + for (p = MOJOGUI_PRIORITY_USER_REQUESTED; p < MOJOGUI_PRIORITY_TOTAL; p++) + { + PluginList *i; + for (i = plugins->next; i != NULL; i = i->next) + { + if ( (i->priority == p) && (i->gui->init()) ) + { + logInfo("Selected '%0' UI.", i->gui->name()); + return i; + } // if + } // for + } // for + + return NULL; +} // initGuiPluginsByPriority + + +static void deleteGuiPlugin(PluginList *plugin) +{ + if (plugin != NULL) + { + if (plugin->gui) + plugin->gui->deinit(); + if (plugin->lib) + MojoPlatform_dlclose(plugin->lib); + free(plugin); + } // if +} // deleteGuiPlugin + + +static boolean tryGuiPlugin(PluginList *plugins, MojoGuiEntryPoint entry) +{ + boolean retval = false; + const MojoGui *gui = entry(MOJOGUI_INTERFACE_REVISION, &GEntryPoints); + if (gui != NULL) + { + PluginList *plug = xmalloc(sizeof (PluginList)); + plug->lib = NULL; + plug->gui = gui; + plug->priority = calcGuiPriority(gui); + plug->next = plugins->next; + plugins->next = plug; + retval = true; + } // if + + return retval; +} // tryGuiPlugin + + +static void loadStaticGuiPlugins(PluginList *plugins) +{ + int i; + for (i = 0; staticGui[i] != NULL; i++) + tryGuiPlugin(plugins, staticGui[i]); +} // loadStaticGuiPlugins + + +static boolean loadDynamicGuiPlugin(PluginList *plugins, MojoArchive *ar) +{ + boolean rc = false; + void *lib = NULL; + MojoInput *io = ar->openCurrentEntry(ar); + if (io != NULL) + { + const uint32 imglen = (uint32) io->length(io); + uint8 *img = (uint8 *) xmalloc(imglen); + const uint32 br = (uint32) io->read(io, img, imglen); + io->close(io); + if (br == imglen) + lib = MojoPlatform_dlopen(img, imglen); + free(img); + } // if + + if (lib != NULL) + { + void *addr = MojoPlatform_dlsym(lib, MOJOGUI_ENTRY_POINT_STR); + MojoGuiEntryPoint entry = (MojoGuiEntryPoint) addr; + if (entry != NULL) + { + if ((rc = tryGuiPlugin(plugins, entry)) == false) + MojoPlatform_dlclose(lib); + } // if + } // if + + return rc; +} // loadDynamicGuiPlugin + + +static void loadDynamicGuiPlugins(PluginList *plugins) +{ + if (GBaseArchive->enumerate(GBaseArchive)) + { + const MojoArchiveEntry *entinfo; + while ((entinfo = GBaseArchive->enumNext(GBaseArchive)) != NULL) + { + if (entinfo->type != MOJOARCHIVE_ENTRY_FILE) + continue; + + if (strncmp(entinfo->filename, "guis/", 5) != 0) + continue; + + loadDynamicGuiPlugin(plugins, GBaseArchive); + } // while + } // if +} // loadDynamicGuiPlugins + + +const MojoGui *MojoGui_initGuiPlugin(void) +{ + PluginList plugins; + PluginList *i = NULL; + + if (pluginDetails != NULL) + return pluginDetails->gui; + + memset(&plugins, '\0', sizeof (plugins)); + assert(GGui == NULL); + + loadDynamicGuiPlugins(&plugins); + loadStaticGuiPlugins(&plugins); + + pluginDetails = initGuiPluginsByPriority(&plugins); + + // cleanout unused plugins... + i = plugins.next; + while (i != NULL) + { + PluginList *next = i->next; + if (i != pluginDetails) + deleteGuiPlugin(i); + i = next; + } // while + + if (pluginDetails != NULL) + { + GGui = pluginDetails->gui; + pluginDetails->next = NULL; + } // if + + return GGui; +} // MojoGui_findGuiPlugin + + +void MojoGui_deinitGuiPlugin(void) +{ + GGui = NULL; + deleteGuiPlugin(pluginDetails); + pluginDetails = NULL; +} // MojoGui_deinitGuiPlugin + +// end of gui.c ... + diff --git a/mk/linux/mojosetup/gui.h b/mk/linux/mojosetup/gui.h new file mode 100644 index 00000000..7b80dda8 --- /dev/null +++ b/mk/linux/mojosetup/gui.h @@ -0,0 +1,302 @@ +/** + * MojoSetup; a portable, flexible installation application. + * + * Please see the file LICENSE.txt in the source's root directory. + * + * This file written by Ryan C. Gordon. + */ + +#ifndef _INCL_GUI_H_ +#define _INCL_GUI_H_ + +#include "universal.h" + +#ifdef __cplusplus +extern "C" { +#endif + +typedef enum +{ + MOJOGUI_PRIORITY_NEVER_TRY = 0, + MOJOGUI_PRIORITY_USER_REQUESTED, + MOJOGUI_PRIORITY_TRY_FIRST, + MOJOGUI_PRIORITY_TRY_NORMAL, + MOJOGUI_PRIORITY_TRY_LAST, + MOJOGUI_PRIORITY_TRY_ABSOLUTELY_LAST, + MOJOGUI_PRIORITY_TOTAL +} MojoGuiPluginPriority; + + +typedef enum +{ + MOJOGUI_NO, + MOJOGUI_YES, + MOJOGUI_ALWAYS, + MOJOGUI_NEVER +} MojoGuiYNAN; + + + +/* + * Abstract GUI interfaces. + */ + +typedef struct MojoGuiSetupOptions MojoGuiSetupOptions; +struct MojoGuiSetupOptions +{ + const char *description; + const char *tooltip; + boolean value; + boolean is_group_parent; + uint64 size; + int opaque; // GUI drivers shouldn't touch this. + void *guiopaque; // For GUI drivers. App won't touch or free this. + MojoGuiSetupOptions *next_sibling; + MojoGuiSetupOptions *child; +}; + + +typedef enum +{ + MOJOGUI_SPLASH_NONE, + MOJOGUI_SPLASH_TOP, + MOJOGUI_SPLASH_LEFT, + MOJOGUI_SPLASH_RIGHT, + MOJOGUI_SPLASH_BOTTOM, + MOJOGUI_SPLASH_BACKGROUND, +} MojoGuiSplashPos; + +typedef struct MojoGuiSplash MojoGuiSplash; +struct MojoGuiSplash +{ + const uint8 *rgba; // framebuffer. + uint32 w; // width in pixels. + uint32 h; // height in pixels. + MojoGuiSplashPos position; // where to put the splash. +}; + + +#define MOJOGUI_ENTRY_POINT MojoSetup_Gui_GetInterface +#define MOJOGUI_ENTRY_POINT_STR DEFINE_TO_STR(MOJOGUI_ENTRY_POINT) + +// Increment this value when MojoGui's structure changes. +#define MOJOGUI_INTERFACE_REVISION 6 + +typedef struct MojoGui MojoGui; +struct MojoGui +{ + uint8 (*priority)(boolean istty); + const char* (*name)(void); + boolean (*init)(void); + void (*deinit)(void); + void (*msgbox)(const char *title, const char *text); + boolean (*promptyn)(const char *title, const char *text, boolean def); + MojoGuiYNAN (*promptynan)(const char *title, const char *text, boolean def); + boolean (*start)(const char *title, const MojoGuiSplash *splash); + void (*stop)(void); + int (*readme)(const char *name, const uint8 *data, size_t len, + boolean can_back, boolean can_fwd); + int (*options)(MojoGuiSetupOptions *opts, + boolean can_back, boolean can_fwd); + char * (*destination)(const char **recommendations, int recnum, + int *command, boolean can_back, boolean can_fwd); + int (*productkey)(const char *desc, const char *fmt, char *buf, + const int buflen, boolean can_back, boolean can_fwd); + boolean (*insertmedia)(const char *medianame); + void (*progressitem)(void); + boolean (*progress)(const char *type, const char *component, + int percent, const char *item, boolean can_cancel); + void (*final)(const char *msg); +}; + +typedef const MojoGui* (*MojoGuiEntryPoint)(int revision, + const MojoSetupEntryPoints *e); + +#if !BUILDING_EXTERNAL_PLUGIN +extern const MojoGui *GGui; +const MojoGui *MojoGui_initGuiPlugin(void); +void MojoGui_deinitGuiPlugin(void); +#else + +__EXPORT__ const MojoGui *MOJOGUI_ENTRY_POINT(int revision, + const MojoSetupEntryPoints *e); + +/* + * We do this as a macro so we only have to update one place, and it + * enforces some details in the plugins. Without effort, plugins don't + * support anything but the latest version of the interface. + */ +#define MOJOGUI_PLUGIN(module) \ +static const MojoSetupEntryPoints *entry = NULL; \ +static uint8 MojoGui_##module##_priority(boolean istty); \ +static const char* MojoGui_##module##_name(void) { return #module; } \ +static boolean MojoGui_##module##_init(void); \ +static void MojoGui_##module##_deinit(void); \ +static void MojoGui_##module##_msgbox(const char *title, const char *text); \ +static boolean MojoGui_##module##_promptyn(const char *t1, const char *t2, \ + boolean d); \ +static MojoGuiYNAN MojoGui_##module##_promptynan(const char *t1, \ + const char *t2, boolean d); \ +static boolean MojoGui_##module##_start(const char *t, \ + const MojoGuiSplash *splash); \ +static void MojoGui_##module##_stop(void); \ +static int MojoGui_##module##_readme(const char *name, const uint8 *data, \ + size_t len, boolean can_back, \ + boolean can_fwd); \ +static int MojoGui_##module##_options(MojoGuiSetupOptions *opts, \ + boolean can_back, boolean can_fwd); \ +static char *MojoGui_##module##_destination(const char **r, int recnum, \ + int *command, boolean can_back, boolean can_fwd); \ +static int MojoGui_##module##_productkey(const char *desc, const char *fmt, \ + char *buf, const int buflen, boolean can_back, \ + boolean can_fwd); \ +static boolean MojoGui_##module##_insertmedia(const char *medianame); \ +static void MojoGui_##module##_progressitem(void); \ +static boolean MojoGui_##module##_progress(const char *typ, const char *comp, \ + int percent, const char *item, \ + boolean can_cancel); \ +static void MojoGui_##module##_final(const char *msg); \ +const MojoGui *MojoGuiPlugin_##module(int rev, const MojoSetupEntryPoints *e) \ +{ \ + if (rev == MOJOGUI_INTERFACE_REVISION) { \ + static const MojoGui retval = { \ + MojoGui_##module##_priority, \ + MojoGui_##module##_name, \ + MojoGui_##module##_init, \ + MojoGui_##module##_deinit, \ + MojoGui_##module##_msgbox, \ + MojoGui_##module##_promptyn, \ + MojoGui_##module##_promptynan, \ + MojoGui_##module##_start, \ + MojoGui_##module##_stop, \ + MojoGui_##module##_readme, \ + MojoGui_##module##_options, \ + MojoGui_##module##_destination, \ + MojoGui_##module##_productkey, \ + MojoGui_##module##_insertmedia, \ + MojoGui_##module##_progressitem, \ + MojoGui_##module##_progress, \ + MojoGui_##module##_final, \ + }; \ + entry = e; \ + return &retval; \ + } \ + return NULL; \ +} \ + +#define CREATE_MOJOGUI_ENTRY_POINT(module) \ +const MojoGui *MOJOGUI_ENTRY_POINT(int rev, const MojoSetupEntryPoints *e) \ +{ \ + return MojoGuiPlugin_##module(rev, e); \ +} \ + + +// Redefine things that need to go through the plugin entry point interface, +// so plugins calling into the MojoSetup core can use the same code as the +// rest of the app. + +#ifdef _ +#undef _ +#endif +#define _(x) entry->translate(x) + +#ifdef xmalloc +#undef xmalloc +#endif +#define xmalloc(x) entry->xmalloc(x) + +#ifdef xrealloc +#undef xrealloc +#endif +#define xrealloc(x,y) entry->xrealloc(x,y) + +#ifdef xstrdup +#undef xstrdup +#endif +#define xstrdup(x) entry->xstrdup(x) + +#ifdef xstrncpy +#undef xstrncpy +#endif +#define xstrncpy(x,y,z) entry->xstrcpy(x,y,z) + +#ifdef logWarning +#undef logWarning +#endif +#define logWarning entry->logWarning + +#ifdef logError +#undef logError +#endif +#define logError entry->logError + +#ifdef logInfo +#undef logInfo +#endif +#define logInfo entry->logInfo + +#ifdef logDebug +#undef logDebug +#endif +#define logDebug entry->logDebug + +#ifdef format +#undef format +#endif +#define format entry->format + +#ifdef numstr +#undef numstr +#endif +#define numstr(x) entry->numstr(x) + +#ifdef ticks +#undef ticks +#endif +#define ticks() entry->ticks() + +#ifdef utf8codepoint +#undef utf8codepoint +#endif +#define utf8codepoint(x) entry->utf8codepoint(x) + +#ifdef utf8len +#undef utf8len +#endif +#define utf8len(x) entry->utf8len(x) + +#ifdef splitText +#undef splitText +#endif +#define splitText(w,x,y,z) entry->splitText(w,x,y,z) + +#ifdef isValidProductKey +#undef isValidProductKey +#endif +#define isValidProductKey(x,y) entry->isValidProductKey(x,y) + +#endif + + +/* + * make some decisions about which GUI plugins to build... + * We list them all here, but some are built, some aren't. Some are DLLs, + * some aren't... + */ + +const MojoGui *MojoGuiPlugin_stdio(int rev, const MojoSetupEntryPoints *e); +const MojoGui *MojoGuiPlugin_ncurses(int rev, const MojoSetupEntryPoints *e); +const MojoGui *MojoGuiPlugin_gtkplus2(int rev, const MojoSetupEntryPoints *e); +const MojoGui *MojoGuiPlugin_www(int rev, const MojoSetupEntryPoints *e); +const MojoGui *MojoGuiPlugin_cocoa(int rev, const MojoSetupEntryPoints *e); + +// !!! FIXME: Qt? KDE? Gnome? Console? wxWidgets? + +#ifdef __cplusplus +} +#endif + +#endif + +// end of gui.h ... + diff --git a/mk/linux/mojosetup/gui_cocoa.m b/mk/linux/mojosetup/gui_cocoa.m new file mode 100644 index 00000000..05d0e685 --- /dev/null +++ b/mk/linux/mojosetup/gui_cocoa.m @@ -0,0 +1,800 @@ +/** + * MojoSetup; a portable, flexible installation application. + * + * Please see the file LICENSE.txt in the source's root directory. + * + * This file written by Ryan C. Gordon. + */ + +#if !SUPPORT_GUI_COCOA +#error Something is wrong in the build system. +#endif + +#import +#undef true +#undef false + +#define BUILDING_EXTERNAL_PLUGIN 1 +#include "gui.h" + +MOJOGUI_PLUGIN(cocoa) + +#if !GUI_STATIC_LINK_COCOA +CREATE_MOJOGUI_ENTRY_POINT(cocoa) +#endif + +typedef enum +{ + CLICK_BACK=-1, + CLICK_CANCEL, + CLICK_NEXT, + CLICK_NONE +} ClickValue; + +// This nasty hack is because we appear to need to be under +// -[NSApp run] when calling things like NSRunAlertPanel(). +// So we push a custom event, call -[NSApp run], catch it, do +// the panel, then call -[NSApp stop]. Yuck. +typedef enum +{ + CUSTOMEVENT_BASEVALUE=3234, + CUSTOMEVENT_RUNQUEUE, + CUSTOMEVENT_MSGBOX, + CUSTOMEVENT_PROMPTYN, + CUSTOMEVENT_PROMPTYNAN, + CUSTOMEVENT_INSERTMEDIA, +} CustomEvent; + + +static NSAutoreleasePool *GAutoreleasePool = nil; + +@interface MojoSetupController : NSView +{ + IBOutlet NSButton *BackButton; + IBOutlet NSButton *CancelButton; + IBOutlet NSComboBox *DestinationCombo; + IBOutlet NSTextField *FinalText; + IBOutlet NSWindow *MainWindow; + IBOutlet NSButton *NextButton; + IBOutlet NSProgressIndicator *ProgressBar; + IBOutlet NSTextField *ProgressComponentLabel; + IBOutlet NSTextField *ProgressItemLabel; + IBOutlet NSTextView *ReadmeText; + IBOutlet NSTabView *TabView; + IBOutlet NSTextField *TitleLabel; + IBOutlet NSMenuItem *QuitMenuItem; + IBOutlet NSMenuItem *AboutMenuItem; + IBOutlet NSMenuItem *HideMenuItem; + IBOutlet NSMenuItem *WindowMenuItem; + IBOutlet NSMenuItem *HideOthersMenuItem; + IBOutlet NSMenuItem *ShowAllMenuItem; + IBOutlet NSMenuItem *ServicesMenuItem; + IBOutlet NSMenuItem *MinimizeMenuItem; + IBOutlet NSMenuItem *ZoomMenuItem; + IBOutlet NSMenuItem *BringAllToFrontMenuItem; + IBOutlet NSView *OptionsView; + ClickValue clickValue; + boolean canForward; + boolean needToBreakEventLoop; + boolean finalPage; + MojoGuiYNAN answerYNAN; + MojoGuiSetupOptions *mojoOpts; +} +- (void)awakeFromNib; +- (void)applicationDidFinishLaunching:(NSNotification *)aNotification; +- (void)prepareWidgets:(const char*)winTitle; +- (void)unprepareWidgets; +- (void)fireCustomEvent:(CustomEvent)eventType data1:(NSInteger)data1 data2:(NSInteger)data2 atStart:(BOOL)atStart; +- (void)doCustomEvent:(NSEvent *)event; +- (void)doMsgBox:(const char *)title text:(const char *)text; +- (void)doPromptYN:(const char *)title text:(const char *)text; +- (void)doPromptYNAN:(const char *)title text:(const char *)text; +- (void)doInsertMedia:(const char *)medianame; +- (MojoGuiYNAN)getAnswerYNAN; +- (IBAction)backClicked:(NSButton *)sender; +- (IBAction)cancelClicked:(NSButton *)sender; +- (IBAction)nextClicked:(NSButton *)sender; +- (IBAction)browseClicked:(NSButton *)sender; +- (IBAction)menuQuit:(NSMenuItem *)sender; +- (int)doPage:(NSString *)pageId title:(const char *)_title canBack:(boolean)canBack canFwd:(boolean)canFwd canCancel:(boolean)canCancel canFwdAtStart:(boolean)canFwdAtStart shouldBlock:(BOOL)shouldBlock; +- (int)doReadme:(const char *)title text:(NSString *)text canBack:(boolean)canBack canFwd:(boolean)canFwd; +- (void)setOptionTreeSensitivity:(MojoGuiSetupOptions *)opts enabled:(boolean)val; +- (void)optionToggled:(id)toggle; +- (NSView *)newOptionLevel:(NSView *)box; +- (void)buildOptions:(MojoGuiSetupOptions *)opts view:(NSView *)box sensitive:(boolean)sensitive; +- (int)doOptions:(MojoGuiSetupOptions *)opts canBack:(boolean)canBack canFwd:(boolean)canFwd; +- (char *)doDestination:(const char **)recommends recnum:(int)recnum command:(int *)command canBack:(boolean)canBack canFwd:(boolean)canFwd; +- (int)doProductKey:(const char *)desc fmt:(const char *)fmt buf:(char *)buf buflen:(const int)buflen canBack:(boolean)canBack canFwd:(boolean)canFwd; +- (int)doProgress:(const char *)type component:(const char *)component percent:(int)percent item:(const char *)item canCancel:(boolean)canCancel; +- (void)doFinal:(const char *)msg; +@end // interface MojoSetupController + +@implementation MojoSetupController + - (void)awakeFromNib + { + clickValue = CLICK_NONE; + canForward = false; + answerYNAN = MOJOGUI_NO; + needToBreakEventLoop = false; + finalPage = false; + mojoOpts = nil; + } // awakeFromNib + + - (void)applicationDidFinishLaunching:(NSNotification *)aNotification + { + printf("didfinishlaunching\n"); + [NSApp stop:self]; // break out of NSApp::run() + } // applicationDidFinishLaunching + + - (void)prepareWidgets:(const char*)winTitle + { + #if 1 + [BackButton setTitle:[NSString stringWithUTF8String:_("Back")]]; + [NextButton setTitle:[NSString stringWithUTF8String:_("Next")]]; + [CancelButton setTitle:[NSString stringWithUTF8String:_("Cancel")]]; + #else + // !!! FIXME: there's probably a better way to do this. + // Set the correct localization for the buttons, then resize them so + // the new text fits perfectly. After that, we need to reposition + // them so they don't look scattered. + NSRect frameBack = [BackButton frame]; + NSRect frameNext = [NextButton frame]; + NSRect frameCancel = [CancelButton frame]; + const float startX = frameCancel.origin.x + frameCancel.size.width; + const float spacing = (frameBack.origin.x + frameBack.size.width) - frameNext.origin.x; + [BackButton setTitle:[NSString stringWithUTF8String:_("Back")]]; + [NextButton setTitle:[NSString stringWithUTF8String:_("Next")]]; + [CancelButton setTitle:[NSString stringWithUTF8String:_("Cancel")]]; + [BackButton sizeToFit]; + [NextButton sizeToFit]; + [CancelButton sizeToFit]; + frameBack = [BackButton frame]; + frameNext = [NextButton frame]; + frameCancel = [CancelButton frame]; + frameCancel.origin.x = startX - frameCancel.size.width; + frameNext.origin.x = (frameCancel.origin.x - frameNext.size.width) - spacing; + frameBack.origin.x = (frameNext.origin.x - frameBack.size.width) - spacing; + [CancelButton setFrame:frameCancel]; + [CancelButton setNeedsDisplay:YES]; + [NextButton setFrame:frameNext]; + [NextButton setNeedsDisplay:YES]; + [BackButton setFrame:frameBack]; + [BackButton setNeedsDisplay:YES]; + #endif + + [ProgressBar setUsesThreadedAnimation:YES]; // we don't pump fast enough. + [ProgressBar startAnimation:self]; + + [WindowMenuItem setTitle:[NSString stringWithUTF8String:_("Window")]]; + [HideOthersMenuItem setTitle:[NSString stringWithUTF8String:_("Hide Others")]]; + [ShowAllMenuItem setTitle:[NSString stringWithUTF8String:_("Show All")]]; + [ServicesMenuItem setTitle:[NSString stringWithUTF8String:_("Services")]]; + [MinimizeMenuItem setTitle:[NSString stringWithUTF8String:_("Minimize")]]; + [ZoomMenuItem setTitle:[NSString stringWithUTF8String:_("Zoom")]]; + [BringAllToFrontMenuItem setTitle:[NSString stringWithUTF8String:_("Bring All to Front")]]; + + NSString *appName; + appName = (NSString *) [[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleName"]; + if (appName == nil) + appName = [[NSProcessInfo processInfo] processName]; + + const char *utf8AppName = [appName UTF8String]; + char *text; + + text = format(_("About %0"), utf8AppName); + [AboutMenuItem setTitle:[NSString stringWithUTF8String:text]]; + free(text); + + text = format(_("Hide %0"), utf8AppName); + [HideMenuItem setTitle:[NSString stringWithUTF8String:text]]; + free(text); + + text = format(_("Quit %0"), utf8AppName); + [QuitMenuItem setTitle:[NSString stringWithUTF8String:text]]; + free(text); + + [MainWindow setTitle:[NSString stringWithUTF8String:winTitle]]; + [MainWindow center]; + [MainWindow makeKeyAndOrderFront:self]; + } // prepareWidgets + + - (void)unprepareWidgets + { + [MainWindow orderOut:self]; + } // unprepareWidgets + + - (void)fireCustomEvent:(CustomEvent)eventType data1:(NSInteger)data1 data2:(NSInteger)data2 atStart:(BOOL)atStart + { + NSEvent *event = [NSEvent otherEventWithType:NSApplicationDefined location:NSZeroPoint modifierFlags:0 timestamp:0 windowNumber:0 context:nil subtype:(short)eventType data1:data1 data2:data2]; + [NSApp postEvent:event atStart:atStart]; + [NSApp run]; // event handler _must_ call -[NSApp stop], or you block here forever. + } // fireCustomEvent + + - (void)doCustomEvent:(NSEvent*)event + { + printf("custom event!\n"); + switch ((CustomEvent) [event subtype]) + { + case CUSTOMEVENT_RUNQUEUE: + if ([NSApp modalWindow] != nil) + { + // If we're in a modal thing, so don't break the event loop. + // Just make a note to break it later. + needToBreakEventLoop = true; + return; + } // if + break; // we just need the -[NSApp stop] call. + case CUSTOMEVENT_MSGBOX: + [self doMsgBox:(const char *)[event data1] text:(const char *)[event data2]]; + break; + case CUSTOMEVENT_PROMPTYN: + [self doPromptYN:(const char *)[event data1] text:(const char *)[event data2]]; + break; + case CUSTOMEVENT_PROMPTYNAN: + [self doPromptYNAN:(const char *)[event data1] text:(const char *)[event data2]]; + break; + case CUSTOMEVENT_INSERTMEDIA: + [self doInsertMedia:(const char *)[event data1]]; + break; + default: + return; // let it go without breaking the event loop. + } // switch + + [NSApp stop:self]; // break the event loop. + } // doCustomEvent + + - (void)doMsgBox:(const char *)title text:(const char *)text + { + NSString *titlestr = [NSString stringWithUTF8String:title]; + NSString *textstr = [NSString stringWithUTF8String:text]; + NSString *okstr = [NSString stringWithUTF8String:_("OK")]; + NSRunInformationalAlertPanel(titlestr, textstr, okstr, nil, nil); + if (needToBreakEventLoop) + { + needToBreakEventLoop = false; + [self fireCustomEvent:CUSTOMEVENT_RUNQUEUE data1:0 data2:0 atStart:NO]; + } // if + } // doMsgBox + + - (void)doPromptYN:(const char *)title text:(const char *)text + { + NSString *titlestr = [NSString stringWithUTF8String:title]; + NSString *textstr = [NSString stringWithUTF8String:text]; + NSString *yesstr = [NSString stringWithUTF8String:_("Yes")]; + NSString *nostr = [NSString stringWithUTF8String:_("No")]; + const NSInteger rc = NSRunAlertPanel(titlestr, textstr, yesstr, nostr, nil); + answerYNAN = ((rc == NSAlertDefaultReturn) ? MOJOGUI_YES : MOJOGUI_NO); + if (needToBreakEventLoop) + { + needToBreakEventLoop = false; + [self fireCustomEvent:CUSTOMEVENT_RUNQUEUE data1:0 data2:0 atStart:NO]; + } // if + } // doPromptYN + + - (void)doPromptYNAN:(const char *)title text:(const char *)text + { + // !!! FIXME + [self doPromptYN:title text:text]; + } // doPromptYN + + - (void)doInsertMedia:(const char *)medianame + { + NSString *title = [NSString stringWithUTF8String:_("Media change")]; + char *fmt = xstrdup(_("Please insert '%0'")); + char *_text = format(fmt, medianame); + NSString *text = [NSString stringWithUTF8String:_text]; + free(_text); + free(fmt); + NSString *okstr = [NSString stringWithUTF8String:_("OK")]; + NSString *cancelstr = [NSString stringWithUTF8String:_("Cancel")]; + const NSInteger rc = NSRunAlertPanel(title, text, okstr, cancelstr, nil); + answerYNAN = ((rc == NSAlertDefaultReturn) ? MOJOGUI_YES : MOJOGUI_NO); + if (needToBreakEventLoop) + { + needToBreakEventLoop = false; + [self fireCustomEvent:CUSTOMEVENT_RUNQUEUE data1:0 data2:0 atStart:NO]; + } // if + } // doInsertMedia + + - (MojoGuiYNAN)getAnswerYNAN + { + return answerYNAN; + } // getAnswerYNAN + + - (IBAction)backClicked:(NSButton *)sender + { + clickValue = CLICK_BACK; + [NSApp stop:self]; + } // backClicked + + - (IBAction)cancelClicked:(NSButton *)sender + { + char *title = xstrdup(_("Cancel installation")); + char *text = xstrdup(_("Are you sure you want to cancel installation?")); + [self doPromptYN:title text:text]; + free(title); + free(text); + if (answerYNAN == MOJOGUI_YES) + { + clickValue = CLICK_CANCEL; + [NSApp stop:self]; + } // if + } // cancelClicked + + - (IBAction)nextClicked:(NSButton *)sender + { + clickValue = CLICK_NEXT; + [NSApp stop:self]; + } // nextClicked + + - (IBAction)browseClicked:(NSButton *)sender + { + NSOpenPanel *panel = [NSOpenPanel openPanel]; + [panel setTitle:[NSString stringWithUTF8String:_("Destination")]]; + [panel setAllowsMultipleSelection:NO]; + [panel setCanCreateDirectories:YES]; + [panel setCanChooseDirectories:YES]; + [panel setCanChooseFiles:NO]; + if ([panel runModal] == NSOKButton) + [DestinationCombo setStringValue:[panel filename]]; + } // browseClicked + + - (IBAction)menuQuit:(NSMenuItem *)sender + { + if (finalPage) // make this work like you clicked "finished". + [self nextClicked:nil]; + else if ([CancelButton isEnabled]) // make this work like you clicked "cancel". + [self cancelClicked:nil]; + } // menuQuit + + - (int)doPage:(NSString *)pageId title:(const char *)_title canBack:(boolean)canBack canFwd:(boolean)canFwd canCancel:(boolean)canCancel canFwdAtStart:(boolean)canFwdAtStart shouldBlock:(BOOL)shouldBlock + { + [TitleLabel setStringValue:[NSString stringWithUTF8String:_title]]; + clickValue = CLICK_NONE; + canForward = canFwd; + [BackButton setEnabled:canBack ? YES : NO]; + [NextButton setEnabled:canFwdAtStart ? YES : NO]; + [CancelButton setEnabled:canCancel ? YES : NO]; + [TabView selectTabViewItemWithIdentifier:pageId]; + if (shouldBlock == NO) + [self fireCustomEvent:CUSTOMEVENT_RUNQUEUE data1:0 data2:0 atStart:NO]; + else + { + [NSApp run]; + assert(clickValue < CLICK_NONE); + } // else + return (int) clickValue; + } // doPage + + - (int)doReadme:(const char *)title text:(NSString *)text canBack:(boolean)canBack canFwd:(boolean)canFwd + { + NSRange range = {0, 1}; // reset scrolling to start of text. + [ReadmeText setString:text]; + [ReadmeText scrollRangeToVisible:range]; + return [self doPage:@"Readme" title:title canBack:canBack canFwd:canFwd canCancel:true canFwdAtStart:canFwd shouldBlock:YES]; + } // doReadme + + - (void)setOptionTreeSensitivity:(MojoGuiSetupOptions *)opts enabled:(boolean)val + { + if (opts != nil) + { + [((id) opts->guiopaque) setEnabled:(val ? YES : NO)]; + [self setOptionTreeSensitivity:opts->next_sibling enabled:val]; + [self setOptionTreeSensitivity:opts->child enabled:(val && opts->value)]; + } // if + } // setOptionTreeSensitivity + + - (MojoGuiSetupOptions *)findMojoOption:(id)obj opt:(MojoGuiSetupOptions *)opt + { + // !!! FIXME: this is not ideal. How can we attach this pointer to + // !!! FIXME: the objects themselves so we don't have to walk a tree + // !!! FIXME: to find it on each action? The objects are controls + // !!! FIXME: and cells (distinct classes), and I don't control the + // !!! FIXME: creation of all of them (radio buttons). + // !!! FIXME: Alternately, let's just hold a hashtable to map + // !!! FIXME: objects to options without walking this tree. + if (opt == nil) + return nil; + + MojoGuiSetupOptions *i; + for (i = opt; i != nil; i = i->next_sibling) + { + if (i->guiopaque == ((void *) obj)) + return i; + MojoGuiSetupOptions *rc = [self findMojoOption:obj opt:i->child]; + if (rc != nil) + return rc; + } // for + + return [self findMojoOption:obj opt:opt->child]; + } // findMojoOption + + - (void)optionToggled:(id)toggle + { + MojoGuiSetupOptions *opts = [self findMojoOption:toggle opt:mojoOpts]; + assert(opts != nil); + // !!! FIXME: cast is wrong. use a selector? + const boolean enabled = ([((NSControl*)toggle) isEnabled] == YES); + opts->value = enabled; + [self setOptionTreeSensitivity:opts->child enabled:enabled]; + } // optionToggled + + - (NSView *)newOptionLevel:(NSView *)box + { + NSRect frame = NSMakeRect(10, 10, 10, 10); + NSView *widget = [[NSView alloc] initWithFrame:frame]; + [box addSubview:widget positioned:NSWindowBelow relativeTo:nil]; + [widget release]; // (box) owns it now. + return widget; + } // newOptionLevel + + // !!! FIXME: most of this mess is cut, pasted, and Cocoaized from the + // !!! FIXME: GTK+ GUI. Can we abstract this in the high level and just + // !!! FIXME: implement the target-specific bits in the plugins? + - (void)buildOptions:(MojoGuiSetupOptions *)opts view:(NSView *)box sensitive:(boolean)sensitive + { + NSRect frame = NSMakeRect(10, 10, 10, 10); + if (opts != nil) + { + if (opts->is_group_parent) + { + MojoGuiSetupOptions *kids = opts->child; + NSView *childbox = nil; + //GtkWidget *alignment = gtk_alignment_new(0.0, 0.5, 0, 0); + //gtk_widget_show(alignment); + + // !!! FIXME: disable line wrap? + // !!! FIXME: resize on superview resize? + NSTextField *widget = [[NSTextField alloc] initWithFrame:frame]; + [widget setStringValue:[NSString stringWithUTF8String:opts->description]]; + [widget setEnabled:(sensitive ? YES : NO)]; + [widget setEditable:NO]; + [widget setSelectable:NO]; + [widget setBordered:NO]; + [widget setBezeled:NO]; + [widget setAlignment:NSLeftTextAlignment]; + [widget sizeToFit]; + if (opts->tooltip != nil) + [widget setToolTip:[NSString stringWithUTF8String:opts->tooltip]]; + [box addSubview:widget positioned:NSWindowBelow relativeTo:nil]; + [widget release]; // (box) owns it now. + //!!! FIXME[box sizeToFit]; + + childbox = [self newOptionLevel:box]; + NSButtonCell *prototype = [[NSButtonCell alloc] init]; + [prototype setButtonType:NSRadioButton]; + [prototype setAllowsMixedState:NO]; + NSMatrix *matrix = [[NSMatrix alloc] initWithFrame:frame mode:NSRadioModeMatrix prototype:(NSCell *)prototype numberOfRows:0 numberOfColumns:1]; + int row = 0; + while (kids) + { + [matrix addRow]; + NSButtonCell *cell = (NSButtonCell *) [matrix cellAtRow:row column:0]; + kids->guiopaque = cell; + [cell setTitle:[NSString stringWithUTF8String:kids->description]]; + [matrix setState:(kids->value ? NSOnState : NSOffState) atRow:row column:0]; + [cell setEnabled:(kids->value ? YES : NO)]; + [cell setTarget:self]; + [cell setAction:@selector(optionToggled:)]; + + if (kids->tooltip != nil) + [matrix setToolTip:[NSString stringWithUTF8String:kids->tooltip] forCell:cell]; + + if (kids->child != nil) + [self buildOptions:kids->child view:[self newOptionLevel:childbox] sensitive:sensitive]; + + kids = kids->next_sibling; + row++; + } // while + + [matrix sizeToCells]; + [childbox addSubview:matrix positioned:NSWindowBelow relativeTo:nil]; + [matrix release]; // childbox owns it now. + //!!! FIXME: [childbox sizeToFit]; + //!!! FIXME: [[childbox superview] sizeToFit]; + } // if + + else + { + NSButton *widget = [[NSButton alloc] initWithFrame:frame]; + opts->guiopaque = widget; + [widget setAllowsMixedState:NO]; + [widget setTitle:[NSString stringWithUTF8String:opts->description]]; + [widget setState:(opts->value ? NSOnState : NSOffState)]; + [widget setEnabled:(sensitive ? YES : NO)]; + [widget setTarget:self]; + [widget setAction:@selector(optionToggled:)]; + [box addSubview:widget positioned:NSWindowBelow relativeTo:nil]; + [widget release]; // (box) owns it now. + //!!!FIXME:[box sizeToFit]; + + if (opts->tooltip != nil) + [widget setToolTip:[NSString stringWithUTF8String:opts->tooltip]]; + + if (opts->child != nil) + [self buildOptions:opts->child view:[self newOptionLevel:box] sensitive:((sensitive) && (opts->value))]; + } // else + + [self buildOptions:opts->next_sibling view:box sensitive:sensitive]; + } // if + + //!!! FIXME:[box sizeToFit]; + } // buildOptions + + - (int)doOptions:(MojoGuiSetupOptions *)opts canBack:(boolean)canBack canFwd:(boolean)canFwd + { + // add all the option widgets to the page's view. + [self buildOptions:opts view:OptionsView sensitive:true]; + + // run the page. + mojoOpts = opts; + int retval = [self doPage:@"Options" title:_("Options") canBack:canBack canFwd:canFwd canCancel:true canFwdAtStart:canFwd shouldBlock:YES]; + mojoOpts = nil; + + // we're done, so nuke everything from the view. + NSArray *array = [[OptionsView subviews] copy]; + NSEnumerator *enumerator = [array objectEnumerator]; + NSView *obj; + while ((obj = (NSView *) [enumerator nextObject]) != nil) + [obj removeFromSuperviewWithoutNeedingDisplay]; + [OptionsView setNeedsDisplay:YES]; + [enumerator release]; + [array release]; + + return retval; + } // doOptions + + - (char *)doDestination:(const char **)recommends recnum:(int)recnum command:(int *)command canBack:(boolean)canBack canFwd:(boolean)canFwd + { + const boolean fwdAtStart = ( (recnum > 0) && (*(recommends[0])) ); + int i; + + [DestinationCombo removeAllItems]; + for (i = 0; i < recnum; i++) + [DestinationCombo addItemWithObjectValue:[NSString stringWithUTF8String:recommends[i]]]; + + if (recnum > 0) + [DestinationCombo setStringValue:[NSString stringWithUTF8String:recommends[0]]]; + else + [DestinationCombo setStringValue:@""]; + + *command = [self doPage:@"Destination" title:_("Destination") canBack:canBack canFwd:canFwd canCancel:true canFwdAtStart:fwdAtStart shouldBlock:YES]; + char *retval = xstrdup([[DestinationCombo stringValue] UTF8String]); + [DestinationCombo removeAllItems]; + [DestinationCombo setStringValue:@""]; + return retval; + } // doDestination + + - (int)doProductKey:(const char *)desc fmt:(const char *)fmt buf:(char *)buf buflen:(const int)buflen canBack:(boolean)canBack canFwd:(boolean)canFwd + { + // !!! FIXME: write me! + return [self doPage:@"ProductKey" title:desc canBack:canBack canFwd:canFwd canCancel:true canFwdAtStart:canFwd shouldBlock:YES]; + } // doProductKey + + - (int)doProgress:(const char *)type component:(const char *)component percent:(int)percent item:(const char *)item canCancel:(boolean)canCancel + { + const BOOL indeterminate = (percent < 0) ? YES : NO; + [ProgressComponentLabel setStringValue:[NSString stringWithUTF8String:component]]; + [ProgressItemLabel setStringValue:[NSString stringWithUTF8String:item]]; + [ProgressBar setIndeterminate:indeterminate]; + if (!indeterminate) + [ProgressBar setDoubleValue:(double)percent]; + return [self doPage:@"Progress" title:type canBack:false canFwd:false canCancel:canCancel canFwdAtStart:false shouldBlock:NO]; + } // doProgress + + - (void)doFinal:(const char *)msg + { + finalPage = true; + [FinalText setStringValue:[NSString stringWithUTF8String:msg]]; + [NextButton setTitle:[NSString stringWithUTF8String:_("Finish")]]; + [self doPage:@"Final" title:_("Finish") canBack:false canFwd:true canCancel:false canFwdAtStart:true shouldBlock:YES]; + } // doFinal +@end // implementation MojoSetupController + +// Override [NSApplication sendEvent], so we can catch custom events. +@interface MojoSetupApplication : NSApplication +{ +} +- (void)sendEvent:(NSEvent *)event; +@end // interface MojoSetupApplication + +@implementation MojoSetupApplication + - (void)sendEvent:(NSEvent *)event + { + if ([event type] == NSApplicationDefined) + [((MojoSetupController *)[self delegate]) doCustomEvent:event]; + [super sendEvent:event]; + } // sendEvent +@end // implementation MojoSetupApplication + + +static uint8 MojoGui_cocoa_priority(boolean istty) +{ + // obviously this is the thing you want on Mac OS X. + return MOJOGUI_PRIORITY_TRY_FIRST; +} // MojoGui_cocoa_priority + + +static boolean MojoGui_cocoa_init(void) +{ + // This lets a stdio app become a GUI app. Otherwise, you won't get + // GUI events from the system and other things will fail to work. + // Putting the app in an application bundle does the same thing. + // TransformProcessType() is a 10.3+ API. SetFrontProcess() is 10.0+. + if (TransformProcessType != NULL) // check it as a weak symbol. + { + ProcessSerialNumber psn = { 0, kCurrentProcess }; + TransformProcessType(&psn, kProcessTransformToForegroundApplication); + SetFrontProcess(&psn); + } // if + + GAutoreleasePool = [[NSAutoreleasePool alloc] init]; + + // !!! FIXME: make sure we have access to the desktop...may be ssh'd in + // !!! FIXME: as another user that doesn't have the Finder loaded or + // !!! FIXME: something. + + // For NSApp to be our subclass, instead of default NSApplication. + [MojoSetupApplication sharedApplication]; + if ([NSBundle loadNibNamed:@"MojoSetup" owner:NSApp] == NO) + return false; + + // Force NSApp initialization stuff. MojoSetupController is set, in the + // .nib, to be NSApp's delegate. Its applicationDidFinishLaunching calls + // [NSApp stop] to break event loop right away so we can continue. + [NSApp run]; + + return true; // always succeeds. +} // MojoGui_cocoa_init + + +static void MojoGui_cocoa_deinit(void) +{ + [GAutoreleasePool release]; + GAutoreleasePool = nil; + // !!! FIXME: destroy nib and NSApp? +} // MojoGui_cocoa_deinit + + +static void MojoGui_cocoa_msgbox(const char *title, const char *text) +{ + NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; + [[NSApp delegate] fireCustomEvent:CUSTOMEVENT_MSGBOX data1:(NSInteger)title data2:(NSInteger)text atStart:YES]; + [pool release]; +} // MojoGui_cocoa_msgbox + + +static boolean MojoGui_cocoa_promptyn(const char *title, const char *text, + boolean defval) +{ + NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; + [[NSApp delegate] fireCustomEvent:CUSTOMEVENT_PROMPTYN data1:(NSInteger)title data2:(NSInteger)text atStart:YES]; + const MojoGuiYNAN ynan = [[NSApp delegate] getAnswerYNAN]; + [pool release]; + assert((ynan == MOJOGUI_YES) || (ynan == MOJOGUI_NO)); + return (ynan == MOJOGUI_YES); +} // MojoGui_cocoa_promptyn + + +static MojoGuiYNAN MojoGui_cocoa_promptynan(const char *title, + const char *text, + boolean defval) +{ + NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; + [[NSApp delegate] fireCustomEvent:CUSTOMEVENT_PROMPTYNAN data1:(NSInteger)title data2:(NSInteger)text atStart:YES]; + const MojoGuiYNAN retval = [[NSApp delegate] getAnswerYNAN]; + [pool release]; + return retval; +} // MojoGui_cocoa_promptynan + + +static boolean MojoGui_cocoa_start(const char *title, + const MojoGuiSplash *splash) +{ +printf("start\n"); + NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; + // !!! FIXME: deal with (splash). + [[NSApp delegate] prepareWidgets:title]; + [pool release]; + return true; +} // MojoGui_cocoa_start + + +static void MojoGui_cocoa_stop(void) +{ +printf("stop\n"); + NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; + [[NSApp delegate] unprepareWidgets]; + [pool release]; +} // MojoGui_cocoa_stop + + +static int MojoGui_cocoa_readme(const char *name, const uint8 *data, + size_t len, boolean can_back, + boolean can_fwd) +{ +printf("readme\n"); + NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; + NSString *str = [[[NSString alloc] initWithBytes:data length:len encoding:NSUTF8StringEncoding] autorelease]; + const int retval = [[NSApp delegate] doReadme:name text:str canBack:can_back canFwd:can_fwd]; + [pool release]; + return retval; +} // MojoGui_cocoa_readme + + +static int MojoGui_cocoa_options(MojoGuiSetupOptions *opts, + boolean can_back, boolean can_fwd) +{ +printf("options\n"); + NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; + const int retval = [[NSApp delegate] doOptions:opts canBack:can_back canFwd:can_fwd]; + [pool release]; + return retval; +} // MojoGui_cocoa_options + + +static char *MojoGui_cocoa_destination(const char **recommends, int recnum, + int *command, boolean can_back, + boolean can_fwd) +{ +printf("destination\n"); + NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; + char *retval = [[NSApp delegate] doDestination:recommends recnum:recnum command:command canBack:can_back canFwd:can_fwd]; + [pool release]; + return retval; +} // MojoGui_cocoa_destination + + +static int MojoGui_cocoa_productkey(const char *desc, const char *fmt, + char *buf, const int buflen, + boolean can_back, boolean can_fwd) +{ +printf("productkey\n"); + NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; + const int retval = [[NSApp delegate] doProductKey:desc fmt:fmt buf:buf buflen:buflen canBack:can_back canFwd:can_fwd]; + [pool release]; + return retval; +} // MojoGui_cocoa_productkey + + +static boolean MojoGui_cocoa_insertmedia(const char *medianame) +{ +printf("insertmedia\n"); + NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; + [[NSApp delegate] fireCustomEvent:CUSTOMEVENT_INSERTMEDIA data1:(NSInteger)medianame data2:0 atStart:YES]; + const MojoGuiYNAN ynan = [[NSApp delegate] getAnswerYNAN]; + assert((ynan == MOJOGUI_YES) || (ynan == MOJOGUI_NO)); + [pool release]; + return (ynan == MOJOGUI_YES); +} // MojoGui_cocoa_insertmedia + + +static void MojoGui_cocoa_progressitem(void) +{ +printf("progressitem\n"); + // no-op in this UI target. +} // MojoGui_cocoa_progressitem + + +static int MojoGui_cocoa_progress(const char *type, const char *component, + int percent, const char *item, + boolean can_cancel) +{ +printf("progress\n"); + NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; + const int retval = [[NSApp delegate] doProgress:type component:component percent:percent item:item canCancel:can_cancel]; + [pool release]; + return retval; +} // MojoGui_cocoa_progress + + +static void MojoGui_cocoa_final(const char *msg) +{ +printf("final\n"); + NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; + [[NSApp delegate] doFinal:msg]; + [pool release]; +} // MojoGui_cocoa_final + +// end of gui_cocoa.m ... + diff --git a/mk/linux/mojosetup/gui_gtkplus2.c b/mk/linux/mojosetup/gui_gtkplus2.c new file mode 100644 index 00000000..fed2f133 --- /dev/null +++ b/mk/linux/mojosetup/gui_gtkplus2.c @@ -0,0 +1,912 @@ +/** + * MojoSetup; a portable, flexible installation application. + * + * Please see the file LICENSE.txt in the source's root directory. + * + * This file written by Ryan C. Gordon. + */ + +// Not only does GTK+ 2.x _look_ better than 1.x, it offers a lot of basic +// functionality, like message boxes, that you'd expect to exist in a GUI +// toolkit. In GTK+v1, you'd have to roll all that on your own! +// +// It's easier to implement in that regard, and produces a smaller DLL, but +// it has a million dependencies, so you might need to use a GTK+v1 plugin, +// too, in case they break backwards compatibility. + +#if !SUPPORT_GUI_GTKPLUS2 +#error Something is wrong in the build system. +#endif + +#define BUILDING_EXTERNAL_PLUGIN 1 +#include "gui.h" + +MOJOGUI_PLUGIN(gtkplus2) + +#if !GUI_STATIC_LINK_GTKPLUS2 +CREATE_MOJOGUI_ENTRY_POINT(gtkplus2) +#endif + +#undef format +#include +#define format entry->format + +typedef enum +{ + PAGE_INTRO, + PAGE_README, + PAGE_OPTIONS, + PAGE_DEST, + PAGE_PRODUCTKEY, + PAGE_PROGRESS, + PAGE_FINAL +} WizardPages; + +static WizardPages currentpage = PAGE_INTRO; +static gboolean canfwd = TRUE; +static GtkWidget *gtkwindow = NULL; +static GtkWidget *pagetitle = NULL; +static GtkWidget *notebook = NULL; +static GtkWidget *readme = NULL; +static GtkWidget *cancel = NULL; +static GtkWidget *back = NULL; +static GtkWidget *next = NULL; +static GtkWidget *finish = NULL; +static GtkWidget *msgbox = NULL; +static GtkWidget *destination = NULL; +static GtkWidget *productkey = NULL; +static GtkWidget *progressbar = NULL; +static GtkWidget *progresslabel = NULL; +static GtkWidget *finallabel = NULL; +static GtkWidget *browse = NULL; +static GtkWidget *splash = NULL; + +static volatile enum +{ + CLICK_BACK=-1, + CLICK_CANCEL, + CLICK_NEXT, + CLICK_NONE +} click_value = CLICK_NONE; + + +static void prepare_wizard(const char *name, WizardPages page, + boolean can_back, boolean can_fwd, + boolean can_cancel, boolean fwd_at_start) +{ + char *markup = g_markup_printf_escaped( + "%s", + name); + + currentpage = page; + canfwd = can_fwd; + + gtk_label_set_markup(GTK_LABEL(pagetitle), markup); + g_free(markup); + + gtk_widget_set_sensitive(back, can_back); + gtk_widget_set_sensitive(next, fwd_at_start); + gtk_widget_set_sensitive(cancel, can_cancel); + gtk_notebook_set_current_page(GTK_NOTEBOOK(notebook), (gint) page); + + assert(click_value == CLICK_NONE); + assert(gtkwindow != NULL); + assert(msgbox == NULL); +} // prepare_wizard + + +static int wait_event(void) +{ + int retval = 0; + + // signals fired under gtk_main_iteration can change click_value. + gtk_main_iteration(); + if (click_value == CLICK_CANCEL) + { + char *title = xstrdup(_("Cancel installation")); + char *text = xstrdup(_("Are you sure you want to cancel installation?")); + if (!MojoGui_gtkplus2_promptyn(title, text, false)) + click_value = CLICK_NONE; + free(title); + free(text); + } // if + + assert(click_value <= CLICK_NONE); + retval = (int) click_value; + click_value = CLICK_NONE; + return retval; +} // wait_event + + +static int pump_events(void) +{ + int retval = (int) CLICK_NONE; + while ( (retval == ((int) CLICK_NONE)) && (gtk_events_pending()) ) + retval = wait_event(); + return retval; +} // pump_events + + +static int run_wizard(const char *name, WizardPages page, + boolean can_back, boolean can_fwd, boolean can_cancel, + boolean fwd_at_start) +{ + int retval = CLICK_NONE; + prepare_wizard(name, page, can_back, can_fwd, can_cancel, fwd_at_start); + while (retval == ((int) CLICK_NONE)) + retval = wait_event(); + + assert(retval < ((int) CLICK_NONE)); + return retval; +} // run_wizard + + +static gboolean signal_delete(GtkWidget *w, GdkEvent *evt, gpointer data) +{ + click_value = CLICK_CANCEL; + return TRUE; /* eat event: default handler destroys window! */ +} // signal_delete + + +static void signal_clicked(GtkButton *_button, gpointer data) +{ + GtkWidget *button = GTK_WIDGET(_button); + if (button == back) + click_value = CLICK_BACK; + else if (button == cancel) + click_value = CLICK_CANCEL; + else if ((button == next) || (button == finish)) + click_value = CLICK_NEXT; + else + { + assert(0 && "Unknown click event."); + } // else +} // signal_clicked + + +static void signal_browse_clicked(GtkButton *_button, gpointer data) +{ + GtkWidget *dialog = gtk_file_chooser_dialog_new ( + _("Destination"), + NULL, + GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER, + GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, + GTK_STOCK_OPEN, GTK_RESPONSE_ACCEPT, + NULL); + + gtk_file_chooser_set_current_folder(GTK_FILE_CHOOSER(dialog), + gtk_combo_box_get_active_text(GTK_COMBO_BOX(destination))); + + if (gtk_dialog_run (GTK_DIALOG (dialog)) == GTK_RESPONSE_ACCEPT) { + gchar *filename; + gchar *utfname; + + filename = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(dialog)); + + utfname = g_filename_to_utf8(filename, -1, NULL, NULL, NULL); + gtk_combo_box_prepend_text(GTK_COMBO_BOX(destination), utfname); + gtk_combo_box_set_active(GTK_COMBO_BOX(destination), 0); + + g_free(utfname); + g_free(filename); + } + + // !!! FIXME: should append the package name to the directory they chose? + // !!! FIXME: This is annoying, they might have created the folder + // !!! FIXME: themselves in the dialog. + // !!! FIXME: Could warn when the target directory already contains files? + + gtk_widget_destroy(dialog); +} // signal_browse_clicked + + +static void signal_dest_changed(GtkComboBox *combo, gpointer user_data) +{ + // Disable the forward button when the destination entry is blank. + if ((currentpage == PAGE_DEST) && (canfwd)) + { + gchar *str = gtk_combo_box_get_active_text(combo); + const gboolean filled_in = ((str != NULL) && (*str != '\0')); + g_free(str); + gtk_widget_set_sensitive(next, filled_in); + } // if +} // signal_dest_changed + + +static void signal_productkey_changed(GtkEditable *edit, gpointer user_data) +{ + // Disable the forward button when the entry is blank. + if ((currentpage == PAGE_PRODUCTKEY) && (canfwd)) + { + const char *fmt = (const char *) user_data; + char *key = (char *) gtk_editable_get_chars(edit, 0, -1); + const gboolean okay = isValidProductKey(fmt, key); + g_free(key); + gtk_widget_set_sensitive(next, okay); + } // if +} // signal_productkey_changed + + +static uint8 MojoGui_gtkplus2_priority(boolean istty) +{ + // gnome-session exports this environment variable since 2002. + if (getenv("GNOME_DESKTOP_SESSION_ID") != NULL) + return MOJOGUI_PRIORITY_TRY_FIRST; + + return MOJOGUI_PRIORITY_TRY_NORMAL; +} // MojoGui_gtkplus2_priority + + +static boolean MojoGui_gtkplus2_init(void) +{ + int tmpargc = 0; + char *args[] = { NULL, NULL }; + char **tmpargv = args; + if (!gtk_init_check(&tmpargc, &tmpargv)) + { + logInfo("gtkplus2: gtk_init_check() failed, use another UI."); + return false; + } // if + return true; +} // MojoGui_gtkplus2_init + + +static void MojoGui_gtkplus2_deinit(void) +{ + // !!! FIXME: GTK+ doesn't have a deinit function...it installs a crappy + // !!! FIXME: atexit() function! +} // MojoGui_gtkplus2_deinit + +/** + * + * @param defbutton The response ID to use when enter is pressed, or 0 + * to leave it up to GTK+. + */ +static gint do_msgbox(const char *title, const char *text, + GtkMessageType mtype, GtkButtonsType btype, + GtkResponseType defbutton, + void (*addButtonCallback)(GtkWidget *_msgbox)) +{ + gint retval = 0; + + // Modal dialog, this will never be called recursively. + assert(msgbox == NULL); + + msgbox = gtk_message_dialog_new(GTK_WINDOW(gtkwindow), GTK_DIALOG_MODAL, + mtype, btype, "%s", title); + gtk_message_dialog_format_secondary_text(GTK_MESSAGE_DIALOG(msgbox), + "%s", text); + + if (defbutton) + gtk_dialog_set_default_response(GTK_DIALOG(msgbox), defbutton); + + if (addButtonCallback != NULL) + addButtonCallback(msgbox); + + retval = gtk_dialog_run(GTK_DIALOG(msgbox)); + gtk_widget_destroy(msgbox); + msgbox = NULL; + + return retval; +} // do_msgbox + + +static void MojoGui_gtkplus2_msgbox(const char *title, const char *text) +{ + do_msgbox(title, text, GTK_MESSAGE_INFO, GTK_BUTTONS_CLOSE, 0, NULL); +} // MojoGui_gtkplus2_msgbox + + +static boolean MojoGui_gtkplus2_promptyn(const char *title, const char *text, + boolean defval) +{ + gint rc = do_msgbox(title, text, GTK_MESSAGE_QUESTION, + GTK_BUTTONS_YES_NO, + defval ? GTK_RESPONSE_YES : GTK_RESPONSE_NO, + NULL); + + return (rc == GTK_RESPONSE_YES); +} // MojoGui_gtkplus2_promptyn + + +static void promptynanButtonCallback(GtkWidget *_msgbox) +{ + char *always = xstrdup(_("_Always")); + char *never = xstrdup(_("N_ever")); + gtk_dialog_add_buttons(GTK_DIALOG(_msgbox), + GTK_STOCK_YES, GTK_RESPONSE_YES, + GTK_STOCK_NO, GTK_RESPONSE_NO, + always, 1, + never, 0, + NULL); + + free(always); + free(never); +} // promptynanButtonCallback + + +static MojoGuiYNAN MojoGui_gtkplus2_promptynan(const char *title, + const char *text, + boolean defval) +{ + const gint rc = do_msgbox(title, text, GTK_MESSAGE_QUESTION, + GTK_BUTTONS_NONE, + defval ? GTK_RESPONSE_YES : GTK_RESPONSE_NO, + promptynanButtonCallback); + switch (rc) + { + case GTK_RESPONSE_YES: return MOJOGUI_YES; + case GTK_RESPONSE_NO: return MOJOGUI_NO; + case 1: return MOJOGUI_ALWAYS; + case 0: return MOJOGUI_NEVER; + } // switch + + assert(false && "BUG: unhandled case in switch statement"); + return MOJOGUI_NO; // just in case. +} // MojoGui_gtkplus2_promptynan + + +static GtkWidget *create_button(GtkWidget *box, const char *iconname, + const char *text, + void (*signal_callback) + (GtkButton *button, gpointer data)) +{ + GtkWidget *button = gtk_button_new_with_mnemonic(text); + GtkWidget *image = gtk_image_new_from_stock(iconname, GTK_ICON_SIZE_BUTTON); + gtk_button_set_image (GTK_BUTTON(button), image); + gtk_widget_show(button); + gtk_box_pack_start(GTK_BOX(box), button, FALSE, FALSE, 6); + gtk_signal_connect(GTK_OBJECT(button), "clicked", + GTK_SIGNAL_FUNC(signal_callback), NULL); + return button; +} // create_button + + +static void free_splash(guchar *pixels, gpointer data) +{ + free(pixels); +} // free_splash + + +static GtkWidget *build_splash(const MojoGuiSplash *splash) +{ + GtkWidget *retval = NULL; + GdkPixbuf *pixbuf = NULL; + guchar *rgba = NULL; + const uint32 splashlen = splash->w * splash->h * 4; + + if (splash->position == MOJOGUI_SPLASH_NONE) + return NULL; + + if ((splash->rgba == NULL) || (splashlen == 0)) + return NULL; + + rgba = (guchar *) xmalloc(splashlen); + memcpy(rgba, splash->rgba, splashlen); + pixbuf = gdk_pixbuf_new_from_data(rgba, GDK_COLORSPACE_RGB, TRUE, 8, + splash->w, splash->h, splash->w * 4, + free_splash, NULL); + if (pixbuf == NULL) + free(rgba); + else + { + retval = gtk_image_new_from_pixbuf(pixbuf); + g_object_unref(pixbuf); // retval adds a ref to pixbuf, so lose our's. + if (retval != NULL) + gtk_widget_show(retval); + } // else + + return retval; +} // build_splash + + +static GtkWidget *create_gtkwindow(const char *title, + const MojoGuiSplash *_splash) +{ + GtkWidget *splashbox = NULL; + GtkWidget *window; + GtkWidget *widget; + GtkWidget *box; + GtkWidget *alignment; + GtkWidget *hbox; + + currentpage = PAGE_INTRO; + canfwd = TRUE; + + window = gtk_window_new(GTK_WINDOW_TOPLEVEL); + gtk_window_set_resizable(GTK_WINDOW(window), FALSE); + gtk_window_set_title(GTK_WINDOW(window), title); + gtk_container_set_border_width(GTK_CONTAINER(window), 8); + + GdkPixbuf *icon = gtk_icon_theme_load_icon (gtk_icon_theme_get_default (), + "system-software-installer", + 48, 0, NULL); + if (icon) + gtk_window_set_icon(GTK_WINDOW(window), icon); + + assert(splash == NULL); + splash = build_splash(_splash); + if (splash != NULL) + { + // !!! FIXME: MOJOGUI_SPLASH_BACKGROUND? + const MojoGuiSplashPos pos = _splash->position; + if ((pos == MOJOGUI_SPLASH_LEFT) || (pos == MOJOGUI_SPLASH_RIGHT)) + { + splashbox = gtk_hbox_new(FALSE, 6); + gtk_widget_show(splashbox); + gtk_container_add(GTK_CONTAINER(window), splashbox); + if (pos == MOJOGUI_SPLASH_LEFT) + gtk_box_pack_start(GTK_BOX(splashbox), splash, FALSE, FALSE, 6); + else + gtk_box_pack_end(GTK_BOX(splashbox), splash, FALSE, FALSE, 6); + } // if + + else if ((pos == MOJOGUI_SPLASH_TOP) || (pos == MOJOGUI_SPLASH_BOTTOM)) + { + splashbox = gtk_vbox_new(FALSE, 6); + gtk_widget_show(splashbox); + gtk_container_add(GTK_CONTAINER(window), splashbox); + if (pos == MOJOGUI_SPLASH_TOP) + gtk_box_pack_start(GTK_BOX(splashbox), splash, FALSE, FALSE, 6); + else + gtk_box_pack_end(GTK_BOX(splashbox), splash, FALSE, FALSE, 6); + } // else if + } // if + + if (splashbox == NULL) // no splash, use the window for the top container. + splashbox = window; + + box = gtk_vbox_new(FALSE, 6); + gtk_widget_show(box); + gtk_container_add(GTK_CONTAINER(splashbox), box); + + pagetitle = gtk_label_new(""); + gtk_widget_show(pagetitle); + gtk_box_pack_start(GTK_BOX(box), pagetitle, FALSE, TRUE, 16); + + notebook = gtk_notebook_new(); + gtk_widget_show(notebook); + gtk_container_set_border_width(GTK_CONTAINER(notebook), 0); + gtk_box_pack_start(GTK_BOX(box), notebook, TRUE, TRUE, 0); + gtk_notebook_set_show_tabs(GTK_NOTEBOOK(notebook), FALSE); + gtk_notebook_set_show_border(GTK_NOTEBOOK(notebook), FALSE); + gtk_widget_set_size_request(notebook, + (gint) (((float) gdk_screen_width()) * 0.3), + (gint) (((float) gdk_screen_height()) * 0.3)); + + widget = gtk_hbutton_box_new(); + gtk_widget_show(widget); + gtk_box_pack_start(GTK_BOX(box), widget, FALSE, FALSE, 0); + gtk_button_box_set_layout(GTK_BUTTON_BOX (widget), GTK_BUTTONBOX_END); + gtk_button_box_set_child_ipadding(GTK_BUTTON_BOX (widget), 6, 0); + gtk_button_box_set_spacing(GTK_BUTTON_BOX (widget), 6); + + box = widget; + cancel = create_button(box, "gtk-cancel", _("Cancel"), signal_clicked); + back = create_button(box, "gtk-go-back", _("Back"), signal_clicked); + next = create_button(box, "gtk-go-forward", _("Next"), signal_clicked); + finish = create_button(box, "gtk-goto-last", _("Finish"), signal_clicked); + gtk_widget_hide(finish); + + // !!! FIXME: intro page. + widget = gtk_vbox_new(FALSE, 0); + gtk_widget_show(widget); + gtk_container_add(GTK_CONTAINER(notebook), widget); + + // README/EULA page. + widget = gtk_scrolled_window_new(NULL, NULL); + gtk_scrolled_window_set_policy( + GTK_SCROLLED_WINDOW(widget), + GTK_POLICY_AUTOMATIC, GTK_POLICY_ALWAYS); + gtk_scrolled_window_set_shadow_type( + GTK_SCROLLED_WINDOW(widget), + GTK_SHADOW_IN); + gtk_widget_show(widget); + gtk_container_add(GTK_CONTAINER(notebook), widget); + + readme = gtk_text_view_new(); + gtk_widget_show(readme); + gtk_container_add(GTK_CONTAINER(widget), readme); + gtk_text_view_set_editable(GTK_TEXT_VIEW(readme), FALSE); + gtk_text_view_set_wrap_mode(GTK_TEXT_VIEW(readme), GTK_WRAP_NONE); + gtk_text_view_set_cursor_visible(GTK_TEXT_VIEW(readme), FALSE); + gtk_text_view_set_left_margin(GTK_TEXT_VIEW(readme), 4); + gtk_text_view_set_right_margin(GTK_TEXT_VIEW(readme), 4); + + // !!! FIXME: options page. + box = gtk_vbox_new(FALSE, 0); + gtk_widget_show(box); + gtk_container_add(GTK_CONTAINER(notebook), box); + + // Destination page + box = gtk_vbox_new(FALSE, 0); + gtk_widget_show(box); + + hbox = gtk_hbox_new (FALSE, 6); + widget = gtk_label_new(_("Folder:")); + gtk_widget_show(widget); + gtk_box_pack_start(GTK_BOX(hbox), widget, FALSE, TRUE, 0); + gtk_label_set_justify(GTK_LABEL(widget), GTK_JUSTIFY_CENTER); + gtk_label_set_line_wrap(GTK_LABEL(widget), FALSE); + alignment = gtk_alignment_new(0.5, 0.5, 1, 0); + destination = gtk_combo_box_entry_new_text(); + gtk_signal_connect(GTK_OBJECT(destination), "changed", + GTK_SIGNAL_FUNC(signal_dest_changed), NULL); + gtk_container_add(GTK_CONTAINER(alignment), destination); + gtk_box_pack_start(GTK_BOX(hbox), alignment, TRUE, TRUE, 0); + browse = create_button(hbox, "gtk-open", + _("B_rowse..."), signal_browse_clicked); + gtk_widget_show_all (hbox); + gtk_box_pack_start(GTK_BOX(box), hbox, FALSE, FALSE, 0); + gtk_container_add(GTK_CONTAINER(notebook), box); + + // Product key page + box = gtk_vbox_new(FALSE, 0); + gtk_widget_show(box); + + widget = gtk_label_new(_("Please enter your product key")); + gtk_label_set_justify(GTK_LABEL(widget), GTK_JUSTIFY_CENTER); + gtk_label_set_line_wrap(GTK_LABEL(widget), TRUE); + gtk_widget_show(widget); + gtk_box_pack_start(GTK_BOX(box), widget, FALSE, TRUE, 0); + + hbox = gtk_hbox_new(FALSE, 0); + gtk_widget_show(hbox); + productkey = gtk_entry_new(); + gtk_entry_set_editable(GTK_ENTRY(productkey), TRUE); + gtk_entry_set_visibility(GTK_ENTRY(productkey), TRUE); + gtk_widget_show(productkey); + gtk_box_pack_start(GTK_BOX(hbox), productkey, TRUE, FALSE, 0); + gtk_box_pack_start(GTK_BOX(box), hbox, FALSE, TRUE, 0); + + gtk_container_add(GTK_CONTAINER(notebook), box); + + // Progress page + box = gtk_vbox_new(FALSE, 6); + gtk_widget_show(box); + alignment = gtk_alignment_new(0.5, 0.5, 1, 0); + gtk_widget_show(alignment); + progressbar = gtk_progress_bar_new(); + gtk_widget_show(progressbar); + gtk_container_add(GTK_CONTAINER(alignment), progressbar); + gtk_box_pack_start(GTK_BOX(box), alignment, FALSE, TRUE, 0); + progresslabel = gtk_label_new(""); + gtk_widget_show(progresslabel); + gtk_box_pack_start(GTK_BOX(box), progresslabel, FALSE, TRUE, 0); + gtk_label_set_justify(GTK_LABEL(progresslabel), GTK_JUSTIFY_LEFT); + gtk_label_set_line_wrap(GTK_LABEL(progresslabel), FALSE); + gtk_container_add(GTK_CONTAINER(notebook), box); + + // !!! FIXME: final page. + widget = gtk_vbox_new(FALSE, 0); + gtk_widget_show(widget); + gtk_container_add(GTK_CONTAINER(notebook), widget); + finallabel = gtk_label_new(""); + gtk_widget_show(finallabel); + gtk_box_pack_start(GTK_BOX(widget), finallabel, FALSE, TRUE, 0); + gtk_label_set_justify(GTK_LABEL(finallabel), GTK_JUSTIFY_LEFT); + gtk_label_set_line_wrap(GTK_LABEL(finallabel), TRUE); + + gtk_signal_connect(GTK_OBJECT(window), "delete-event", + GTK_SIGNAL_FUNC(signal_delete), NULL); + + gtk_window_set_position(GTK_WINDOW(window), GTK_WIN_POS_CENTER); + gtk_widget_show(window); + return window; +} // create_gtkwindow + + +static boolean MojoGui_gtkplus2_start(const char *title, + const MojoGuiSplash *splash) +{ + gtkwindow = create_gtkwindow(title, splash); + return (gtkwindow != NULL); +} // MojoGui_gtkplus2_start + + +static void MojoGui_gtkplus2_stop(void) +{ + assert(msgbox == NULL); + if (gtkwindow != NULL) + gtk_widget_destroy(gtkwindow); + + gtkwindow = NULL; + pagetitle = NULL; + finallabel = NULL; + progresslabel = NULL; + progressbar = NULL; + destination = NULL; + productkey = NULL; + notebook = NULL; + readme = NULL; + cancel = NULL; + back = NULL; + next = NULL; + finish = NULL; + splash = NULL; +} // MojoGui_gtkplus2_stop + + +static int MojoGui_gtkplus2_readme(const char *name, const uint8 *data, + size_t datalen, boolean can_back, + boolean can_fwd) +{ + GtkTextBuffer *textbuf = gtk_text_view_get_buffer(GTK_TEXT_VIEW(readme)); + gtk_text_buffer_set_text(textbuf, (const gchar *) data, datalen); + return run_wizard(name, PAGE_README, can_back, can_fwd, true, can_fwd); +} // MojoGui_gtkplus2_readme + + +static void set_option_tree_sensitivity(MojoGuiSetupOptions *opts, boolean val) +{ + if (opts != NULL) + { + gtk_widget_set_sensitive((GtkWidget *) opts->guiopaque, val); + set_option_tree_sensitivity(opts->next_sibling, val); + set_option_tree_sensitivity(opts->child, val && opts->value); + } // if +} // set_option_tree_sensitivity + + +static void signal_option_toggled(GtkToggleButton *toggle, gpointer data) +{ + MojoGuiSetupOptions *opts = (MojoGuiSetupOptions *) data; + const boolean enabled = gtk_toggle_button_get_active(toggle); + opts->value = enabled; + set_option_tree_sensitivity(opts->child, enabled); +} // signal_option_toggled + + +static GtkWidget *new_option_level(GtkWidget *box) +{ + GtkWidget *alignment = gtk_alignment_new(0.0, 0.5, 0, 0); + GtkWidget *retval = gtk_vbox_new(FALSE, 0); + gtk_alignment_set_padding(GTK_ALIGNMENT(alignment), 0, 0, 15, 0); + gtk_widget_show(alignment); + gtk_widget_show(retval); + gtk_container_add(GTK_CONTAINER(alignment), retval); + gtk_box_pack_start(GTK_BOX(box), alignment, TRUE, TRUE, 0); + return retval; +} // new_option_level + + +// use this to generate a tooltip only as needed. +static GtkTooltips *get_tip(GtkTooltips **_tip) +{ + if (*_tip == NULL) + { + GtkTooltips *tip = gtk_tooltips_new(); + gtk_tooltips_enable(tip); + *_tip = tip; + } // if + + return *_tip; +} // get_tip + + +static void build_options(MojoGuiSetupOptions *opts, GtkWidget *box, + gboolean sensitive) +{ + if (opts != NULL) + { + GtkTooltips *tip = NULL; + GtkWidget *widget = NULL; + + if (opts->is_group_parent) + { + MojoGuiSetupOptions *kids = opts->child; + GtkWidget *childbox = NULL; + GtkWidget *alignment = gtk_alignment_new(0.0, 0.5, 0, 0); + gtk_widget_show(alignment); + widget = gtk_label_new(opts->description); + opts->guiopaque = widget; + gtk_widget_set_sensitive(widget, sensitive); + gtk_widget_show(widget); + gtk_label_set_justify(GTK_LABEL(widget), GTK_JUSTIFY_LEFT); + gtk_label_set_line_wrap(GTK_LABEL(widget), FALSE); + gtk_container_add(GTK_CONTAINER(alignment), widget); + gtk_box_pack_start(GTK_BOX(box), alignment, FALSE, TRUE, 0); + + if (opts->tooltip != NULL) + gtk_tooltips_set_tip(get_tip(&tip), widget, opts->tooltip, 0); + + widget = NULL; + childbox = new_option_level(box); + while (kids) + { + widget = gtk_radio_button_new_with_label_from_widget( + GTK_RADIO_BUTTON(widget), + kids->description); + kids->guiopaque = widget; + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widget), + kids->value); + gtk_widget_set_sensitive(widget, sensitive); + gtk_widget_show(widget); + gtk_box_pack_start(GTK_BOX(childbox), widget, FALSE, TRUE, 0); + gtk_signal_connect(GTK_OBJECT(widget), "toggled", + GTK_SIGNAL_FUNC(signal_option_toggled), kids); + + if (kids->tooltip != NULL) + gtk_tooltips_set_tip(get_tip(&tip),widget,kids->tooltip,0); + + if (kids->child != NULL) + { + build_options(kids->child, new_option_level(childbox), + sensitive); + } // if + kids = kids->next_sibling; + } // while + } // if + + else + { + widget = gtk_check_button_new_with_label(opts->description); + opts->guiopaque = widget; + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widget), + opts->value); + gtk_widget_set_sensitive(widget, sensitive); + gtk_widget_show(widget); + gtk_box_pack_start(GTK_BOX(box), widget, FALSE, TRUE, 0); + gtk_signal_connect(GTK_OBJECT(widget), "toggled", + GTK_SIGNAL_FUNC(signal_option_toggled), opts); + + if (opts->tooltip != NULL) + gtk_tooltips_set_tip(get_tip(&tip), widget, opts->tooltip, 0); + + if (opts->child != NULL) + { + build_options(opts->child, new_option_level(box), + ((sensitive) && (opts->value)) ); + } // if + } // else + + build_options(opts->next_sibling, box, sensitive); + } // if +} // build_options + + +static int MojoGui_gtkplus2_options(MojoGuiSetupOptions *opts, + boolean can_back, boolean can_fwd) +{ + int retval; + GtkWidget *box; + GtkWidget *page; // this is a vbox. + + page = gtk_notebook_get_nth_page(GTK_NOTEBOOK(notebook), PAGE_OPTIONS); + box = gtk_vbox_new(FALSE, 0); + gtk_widget_show(box); + gtk_box_pack_start(GTK_BOX(page), box, FALSE, FALSE, 0); + + build_options(opts, box, TRUE); + retval = run_wizard(_("Options"), PAGE_OPTIONS, + can_back, can_fwd, true, can_fwd); + gtk_widget_destroy(box); + return retval; +} // MojoGui_gtkplus2_options + + +static char *MojoGui_gtkplus2_destination(const char **recommends, int recnum, + int *command, boolean can_back, + boolean can_fwd) +{ + GtkComboBox *combo = GTK_COMBO_BOX(destination); + const boolean fwd_at_start = ( (recnum > 0) && (*(recommends[0])) ); + gchar *str = NULL; + char *retval = NULL; + int i; + + for (i = 0; i < recnum; i++) + gtk_combo_box_append_text(combo, recommends[i]); + gtk_combo_box_set_active (combo, 0); + + *command = run_wizard(_("Destination"), PAGE_DEST, + can_back, can_fwd, true, fwd_at_start); + + str = gtk_combo_box_get_active_text(combo); + + // shouldn't ever be empty ("next" should be disabled in that case). + assert( (*command <= 0) || ((str != NULL) && (*str != '\0')) ); + + retval = xstrdup(str); + g_free(str); + + for (i = recnum-1; i >= 0; i--) + gtk_combo_box_remove_text(combo, i); + + return retval; +} // MojoGui_gtkplus2_destination + + +static int MojoGui_gtkplus2_productkey(const char *desc, const char *fmt, + char *buf, const int buflen, + boolean can_back, boolean can_fwd) +{ + gchar *str = NULL; + int retval = 0; + const boolean fwd_at_start = isValidProductKey(fmt, buf); + + gtk_entry_set_max_length(GTK_ENTRY(productkey), buflen - 1); + gtk_entry_set_width_chars(GTK_ENTRY(productkey), buflen - 1); + gtk_entry_set_text(GTK_ENTRY(productkey), (gchar *) buf); + + const guint connid = gtk_signal_connect(GTK_OBJECT(productkey), "changed", + GTK_SIGNAL_FUNC(signal_productkey_changed), + (void *) fmt); + retval = run_wizard(desc, PAGE_PRODUCTKEY, + can_back, can_fwd, true, fwd_at_start); + gtk_signal_disconnect(GTK_OBJECT(productkey), connid); + + str = gtk_editable_get_chars(GTK_EDITABLE(productkey), 0, -1); + // should never be invalid ("next" should be disabled in that case). + assert( (retval <= 0) || ((str) && (isValidProductKey(fmt, str))) ); + assert(strlen(str) < buflen); + strcpy(buf, (char *) str); + g_free(str); + gtk_entry_set_text(GTK_ENTRY(productkey), ""); + + return retval; +} // MojoGui_gtkplus2_productkey + + +static boolean MojoGui_gtkplus2_insertmedia(const char *medianame) +{ + gint rc = 0; + // !!! FIXME: Use stock GTK icon for "media"? + // !!! FIXME: better text. + const char *title = xstrdup(_("Media change")); + // !!! FIXME: better text. + const char *fmt = xstrdup(_("Please insert '%0'")); + const char *text = format(fmt, medianame); + rc = do_msgbox(title, text, GTK_MESSAGE_WARNING, + GTK_BUTTONS_OK_CANCEL, GTK_RESPONSE_OK, NULL); + free((void *) text); + free((void *) fmt); + free((void *) title); + return (rc == GTK_RESPONSE_OK); +} // MojoGui_gtkplus2_insertmedia + + +static void MojoGui_gtkplus2_progressitem(void) +{ + // no-op in this UI target. +} // MojoGui_gtkplus2_progressitem + + +static boolean MojoGui_gtkplus2_progress(const char *type, const char *component, + int percent, const char *item, + boolean can_cancel) +{ + static uint32 lastTicks = 0; + const uint32 ticks = ticks(); + int rc; + + if ((ticks - lastTicks) > 200) // just not to spam this... + { + GtkProgressBar *progress = GTK_PROGRESS_BAR(progressbar); + if (percent < 0) + gtk_progress_bar_pulse(progress); + else + gtk_progress_bar_set_fraction(progress, ((gdouble) percent) / 100.0); + + gtk_progress_bar_set_text(progress, component); + gtk_label_set_text(GTK_LABEL(progresslabel), item); + lastTicks = ticks; + } // if + + prepare_wizard(type, PAGE_PROGRESS, false, false, can_cancel, false); + rc = pump_events(); + assert( (rc == ((int) CLICK_CANCEL)) || (rc == ((int) CLICK_NONE)) ); + return (rc != CLICK_CANCEL); +} // MojoGui_gtkplus2_progress + + +static void MojoGui_gtkplus2_final(const char *msg) +{ + gtk_widget_hide(next); + gtk_widget_show(finish); + gtk_label_set_text(GTK_LABEL(finallabel), msg); + run_wizard(_("Finish"), PAGE_FINAL, false, true, false, true); +} // MojoGui_gtkplus2_final + +// end of gui_gtkplus2.c ... + diff --git a/mk/linux/mojosetup/gui_ncurses.c b/mk/linux/mojosetup/gui_ncurses.c new file mode 100644 index 00000000..733f0b26 --- /dev/null +++ b/mk/linux/mojosetup/gui_ncurses.c @@ -0,0 +1,1487 @@ +/** + * MojoSetup; a portable, flexible installation application. + * + * Please see the file LICENSE.txt in the source's root directory. + * + * This file written by Ryan C. Gordon. + */ + +#if !SUPPORT_GUI_NCURSES +#error Something is wrong in the build system. +#endif + +#define BUILDING_EXTERNAL_PLUGIN 1 +#include "gui.h" + +MOJOGUI_PLUGIN(ncurses) + +#if !GUI_STATIC_LINK_NCURSES +CREATE_MOJOGUI_ENTRY_POINT(ncurses) +#endif + +#include +#include +// CMake searches for a whole bunch of different possible curses includes +#if defined(HAVE_NCURSESW_NCURSES_H) +#include +#elif defined(HAVE_NCURSESW_CURSES_H) +#include +#elif defined(HAVE_NCURSESW_H) +#include +#else +#error ncurses gui enabled, but no known header file found +#endif + +#include + +// This was built to look roughly like dialog(1), but it's not nearly as +// robust. Also, I didn't use any of dialog's code, as it is GPL/LGPL, +// depending on what version you start with. There _is_ a libdialog, but +// it's never something installed on any systems, and I can't link it +// statically due to the license. +// +// ncurses is almost always installed as a shared library, though, so we'll +// just talk to it directly. Fortunately we don't need much of what dialog(1) +// offers, so rolling our own isn't too painful (well, compared to massive +// head trauma, I guess). +// +// Pradeep Padala's ncurses HOWTO was very helpful in teaching me curses +// quickly: http://tldp.org/HOWTO/NCURSES-Programming-HOWTO/index.html + +// !!! FIXME: this should all be UTF-8 and Unicode clean with ncursesw, but +// !!! FIXME: it relies on the terminal accepting UTF-8 output (we don't +// !!! FIXME: attempt to convert) and assumes all characters fit in one +// !!! FIXME: column, which they don't necessarily for some Asian languages, +// !!! FIXME: etc. I'm not sure how to properly figure out column width, if +// !!! FIXME: it's possible at all, but for that, you should probably +// !!! FIXME: go to a proper GUI plugin like GTK+ anyhow. + +typedef enum +{ + MOJOCOLOR_BACKGROUND=1, + MOJOCOLOR_BORDERTOP, + MOJOCOLOR_BORDERBOTTOM, + MOJOCOLOR_BORDERTITLE, + MOJOCOLOR_TEXT, + MOJOCOLOR_TEXTENTRY, + MOJOCOLOR_BUTTONHOVER, + MOJOCOLOR_BUTTONNORMAL, + MOJOCOLOR_BUTTONBORDER, + MOJOCOLOR_TODO, + MOJOCOLOR_DONE, +} MojoColor; + + +typedef struct +{ + WINDOW *mainwin; + WINDOW *textwin; + WINDOW **buttons; + char *title; + char *text; + char **textlines; + char **buttontext; + int buttoncount; + int textlinecount; + int hoverover; + int textpos; + boolean hidecursor; + boolean ndelay; + int cursval; +} MojoBox; + + +static char *lastProgressType = NULL; +static char *lastComponent = NULL; +static boolean lastCanCancel = false; +static uint32 percentTicks = 0; +static char *title = NULL; +static MojoBox *progressBox = NULL; + + +static void drawButton(MojoBox *mojobox, int button) +{ + const boolean hover = (mojobox->hoverover == button); + int borderattr = 0; + WINDOW *win = mojobox->buttons[button]; + const char *str = mojobox->buttontext[button]; + int w, h; + getmaxyx(win, h, w); + + if (!hover) + wbkgdset(win, COLOR_PAIR(MOJOCOLOR_BUTTONNORMAL)); + else + { + borderattr = COLOR_PAIR(MOJOCOLOR_BUTTONBORDER) | A_BOLD; + wbkgdset(win, COLOR_PAIR(MOJOCOLOR_BUTTONHOVER)); + } // else + + werase(win); + wmove(win, 0, 0); + waddch(win, borderattr | '<'); + wmove(win, 0, w-1); + waddch(win, borderattr | '>'); + wmove(win, 0, 2); + + if (!hover) + waddstr(win, str); + else + { + wattron(win, COLOR_PAIR(MOJOCOLOR_BUTTONHOVER) | A_BOLD); + waddstr(win, str); + wattroff(win, COLOR_PAIR(MOJOCOLOR_BUTTONHOVER) | A_BOLD); + } // else +} // drawButton + + +static void drawText(MojoBox *mojobox) +{ + int i; + const int tcount = mojobox->textlinecount; + int pos = mojobox->textpos; + int w, h; + WINDOW *win = mojobox->textwin; + getmaxyx(win, h, w); + + werase(mojobox->textwin); + for (i = 0; (pos < tcount) && (i < h); i++, pos++) + mvwaddstr(win, i, 0, mojobox->textlines[pos]); + + if (tcount > h) + { + const int pct = (int) ((((double) pos) / ((double) tcount)) * 100.0); + win = mojobox->mainwin; + wattron(win, COLOR_PAIR(MOJOCOLOR_BORDERTITLE) | A_BOLD); + mvwprintw(win, h+1, w-5, "(%3d%%)", pct); + wattroff(win, COLOR_PAIR(MOJOCOLOR_BORDERTITLE) | A_BOLD); + } // if +} // drawText + + +static void drawBackground(WINDOW *win) +{ + wclear(win); + if (title != NULL) + { + int w, h; + getmaxyx(win, h, w); + wattron(win, COLOR_PAIR(MOJOCOLOR_BACKGROUND) | A_BOLD); + mvwaddstr(win, 0, 0, title); + mvwhline(win, 1, 1, ACS_HLINE, w-2); + wattroff(win, COLOR_PAIR(MOJOCOLOR_BACKGROUND) | A_BOLD); + } // if +} // drawBackground + + +static void confirmTerminalSize(void) +{ + int scrw = 0; + int scrh = 0; + char *msg = NULL; + int len = 0; + int x = 0; + int y = 0; + + while (1) // loop until the window meets a minimum dimension requirement. + { + getmaxyx(stdscr, scrh, scrw); + scrh--; // -1 to save the title at the top of the screen... + + if (scrw < 30) // too thin + msg = xstrdup(_("[Make the window wider!]")); + else if (scrh < 10) // too short + msg = xstrdup(_("[Make the window taller!]")); + else + break; // we're good, get out. + + len = utf8len(msg); + y = scrh / 2; + x = ((scrw - len) / 2); + + if (y < 0) y = 0; + if (x < 0) x = 0; + + wclear(stdscr); + wmove(stdscr, y, x); + wrefresh(stdscr); + wmove(stdscr, y, x); + wattron(stdscr, COLOR_PAIR(MOJOCOLOR_BACKGROUND) | A_BOLD); + waddstr(stdscr, msg); + wattroff(stdscr, COLOR_PAIR(MOJOCOLOR_BACKGROUND) | A_BOLD); + nodelay(stdscr, 0); + wrefresh(stdscr); + free(msg); + + while (wgetch(stdscr) != KEY_RESIZE) { /* no-op. */ } + } // while +} // confirmTerminalSize + + +static MojoBox *makeBox(const char *title, const char *text, + char **buttons, int bcount, + boolean ndelay, boolean hidecursor) +{ + MojoBox *retval = NULL; + WINDOW *win = NULL; + int scrw, scrh; + int len = 0; + int buttonsw = 0; + int x = 0; + int y = 0; + int h = 0; + int w = 0; + int texth = 0; + int i; + + confirmTerminalSize(); // blocks until window is large enough to continue. + + getmaxyx(stdscr, scrh, scrw); + scrh--; // -1 to save the title at the top of the screen... + + retval = (MojoBox *) xmalloc(sizeof (MojoBox)); + retval->hidecursor = hidecursor; + retval->ndelay = ndelay; + retval->cursval = ((hidecursor) ? curs_set(0) : ERR); + retval->title = xstrdup(title); + retval->text = xstrdup(text); + retval->buttoncount = bcount; + retval->buttons = (WINDOW **) xmalloc(sizeof (WINDOW*) * bcount); + retval->buttontext = (char **) xmalloc(sizeof (char*) * bcount); + + for (i = 0; i < bcount; i++) + retval->buttontext[i] = xstrdup(buttons[i]); + + retval->textlines = splitText(retval->text, scrw-4, + &retval->textlinecount, &w); + + len = utf8len(title); + if (len > scrw-4) + { + len = scrw-4; + strcpy(&retval->title[len-3], "..."); // !!! FIXME: not Unicode safe! + } // if + + if (len > w) + w = len; + + if (bcount > 0) + { + for (i = 0; i < bcount; i++) + buttonsw += utf8len(buttons[i]) + 5; // '<', ' ', ' ', '>', ' ' + if (buttonsw > w) + w = buttonsw; + // !!! FIXME: what if these overflow the screen? + } // if + + w += 4; + h = retval->textlinecount + 2; + if (bcount > 0) + h += 2; + + if (h > scrh-2) + h = scrh-2; + + x = (scrw - w) / 2; + y = ((scrh - h) / 2) + 1; + + // can't have negative coordinates, so in case we survived the call to + // confirmTerminalSize() but still need more, just draw as much as + // possible from the top/left to fill the window. + if (x < 0) x = 0; + if (y < 0) y = 0; + + win = retval->mainwin = newwin(h, w, y, x); + keypad(win, TRUE); + nodelay(win, ndelay); + wbkgdset(win, COLOR_PAIR(MOJOCOLOR_TEXT)); + wclear(win); + waddch(win, ACS_ULCORNER | A_BOLD | COLOR_PAIR(MOJOCOLOR_BORDERTOP)); + whline(win, ACS_HLINE | A_BOLD | COLOR_PAIR(MOJOCOLOR_BORDERTOP), w-2); + wmove(win, 0, w-1); + waddch(win, ACS_URCORNER | COLOR_PAIR(MOJOCOLOR_BORDERBOTTOM)); + wmove(win, 1, 0); + wvline(win, ACS_VLINE | A_BOLD | COLOR_PAIR(MOJOCOLOR_BORDERTOP), h-2); + wmove(win, 1, w-1); + wvline(win, ACS_VLINE | COLOR_PAIR(MOJOCOLOR_BORDERBOTTOM), h-2); + wmove(win, h-1, 0); + waddch(win, ACS_LLCORNER | A_BOLD | COLOR_PAIR(MOJOCOLOR_BORDERTOP)); + whline(win, ACS_HLINE | COLOR_PAIR(MOJOCOLOR_BORDERBOTTOM), w-2); + wmove(win, h-1, w-1); + waddch(win, ACS_LRCORNER | COLOR_PAIR(MOJOCOLOR_BORDERBOTTOM)); + + len = utf8len(retval->title); + wmove(win, 0, ((w-len)/2)-1); + wattron(win, COLOR_PAIR(MOJOCOLOR_BORDERTITLE) | A_BOLD); + waddch(win, ' '); + waddstr(win, retval->title); + wmove(win, 0, ((w-len)/2)+len); + waddch(win, ' '); + wattroff(win, COLOR_PAIR(MOJOCOLOR_BORDERTITLE) | A_BOLD); + + if (bcount > 0) + { + const int buttony = (y + h) - 2; + int buttonx = (x + w) - ((w - buttonsw) / 2); + wmove(win, h-3, 1); + whline(win, ACS_HLINE | A_BOLD | COLOR_PAIR(MOJOCOLOR_BORDERTOP), w-2); + for (i = 0; i < bcount; i++) + { + len = utf8len(buttons[i]) + 4; + buttonx -= len+1; + win = retval->buttons[i] = newwin(1, len, buttony, buttonx); + keypad(win, TRUE); + nodelay(win, ndelay); + } // for + } // if + + texth = h-2; + if (bcount > 0) + texth -= 2; + win = retval->textwin = newwin(texth, w-4, y+1, x+2); + keypad(win, TRUE); + nodelay(win, ndelay); + wbkgdset(win, COLOR_PAIR(MOJOCOLOR_TEXT)); + drawText(retval); + + drawBackground(stdscr); + wnoutrefresh(stdscr); + wnoutrefresh(retval->mainwin); + wnoutrefresh(retval->textwin); + for (i = 0; i < bcount; i++) + { + drawButton(retval, i); + wnoutrefresh(retval->buttons[i]); + } // for + + doupdate(); // push it all to the screen. + + return retval; +} // makeBox + + +static void freeBox(MojoBox *mojobox, boolean clearscreen) +{ + if (mojobox != NULL) + { + int i; + const int bcount = mojobox->buttoncount; + const int tcount = mojobox->textlinecount; + + if (mojobox->cursval != ERR) + curs_set(mojobox->cursval); + + for (i = 0; i < bcount; i++) + { + free(mojobox->buttontext[i]); + delwin(mojobox->buttons[i]); + } // for + + free(mojobox->buttontext); + free(mojobox->buttons); + + delwin(mojobox->textwin); + delwin(mojobox->mainwin); + + free(mojobox->title); + free(mojobox->text); + + for (i = 0; i < tcount; i++) + free(mojobox->textlines[i]); + + free(mojobox->textlines); + free(mojobox); + + if (clearscreen) + { + wclear(stdscr); + wrefresh(stdscr); + } // if + } // if +} // freeBox + + +static int upkeepBox(MojoBox **_mojobox, int ch) +{ + static boolean justResized = false; + MEVENT mevt; + int i; + int w, h; + MojoBox *mojobox = *_mojobox; + if (mojobox == NULL) + return -2; + + if (justResized) // !!! FIXME: this is a kludge. + { + justResized = false; + if (ch == ERR) + return -1; + } // if + + switch (ch) + { + case ERR: + return -2; + + case '\r': + case '\n': + case KEY_ENTER: + case ' ': + return (mojobox->buttoncount <= 0) ? -1 : mojobox->hoverover; + + case '\e': + return mojobox->buttoncount-1; + + case KEY_UP: + if (mojobox->textpos > 0) + { + mojobox->textpos--; + drawText(mojobox); + wrefresh(mojobox->textwin); + } // if + return -1; + + case KEY_DOWN: + getmaxyx(mojobox->textwin, h, w); + if (mojobox->textpos < (mojobox->textlinecount-h)) + { + mojobox->textpos++; + drawText(mojobox); + wrefresh(mojobox->textwin); + } // if + return -1; + + case KEY_PPAGE: + if (mojobox->textpos > 0) + { + getmaxyx(mojobox->textwin, h, w); + mojobox->textpos -= h; + if (mojobox->textpos < 0) + mojobox->textpos = 0; + drawText(mojobox); + wrefresh(mojobox->textwin); + } // if + return -1; + + case KEY_NPAGE: + getmaxyx(mojobox->textwin, h, w); + if (mojobox->textpos < (mojobox->textlinecount-h)) + { + mojobox->textpos += h; + if (mojobox->textpos > (mojobox->textlinecount-h)) + mojobox->textpos = (mojobox->textlinecount-h); + drawText(mojobox); + wrefresh(mojobox->textwin); + } // if + return -1; + + case KEY_LEFT: + if (mojobox->buttoncount > 1) + { + if (mojobox->hoverover < (mojobox->buttoncount-1)) + { + mojobox->hoverover++; + drawButton(mojobox, mojobox->hoverover-1); + drawButton(mojobox, mojobox->hoverover); + wrefresh(mojobox->buttons[mojobox->hoverover-1]); + wrefresh(mojobox->buttons[mojobox->hoverover]); + } // if + } // if + return -1; + + case KEY_RIGHT: + if (mojobox->buttoncount > 1) + { + if (mojobox->hoverover > 0) + { + mojobox->hoverover--; + drawButton(mojobox, mojobox->hoverover+1); + drawButton(mojobox, mojobox->hoverover); + wrefresh(mojobox->buttons[mojobox->hoverover+1]); + wrefresh(mojobox->buttons[mojobox->hoverover]); + } // if + } // if + return -1; + + case 12: // ctrl-L...redraw everything on the screen. + redrawwin(stdscr); + wnoutrefresh(stdscr); + redrawwin(mojobox->mainwin); + wnoutrefresh(mojobox->mainwin); + redrawwin(mojobox->textwin); + wnoutrefresh(mojobox->textwin); + for (i = 0; i < mojobox->buttoncount; i++) + { + redrawwin(mojobox->buttons[i]); + wnoutrefresh(mojobox->buttons[i]); + } // for + doupdate(); // push it all to the screen. + return -1; + + case KEY_RESIZE: + mojobox = makeBox(mojobox->title, mojobox->text, + mojobox->buttontext, mojobox->buttoncount, + mojobox->ndelay, mojobox->hidecursor); + mojobox->cursval = (*_mojobox)->cursval; // keep this sane. + mojobox->hoverover = (*_mojobox)->hoverover; + freeBox(*_mojobox, false); + if (mojobox->hidecursor) + curs_set(0); // make sure this stays sane. + *_mojobox = mojobox; + justResized = true; // !!! FIXME: kludge. + return -1; + + case KEY_MOUSE: + if ((getmouse(&mevt) == OK) && (mevt.bstate & BUTTON1_CLICKED)) + { + int i; + for (i = 0; i < mojobox->buttoncount; i++) + { + int x1, y1, x2, y2; + getbegyx(mojobox->buttons[i], y1, x1); + getmaxyx(mojobox->buttons[i], y2, x2); + x2 += x1; + y2 += y1; + if ( (mevt.x >= x1) && (mevt.x < x2) && + (mevt.y >= y1) && (mevt.y < y2) ) + return i; + } // for + } // if + return -1; + } // switch + + return -1; +} // upkeepBox + + +static uint8 MojoGui_ncurses_priority(boolean istty) +{ + if (!istty) + return MOJOGUI_PRIORITY_NEVER_TRY; // need a terminal for this! + else if (getenv("DISPLAY") != NULL) + return MOJOGUI_PRIORITY_TRY_LAST; // let graphical stuff go first. + return MOJOGUI_PRIORITY_TRY_NORMAL; +} // MojoGui_ncurses_priority + + +static boolean MojoGui_ncurses_init(void) +{ + setlocale(LC_CTYPE, ""); // !!! FIXME: we assume you have a UTF-8 terminal. + if (initscr() == NULL) + { + logInfo("ncurses: initscr() failed, use another UI."); + return false; + } // if + + cbreak(); + keypad(stdscr, TRUE); + noecho(); + start_color(); + mousemask(BUTTON1_CLICKED, NULL); + init_pair(MOJOCOLOR_BACKGROUND, COLOR_CYAN, COLOR_BLUE); + init_pair(MOJOCOLOR_BORDERTOP, COLOR_WHITE, COLOR_WHITE); + init_pair(MOJOCOLOR_BORDERBOTTOM, COLOR_BLACK, COLOR_WHITE); + init_pair(MOJOCOLOR_BORDERTITLE, COLOR_YELLOW, COLOR_WHITE); + init_pair(MOJOCOLOR_TEXT, COLOR_BLACK, COLOR_WHITE); + init_pair(MOJOCOLOR_TEXTENTRY, COLOR_WHITE, COLOR_BLUE); + init_pair(MOJOCOLOR_BUTTONHOVER, COLOR_YELLOW, COLOR_BLUE); + init_pair(MOJOCOLOR_BUTTONNORMAL, COLOR_BLACK, COLOR_WHITE); + init_pair(MOJOCOLOR_BUTTONBORDER, COLOR_WHITE, COLOR_BLUE); + init_pair(MOJOCOLOR_DONE, COLOR_YELLOW, COLOR_RED); + init_pair(MOJOCOLOR_TODO, COLOR_CYAN, COLOR_BLUE); + + wbkgdset(stdscr, COLOR_PAIR(MOJOCOLOR_BACKGROUND)); + wclear(stdscr); + wrefresh(stdscr); + + percentTicks = 0; + return true; // always succeeds. +} // MojoGui_ncurses_init + + +static void MojoGui_ncurses_deinit(void) +{ + freeBox(progressBox, false); + progressBox = NULL; + endwin(); + delwin(stdscr); // not sure if this is safe, but valgrind said it leaks. + stdscr = NULL; + free(title); + title = NULL; + free(lastComponent); + lastComponent = NULL; + free(lastProgressType); + lastProgressType = NULL; +} // MojoGui_ncurses_deinit + + +static void MojoGui_ncurses_msgbox(const char *title, const char *text) +{ + char *localized_ok = xstrdup(_("OK")); + MojoBox *mojobox = makeBox(title, text, &localized_ok, 1, false, true); + while (upkeepBox(&mojobox, wgetch(mojobox->mainwin)) == -1) {} + freeBox(mojobox, true); + free(localized_ok); +} // MojoGui_ncurses_msgbox + + +static boolean MojoGui_ncurses_promptyn(const char *title, const char *text, + boolean defval) +{ + char *localized_yes = xstrdup(_("Yes")); + char *localized_no = xstrdup(_("No")); + char *buttons[] = { localized_yes, localized_no }; + MojoBox *mojobox = makeBox(title, text, buttons, 2, false, true); + int rc = 0; + + // set the default to "no" instead of "yes"? + if (defval == false) + { + mojobox->hoverover = 1; + drawButton(mojobox, 0); + drawButton(mojobox, 1); + wrefresh(mojobox->buttons[0]); + wrefresh(mojobox->buttons[1]); + } // if + + while ((rc = upkeepBox(&mojobox, wgetch(mojobox->mainwin))) == -1) {} + freeBox(mojobox, true); + free(localized_yes); + free(localized_no); + return (rc == 0); +} // MojoGui_ncurses_promptyn + + +static MojoGuiYNAN MojoGui_ncurses_promptynan(const char *title, + const char *text, + boolean defval) +{ + char *loc_yes = xstrdup(_("Yes")); + char *loc_no = xstrdup(_("No")); + char *loc_always = xstrdup(_("Always")); + char *loc_never = xstrdup(_("Never")); + char *buttons[] = { loc_yes, loc_always, loc_never, loc_no }; + MojoBox *mojobox = makeBox(title, text, buttons, 4, false, true); + int rc = 0; + + // set the default to "no" instead of "yes"? + if (defval == false) + { + mojobox->hoverover = 3; + drawButton(mojobox, 0); + drawButton(mojobox, 3); + wrefresh(mojobox->buttons[0]); + wrefresh(mojobox->buttons[3]); + } // if + + while ((rc = upkeepBox(&mojobox, wgetch(mojobox->mainwin))) == -1) {} + freeBox(mojobox, true); + free(loc_yes); + free(loc_no); + free(loc_always); + free(loc_never); + + switch (rc) + { + case 0: return MOJOGUI_YES; + case 1: return MOJOGUI_ALWAYS; + case 2: return MOJOGUI_NEVER; + case 3: return MOJOGUI_NO; + } // switch + + assert(false && "BUG: unhandled case in switch statement!"); + return MOJOGUI_NO; +} // MojoGui_ncurses_promptynan + + +static boolean MojoGui_ncurses_start(const char *_title, + const MojoGuiSplash *splash) +{ + free(title); + title = xstrdup(_title); + drawBackground(stdscr); + wrefresh(stdscr); + return true; +} // MojoGui_ncurses_start + + +static void MojoGui_ncurses_stop(void) +{ + free(title); + title = NULL; + drawBackground(stdscr); + wrefresh(stdscr); +} // MojoGui_ncurses_stop + + +static int MojoGui_ncurses_readme(const char *name, const uint8 *data, + size_t datalen, boolean can_back, + boolean can_fwd) +{ + MojoBox *mojobox = NULL; + char *buttons[3] = { NULL, NULL, NULL }; + int bcount = 0; + int backbutton = -99; + int fwdbutton = -99; + int rc = 0; + int i = 0; + + if (can_fwd) + { + fwdbutton = bcount++; + buttons[fwdbutton] = xstrdup(_("Next")); + } // if + + if (can_back) + { + backbutton = bcount++; + buttons[backbutton] = xstrdup(_("Back")); + } // if + + buttons[bcount++] = xstrdup(_("Cancel")); + + mojobox = makeBox(name, (char *) data, buttons, bcount, false, true); + while ((rc = upkeepBox(&mojobox, wgetch(mojobox->mainwin))) == -1) {} + freeBox(mojobox, true); + + for (i = 0; i < bcount; i++) + free(buttons[i]); + + if (rc == backbutton) + return -1; + else if (rc == fwdbutton) + return 1; + + return 0; // error? Cancel? +} // MojoGui_ncurses_readme + + +static int toggle_option(MojoGuiSetupOptions *parent, + MojoGuiSetupOptions *opts, int *line, int target) +{ + int rc = -1; + if ((opts != NULL) && (target > *line)) + { + const char *desc = opts->description; + boolean blanked = false; + blanked = ( (opts->is_group_parent) && ((!desc) || (!(*desc))) ); + + if ((!blanked) && (++(*line) == target)) + { + const boolean toggled = ((opts->value) ? false : true); + + if (opts->is_group_parent) + return 0; + + // "radio buttons" in a group? + if ((parent) && (parent->is_group_parent)) + { + if (toggled) // drop unless we weren't the current toggle. + { + // set all siblings to false... + MojoGuiSetupOptions *i = parent->child; + while (i != NULL) + { + i->value = false; + i = i->next_sibling; + } // while + opts->value = true; // reset us to be true. + } // if + } // if + + else // individual "check box" was chosen. + { + opts->value = toggled; + } // else + + return 1; // we found it, bail. + } // if + + if (opts->value) // if option is toggled on, descend to children. + rc = toggle_option(opts, opts->child, line, target); + if (rc == -1) + rc = toggle_option(parent, opts->next_sibling, line, target); + } // if + + return rc; +} // toggle_option + + +// This code is pretty scary. +static void build_options(MojoGuiSetupOptions *opts, int *line, int level, + int maxw, char **lines) +{ + if (opts != NULL) + { + const char *desc = opts->description; + char *spacebuf = (char *) xmalloc(maxw + 1); + char *buf = (char *) xmalloc(maxw + 1); + int len = 0; + int spacing = level * 2; + + if ((desc != NULL) && (*desc == '\0')) + desc = NULL; + + if (spacing > (maxw-5)) + spacing = 0; // oh well. + + if (spacing > 0) + memset(spacebuf, ' ', spacing); // null-term'd by xmalloc(). + + if (opts->is_group_parent) + { + if (desc != NULL) + len = snprintf(buf, maxw-2, "%s%s", spacebuf, desc); + } // if + else + { + (*line)++; + len = snprintf(buf, maxw-2, "%s[%c] %s", spacebuf, + opts->value ? 'X' : ' ', desc); + } // else + + free(spacebuf); + + if (len >= maxw-1) + strcpy(buf+(maxw-4), "..."); // !!! FIXME: Unicode issues! + + if (len > 0) + { + const size_t newlen = strlen(*lines) + strlen(buf) + 2; + *lines = (char*) xrealloc(*lines, newlen); + strcat(*lines, buf); + strcat(*lines, "\n"); // I'm sorry, Joel Spolsky! + } // if + + if ((opts->value) || (opts->is_group_parent)) + { + int newlev = level + 1; + if ((opts->is_group_parent) && (desc == NULL)) + newlev--; + build_options(opts->child, line, newlev, maxw, lines); + } // if + + build_options(opts->next_sibling, line, level, maxw, lines); + } // if +} // build_options + + +static int optionBox(const char *title, MojoGuiSetupOptions *opts, + boolean can_back, boolean can_fwd) +{ + MojoBox *mojobox = NULL; + char *buttons[4] = { NULL, NULL, NULL, NULL }; + boolean ignoreerr = false; + int lasthoverover = 0; + int lasttextpos = 0; + int bcount = 0; + int backbutton = -99; + int fwdbutton = -99; + int togglebutton = -99; + int cancelbutton = -99; + int selected = 0; + int ch = 0; + int rc = -1; + int i = 0; + + if (can_fwd) + { + fwdbutton = bcount++; + buttons[fwdbutton] = xstrdup(_("Next")); + } // if + + if (can_back) + { + backbutton = bcount++; + buttons[backbutton] = xstrdup(_("Back")); + } // if + + lasthoverover = togglebutton = bcount++; + buttons[togglebutton] = xstrdup(_("Toggle")); + cancelbutton = bcount++; + buttons[cancelbutton] = xstrdup(_("Cancel")); + + do + { + if (mojobox == NULL) + { + int y = 0; + int line = 0; + int maxw, maxh; + getmaxyx(stdscr, maxh, maxw); + char *text = xstrdup(""); + build_options(opts, &line, 0, maxw-6, &text); + mojobox = makeBox(title, text, buttons, bcount, false, true); + free(text); + + getmaxyx(mojobox->textwin, maxh, maxw); + + if (lasthoverover != mojobox->hoverover) + { + const int orighover = mojobox->hoverover; + mojobox->hoverover = lasthoverover; + drawButton(mojobox, orighover); + drawButton(mojobox, lasthoverover); + wrefresh(mojobox->buttons[orighover]); + wrefresh(mojobox->buttons[lasthoverover]); + } // if + + if (lasttextpos != mojobox->textpos) + { + mojobox->textpos = lasttextpos; + drawText(mojobox); + } // if + + if (selected >= (mojobox->textlinecount - 1)) + selected = mojobox->textlinecount - 1; + if (selected >= mojobox->textpos+maxh) + selected = (mojobox->textpos+maxh) - 1; + y = selected - lasttextpos; + + wattron(mojobox->textwin, COLOR_PAIR(MOJOCOLOR_BUTTONHOVER) | A_BOLD); + mvwhline(mojobox->textwin, y, 0, ' ', maxw); + mvwaddstr(mojobox->textwin, y, 0, mojobox->textlines[selected]); + wattroff(mojobox->textwin, COLOR_PAIR(MOJOCOLOR_BUTTONHOVER) | A_BOLD); + wrefresh(mojobox->textwin); + } // if + + lasttextpos = mojobox->textpos; + lasthoverover = mojobox->hoverover; + + ch = wgetch(mojobox->mainwin); + + if (ignoreerr) // kludge. + { + ignoreerr = false; + if (ch == ERR) + continue; + } // if + + if (ch == KEY_RESIZE) + { + freeBox(mojobox, false); // catch and rebuild without upkeepBox, + mojobox = NULL; // so we can rebuild the text ourself. + ignoreerr = true; // kludge. + } // if + + else if (ch == KEY_UP) + { + if (selected > 0) + { + WINDOW *win = mojobox->textwin; + int maxw, maxh; + int y = --selected - mojobox->textpos; + getmaxyx(win, maxh, maxw); + if (selected < mojobox->textpos) + { + upkeepBox(&mojobox, ch); // upkeepBox does scrolling + y++; + } // if + else + { + wattron(win, COLOR_PAIR(MOJOCOLOR_TEXT)); + mvwhline(win, y+1, 0, ' ', maxw); + mvwaddstr(win, y+1, 0, mojobox->textlines[selected+1]); + wattroff(win, COLOR_PAIR(MOJOCOLOR_TEXT)); + } // else + wattron(win, COLOR_PAIR(MOJOCOLOR_BUTTONHOVER) | A_BOLD); + mvwhline(win, y, 0, ' ', maxw); + mvwaddstr(win, y, 0, mojobox->textlines[selected]); + wattroff(win, COLOR_PAIR(MOJOCOLOR_BUTTONHOVER) | A_BOLD); + wrefresh(win); + } // if + } // else if + + else if (ch == KEY_DOWN) + { + if (selected < (mojobox->textlinecount-1)) + { + WINDOW *win = mojobox->textwin; + int maxw, maxh; + int y = ++selected - mojobox->textpos; + getmaxyx(win, maxh, maxw); + if (selected >= mojobox->textpos+maxh) + { + upkeepBox(&mojobox, ch); // upkeepBox does scrolling + y--; + } // if + else + { + wattron(win, COLOR_PAIR(MOJOCOLOR_TEXT)); + mvwhline(win, y-1, 0, ' ', maxw); + mvwaddstr(win, y-1, 0, mojobox->textlines[selected-1]); + wattroff(win, COLOR_PAIR(MOJOCOLOR_TEXT)); + } // else + wattron(win, COLOR_PAIR(MOJOCOLOR_BUTTONHOVER) | A_BOLD); + mvwhline(win, y, 0, ' ', maxw); + mvwaddstr(win, y, 0, mojobox->textlines[selected]); + wattroff(win, COLOR_PAIR(MOJOCOLOR_BUTTONHOVER) | A_BOLD); + wrefresh(win); + } // if + } // else if + + else if ((ch == KEY_NPAGE) || (ch == KEY_NPAGE)) + { + // !!! FIXME: maybe handle this when I'm not so lazy. + // !!! FIXME: For now, this if statement is to block + // !!! FIXME: upkeepBox() from scrolling and screwing up state. + } // else if + + else // let upkeepBox handle other input (button selection, etc). + { + rc = upkeepBox(&mojobox, ch); + if (rc == togglebutton) + { + int line = 0; + rc = -1; // reset so we don't stop processing input. + if (toggle_option(NULL, opts, &line, selected+1) == 1) + { + freeBox(mojobox, false); // rebuild to reflect new options... + mojobox = NULL; + } // if + } // if + } // else + } while (rc == -1); + + freeBox(mojobox, true); + + for (i = 0; i < bcount; i++) + free(buttons[i]); + + if (rc == backbutton) + return -1; + else if (rc == fwdbutton) + return 1; + + return 0; // error? Cancel? +} // optionBox + + +static int MojoGui_ncurses_options(MojoGuiSetupOptions *opts, + boolean can_back, boolean can_fwd) +{ + char *title = xstrdup(_("Options")); + int rc = optionBox(title, opts, can_back, can_fwd); + free(title); + return rc; +} // MojoGui_ncurses_options + + +static char *inputBox(const char *prompt, int *command, boolean can_back, + const char *defval) +{ + char *text = NULL; + int w, h; + int i; + int ch; + int rc = -1; + MojoBox *mojobox = NULL; + size_t retvalalloc = 64; + size_t retvallen = 0; + char *retval = NULL; + char *buttons[3] = { NULL, NULL, NULL }; + int drawpos = 0; + int drawlen = 0; + int bcount = 0; + int backbutton = -1; + int cancelbutton = -1; + + if (defval == NULL) + retval = (char *) xmalloc(retvalalloc); + else + { + const size_t defvallen = strlen(defval); + if ((defvallen * 2) > retvalalloc) + retvalalloc = defvallen * 2; + retval = (char *) xmalloc(retvalalloc); + retvallen = defvallen; + strcpy(retval, defval); + } // else + + buttons[bcount++] = xstrdup(_("OK")); + + if (can_back) + { + backbutton = bcount++; + buttons[backbutton] = xstrdup(_("Back")); + } // if + + cancelbutton = bcount++; + buttons[cancelbutton] = xstrdup(_("Cancel")); + + getmaxyx(stdscr, h, w); + w -= 10; + text = (char *) xmalloc(w+4); + text[0] = '\n'; + memset(text+1, ' ', w); + text[w+1] = '\n'; + text[w+2] = ' '; + text[w+3] = '\0'; + mojobox = makeBox(prompt, text, buttons, bcount, false, false); + free(text); + text = NULL; + + do + { + getmaxyx(mojobox->textwin, h, w); + w -= 2; + + if (drawpos >= retvallen) + drawpos = 0; + while ((drawlen = (retvallen - drawpos)) >= w) + drawpos += 5; + + wattron(mojobox->textwin, COLOR_PAIR(MOJOCOLOR_TEXTENTRY) | A_BOLD); + mvwhline(mojobox->textwin, 1, 1, ' ', w); // blank line... + mvwaddstr(mojobox->textwin, 1, 1, retval + drawpos); + wattroff(mojobox->textwin, COLOR_PAIR(MOJOCOLOR_TEXTENTRY) | A_BOLD); + wrefresh(mojobox->textwin); + + ch = wgetch(mojobox->mainwin); + if ( (ch > 0) && (ch < KEY_MIN) && (isprint(ch)) ) // regular key. + { + if (retvalalloc <= retvallen) + { + retvalalloc *= 2; + retval = xrealloc(retval, retvalalloc); + } // if + retval[retvallen++] = (char) ch; + retval[retvallen] = '\0'; + } // if + + else if (ch == KEY_BACKSPACE) + { + if (retvallen > 0) + retval[--retvallen] = '\0'; + } // else if + + else if (ch == KEY_RESIZE) + { + wrefresh(stdscr); + getmaxyx(stdscr, h, w); + w -= 10; + text = (char *) xrealloc(mojobox->text, w+4); + text[0] = '\n'; + memset(text+1, ' ', w); + text[w+1] = '\n'; + text[w+2] = ' '; + text[w+3] = '\0'; + mojobox->text = text; + text = NULL; + upkeepBox(&mojobox, KEY_RESIZE); // let real resize happen... + } // else if + + else + { + rc = upkeepBox(&mojobox, ch); + } // else + } while (rc == -1); + + freeBox(mojobox, true); + + for (i = 0; i < bcount; i++) + free(buttons[i]); + + if (rc == backbutton) + *command = -1; + else if (rc == cancelbutton) + *command = 0; + else + *command = 1; + + if (*command <= 0) + { + free(retval); + retval = NULL; + } // if + + return retval; +} // inputBox + + +static char *MojoGui_ncurses_destination(const char **recommends, int recnum, + int *command, boolean can_back, + boolean can_fwd) +{ + char *retval = NULL; + while (true) + { + const char *localized = NULL; + char *title = NULL; + char *choosetxt = NULL; + int rc = 0; + + if (recnum > 0) // recommendations available. + { + int chosen = -1; + MojoGuiSetupOptions opts; + MojoGuiSetupOptions *prev = &opts; + MojoGuiSetupOptions *next = NULL; + MojoGuiSetupOptions *opt = NULL; + memset(&opts, '\0', sizeof (MojoGuiSetupOptions)); + int i; + for (i = 0; i < recnum; i++) + { + opt = (MojoGuiSetupOptions *) xmalloc(sizeof (*opt)); + opt->description = recommends[i]; + opt->size = -1; + prev->next_sibling = opt; + prev = opt; + } // for + + choosetxt = xstrdup(_("(I want to specify a path.)")); + opt = (MojoGuiSetupOptions *) xmalloc(sizeof (*opt)); + opt->description = choosetxt; + opt->size = -1; + prev->next_sibling = opt; + prev = opt; + + opts.child = opts.next_sibling; // fix this field. + opts.next_sibling = NULL; + opts.value = opts.child->value = true; // make first default. + opts.is_group_parent = true; + opts.size = -1; + + title = xstrdup(_("Destination")); + rc = optionBox(title, &opts, can_back, can_fwd); + free(title); + + for (i = 0, next = opts.child; next != NULL; i++) + { + if (next->value) + chosen = i; + prev = next; + next = prev->next_sibling; + free(prev); + } // for + + free(choosetxt); + + *command = rc; + if (rc <= 0) // back or cancel. + return NULL; + + else if ((chosen >= 0) && (chosen < recnum)) // a specific entry + return xstrdup(recommends[chosen]); + } // if + + // either no recommendations or user wants to enter own path... + + localized = _("Enter path where files will be installed."); + title = xstrdup(localized); + retval = inputBox(title, &rc, (can_back) || (recnum > 0), NULL); + free(title); + + // user cancelled or entered text, or hit back and we aren't falling + // back to the option list...return. + if ( (rc >= 0) || ((rc == -1) && (recnum == 0)) ) + { + *command = rc; + return retval; + } // if + + // falling back to the option list again...loop. + } // while + + // Shouldn't ever hit this, but just in case... + *command = 0; + return NULL; +} // MojoGui_ncurses_destination + + +static int MojoGui_ncurses_productkey(const char *desc, const char *fmt, + char *buf, const int buflen, + boolean can_back, boolean can_fwd) +{ + // !!! FIXME: need text option for (desc). + // !!! FIXME: need max text entry of (buflen) + // !!! FIXME: need to disable "next" button if code is invalid. + char *prompt = xstrdup(_("Please enter your product key")); + boolean getout = false; + int retval = 0; + + while (!getout) + { + char *text = inputBox(prompt, &retval, can_back, buf); + + if (retval != 1) + getout = true; + else + { + snprintf(buf, buflen, "%s", text); + if (isValidProductKey(fmt, text)) + getout = true; + else + { + // !!! FIXME: just improve inputBox. + // We can't check the input character-by-character, so reuse + // the failed-verification localized string. + char *failtitle = xstrdup(_("Invalid product key")); + char *failstr = xstrdup(_("That key appears to be invalid. Please try again.")); + MojoGui_ncurses_msgbox(failtitle, failstr); + free(failstr); + free(failtitle); + } // else + } // else + free(text); + } // while + + free(prompt); + + return retval; +} // MojoGui_ncurses_productkey + + +static boolean MojoGui_ncurses_insertmedia(const char *medianame) +{ + char *fmt = xstrdup(_("Please insert '%0'")); + char *text = format(fmt, medianame); + char *localized_ok = xstrdup(_("OK")); + char *localized_cancel = xstrdup(_("Cancel")); + char *buttons[] = { localized_ok, localized_cancel }; + MojoBox *mojobox = NULL; + int rc = 0; + + mojobox = makeBox(_("Media change"), text, buttons, 2, false, true); + while ((rc = upkeepBox(&mojobox, wgetch(mojobox->mainwin))) == -1) {} + + freeBox(mojobox, true); + free(localized_cancel); + free(localized_ok); + free(text); + free(fmt); + return (rc == 0); +} // MojoGui_ncurses_insertmedia + + +static void MojoGui_ncurses_progressitem(void) +{ + // no-op in this UI target. +} // MojoGui_ncurses_progressitem + + +static boolean MojoGui_ncurses_progress(const char *type, const char *component, + int percent, const char *item, + boolean can_cancel) +{ + const uint32 now = ticks(); + boolean rebuild = (progressBox == NULL); + int ch = 0; + int rc = -1; + + if ( (lastComponent == NULL) || + (strcmp(lastComponent, component) != 0) || + (lastProgressType == NULL) || + (strcmp(lastProgressType, type) != 0) || + (lastCanCancel != can_cancel) ) + { + free(lastProgressType); + free(lastComponent); + lastProgressType = xstrdup(type); + lastComponent = xstrdup(component); + lastCanCancel = can_cancel; + rebuild = true; + } // if + + if (rebuild) + { + int w, h; + char *text = NULL; + char *localized_cancel = (can_cancel) ? xstrdup(_("Cancel")) : NULL; + char *buttons[] = { localized_cancel }; + const int buttoncount = (can_cancel) ? 1 : 0; + char *spacebuf = NULL; + getmaxyx(stdscr, h, w); + w -= 10; + text = (char *) xmalloc((w * 3) + 16); + if (snprintf(text, w, "%s", component) > (w-4)) + strcpy((text+w)-4, "..."); // !!! FIXME: Unicode problem. + strcat(text, "\n\n"); + spacebuf = (char *) xmalloc(w+1); + memset(spacebuf, ' ', w); // xmalloc provides null termination. + strcat(text, spacebuf); + free(spacebuf); + strcat(text, "\n\n "); + + freeBox(progressBox, false); + progressBox = makeBox(type, text, buttons, buttoncount, true, true); + free(text); + free(localized_cancel); + } // if + + // limit update spam... will only write every one second, tops. + if ((rebuild) || (percentTicks <= now)) + { + static boolean unknownToggle = false; + char *buf = NULL; + WINDOW *win = progressBox->textwin; + int w, h; + getmaxyx(win, h, w); + w -= 2; + buf = (char *) xmalloc(w+1); + + if (percent < 0) + { + const boolean origToggle = unknownToggle; + int i; + wmove(win, h-3, 1); + for (i = 0; i < w; i++) + { + if (unknownToggle) + waddch(win, ' ' | COLOR_PAIR(MOJOCOLOR_TODO)); + else + waddch(win, ' ' | COLOR_PAIR(MOJOCOLOR_DONE)); + unknownToggle = !unknownToggle; + } // for + unknownToggle = !origToggle; // animate by reversing next time. + } // if + else + { + int cells = (int) ( ((double) w) * (((double) percent) / 100.0) ); + snprintf(buf, w+1, "%d%%", percent); + mvwaddstr(win, h-3, ((w+2) - utf8len(buf)) / 2, buf); + mvwchgat(win, h-3, 1, cells, A_BOLD, MOJOCOLOR_DONE, NULL); + mvwchgat(win, h-3, 1+cells, w-cells, A_BOLD, MOJOCOLOR_TODO, NULL); + } // else + + wtouchln(win, h-3, 1, 1); // force reattributed cells to update. + + if (snprintf(buf, w+1, "%s", item) > (w-4)) + strcpy((buf+w)-4, "..."); // !!! FIXME: Unicode problem. + mvwhline(win, h-2, 1, ' ', w); + mvwaddstr(win, h-2, ((w+2) - utf8len(buf)) / 2, buf); + + free(buf); + wrefresh(win); + + percentTicks = now + 1000; + } // if + + // !!! FIXME: check for input here for cancel button, resize, etc... + ch = wgetch(progressBox->mainwin); + if (ch == KEY_RESIZE) + { + freeBox(progressBox, false); + progressBox = NULL; + } // if + else if (ch == ERR) // can't distinguish between an error and a timeout! + { + // do nothing... + } // else if + else + { + rc = upkeepBox(&progressBox, ch); + } // else + + return (rc == -1); +} // MojoGui_ncurses_progress + + +static void MojoGui_ncurses_final(const char *msg) +{ + char *title = xstrdup(_("Finish")); + MojoGui_ncurses_msgbox(title, msg); + free(title); +} // MojoGui_ncurses_final + +// end of gui_ncurses.c ... + diff --git a/mk/linux/mojosetup/gui_stdio.c b/mk/linux/mojosetup/gui_stdio.c new file mode 100644 index 00000000..e5f24db8 --- /dev/null +++ b/mk/linux/mojosetup/gui_stdio.c @@ -0,0 +1,631 @@ +/** + * MojoSetup; a portable, flexible installation application. + * + * Please see the file LICENSE.txt in the source's root directory. + * + * This file written by Ryan C. Gordon. + */ + +#if !SUPPORT_GUI_STDIO +#error Something is wrong in the build system. +#endif + +#define BUILDING_EXTERNAL_PLUGIN 1 +#include "gui.h" + +MOJOGUI_PLUGIN(stdio) + +#if !GUI_STATIC_LINK_STDIO +CREATE_MOJOGUI_ENTRY_POINT(stdio) +#endif + +#include + +static char *lastProgressType = NULL; +static char *lastComponent = NULL; +static uint32 percentTicks = 0; + +static int read_stdin(char *buf, int len) +{ + if (fgets(buf, len, stdin) == NULL) + return -1; + + len = strlen(buf) - 1; + while ( (len >= 0) && ((buf[len] == '\n') || (buf[len] == '\r')) ) + buf[len--] = '\0'; + + return len+1; +} // read_stdin + + +static int readstr(const char *prompt, char *buf, int len, + boolean back, boolean fwd) +{ + // !!! FIXME: if read_stdin() returns -1, we return 0, which makes it + // !!! FIXME: indistinguishable from "user hit enter" ... maybe we should + // !!! FIXME: abort in read_stdin() if i/o fails? + + int retval = 0; + char *backstr = (back) ? xstrdup(_("back")) : NULL; + + if (prompt != NULL) + printf("%s\n", prompt); + + if (back) + { + char *fmt = xstrdup(_("Type '%0' to go back.")); + char *msg = format(fmt, backstr); + printf("%s\n", msg); + free(msg); + free(fmt); + } // if + + if (fwd) + { + printf("%s", _("Press enter to continue.")); + printf("\n"); + } // if + + printf("%s",_("> ")); + fflush(stdout); + + if ((retval = read_stdin(buf, len)) >= 0) + { + if ((back) && (strcmp(buf, backstr) == 0)) // !!! FIXME: utf8casecmp? + retval = -1; + } // if + + free(backstr); + return retval; +} // readstr + + +static uint8 MojoGui_stdio_priority(boolean istty) +{ + // if not a tty and no other GUI plugins worked out, let the base + // application try to spawn a terminal and try again. If it can't do so, + // it will panic() and thus end the process, so we don't end up blocking + // on some prompt the user can't see. + + if (!istty) + return MOJOGUI_PRIORITY_NEVER_TRY; + + return MOJOGUI_PRIORITY_TRY_ABSOLUTELY_LAST; // always a last resort. +} // MojoGui_stdio_priority + + +static boolean MojoGui_stdio_init(void) +{ + percentTicks = 0; + return true; // always succeeds. +} // MojoGui_stdio_init + + +static void MojoGui_stdio_deinit(void) +{ + free(lastProgressType); + free(lastComponent); + lastProgressType = NULL; + lastComponent = NULL; +} // MojoGui_stdio_deinit + + +static void MojoGui_stdio_msgbox(const char *title, const char *text) +{ + char buf[128]; + char *fmt = xstrdup(_("NOTICE: %0\n[hit enter]")); + char *msg = format(fmt, text); + printf("%s\n", msg); + free(msg); + free(fmt); + fflush(stdout); + read_stdin(buf, sizeof (buf)); +} // MojoGui_stdio_msgbox + + +static boolean MojoGui_stdio_promptyn(const char *title, const char *text, + boolean defval) +{ + boolean retval = false; + if (!feof(stdin)) + { + const char *_fmt = ((defval) ? _("%0 [Y/n]: ") : _("%0 [y/N]: ")); + char *fmt = xstrdup(_fmt); + char *msg = format(fmt, text); + char *localized_no = xstrdup(_("N")); + char *localized_yes = xstrdup(_("Y")); + boolean getout = false; + char buf[128]; + + while (!getout) + { + int rc = 0; + + getout = true; // we may reset this later. + printf("%s", msg); + fflush(stdout); + rc = read_stdin(buf, sizeof (buf)); + + if (rc < 0) + retval = false; + else if (rc == 0) + retval = defval; + else if (strcasecmp(buf, localized_no) == 0) + retval = false; + else if (strcasecmp(buf, localized_yes) == 0) + retval = true; + else + getout = false; // try again. + } // while + + free(localized_yes); + free(localized_no); + free(msg); + free(fmt); + } // if + + return retval; +} // MojoGui_stdio_promptyn + + +static MojoGuiYNAN MojoGui_stdio_promptynan(const char *title, const char *txt, + boolean defval) +{ + MojoGuiYNAN retval = MOJOGUI_NO; + if (!feof(stdin)) + { + char *fmt = xstrdup(_("%0\n[y/n/Always/Never]: ")); + char *msg = format(fmt, txt); + char *localized_no = xstrdup(_("N")); + char *localized_yes = xstrdup(_("Y")); + char *localized_always = xstrdup(_("Always")); + char *localized_never = xstrdup(_("Never")); + boolean getout = false; + char buf[128]; + + while (!getout) + { + int rc = 0; + + getout = true; // we may reset this later. + printf("%s\n", msg); + fflush(stdout); + rc = read_stdin(buf, sizeof (buf)); + + if (rc < 0) + retval = MOJOGUI_NO; + else if (rc == 0) + retval = (defval) ? MOJOGUI_YES : MOJOGUI_NO; + else if (strcasecmp(buf, localized_no) == 0) + retval = MOJOGUI_NO; + else if (strcasecmp(buf, localized_yes) == 0) + retval = MOJOGUI_YES; + else if (strcasecmp(buf, localized_always) == 0) + retval = MOJOGUI_ALWAYS; + else if (strcasecmp(buf, localized_never) == 0) + retval = MOJOGUI_NEVER; + else + getout = false; // try again. + } // while + + free(localized_never); + free(localized_always); + free(localized_yes); + free(localized_no); + free(msg); + free(fmt); + } // if + + return retval; +} // MojoGui_stdio_promptynan + + +static boolean MojoGui_stdio_start(const char *title, + const MojoGuiSplash *splash) +{ + printf("%s\n", title); + return true; +} // MojoGui_stdio_start + + +static void MojoGui_stdio_stop(void) +{ + // no-op. +} // MojoGui_stdio_stop + + +static void dumb_pager(const char *name, const char *data, size_t datalen) +{ + const int MAX_PAGE_LINES = 21; + char *fmt = xstrdup(_("(%0-%1 of %2 lines, see more?)")); + int i = 0; + int w = 0; + int linecount = 0; + boolean getout = false; + char **lines = splitText(data, 80, &linecount, &w); + + assert(linecount >= 0); + + printf("%s\n", name); + + if (lines == NULL) // failed to parse?! + printf("%s\n", data); // just dump it all. Oh well. + else + { + int printed = 0; + do + { + for (i = 0; (i < MAX_PAGE_LINES) && (printed < linecount); i++) + printf("%s", lines[printed++]); + + if (printed >= linecount) + getout = true; + else + { + char *msg = NULL; + printf("\n"); + msg = format(fmt, numstr((printed-i)+1), + numstr(printed), numstr(linecount)); + getout = !MojoGui_stdio_promptyn("", msg, true); + free(msg); + printf("\n"); + } // else + } while (!getout); + } // while + + for (i = 0; i < linecount; i++) + free(lines[i]); + free(lines); + free(fmt); +} // dumb_pager + + +static int MojoGui_stdio_readme(const char *name, const uint8 *_data, + size_t datalen, boolean can_back, + boolean can_fwd) +{ + const char *data = (const char *) _data; + char buf[256]; + int retval = -1; + boolean failed = true; + + // !!! FIXME: popen() isn't reliable. + #if 0 //PLATFORM_UNIX + const size_t namelen = strlen(name); + const char *programs[] = { getenv("PAGER"), "more", "less -M", "less" }; + int i = 0; + + // flush streams, so output doesn't mingle with the popen()'d process. + fflush(stdout); + fflush(stderr); + + for (i = 0; i < STATICARRAYLEN(programs); i++) + { + const char *cmd = programs[i]; + if (cmd != NULL) + { + FILE *io = popen(cmd, "w"); + if (io != NULL) + { + failed = false; + if (!failed) failed = (fwrite("\n", 1, 1, io) != 1); + if (!failed) failed = (fwrite(name, namelen, 1, io) != 1); + if (!failed) failed = (fwrite("\n", 1, 1, io) != 1); + if (!failed) failed = (fwrite(data, datalen, 1, io) != 1); + if (!failed) failed = (fwrite("\n", 1, 1, io) != 1); + failed |= (pclose(io) != 0); // call whether we failed or not. + if (!failed) + break; // it worked, we're done! + } // if + } // if + } // for + #endif // PLATFORM_UNIX + + if (failed) // We're not Unix, or none of the pagers worked? + dumb_pager(name, data, datalen); + + // Put up the "hit enter to continue (or 'back' to go back)" prompt, + // but only if there's an choice to be made here. + if ((!can_back) || (readstr(NULL, buf, sizeof (buf), can_back, true) >= 0)) + retval = 1; + + return retval; +} // MojoGui_stdio_readme + + +static void toggle_option(MojoGuiSetupOptions *parent, + MojoGuiSetupOptions *opts, int *line, int target) +{ + if ((opts != NULL) && (target > *line)) + { + if (!opts->is_group_parent) + { + if (++(*line) == target) + { + const boolean toggled = ((opts->value) ? false : true); + + // "radio buttons" in a group? + if ((parent) && (parent->is_group_parent)) + { + if (toggled) // drop unless we weren't the current toggle. + { + // set all siblings to false... + MojoGuiSetupOptions *i = parent->child; + while (i != NULL) + { + i->value = false; + i = i->next_sibling; + } // while + opts->value = true; // reset us to be true. + } // if + } // if + + else // individual "check box" was chosen. + { + opts->value = toggled; + } // else + + return; // we found it, bail. + } // if + } // if + + if (opts->value) // if option is toggled on, descend to children. + toggle_option(opts, opts->child, line, target); + toggle_option(parent, opts->next_sibling, line, target); + } // if +} // toggle_option + + +static void print_options(MojoGuiSetupOptions *opts, int *line, int level) +{ + if (opts != NULL) + { + int i; + int spacing = 1; + if (opts->is_group_parent) + spacing += 6; + else + { + (*line)++; + printf("%2d [%c]", *line, opts->value ? 'X' : ' '); + } // else + + for (i = 0; i < (level + spacing); i++) + putchar(' '); + + printf("%s%s\n", opts->description, opts->is_group_parent ? ":" : ""); + + if ((opts->value) || (opts->is_group_parent)) + print_options(opts->child, line, level+1); + print_options(opts->next_sibling, line, level); + } // if +} // print_options + + +static int MojoGui_stdio_options(MojoGuiSetupOptions *opts, + boolean can_back, boolean can_fwd) +{ + const char *inst_opts_str = xstrdup(_("Options")); + const char *prompt = xstrdup(_("Choose number to change.")); + int retval = -1; + boolean getout = false; + char buf[128]; + int len = 0; + + while (!getout) + { + int line = 0; + + printf("\n\n"); + printf("%s", inst_opts_str); + printf("\n"); + print_options(opts, &line, 1); + printf("\n"); + + if ((len = readstr(prompt, buf, sizeof (buf), can_back, true)) < 0) + getout = true; + else if (len == 0) + { + getout = true; + retval = 1; + } // else if + else + { + char *endptr = NULL; + int target = (int) strtol(buf, &endptr, 10); + if (*endptr == '\0') // complete string was a valid number? + { + line = 0; + toggle_option(NULL, opts, &line, target); + } // if + } // else + } // while + + free((void *) inst_opts_str); + free((void *) prompt); + + return retval; +} // MojoGui_stdio_options + + +static char *MojoGui_stdio_destination(const char **recommends, int recnum, + int *command, boolean can_back, + boolean can_fwd) +{ + const char *instdeststr = xstrdup(_("Destination")); + const char *prompt = NULL; + char *retval = NULL; + boolean getout = false; + char buf[128]; + int len = 0; + int i = 0; + + *command = -1; + + if (recnum > 0) + prompt = xstrdup(_("Choose install destination by number (hit enter for #1), or enter your own.")); + else + prompt = xstrdup(_("Enter path where files will be installed.")); + + while (!getout) + { + printf("\n\n%s\n", instdeststr); + for (i = 0; i < recnum; i++) + printf(" %2d %s\n", i+1, recommends[i]); + printf("\n"); + + if ((len = readstr(prompt, buf, sizeof (buf), can_back, false)) < 0) + getout = true; + + else if ((len == 0) && (recnum > 0)) // default to first in list. + { + retval = xstrdup(recommends[0]); + *command = 1; + getout = true; + } // else if + + else if (len > 0) + { + char *endptr = NULL; + int target = (int) strtol(buf, &endptr, 10); + // complete string was a valid number? + if ((*endptr == '\0') && (target > 0) && (target <= recnum)) + retval = xstrdup(recommends[target-1]); + else + retval = xstrdup(buf); + + *command = 1; + getout = true; + } // else + } // while + + free((void *) prompt); + free((void *) instdeststr); + + return retval; +} // MojoGui_stdio_destination + + +static int MojoGui_stdio_productkey(const char *desc, const char *fmt, + char *buf, const int buflen, + boolean can_back, boolean can_fwd) +{ + const char *prompt = xstrdup(_("Please enter your product key")); + char *defval = ((*buf) ? xstrdup(buf) : NULL); + boolean getout = false; + int retval = -1; + char *msg = NULL; + + if (defval != NULL) + { + char *locfmt = xstrdup(_("(just press enter to use '%0')")); + msg = format(locfmt, defval); + free(locfmt); + } // if + + while (!getout) + { + int len; + printf("\n\n%s\n", desc); + if (msg != NULL) + printf("%s\n", msg); + if ((len = readstr(prompt, buf, buflen, can_back, false)) < 0) + getout = true; + else + { + if ((len == 0) && (defval != NULL)) + strcpy(buf, defval); + + if (isValidProductKey(fmt, buf)) + { + retval = 1; + getout = true; + } // else if + else + { + // We can't check the input character-by-character, so reuse + // the failed-verification localized string. + printf("\n%s\n\n", + _("That key appears to be invalid. Please try again.")); + } // else + } // else + } // while + + free(msg); + free(defval); + free((void *) prompt); + + return retval; +} // MojoGui_stdio_productkey + + +static boolean MojoGui_stdio_insertmedia(const char *medianame) +{ + char buf[32]; + char *fmt = xstrdup(_("Please insert '%0'")); + char *msg = format(fmt, medianame); + printf("%s\n", _("Media change")); + printf("%s\n", msg); + free(msg); + free(fmt); + return (readstr(NULL, buf, sizeof (buf), false, true) >= 0); +} // MojoGui_stdio_insertmedia + + +static void MojoGui_stdio_progressitem(void) +{ + // force new line of output on next call to MojoGui_stdio_progress() + percentTicks = 0; +} // MojoGui_stdio_progressitem + + +static boolean MojoGui_stdio_progress(const char *type, const char *component, + int percent, const char *item, + boolean can_cancel) +{ + const uint32 now = ticks(); + + if ( (lastComponent == NULL) || + (strcmp(lastComponent, component) != 0) || + (lastProgressType == NULL) || + (strcmp(lastProgressType, type) != 0) ) + { + free(lastProgressType); + free(lastComponent); + lastProgressType = xstrdup(type); + lastComponent = xstrdup(component); + printf("%s\n%s\n", type, component); + } // if + + // limit update spam... will only write every one second, tops, + // on any given filename, but it writes each filename at least once + // so it doesn't look like we only installed a few things. + if (percentTicks <= now) + { + char *fmt = NULL; + char *msg = NULL; + percentTicks = now + 1000; + if (percent < 0) + printf("%s\n", item); + else + { + fmt = xstrdup(_("%0 (total progress: %1%%)")); + msg = format(fmt, item, numstr(percent)); + printf("%s\n", msg); + free(msg); + free(fmt); + } // else + } // if + + return true; +} // MojoGui_stdio_progress + + +static void MojoGui_stdio_final(const char *msg) +{ + printf("%s\n\n", msg); + fflush(stdout); +} // MojoGui_stdio_final + +// end of gui_stdio.c ... + diff --git a/mk/linux/mojosetup/gui_www.c b/mk/linux/mojosetup/gui_www.c new file mode 100644 index 00000000..a2459ba9 --- /dev/null +++ b/mk/linux/mojosetup/gui_www.c @@ -0,0 +1,1116 @@ +/** + * MojoSetup; a portable, flexible installation application. + * + * Please see the file LICENSE.txt in the source's root directory. + * + * This file written by Ryan C. Gordon. + */ + +#if !SUPPORT_GUI_WWW +#error Something is wrong in the build system. +#endif + +#define BUILDING_EXTERNAL_PLUGIN 1 +#include "gui.h" + +MOJOGUI_PLUGIN(www) + +#if !GUI_STATIC_LINK_WWW +CREATE_MOJOGUI_ENTRY_POINT(www) +#endif + +#include + +#define FREE_AND_NULL(x) { free(x); x = NULL; } + +// tapdance between things WinSock and BSD Sockets define differently... +#if PLATFORM_WINDOWS + #include + + typedef int socklen_t; + + #define setprotoent(x) assert(x == 0) + #define sockErrno() WSAGetLastError() + #define wouldBlockError(err) (err == WSAEWOULDBLOCK) + #define intrError(err) (err == WSAEINTR) + + static inline void setBlocking(SOCKET s, boolean blocking) + { + u_long val = (blocking) ? 0 : 1; + ioctlsocket(s, FIONBIO, &val); + } // setBlocking + + static const char *sockStrErrVal(int val) + { + STUBBED("Windows strerror"); + return "sockStrErrVal() is unimplemented."; + } // sockStrErrVal + + + static boolean initSocketSupport(void) + { + WSADATA data; + int rc = WSAStartup(MAKEWORD(1, 1), &data); + if (rc != 0) + { + logError("www: WSAStartup() failed: %0", sockStrErrVal(rc)); + return false; + } // if + + logInfo("www: WinSock initialized (want %0.%1, got %2.%3).", + numstr((int) (LOBYTE(data.wVersion))), + numstr((int) (HIBYTE(data.wVersion))), + numstr((int) (LOBYTE(data.wHighVersion))), + numstr((int) (HIBYTE(data.wHighVersion)))); + logInfo("www: WinSock description: %0", data.szDescription); + logInfo("www: WinSock system status: %0", data.szSystemStatus); + logInfo("www: WinSock max sockets: %0", numstr((int) data.iMaxSockets)); + + return true; + } // initSocketSupport + + #define deinitSocketSupport() WSACleanup() + +#else + #include + #include + #include + #include + #include + #include + #include + #include + #include + + typedef int SOCKET; + + #define SOCKET_ERROR (-1) + #define INVALID_SOCKET (-1) + #define closesocket(x) close(x) + #define sockErrno() (errno) + #define sockStrErrVal(val) strerror(val) + #define intrError(err) (err == EINTR) + #define initSocketSupport() (true) + #define deinitSocketSupport() + + static inline boolean wouldBlockError(int err) + { + return ((err == EWOULDBLOCK) || (err == EAGAIN)); + } // wouldBlockError + + static void setBlocking(SOCKET s, boolean blocking) + { + int flags = fcntl(s, F_GETFL, 0); + if (blocking) + flags &= ~O_NONBLOCK; + else + flags |= O_NONBLOCK; + fcntl(s, F_SETFL, flags); + } // setBlocking + +#endif + +#define sockStrError() (sockStrErrVal(sockErrno())) + + +typedef struct _S_WebRequest +{ + char *key; + char *value; + struct _S_WebRequest *next; +} WebRequest; + + +static char *output = NULL; +static char *lastProgressType = NULL; +static char *lastComponent = NULL; +static char *baseUrl = NULL; +static WebRequest *webRequest = NULL; +static uint32 percentTicks = 0; +static SOCKET listenSocket = INVALID_SOCKET; +static SOCKET clientSocket = INVALID_SOCKET; + + +static uint8 MojoGui_www_priority(boolean istty) +{ + return MOJOGUI_PRIORITY_TRY_LAST; +} // MojoGui_www_priority + + +static void freeWebRequest(void) +{ + while (webRequest) + { + WebRequest *next = webRequest->next; + free(webRequest->key); + free(webRequest->value); + free(webRequest); + webRequest = next; + } // while +} // freeWebRequest + + +static void addWebRequest(const char *key, const char *val) +{ + if ((key != NULL) && (*key != '\0')) + { + WebRequest *req = (WebRequest *) xmalloc(sizeof (WebRequest)); + req->key = xstrdup(key); + req->value = xstrdup(val); + req->next = webRequest; + webRequest = req; + logDebug("www: request element '%0' = '%1'", key, val); + } // if +} // addWebRequest + + +static int hexVal(char ch) +{ + if ((ch >= 'a') && (ch <= 'f')) + return (ch - 'a') + 10; + else if ((ch >= 'A') && (ch <= 'F')) + return (ch - 'A') + 10; + else if ((ch >= '0') && (ch <= '9')) + return (ch - '0'); + return -1; +} // hexVal + + +static void unescapeUri(char *uri) +{ + char *ptr = uri; + while ((ptr = strchr(ptr, '%')) != NULL) + { + int a, b; + if ((a = hexVal(ptr[1])) != -1) + { + if ((b = hexVal(ptr[2])) != -1) + { + *(ptr++) = (char) ((a * 16) + b); + memmove(ptr, ptr+2, strlen(ptr+1)); + } // if + else + { + *(ptr++) = '?'; + memmove(ptr, ptr+1, strlen(ptr)); + } // else + } // if + else + { + *(ptr++) = '?'; + } // else + } // while +} // unescapeUri + + +static int strAdd(char **ptr, size_t *len, size_t *alloc, const char *fmt, ...) +{ + size_t bw = 0; + size_t avail = *alloc - *len; + va_list ap; + va_start(ap, fmt); + bw = vsnprintf(*ptr + *len, avail, fmt, ap); + va_end(ap); + + if (bw >= avail) + { + const size_t add = (*alloc + (bw + 1)); // double plus the new len. + *alloc += add; + avail += add; + *ptr = xrealloc(*ptr, *alloc); + va_start(ap, fmt); + bw = vsnprintf(*ptr + *len, avail, fmt, ap); + va_end(ap); + } // if + + *len += bw; + return bw; +} // strAdd + + +static char *htmlescape(const char *str) +{ + size_t len = 0, alloc = 0; + char *retval = NULL; + char ch; + + while ((ch = *(str++)) != '\0') + { + switch (ch) + { + case '&': strAdd(&retval, &len, &alloc, "&"); break; + case '<': strAdd(&retval, &len, &alloc, "<"); break; + case '>': strAdd(&retval, &len, &alloc, ">"); break; + case '"': strAdd(&retval, &len, &alloc, """); break; + case '\'': strAdd(&retval, &len, &alloc, "'"); break; + default: strAdd(&retval, &len, &alloc, "%c", ch); break; + } // switch + } // while + + return retval; +} // htmlescape + + +static const char *standardResponseHeaders = + "Content-Type: text/html; charset=utf-8\n" + "Accept-Ranges: none\n" + "Cache-Control: no-cache\n" + "Connection: close\n\n"; + + +static void setHtmlString(char **str, int responseCode, + const char *responseString, + const char *title, const char *html) +{ + size_t len = 0, alloc = 0; + FREE_AND_NULL(*str); + strAdd(str, &len, &alloc, + "HTTP/1.1 %d %s\n" // responseCode, responseString + "%s" // standardResponseHeaders + "" + "" + "%s" // title + "" + "%s" // html + "\n", + responseCode, responseString, + standardResponseHeaders, + title, html); +} // setHtmlString + + +static void setHtml(const char *title, const char *html) +{ + setHtmlString(&output, 200, "OK", title, html); +} // setHtml + + +static void sendStringAndDrop(SOCKET *_s, const char *str) +{ + SOCKET s = *_s; + int outlen = 0; + if (str == NULL) + str = ""; + else + outlen = strlen(str); + + setBlocking(s, true); + + while (outlen > 0) + { + int rc = send(s, str, outlen, 0); + if (rc != SOCKET_ERROR) + { + str += rc; + outlen -= rc; + } // if + else + { + const int err = sockErrno(); + if (!intrError(err)) + { + logError("www: send() failed: %0", sockStrErrVal(err)); + break; + } // if + } // else + } // while + + closesocket(s); + *_s = INVALID_SOCKET; +} // sendStringAndDrop + + +static void respond404(SOCKET *s) +{ + char *text = htmlescape(_("Not Found")); + char *str = NULL; + size_t len = 0, alloc = 0; + char *html = NULL; + strAdd(&html, &len, &alloc, "

%s

", text); + setHtmlString(&str, 404, text, text, html); + free(html); + free(text); + sendStringAndDrop(s, str); + free(str); +} // respond404 + + +static boolean parseGet(char *get) +{ + char *uri = NULL; + char *ver = NULL; + + uri = strchr(get, ' '); + if (uri == NULL) return false; + *(uri++) = '\0'; + + ver = strchr(uri, ' '); + if (ver == NULL) return false; + *(ver++) = '\0'; + + if (strcmp(get, "GET") != 0) return false; + if (uri[0] != '/') return false; + uri++; // skip dirsep. + + // !!! FIXME: we may want to feed stock files ( tags, etc) + // !!! FIXME: at some point in the future. + if ((uri[0] != '?') && (uri[0] != '\0')) return false; + if (strncmp(ver, "HTTP/", 5) != 0) return false; + + if (*uri == '?') + uri++; // skip initial argsep. + + do + { + char *next = strchr(uri, '&'); + char *val = NULL; + if (next != NULL) + *(next++) = '\0'; + + val = strchr(uri, '='); + if (val == NULL) + val = ""; + else + *(val++) = '\0'; + + unescapeUri(uri); + unescapeUri(val); + addWebRequest(uri, val); + + uri = next; + } while (uri != NULL); + + return true; +} // parseGet + + +static boolean parseRequest(char *reqstr) +{ + do + { + char *next = strchr(reqstr, '\n'); + char *val = NULL; + if (next != NULL) + *(next++) = '\0'; + + val = strchr(reqstr, ':'); + if (val == NULL) + val = ""; + else + { + *(val++) = '\0'; + while (*val == ' ') + val++; + } // else + + if (*reqstr != '\0') + { + size_t len = 0, alloc = 0; + char *buf = NULL; + strAdd(&buf, &len, &alloc, "HTTP-%s", reqstr); + addWebRequest(buf, val); + free(buf); + } // if + + reqstr = next; + } while (reqstr != NULL); + + return true; +} // parseRequest + + + +static WebRequest *servePage(boolean blocking) +{ + int newline = 0; + char ch = 0; + struct sockaddr_in addr; + socklen_t addrlen = 0; + int s = 0; + char *reqstr = NULL; + size_t len = 0, alloc = 0; + int err = 0; + + freeWebRequest(); + + if (listenSocket == INVALID_SOCKET) + return NULL; + + if (clientSocket != INVALID_SOCKET) // response to feed to client. + sendStringAndDrop(&clientSocket, output); + + if (blocking) + setBlocking(listenSocket, true); + + do + { + s = accept(listenSocket, (struct sockaddr *) &addr, &addrlen); + err = sockErrno(); + } while ( (s == INVALID_SOCKET) && (intrError(err)) ); + + if (blocking) + setBlocking(listenSocket, false); // reset what we toggled up there. + + if (s == INVALID_SOCKET) + { + if (wouldBlockError(err)) + assert(!blocking); + else + { + logError("www: accept() failed: %0", sockStrErrVal(err)); + closesocket(listenSocket); // make all future i/o fail too. + listenSocket = INVALID_SOCKET; + } // else + return NULL; + } // if + + setBlocking(s, true); + + // Doing this one char at a time isn't efficient, but it's easy. + + while (1) + { + if (recv(s, &ch, 1, 0) == SOCKET_ERROR) + { + const int err = sockErrno(); + if (!intrError(err)) // just try again on interrupt. + { + logError("www: recv() failed: %0", sockStrErrVal(err)); + FREE_AND_NULL(reqstr); + closesocket(s); + s = INVALID_SOCKET; + break; + } // if + } // if + + else if (ch == '\n') // newline + { + if (++newline == 2) + break; // end of request. + strAdd(&reqstr, &len, &alloc, "\n"); + } // if + + else if (ch != '\r') + { + newline = 0; + strAdd(&reqstr, &len, &alloc, "%c", ch); + } // else if + } // while + + if (reqstr != NULL) + { + char *get = NULL; + char *ptr = strchr(reqstr, '\n'); + if (ptr != NULL) + { + *ptr = '\0'; + ptr++; + } // if + + // reqstr is the GET (or whatever) request, ptr is the rest. + get = xstrdup(reqstr); + if (ptr == NULL) + { + *ptr = '\0'; + len = 0; + } // if + else + { + len = strlen(ptr); + memmove(reqstr, ptr, len+1); + } // else + + logDebug("www: request '%0'", get); + + // okay, now (get) and (reqptr) are separate strings. + // These parse*() functions update (webRequest). + if ( (parseGet(get)) && (parseRequest(reqstr)) ) + logDebug("www: accepted request"); + else + { + logError("www: rejected bogus request"); + freeWebRequest(); + respond404(&s); + } // else + + free(reqstr); + free(get); + } // if + + clientSocket = s; + return webRequest; +} // servePage + + +static SOCKET create_listen_socket(short portnum) +{ + SOCKET s = INVALID_SOCKET; + int protocol = 0; // pray this is right. + struct protoent *prot; + + setprotoent(0); + prot = getprotobyname("tcp"); + if (prot != NULL) + protocol = prot->p_proto; + + s = socket(PF_INET, SOCK_STREAM, protocol); + if (s == INVALID_SOCKET) + logInfo("www: socket() failed ('%0')", sockStrError()); + else + { + boolean success = false; + struct sockaddr_in addr; + addr.sin_family = AF_INET; + addr.sin_port = htons(portnum); + addr.sin_addr.s_addr = INADDR_ANY; // !!! FIXME: bind to localhost. + + // So we can bind this socket over and over in debug runs... + #if ((!defined _NDEBUG) && (!defined NDEBUG)) + { + int on = 1; + setsockopt(s, SOL_SOCKET, SO_REUSEADDR, (char*) &on, sizeof (on)); + } + #endif + + if (bind(s, (struct sockaddr *) &addr, sizeof (addr)) == SOCKET_ERROR) + logError("www: bind() failed ('%0')", sockStrError()); + else if (listen(s, 5) == SOCKET_ERROR) + logError("www: listen() failed ('%0')", sockStrError()); + else + { + logInfo("www: socket created on port %0", + numstr(portnum)); + success = true; + } // else + + if (!success) + { + closesocket(s); + s = INVALID_SOCKET; + } // if + } // if + + return s; +} // create_listen_socket + + +static boolean MojoGui_www_init(void) +{ + size_t len = 0, alloc = 0; + short portnum = 7341; // !!! FIXME: try some random ports. + percentTicks = 0; + + if (!initSocketSupport()) + { + logInfo("www: socket subsystem init failed, use another UI."); + return false; + } // if + + listenSocket = create_listen_socket(portnum); + if (listenSocket < 0) + { + logInfo("www: no listen socket, use another UI."); + return false; + } // if + + setBlocking(listenSocket, false); + + strAdd(&baseUrl, &len, &alloc, "http://localhost:%d/", (int) portnum); + return true; +} // MojoGui_www_init + + +static void MojoGui_www_deinit(void) +{ + // Catch any waiting browser connections...and tell them to buzz off! :) + char *donetitle = htmlescape(_("Shutting down...")); + char *donetext = htmlescape(_("You can close this browser now.")); + size_t len = 0, alloc = 0; + char *html = NULL; + + strAdd(&html, &len, &alloc, "
%s

", donetext); + setHtml(donetitle, html); + free(html); + free(donetitle); + free(donetext); + while (servePage(false) != NULL) { /* no-op. */ } + + freeWebRequest(); + FREE_AND_NULL(output); + FREE_AND_NULL(lastProgressType); + FREE_AND_NULL(lastComponent); + FREE_AND_NULL(baseUrl); + + if (clientSocket != INVALID_SOCKET) + { + closesocket(clientSocket); + clientSocket = INVALID_SOCKET; + } // if + + if (listenSocket != INVALID_SOCKET) + { + closesocket(listenSocket); + listenSocket = INVALID_SOCKET; + } // if + + deinitSocketSupport(); +} // MojoGui_www_deinit + + +static int doPromptPage(const char *title, const char *text, boolean centertxt, + const char *pagename, + const char **buttons, const char **locButtons, + int bcount) +{ + char *htmltitle = htmlescape(title); + boolean sawPage = false; + int answer = -1; + int i = 0; + char *html = NULL; + size_t len = 0, alloc = 0; + const char *align = ((centertxt) ? " align='center'" : ""); + + strAdd(&html, &len, &alloc, + "
" + "
" // pagename + "" // pagename + "" + "%s" // align, text + "" + "" + "" + "
", pagename, pagename, align, text); + + for (i = 0; i < bcount; i++) + { + const char *button = buttons[i]; + const char *loc = locButtons[i]; + strAdd(&html, &len, &alloc, + "", button, loc); + } // for + + strAdd(&html, &len, &alloc, + "
" + "
" + "
"); + + setHtml(htmltitle, html); + free(htmltitle); + free(html); + + while ((!sawPage) || (answer == -1)) + { + WebRequest *req = servePage(true); + sawPage = false; + answer = -1; + while (req != NULL) + { + const char *k = req->key; + const char *v = req->value; + if ( (strcmp(k, "page") == 0) && (strcmp(v, pagename) == 0) ) + sawPage = true; + else + { + for (i = 0; i < bcount; i++) + { + if (strcmp(k, buttons[i]) == 0) + { + answer = i; + break; + } // if + } // for + } // else + + req = req->next; + } // while + } // while + + return answer; +} // doPromptPage + + +static void MojoGui_www_msgbox(const char *title, const char *text) +{ + const char *buttons[] = { "ok" }; + const char *locButtons[] = { htmlescape(_("OK")) }; + char *htmltext = htmlescape(text); + doPromptPage(title, htmltext, true, "msgbox", buttons, locButtons, 1); + free(htmltext); + free((void *) locButtons[0]); +} // MojoGui_www_msgbox + + +static boolean MojoGui_www_promptyn(const char *title, const char *text, + boolean defval) +{ + // !!! FIXME: + // We currently ignore defval + + int i, rc; + char *htmltext = htmlescape(text); + const char *buttons[] = { "no", "yes" }; + const char *locButtons[] = { htmlescape(_("No")), htmlescape(_("Yes")) }; + + assert(STATICARRAYLEN(buttons) == STATICARRAYLEN(locButtons)); + + rc = doPromptPage(title, htmltext, true, "promptyn", buttons, locButtons, + STATICARRAYLEN(buttons)); + free(htmltext); + + for (i = 0; i < STATICARRAYLEN(locButtons); i++) + free((void *) locButtons[i]); + + return (rc == 1); +} // MojoGui_www_promptyn + + +static MojoGuiYNAN MojoGui_www_promptynan(const char *title, const char *text, + boolean defval) +{ + // !!! FIXME: + // We currently ignore defval + + int i, rc; + char *htmltext = htmlescape(text); + const char *buttons[] = { "no", "yes", "always", "never" }; + const char *locButtons[] = { + htmlescape(_("No")), + htmlescape(_("Yes")), + htmlescape(_("Always")), + htmlescape(_("Never")), + }; + assert(STATICARRAYLEN(buttons) == STATICARRAYLEN(locButtons)); + + rc = doPromptPage(title, htmltext, true, "promptynan", buttons, locButtons, + STATICARRAYLEN(buttons)); + + free(htmltext); + for (i = 0; i < STATICARRAYLEN(locButtons); i++) + free((void *) locButtons[i]); + + return (MojoGuiYNAN) rc; +} // MojoGui_www_promptynan + + +static boolean MojoGui_www_start(const char *title, + const MojoGuiSplash *splash) +{ + return true; +} // MojoGui_www_start + + +static void MojoGui_www_stop(void) +{ + // no-op. +} // MojoGui_www_stop + + +static int MojoGui_www_readme(const char *name, const uint8 *data, + size_t datalen, boolean can_back, + boolean can_fwd) +{ + char *text = NULL; + size_t len = 0, alloc = 0; + char *htmldata = htmlescape((const char *) data); + int i, rc; + int cancelbutton = -1; + int backbutton = -1; + int fwdbutton = -1; + int bcount = 0; + const char *buttons[4] = { NULL, NULL, NULL, NULL }; + const char *locButtons[4] = { NULL, NULL, NULL, NULL }; + assert(STATICARRAYLEN(buttons) == STATICARRAYLEN(locButtons)); + + cancelbutton = bcount++; + buttons[cancelbutton] = "cancel"; + locButtons[cancelbutton] = xstrdup(_("Cancel")); + + if (can_back) + { + backbutton = bcount++; + buttons[backbutton] = "back"; + locButtons[backbutton] = xstrdup(_("Back")); + } // if + + if (can_fwd) + { + fwdbutton = bcount++; + buttons[fwdbutton] = "next"; + locButtons[fwdbutton] = xstrdup(_("Next")); + } // if + + strAdd(&text, &len, &alloc, "
\n%s\n
", htmldata); + free(htmldata); + + rc = doPromptPage(name, text, false, "readme", buttons, locButtons, bcount); + + free(text); + for (i = 0; i < STATICARRAYLEN(locButtons); i++) + free((void *) locButtons[i]); + + if (rc == backbutton) + return -1; + else if (rc == cancelbutton) + return 0; + return 1; +} // MojoGui_www_readme + + +static int MojoGui_www_options(MojoGuiSetupOptions *opts, + boolean can_back, boolean can_fwd) +{ + // !!! FIXME: write me. + STUBBED("www options"); + return 1; +} // MojoGui_www_options + + +static char *MojoGui_www_destination(const char **recommends, int recnum, + int *command, boolean can_back, + boolean can_fwd) +{ + char *retval = NULL; + char *title = xstrdup(_("Destination")); + char *html = NULL; + size_t len = 0, alloc = 0; + boolean checked = true; + int cancelbutton = -1; + int backbutton = -1; + int fwdbutton = -1; + int bcount = 0; + int rc = 0; + int i = 0; + const char *buttons[4] = { NULL, NULL, NULL, NULL }; + const char *locButtons[4] = { NULL, NULL, NULL, NULL }; + assert(STATICARRAYLEN(buttons) == STATICARRAYLEN(locButtons)); + + cancelbutton = bcount++; + buttons[cancelbutton] = "cancel"; + locButtons[cancelbutton] = xstrdup(_("Cancel")); + + if (can_back) + { + backbutton = bcount++; + buttons[backbutton] = "back"; + locButtons[backbutton] = xstrdup(_("Back")); + } // if + + if (can_fwd) + { + fwdbutton = bcount++; + buttons[fwdbutton] = "next"; + locButtons[fwdbutton] = xstrdup(_("Next")); + } // if + + strAdd(&html, &len, &alloc, + "
" + ""); + + for (i = 0; i < recnum; i++) + { + strAdd(&html, &len, &alloc, + "" + "" + "", + ((checked) ? "checked='true'" : ""), recommends[i], recommends[i]); + checked = false; + } // for + + strAdd(&html, &len, &alloc, + "" + "" + "" + "
" + "%s" + "
" + "" + "" + "
" + "
", ((checked) ? "checked='true'" : "")); + + rc = doPromptPage(title, html, true, "destination", + buttons, locButtons, bcount); + + free(title); + free(html); + for (i = 0; i < STATICARRAYLEN(locButtons); i++) + free((void *) locButtons[i]); + + if (rc == backbutton) + *command = -1; + else if (rc == cancelbutton) + *command = 0; + else + { + const char *dest = NULL; + const char *customdest = NULL; + WebRequest *req = webRequest; + while (req != NULL) + { + const char *k = req->key; + const char *v = req->value; + if (strcmp(k, "dest") == 0) + dest = v; + else if (strcmp(k, "customdest") == 0) + customdest = v; + req = req->next; + } // while + + if (dest != NULL) + { + if (strcmp(dest, "*") == 0) + dest = customdest; + } // if + + if (dest == NULL) + *command = 0; // !!! FIXME: maybe loop with doPromptPage again. + else + { + retval = xstrdup(dest); + *command = 1; + } // else + } // else + + return retval; +} // MojoGui_www_destination + + +static int MojoGui_www_productkey(const char *desc, const char *fmt, + char *buf, const int buflen, + boolean can_back, boolean can_fwd) +{ + char *prompt = xstrdup(_("Please enter your product key")); + int retval = -1; + char *html = NULL; + size_t len = 0, alloc = 0; + int cancelbutton = -1; + int backbutton = -1; + int fwdbutton = -1; + int bcount = 0; + int rc = 0; + int i = 0; + const char *buttons[4] = { NULL, NULL, NULL, NULL }; + const char *locButtons[4] = { NULL, NULL, NULL, NULL }; + assert(STATICARRAYLEN(buttons) == STATICARRAYLEN(locButtons)); + + cancelbutton = bcount++; + buttons[cancelbutton] = "cancel"; + locButtons[cancelbutton] = xstrdup(_("Cancel")); + + if (can_back) + { + backbutton = bcount++; + buttons[backbutton] = "back"; + locButtons[backbutton] = xstrdup(_("Back")); + } // if + + if (can_fwd) + { + fwdbutton = bcount++; + buttons[fwdbutton] = "next"; + locButtons[fwdbutton] = xstrdup(_("Next")); + } // if + + strAdd(&html, &len, &alloc, + "
" + "%s
" + "" + "
", prompt, ((*buf) ? buf : "")); + + free(prompt); + + rc = doPromptPage(desc, html, true, "productkey", + buttons, locButtons, bcount); + + free(html); + for (i = 0; i < STATICARRAYLEN(locButtons); i++) + free((void *) locButtons[i]); + + if (rc == backbutton) + retval = -1; + else if (rc == cancelbutton) + retval = 0; + else + { + WebRequest *req = webRequest; + const char *keyval = NULL; + while (req != NULL) + { + const char *k = req->key; + const char *v = req->value; + if (strcmp(k, "productkey") == 0) + keyval = v; + + req = req->next; + } // while + + if (keyval == NULL) + retval = 0; // !!! FIXME: maybe loop with doPromptPage again. + else + { + snprintf(buf, buflen, "%s", keyval); + if (isValidProductKey(fmt, buf)) + retval = 1; + // !!! FIXME: must try again if invalid key. + } // else + } // else + + return retval; +} // MojoGui_www_productkey + + +static boolean MojoGui_www_insertmedia(const char *medianame) +{ + char *htmltext = NULL; + char *text = NULL; + size_t len = 0, alloc = 0; + int i, rc; + + const char *buttons[] = { "cancel", "ok" }; + const char *locButtons[] = { htmlescape(_("Cancel")), htmlescape(_("OK")) }; + + char *title = xstrdup(_("Media change")); + char *fmt = xstrdup(_("Please insert '%0'")); + char *msg = format(fmt, medianame); + strAdd(&text, &len, &alloc, msg); + free(msg); + free(fmt); + + htmltext = htmlescape(text); + free(text); + + assert(STATICARRAYLEN(buttons) == STATICARRAYLEN(locButtons)); + + rc = doPromptPage(title, htmltext, true, "insertmedia", buttons, + locButtons, STATICARRAYLEN(buttons)); + + free(title); + free(htmltext); + for (i = 0; i < STATICARRAYLEN(locButtons); i++) + free((void *) locButtons[i]); + + return (rc == 1); +} // MojoGui_www_insertmedia + + +static void MojoGui_www_progressitem(void) +{ + // no-op in this UI target. +} // MojoGui_www_progressitem + + +static boolean MojoGui_www_progress(const char *type, const char *component, + int percent, const char *item, + boolean can_cancel) +{ + return true; +} // MojoGui_www_progress + + +static void MojoGui_www_final(const char *msg) +{ + MojoGui_www_msgbox(_("Finish"), msg); +} // MojoGui_www_final + +// end of gui_www.c ... + diff --git a/mk/linux/mojosetup/libfetch/README.txt b/mk/linux/mojosetup/libfetch/README.txt new file mode 100644 index 00000000..a21514e2 --- /dev/null +++ b/mk/linux/mojosetup/libfetch/README.txt @@ -0,0 +1,48 @@ + +This is libfetch, from FreeBSD. + +I grabbed it from CVS, like this: + cvs -z9 -dfreebsdanoncvs@anoncvs.FreeBSD.org:/home/ncvs co src/lib/libfetch + +Checkout was from May 5th, 2007, 1pm EST. + +This just has minor modifications to make it play nicely with our build system, + and code, and stuff we don't need was trimmed out. + +Changes made for MojoSetup that aren't part of a virgin copy of libfetch are + noted with "#if __MOJOSETUP__" sections. + + +Here is the libfetch copyright from common.c ... + +/*- + * Copyright (c) 1998-2004 Dag-Erling Coïdan Smørgrav + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer + * in this position and unchanged. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + + +--ryan. + diff --git a/mk/linux/mojosetup/libfetch/common.c b/mk/linux/mojosetup/libfetch/common.c new file mode 100644 index 00000000..36e1075e --- /dev/null +++ b/mk/linux/mojosetup/libfetch/common.c @@ -0,0 +1,1114 @@ +/*- + * Copyright (c) 1998-2004 Dag-Erling Coïdan Smørgrav + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer + * in this position and unchanged. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#if __MOJOSETUP__ +#include "mojosetup_libfetch.h" +#include +#endif + +#if !sun /* __MOJOSETUP__ Solaris support... */ +#include +__FBSDID("$FreeBSD: src/lib/libfetch/common.c,v 1.50 2005/02/16 12:46:46 des Exp $"); +#endif + +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +#include "fetch.h" +#include "common.h" + + +/*** Local data **************************************************************/ + +/* + * Error messages for resolver errors + */ +static struct fetcherr _netdb_errlist[] = { +#ifdef EAI_NODATA + { EAI_NODATA, FETCH_RESOLV, "Host not found" }, +#endif + { EAI_AGAIN, FETCH_TEMP, "Transient resolver failure" }, + { EAI_FAIL, FETCH_RESOLV, "Non-recoverable resolver failure" }, + { EAI_NONAME, FETCH_RESOLV, "No address record" }, + { -1, FETCH_UNKNOWN, "Unknown resolver error" } +}; + +/* End-of-Line */ +static const char ENDL[2] = "\r\n"; + + +/*** Error-reporting functions ***********************************************/ + +/* + * Map error code to string + */ +static struct fetcherr * +_fetch_finderr(struct fetcherr *p, int e) +{ + while (p->num != -1 && p->num != e) + p++; + return (p); +} + +/* + * Set error code + */ +void +_fetch_seterr(struct fetcherr *p, int e) +{ + p = _fetch_finderr(p, e); + fetchLastErrCode = p->cat; + snprintf(fetchLastErrString, MAXERRSTRING, "%s", p->string); +} + +/* + * Set error code according to errno + */ +void +_fetch_syserr(void) +{ + switch (errno) { + case 0: + fetchLastErrCode = FETCH_OK; + break; + case EPERM: + case EACCES: + case EROFS: +#if __MOJOSETUP__ +#if FREEBSD + case EAUTH: + case ENEEDAUTH: +#endif +#endif + fetchLastErrCode = FETCH_AUTH; + break; + case ENOENT: + case EISDIR: /* XXX */ + fetchLastErrCode = FETCH_UNAVAIL; + break; + case ENOMEM: + fetchLastErrCode = FETCH_MEMORY; + break; + case EBUSY: + case EAGAIN: + fetchLastErrCode = FETCH_TEMP; + break; + case EEXIST: + fetchLastErrCode = FETCH_EXISTS; + break; + case ENOSPC: + fetchLastErrCode = FETCH_FULL; + break; + case EADDRINUSE: + case EADDRNOTAVAIL: + case ENETDOWN: + case ENETUNREACH: + case ENETRESET: + case EHOSTUNREACH: + fetchLastErrCode = FETCH_NETWORK; + break; + case ECONNABORTED: + case ECONNRESET: + fetchLastErrCode = FETCH_ABORT; + break; + case ETIMEDOUT: + fetchLastErrCode = FETCH_TIMEOUT; + break; + case ECONNREFUSED: + case EHOSTDOWN: + fetchLastErrCode = FETCH_DOWN; + break; +default: + fetchLastErrCode = FETCH_UNKNOWN; + } + snprintf(fetchLastErrString, MAXERRSTRING, "%s", strerror(errno)); +} + + +/* + * Emit status message + */ +void +_fetch_info(const char *fmt, ...) +{ + va_list ap; + + va_start(ap, fmt); + vfprintf(stderr, fmt, ap); + va_end(ap); + fputc('\n', stderr); +} + + +/*** Network-related utility functions ***************************************/ + +/* + * Return the default port for a scheme + */ +int +_fetch_default_port(const char *scheme) +{ + struct servent *se; + + if ((se = getservbyname(scheme, "tcp")) != NULL) + return (ntohs(se->s_port)); + if (strcasecmp(scheme, SCHEME_FTP) == 0) + return (FTP_DEFAULT_PORT); + if (strcasecmp(scheme, SCHEME_HTTP) == 0) + return (HTTP_DEFAULT_PORT); + return (0); +} + +/* + * Return the default proxy port for a scheme + */ +int +_fetch_default_proxy_port(const char *scheme) +{ + if (strcasecmp(scheme, SCHEME_FTP) == 0) + return (FTP_DEFAULT_PROXY_PORT); + if (strcasecmp(scheme, SCHEME_HTTP) == 0) + return (HTTP_DEFAULT_PROXY_PORT); + return (0); +} + + +/* + * Create a connection for an existing descriptor. + */ +conn_t * +_fetch_reopen(int sd) +{ + conn_t *conn; + + /* allocate and fill connection structure */ + if ((conn = calloc(1, sizeof(*conn))) == NULL) + return (NULL); + conn->sd = sd; + ++conn->ref; + return (conn); +} + + +/* + * Bump a connection's reference count. + */ +conn_t * +_fetch_ref(conn_t *conn) +{ + + ++conn->ref; + return (conn); +} + + +/* + * Bind a socket to a specific local address + */ +int +_fetch_bind(int sd, int af, const char *addr) +{ + struct addrinfo hints, *res, *res0; + int err; + + memset(&hints, 0, sizeof(hints)); + hints.ai_family = af; + hints.ai_socktype = SOCK_STREAM; + hints.ai_protocol = 0; + if ((err = getaddrinfo(addr, NULL, &hints, &res0)) != 0) + return (-1); + for (res = res0; res; res = res->ai_next) + if (bind(sd, res->ai_addr, res->ai_addrlen) == 0) + return (0); + return (-1); +} + + +/* + * Establish a TCP connection to the specified port on the specified host. + */ +conn_t * +_fetch_connect(const char *host, int port, int af, int verbose) +{ + conn_t *conn; + char pbuf[10]; + const char *bindaddr; + struct addrinfo hints, *res, *res0; + int sd, err; + + DEBUG(fprintf(stderr, "---> %s:%d\n", host, port)); + + if (verbose) + _fetch_info("looking up %s", host); + + /* look up host name and set up socket address structure */ + snprintf(pbuf, sizeof(pbuf), "%d", port); + memset(&hints, 0, sizeof(hints)); + hints.ai_family = af; + hints.ai_socktype = SOCK_STREAM; + hints.ai_protocol = 0; + if ((err = getaddrinfo(host, pbuf, &hints, &res0)) != 0) { + _netdb_seterr(err); + return (NULL); + } + bindaddr = getenv("FETCH_BIND_ADDRESS"); + + if (verbose) + _fetch_info("connecting to %s:%d", host, port); + + /* try to connect */ + for (sd = -1, res = res0; res; sd = -1, res = res->ai_next) { + if ((sd = socket(res->ai_family, res->ai_socktype, + res->ai_protocol)) == -1) + continue; + if (bindaddr != NULL && *bindaddr != '\0' && + _fetch_bind(sd, res->ai_family, bindaddr) != 0) { + _fetch_info("failed to bind to '%s'", bindaddr); + close(sd); + continue; + } + if (connect(sd, res->ai_addr, res->ai_addrlen) == 0) + break; + close(sd); + } + freeaddrinfo(res0); + if (sd == -1) { + _fetch_syserr(); + return (NULL); + } + + if ((conn = _fetch_reopen(sd)) == NULL) { + _fetch_syserr(); + close(sd); + } + return (conn); +} + + +/* + * Enable SSL on a connection. + */ +int +_fetch_ssl(conn_t *conn, int verbose) +{ + +#ifdef WITH_SSL + /* Init the SSL library and context */ + if (!SSL_library_init()){ + fprintf(stderr, "SSL library init failed\n"); + return (-1); + } + + SSL_load_error_strings(); + + conn->ssl_meth = SSLv23_client_method(); + conn->ssl_ctx = SSL_CTX_new(conn->ssl_meth); + SSL_CTX_set_mode(conn->ssl_ctx, SSL_MODE_AUTO_RETRY); + + conn->ssl = SSL_new(conn->ssl_ctx); + if (conn->ssl == NULL){ + fprintf(stderr, "SSL context creation failed\n"); + return (-1); + } + SSL_set_fd(conn->ssl, conn->sd); + if (SSL_connect(conn->ssl) == -1){ + ERR_print_errors_fp(stderr); + return (-1); + } + + if (verbose) { + X509_NAME *name; + char *str; + + fprintf(stderr, "SSL connection established using %s\n", + SSL_get_cipher(conn->ssl)); + conn->ssl_cert = SSL_get_peer_certificate(conn->ssl); + name = X509_get_subject_name(conn->ssl_cert); + str = X509_NAME_oneline(name, 0, 0); + printf("Certificate subject: %s\n", str); + free(str); + name = X509_get_issuer_name(conn->ssl_cert); + str = X509_NAME_oneline(name, 0, 0); + printf("Certificate issuer: %s\n", str); + free(str); + } + + return (0); +#else + (void)conn; + (void)verbose; + fprintf(stderr, "SSL support disabled\n"); + return (-1); +#endif +} + + +/* + * Read a character from a connection w/ timeout + */ +ssize_t +_fetch_read(conn_t *conn, char *buf, size_t len) +{ + struct timeval now, timeout, wait; + fd_set readfds; + ssize_t rlen, total; + int r; + + if (fetchTimeout) { + FD_ZERO(&readfds); + gettimeofday(&timeout, NULL); + timeout.tv_sec += fetchTimeout; + } + + total = 0; + while (len > 0) { + while (fetchTimeout && !FD_ISSET(conn->sd, &readfds)) { + FD_SET(conn->sd, &readfds); + gettimeofday(&now, NULL); + wait.tv_sec = timeout.tv_sec - now.tv_sec; + wait.tv_usec = timeout.tv_usec - now.tv_usec; + if (wait.tv_usec < 0) { + wait.tv_usec += 1000000; + wait.tv_sec--; + } + if (wait.tv_sec < 0) { + errno = ETIMEDOUT; + _fetch_syserr(); + return (-1); + } + errno = 0; + r = select(conn->sd + 1, &readfds, NULL, NULL, &wait); + if (r == -1) { + if (errno == EINTR && fetchRestartCalls) + continue; + _fetch_syserr(); + return (-1); + } + } +#ifdef WITH_SSL + if (conn->ssl != NULL) + rlen = SSL_read(conn->ssl, buf, len); + else +#endif + rlen = read(conn->sd, buf, len); + if (rlen == 0) + break; + if (rlen < 0) { + if (errno == EINTR && fetchRestartCalls) + continue; + return (-1); + } + len -= rlen; + buf += rlen; + total += rlen; + } + return (total); +} + + +/* + * Read a line of text from a connection w/ timeout + */ +#define MIN_BUF_SIZE 1024 + +int +_fetch_getln(conn_t *conn) +{ + char *tmp; + size_t tmpsize; + ssize_t len; + char c; + + if (conn->buf == NULL) { + if ((conn->buf = malloc(MIN_BUF_SIZE)) == NULL) { + errno = ENOMEM; + return (-1); + } + conn->bufsize = MIN_BUF_SIZE; + } + + conn->buf[0] = '\0'; + conn->buflen = 0; + + do { + len = _fetch_read(conn, &c, 1); + if (len == -1) + return (-1); + if (len == 0) + break; + conn->buf[conn->buflen++] = c; + if (conn->buflen == conn->bufsize) { + tmp = conn->buf; + tmpsize = conn->bufsize * 2 + 1; + if ((tmp = realloc(tmp, tmpsize)) == NULL) { + errno = ENOMEM; + return (-1); + } + conn->buf = tmp; + conn->bufsize = tmpsize; + } + } while (c != '\n'); + + conn->buf[conn->buflen] = '\0'; + DEBUG(fprintf(stderr, "<<< %s", conn->buf)); + return (0); +} + + +/* + * Write to a connection w/ timeout + */ +ssize_t +_fetch_write(conn_t *conn, const char *buf, size_t len) +{ + struct iovec iov; + + iov.iov_base = __DECONST(char *, buf); + iov.iov_len = len; + return _fetch_writev(conn, &iov, 1); +} + +/* + * Write a vector to a connection w/ timeout + * Note: can modify the iovec. + */ +ssize_t +_fetch_writev(conn_t *conn, struct iovec *iov, int iovcnt) +{ + struct timeval now, timeout, wait; + fd_set writefds; + ssize_t wlen, total; + int r; + + if (fetchTimeout) { + FD_ZERO(&writefds); + gettimeofday(&timeout, NULL); + timeout.tv_sec += fetchTimeout; + } + + total = 0; + while (iovcnt > 0) { + while (fetchTimeout && !FD_ISSET(conn->sd, &writefds)) { + FD_SET(conn->sd, &writefds); + gettimeofday(&now, NULL); + wait.tv_sec = timeout.tv_sec - now.tv_sec; + wait.tv_usec = timeout.tv_usec - now.tv_usec; + if (wait.tv_usec < 0) { + wait.tv_usec += 1000000; + wait.tv_sec--; + } + if (wait.tv_sec < 0) { + errno = ETIMEDOUT; + _fetch_syserr(); + return (-1); + } + errno = 0; + r = select(conn->sd + 1, NULL, &writefds, NULL, &wait); + if (r == -1) { + if (errno == EINTR && fetchRestartCalls) + continue; + return (-1); + } + } + errno = 0; +#ifdef WITH_SSL + if (conn->ssl != NULL) + wlen = SSL_write(conn->ssl, + iov->iov_base, iov->iov_len); + else +#endif + wlen = writev(conn->sd, iov, iovcnt); + if (wlen == 0) { + /* we consider a short write a failure */ + errno = EPIPE; + _fetch_syserr(); + return (-1); + } + if (wlen < 0) { + if (errno == EINTR && fetchRestartCalls) + continue; + return (-1); + } + total += wlen; + while (iovcnt > 0 && wlen >= (ssize_t)iov->iov_len) { + wlen -= iov->iov_len; + iov++; + iovcnt--; + } + if (iovcnt > 0) { + iov->iov_len -= wlen; + iov->iov_base = __DECONST(char *, iov->iov_base) + wlen; + } + } + return (total); +} + + +/* + * Write a line of text to a connection w/ timeout + */ +int +_fetch_putln(conn_t *conn, const char *str, size_t len) +{ + struct iovec iov[2]; + int ret; + + DEBUG(fprintf(stderr, ">>> %s\n", str)); + iov[0].iov_base = __DECONST(char *, str); + iov[0].iov_len = len; + iov[1].iov_base = __DECONST(char *, ENDL); + iov[1].iov_len = sizeof(ENDL); + if (len == 0) + ret = _fetch_writev(conn, &iov[1], 1); + else + ret = _fetch_writev(conn, iov, 2); + if (ret == -1) + return (-1); + return (0); +} + + +/* + * Close connection + */ +int +_fetch_close(conn_t *conn) +{ + int ret; + + if (--conn->ref > 0) + return (0); + ret = close(conn->sd); + free(conn->buf); + free(conn); + return (ret); +} + + +/*** Directory-related utility functions *************************************/ + +int +_fetch_add_entry(struct url_ent **p, int *size, int *len, + const char *name, struct url_stat *us) +{ + struct url_ent *tmp; + + if (*p == NULL) { + *size = 0; + *len = 0; + } + + if (*len >= *size - 1) { + tmp = realloc(*p, (*size * 2 + 1) * sizeof(**p)); + if (tmp == NULL) { + errno = ENOMEM; + _fetch_syserr(); + return (-1); + } + *size = (*size * 2 + 1); + *p = tmp; + } + + tmp = *p + *len; + snprintf(tmp->name, PATH_MAX, "%s", name); + +#if __MOJOSETUP__ + memmove(&tmp->stat, us, sizeof(*us)); +#else + bcopy(us, &tmp->stat, sizeof(*us)); +#endif + + (*len)++; + (++tmp)->name[0] = 0; + + return (0); +} + + +/*** Authentication-related utility functions ********************************/ + +static const char * +_fetch_read_word(FILE *f) +{ + static char word[1024]; + + if (fscanf(f, " %1024s ", word) != 1) + return (NULL); + return (word); +} + +/* + * Get authentication data for a URL from .netrc + */ +int +_fetch_netrc_auth(struct url *url) +{ + char fn[PATH_MAX]; + const char *word; + char *p; + FILE *f; + + if ((p = getenv("NETRC")) != NULL) { + if (snprintf(fn, sizeof(fn), "%s", p) >= (int)sizeof(fn)) { + _fetch_info("$NETRC specifies a file name " + "longer than PATH_MAX"); + return (-1); + } + } else { + if ((p = getenv("HOME")) != NULL) { + struct passwd *pwd; + + if ((pwd = getpwuid(getuid())) == NULL || + (p = pwd->pw_dir) == NULL) + return (-1); + } + if (snprintf(fn, sizeof(fn), "%s/.netrc", p) >= (int)sizeof(fn)) + return (-1); + } + + if ((f = fopen(fn, "r")) == NULL) + return (-1); + while ((word = _fetch_read_word(f)) != NULL) { + if (strcmp(word, "default") == 0) { + DEBUG(_fetch_info("Using default .netrc settings")); + break; + } + if (strcmp(word, "machine") == 0 && + (word = _fetch_read_word(f)) != NULL && + strcasecmp(word, url->host) == 0) { + DEBUG(_fetch_info("Using .netrc settings for %s", word)); + break; + } + } + if (word == NULL) + goto ferr; + while ((word = _fetch_read_word(f)) != NULL) { + if (strcmp(word, "login") == 0) { + if ((word = _fetch_read_word(f)) == NULL) + goto ferr; + if (snprintf(url->user, sizeof(url->user), + "%s", word) > (int)sizeof(url->user)) { + _fetch_info("login name in .netrc is too long"); + url->user[0] = '\0'; + } + } else if (strcmp(word, "password") == 0) { + if ((word = _fetch_read_word(f)) == NULL) + goto ferr; + if (snprintf(url->pwd, sizeof(url->pwd), + "%s", word) > (int)sizeof(url->pwd)) { + _fetch_info("password in .netrc is too long"); + url->pwd[0] = '\0'; + } + } else if (strcmp(word, "account") == 0) { + if ((word = _fetch_read_word(f)) == NULL) + goto ferr; + /* XXX not supported! */ + } else { + break; + } + } + fclose(f); + return (0); + ferr: + fclose(f); + return (-1); +} + +#if __MOJOSETUP__ +int MOJOSETUP_vasprintf(char **strp, const char *fmt, va_list ap) +{ + int len = 0; + char dummy = 0; + va_list aq; + va_copy(aq, ap); + len = vsnprintf(&dummy, sizeof (dummy), fmt, aq); + va_end(aq); + *strp = (char *) xmalloc(len+1); + return vsnprintf(*strp, len+1, fmt, ap); +} // MOJOSETUP_vasprintf + +int MOJOSETUP_asprintf(char **strp, const char *fmt, ...) +{ + va_list ap; + int len = 0; + char dummy = 0; + va_start(ap, fmt); + len = vsnprintf(&dummy, sizeof (dummy), fmt, ap); + va_end(ap); + *strp = (char *) xmalloc(len+1); + va_start(ap, fmt); + len = vsnprintf(*strp, len+1, fmt, ap); + va_end(ap); + return len; +} // MOJOSETUP_asprintf + +time_t timegm_portable(struct tm *tm) +{ + char *envr = getenv("TZ"); + time_t retval; + setenv("TZ", "", 1); + tzset(); + retval = mktime(tm); + if (envr) + setenv("TZ", envr, 1); + else + unsetenv("TZ"); + tzset(); + return retval; +} // timegm_portable + +boolean ishexnumber(char ch) +{ + return ( ((ch >= '0') && (ch <= '9')) || + ((ch >= 'a') && (ch <= 'f')) || + ((ch >= 'A') && (ch <= 'F')) ); +} // ishexnumber + + +// This is a workaround because libfetch is a pain to make non-blocking. +// The ring buffer code is from my OpenAL implementation: +// http://icculus.org/al_osx/ + +typedef struct +{ + uint8 *buffer; + uint32 size; + uint32 write; + uint32 read; + uint32 used; +} MojoRing; + +static MojoRing *MojoRing_new(uint32 size) +{ + MojoRing *ring = (MojoRing *) xmalloc(sizeof (MojoRing)); + ring->buffer = (uint8 *) xmalloc(size); + ring->size = size; + ring->write = 0; + ring->read = 0; + ring->used = 0; + return ring; +} // MojoRing_new + +static void MojoRing_free(MojoRing *ring) +{ + free(ring->buffer); + free(ring); +} // MojoRing_free + +uint32 MojoRing_availableForGet(MojoRing *ring) +{ + return(ring->used); +} // MojoRing_size + +uint32 MojoRing_availableForPut(MojoRing *ring) +{ + return ring->size - ring->used; +} // MojoRing_size + +void MojoRing_put(MojoRing *ring, uint8 *data, uint32 size) +{ + uint32 cpy; + uint32 avail; + + if (!size) // just in case... + return; + + // Putting more data than ring buffer holds in total? Replace it all. + if (size > ring->size) + { + ring->write = 0; + ring->read = 0; + ring->used = ring->size; + memcpy(ring->buffer, data + (size - ring->size), ring->size); + return; + } // if + + // Buffer overflow? Push read pointer to oldest sample not overwritten... + avail = ring->size - ring->used; + if (size > avail) + { + ring->read += size - avail; + if (ring->read > ring->size) + ring->read -= ring->size; + } // if + + // Clip to end of buffer and copy first block... + cpy = ring->size - ring->write; + if (size < cpy) + cpy = size; + if (cpy) memcpy(ring->buffer + ring->write, data, cpy); + + // Wrap around to front of ring buffer and copy remaining data... + avail = size - cpy; + if (avail) memcpy(ring->buffer, data + cpy, avail); + + // Update write pointer... + ring->write += size; + if (ring->write > ring->size) + ring->write -= ring->size; + + ring->used += size; + if (ring->used > ring->size) + ring->used = ring->size; +} // MojoRing_put + +uint32 MojoRing_get(MojoRing *ring, uint8 *data, uint32 size) +{ + uint32 cpy; + uint32 avail = ring->used; + + // Clamp amount to read to available data... + if (size > avail) + size = avail; + + // Clip to end of buffer and copy first block... + cpy = ring->size - ring->read; + if (cpy > size) cpy = size; + if (cpy) memcpy(data, ring->buffer + ring->read, cpy); + + // Wrap around to front of ring buffer and copy remaining data... + avail = size - cpy; + if (avail) memcpy(data + cpy, ring->buffer, avail); + + // Update read pointer... + ring->read += size; + if (ring->read > ring->size) + ring->read -= ring->size; + + ring->used -= size; + + return(size); // may have been clamped if there wasn't enough data... +} // MojoRing_get + + + +typedef struct +{ + const char *url; + MojoRing *ring; + int64 bytes_read; + int64 length; + boolean error; + volatile boolean stop; + pthread_t tid; + pthread_mutex_t mutex; +} BlockingInfo; + +static void *blocking_thread(void *data) +{ + struct url_stat us; + uint8 buf[512]; + BlockingInfo *info = (BlockingInfo *) data; + + // !!! FIXME: This function can hang until the connect() or read() times + // !!! FIXME: out, without any way to stop it. ready() can deal with + // !!! FIXME: the blocking reads, but closing the socket has to wait + // !!! FIXME: for a pthread_join, and thus can block for a LONG time. + // !!! FIXME: This is only a problem if the user wants to cancel a + // !!! FIXME: download, but it needs to be addressed. Moving libfetch + // !!! FIXME: to non-blocking sockets will fix this and let me flush + // !!! FIXME: all this heroic coding, too. + + MojoInput *io = fetchXGetURL(info->url, &us, "rbp"); + if (io != NULL) + { + if (!info->stop) + info->length = io->length(io); + } // if + else + { + info->error = true; + info->stop = true; + } // else + + while (!info->stop) + { + uint8 *ptr = buf; + int64 br = io->read(io, buf, sizeof (buf)); + + if (br < 0) + info->stop = info->error = true; + else if (br == 0) + info->stop = true; + else + { + while (br > 0) + { + uint32 avail; + pthread_mutex_lock(&info->mutex); + avail = MojoRing_availableForPut(info->ring); + if (avail > br) + avail = br; + if (avail) + MojoRing_put(info->ring, ptr, avail); + pthread_mutex_unlock(&info->mutex); + ptr += avail; + br -= avail; + if (br > 0) + MojoPlatform_sleep(10); + } // while + } // else + } // while + + if (io != NULL) + io->close(io); + + return NULL; +} // blocking_thread + +static boolean MojoInput_blocking_ready(MojoInput *io) +{ + boolean retval = false; + BlockingInfo *info = (BlockingInfo *) io->opaque; + if (pthread_mutex_lock(&info->mutex) == 0) + { + retval = ( (info->stop) || (info->error) || + MojoRing_availableForGet(info->ring) ); + pthread_mutex_unlock(&info->mutex); + } // if + return retval; +} // MojoInput_blocking_ready + +static int64 MojoInput_blocking_read(MojoInput *io, void *buf, uint32 bufsize) +{ + BlockingInfo *info = (BlockingInfo *) io->opaque; + uint32 avail = 0; + while (!io->ready(io)) + MojoPlatform_sleep(100); + + if (pthread_mutex_lock(&info->mutex) != 0) + { + info->stop = info->error = true; // oh well. + return -1; + } // if + + avail = MojoRing_availableForGet(info->ring); + if (avail > 0) + { + if (avail > bufsize) + avail = bufsize; + MojoRing_get(info->ring, (uint8 *) buf, avail); + info->bytes_read += avail; + } // if + + pthread_mutex_unlock(&info->mutex); + + if (avail > 0) + return avail; + + if (info->error) + return -1; + + assert(info->stop); + return 0; +} // MojoInput_blocking_read + +static boolean MojoInput_blocking_seek(MojoInput *io, uint64 pos) +{ + return -1; +} // MojoInput_blocking_seek + +static int64 MojoInput_blocking_tell(MojoInput *io) +{ + BlockingInfo *info = (BlockingInfo *) io->opaque; + return info->bytes_read; +} // MojoInput_blocking_tell + +static int64 MojoInput_blocking_length(MojoInput *io) +{ + BlockingInfo *info = (BlockingInfo *) io->opaque; + return info->length; +} // MojoInput_blocking_length + +static MojoInput* MojoInput_blocking_duplicate(MojoInput *io) +{ + return NULL; +} // MojoInput_blocking_duplicate + +static void MojoInput_blocking_free(MojoInput *io) +{ + BlockingInfo *info = (BlockingInfo *) io->opaque; + MojoRing_free(info->ring); + pthread_mutex_destroy(&info->mutex); + free((void *) info->url); + free(info); + free(io); +} // MojoInput_blocking_free + +static void MojoInput_blocking_close(MojoInput *io) +{ + BlockingInfo *info = (BlockingInfo *) io->opaque; + info->stop = true; + pthread_join(info->tid, NULL); + MojoInput_blocking_free(io); +} // MojoInput_blocking_close + + + +MojoInput *MojoInput_newFromURL(const char *url) +{ + MojoInput *retval = NULL; + if (url != NULL) + { + BlockingInfo *info = (BlockingInfo *) xmalloc(sizeof (BlockingInfo)); + info->url = xstrdup(url); + info->ring = MojoRing_new(512 * 1024); + info->length = -1; + retval = (MojoInput *) xmalloc(sizeof (MojoInput)); + retval->ready = MojoInput_blocking_ready; + retval->read = MojoInput_blocking_read; + retval->seek = MojoInput_blocking_seek; + retval->tell = MojoInput_blocking_tell; + retval->length = MojoInput_blocking_length; + retval->duplicate = MojoInput_blocking_duplicate; + retval->close = MojoInput_blocking_close; + retval->opaque = info; + + if ( (pthread_mutex_init(&info->mutex, NULL) != 0) || + (pthread_create(&info->tid, NULL, blocking_thread, info) != 0) ) + { + MojoInput_blocking_free(retval); + retval = NULL; + } // if + } // if + return retval; +} // MojoInput_newFromURL +#endif + diff --git a/mk/linux/mojosetup/libfetch/common.h b/mk/linux/mojosetup/libfetch/common.h new file mode 100644 index 00000000..f1b1d66f --- /dev/null +++ b/mk/linux/mojosetup/libfetch/common.h @@ -0,0 +1,135 @@ +/*- + * Copyright (c) 1998-2004 Dag-Erling Coïdan Smørgrav + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer + * in this position and unchanged. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * $FreeBSD: src/lib/libfetch/common.h,v 1.28 2004/09/21 18:35:20 des Exp $ + */ + +#ifndef _COMMON_H_INCLUDED +#define _COMMON_H_INCLUDED + +#define FTP_DEFAULT_PORT 21 +#define HTTP_DEFAULT_PORT 80 +#define FTP_DEFAULT_PROXY_PORT 21 +#define HTTP_DEFAULT_PROXY_PORT 3128 + +#ifdef WITH_SSL +#include +#include +#include +#include +#include +#endif + +/* Connection */ +typedef struct fetchconn conn_t; +struct fetchconn { + int sd; /* socket descriptor */ + char *buf; /* buffer */ + size_t bufsize; /* buffer size */ + size_t buflen; /* length of buffer contents */ + int err; /* last protocol reply code */ +#ifdef WITH_SSL + SSL *ssl; /* SSL handle */ + SSL_CTX *ssl_ctx; /* SSL context */ + X509 *ssl_cert; /* server certificate */ + SSL_METHOD *ssl_meth; /* SSL method */ +#endif + int ref; /* reference count */ +}; + +/* Structure used for error message lists */ +struct fetcherr { + const int num; + const int cat; + const char *string; +}; + +/* for _fetch_writev */ +struct iovec; + +void _fetch_seterr(struct fetcherr *, int); +void _fetch_syserr(void); +#if __MOJOSETUP__ +void _fetch_info(const char *fmt, ...) ISPRINTF(1,2); +#else +void _fetch_info(const char *, ...); +#endif +int _fetch_default_port(const char *); +int _fetch_default_proxy_port(const char *); +int _fetch_bind(int, int, const char *); +conn_t *_fetch_connect(const char *, int, int, int); +conn_t *_fetch_reopen(int); +conn_t *_fetch_ref(conn_t *); +int _fetch_ssl(conn_t *, int); +ssize_t _fetch_read(conn_t *, char *, size_t); +int _fetch_getln(conn_t *); +ssize_t _fetch_write(conn_t *, const char *, size_t); +ssize_t _fetch_writev(conn_t *, struct iovec *, int); +int _fetch_putln(conn_t *, const char *, size_t); +int _fetch_close(conn_t *); +int _fetch_add_entry(struct url_ent **, int *, int *, + const char *, struct url_stat *); +int _fetch_netrc_auth(struct url *url); + +#define _ftp_seterr(n) _fetch_seterr(_ftp_errlist, n) +#define _http_seterr(n) _fetch_seterr(_http_errlist, n) +#define _netdb_seterr(n) _fetch_seterr(_netdb_errlist, n) +#define _url_seterr(n) _fetch_seterr(_url_errlist, n) + +#ifndef NDEBUG +#define DEBUG(x) do { if (fetchDebug) { x; } } while (0) +#else +#define DEBUG(x) do { } while (0) +#endif + +/* + * I don't really like exporting _http_request() and _ftp_request(), + * but the HTTP and FTP code occasionally needs to cross-call + * eachother, and this saves me from adding a lot of special-case code + * to handle those cases. + * + * Note that _*_request() free purl, which is way ugly but saves us a + * whole lot of trouble. + */ +#if __MOJOSETUP__ +MojoInput *_http_request(struct url *, const char *, + struct url_stat *, struct url *, const char *); +MojoInput *_ftp_request(struct url *, const char *, + struct url_stat *, struct url *, const char *); +#else +FILE *_http_request(struct url *, const char *, + struct url_stat *, struct url *, const char *); +FILE *_ftp_request(struct url *, const char *, + struct url_stat *, struct url *, const char *); +#endif + +/* + * Check whether a particular flag is set + */ +#define CHECK_FLAG(x) (flags && strchr(flags, (x))) + +#endif diff --git a/mk/linux/mojosetup/libfetch/fetch.c b/mk/linux/mojosetup/libfetch/fetch.c new file mode 100644 index 00000000..230bc58e --- /dev/null +++ b/mk/linux/mojosetup/libfetch/fetch.c @@ -0,0 +1,478 @@ +/*- + * Copyright (c) 1998-2004 Dag-Erling Coïdan Smørgrav + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer + * in this position and unchanged. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#if __MOJOSETUP__ +#include "mojosetup_libfetch.h" +#endif + + +#if !sun /* __MOJOSETUP__ Solaris support... */ +#include +__FBSDID("$FreeBSD: src/lib/libfetch/fetch.c,v 1.38 2004/09/21 18:35:20 des Exp $"); +#endif + +#include +#include + +#include +#include +#include +#include + +#include "fetch.h" +#include "common.h" + +auth_t fetchAuthMethod; +int fetchLastErrCode; +char fetchLastErrString[MAXERRSTRING]; +int fetchTimeout; +int fetchRestartCalls = 1; +int fetchDebug; + + +/*** Local data **************************************************************/ + +/* + * Error messages for parser errors + */ +#define URL_MALFORMED 1 +#define URL_BAD_SCHEME 2 +#define URL_BAD_PORT 3 +static struct fetcherr _url_errlist[] = { + { URL_MALFORMED, FETCH_URL, "Malformed URL" }, + { URL_BAD_SCHEME, FETCH_URL, "Invalid URL scheme" }, + { URL_BAD_PORT, FETCH_URL, "Invalid server port" }, + { -1, FETCH_UNKNOWN, "Unknown parser error" } +}; + + +/*** Public API **************************************************************/ + +/* + * Select the appropriate protocol for the URL scheme, and return a + * read-only stream connected to the document referenced by the URL. + * Also fill out the struct url_stat. + */ +#if __MOJOSETUP__ +MojoInput * +#else +FILE * +#endif +fetchXGet(struct url *URL, struct url_stat *us, const char *flags) +{ + int direct; + + direct = CHECK_FLAG('d'); + if (us != NULL) { + us->size = -1; + us->atime = us->mtime = 0; + } +#if __MOJOSETUP__ + #if SUPPORT_URL_FTP + if (strcasecmp(URL->scheme, SCHEME_FTP) == 0) + return (fetchXGetFTP(URL, us, flags)); + #endif + #if SUPPORT_URL_HTTP + if (strcasecmp(URL->scheme, SCHEME_HTTP) == 0) + return (fetchXGetHTTP(URL, us, flags)); + #endif + #if SUPPORT_URL_HTTPS + if (strcasecmp(URL->scheme, SCHEME_HTTPS) == 0) + return (fetchXGetHTTP(URL, us, flags)); + #endif +#else + if (strcasecmp(URL->scheme, SCHEME_FILE) == 0) + return (fetchXGetFile(URL, us, flags)); + else if (strcasecmp(URL->scheme, SCHEME_FTP) == 0) + return (fetchXGetFTP(URL, us, flags)); + else if (strcasecmp(URL->scheme, SCHEME_HTTP) == 0) + return (fetchXGetHTTP(URL, us, flags)); + else if (strcasecmp(URL->scheme, SCHEME_HTTPS) == 0) + return (fetchXGetHTTP(URL, us, flags)); +#endif + _url_seterr(URL_BAD_SCHEME); + return (NULL); +} + +/* + * Select the appropriate protocol for the URL scheme, and return a + * read-only stream connected to the document referenced by the URL. + */ +#if !__MOJOSETUP__ +FILE * +fetchGet(struct url *URL, const char *flags) +{ + return (fetchXGet(URL, NULL, flags)); +} + +/* + * Select the appropriate protocol for the URL scheme, and return a + * write-only stream connected to the document referenced by the URL. + */ +FILE * +fetchPut(struct url *URL, const char *flags) +{ + int direct; + + direct = CHECK_FLAG('d'); + if (strcasecmp(URL->scheme, SCHEME_FILE) == 0) + return (fetchPutFile(URL, flags)); + else if (strcasecmp(URL->scheme, SCHEME_FTP) == 0) + return (fetchPutFTP(URL, flags)); + else if (strcasecmp(URL->scheme, SCHEME_HTTP) == 0) + return (fetchPutHTTP(URL, flags)); + else if (strcasecmp(URL->scheme, SCHEME_HTTPS) == 0) + return (fetchPutHTTP(URL, flags)); + _url_seterr(URL_BAD_SCHEME); + return (NULL); +} + +/* + * Select the appropriate protocol for the URL scheme, and return the + * size of the document referenced by the URL if it exists. + */ +int +fetchStat(struct url *URL, struct url_stat *us, const char *flags) +{ + int direct; + + direct = CHECK_FLAG('d'); + if (us != NULL) { + us->size = -1; + us->atime = us->mtime = 0; + } + if (strcasecmp(URL->scheme, SCHEME_FILE) == 0) + return (fetchStatFile(URL, us, flags)); + else if (strcasecmp(URL->scheme, SCHEME_FTP) == 0) + return (fetchStatFTP(URL, us, flags)); + else if (strcasecmp(URL->scheme, SCHEME_HTTP) == 0) + return (fetchStatHTTP(URL, us, flags)); + else if (strcasecmp(URL->scheme, SCHEME_HTTPS) == 0) + return (fetchStatHTTP(URL, us, flags)); + _url_seterr(URL_BAD_SCHEME); + return (-1); +} + +/* + * Select the appropriate protocol for the URL scheme, and return a + * list of files in the directory pointed to by the URL. + */ +struct url_ent * +fetchList(struct url *URL, const char *flags) +{ + int direct; + + direct = CHECK_FLAG('d'); + if (strcasecmp(URL->scheme, SCHEME_FILE) == 0) + return (fetchListFile(URL, flags)); + else if (strcasecmp(URL->scheme, SCHEME_FTP) == 0) + return (fetchListFTP(URL, flags)); + else if (strcasecmp(URL->scheme, SCHEME_HTTP) == 0) + return (fetchListHTTP(URL, flags)); + else if (strcasecmp(URL->scheme, SCHEME_HTTPS) == 0) + return (fetchListHTTP(URL, flags)); + _url_seterr(URL_BAD_SCHEME); + return (NULL); +} +#endif + +/* + * Attempt to parse the given URL; if successful, call fetchXGet(). + */ +#if __MOJOSETUP__ +MojoInput * +#else +FILE * +#endif +fetchXGetURL(const char *URL, struct url_stat *us, const char *flags) +{ + struct url *u; +#if __MOJOSETUP__ + MojoInput *f = NULL; +#else + FILE *f; +#endif + + if ((u = fetchParseURL(URL)) == NULL) + return (NULL); + + f = fetchXGet(u, us, flags); + + fetchFreeURL(u); + return (f); +} + +/* + * Attempt to parse the given URL; if successful, call fetchGet(). + */ +#if !__MOJOSETUP__ +FILE * +fetchGetURL(const char *URL, const char *flags) +{ + return (fetchXGetURL(URL, NULL, flags)); +} + + +/* + * Attempt to parse the given URL; if successful, call fetchPut(). + */ +FILE * +fetchPutURL(const char *URL, const char *flags) +{ + struct url *u; + FILE *f; + + if ((u = fetchParseURL(URL)) == NULL) + return (NULL); + + f = fetchPut(u, flags); + + fetchFreeURL(u); + return (f); +} + +/* + * Attempt to parse the given URL; if successful, call fetchStat(). + */ +int +fetchStatURL(const char *URL, struct url_stat *us, const char *flags) +{ + struct url *u; + int s; + + if ((u = fetchParseURL(URL)) == NULL) + return (-1); + + s = fetchStat(u, us, flags); + + fetchFreeURL(u); + return (s); +} + +/* + * Attempt to parse the given URL; if successful, call fetchList(). + */ +struct url_ent * +fetchListURL(const char *URL, const char *flags) +{ + struct url *u; + struct url_ent *ue; + + if ((u = fetchParseURL(URL)) == NULL) + return (NULL); + + ue = fetchList(u, flags); + + fetchFreeURL(u); + return (ue); +} +#endif + +/* + * Make a URL + */ +struct url * +fetchMakeURL(const char *scheme, const char *host, int port, const char *doc, + const char *user, const char *pwd) +{ + struct url *u; + + if (!scheme || (!host && !doc)) { + _url_seterr(URL_MALFORMED); + return (NULL); + } + + if (port < 0 || port > 65535) { + _url_seterr(URL_BAD_PORT); + return (NULL); + } + + /* allocate struct url */ + if ((u = calloc(1, sizeof(*u))) == NULL) { + _fetch_syserr(); + return (NULL); + } + + if ((u->doc = strdup(doc ? doc : "/")) == NULL) { + _fetch_syserr(); + free(u); + return (NULL); + } + +#define seturl(x) snprintf(u->x, sizeof(u->x), "%s", x) + seturl(scheme); + seturl(host); + seturl(user); + seturl(pwd); +#undef seturl + u->port = port; + + return (u); +} + +/* + * Split an URL into components. URL syntax is: + * [method:/][/[user[:pwd]@]host[:port]/][document] + * This almost, but not quite, RFC1738 URL syntax. + */ +struct url * +fetchParseURL(const char *URL) +{ + char *doc; + const char *p, *q; + struct url *u; + int i; + + /* allocate struct url */ + if ((u = calloc(1, sizeof(*u))) == NULL) { + _fetch_syserr(); + return (NULL); + } + + /* scheme name */ + if ((p = strstr(URL, ":/"))) { + snprintf(u->scheme, URL_SCHEMELEN+1, + "%.*s", (int)(p - URL), URL); + URL = ++p; + /* + * Only one slash: no host, leave slash as part of document + * Two slashes: host follows, strip slashes + */ + if (URL[1] == '/') + URL = (p += 2); + } else { + p = URL; + } + if (!*URL || *URL == '/' || *URL == '.' || + (u->scheme[0] == '\0' && + strchr(URL, '/') == NULL && strchr(URL, ':') == NULL)) + goto nohost; + + p = strpbrk(URL, "/@"); + if (p && *p == '@') { + /* username */ + for (q = URL, i = 0; (*q != ':') && (*q != '@'); q++) + if (i < URL_USERLEN) + u->user[i++] = *q; + + /* password */ + if (*q == ':') + for (q++, i = 0; (*q != ':') && (*q != '@'); q++) + if (i < URL_PWDLEN) + u->pwd[i++] = *q; + + p++; + } else { + p = URL; + } + + /* hostname */ +#ifdef INET6 + if (*p == '[' && (q = strchr(p + 1, ']')) != NULL && + (*++q == '\0' || *q == '/' || *q == ':')) { + if ((i = q - p - 2) > MAXHOSTNAMELEN) + i = MAXHOSTNAMELEN; + strncpy(u->host, ++p, i); + p = q; + } else +#endif + for (i = 0; *p && (*p != '/') && (*p != ':'); p++) + if (i < MAXHOSTNAMELEN) + u->host[i++] = *p; + + /* port */ + if (*p == ':') { + for (q = ++p; *q && (*q != '/'); q++) + if (isdigit(*q)) + u->port = u->port * 10 + (*q - '0'); + else { + /* invalid port */ + _url_seterr(URL_BAD_PORT); + goto ouch; + } + p = q; + } + +nohost: + /* document */ + if (!*p) + p = "/"; + + if (strcasecmp(u->scheme, SCHEME_HTTP) == 0 || + strcasecmp(u->scheme, SCHEME_HTTPS) == 0) { + const char hexnums[] = "0123456789abcdef"; + + /* percent-escape whitespace. */ + if ((doc = malloc(strlen(p) * 3 + 1)) == NULL) { + _fetch_syserr(); + goto ouch; + } + u->doc = doc; + while (*p != '\0') { + if (!isspace(*p)) { + *doc++ = *p++; + } else { + *doc++ = '%'; + *doc++ = hexnums[((unsigned int)*p) >> 4]; + *doc++ = hexnums[((unsigned int)*p) & 0xf]; + p++; + } + } + *doc = '\0'; + } else if ((u->doc = strdup(p)) == NULL) { + _fetch_syserr(); + goto ouch; + } + + DEBUG(fprintf(stderr, + "scheme: [%s]\n" + "user: [%s]\n" + "password: [%s]\n" + "host: [%s]\n" + "port: [%d]\n" + "document: [%s]\n", + u->scheme, u->user, u->pwd, + u->host, u->port, u->doc)); + + return (u); + +ouch: + free(u); + return (NULL); +} + +/* + * Free a URL + */ +void +fetchFreeURL(struct url *u) +{ + free(u->doc); + free(u); +} + diff --git a/mk/linux/mojosetup/libfetch/fetch.h b/mk/linux/mojosetup/libfetch/fetch.h new file mode 100644 index 00000000..4486169c --- /dev/null +++ b/mk/linux/mojosetup/libfetch/fetch.h @@ -0,0 +1,184 @@ +/*- + * Copyright (c) 1998-2004 Dag-Erling Coïdan Smørgrav + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer + * in this position and unchanged. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * $FreeBSD: src/lib/libfetch/fetch.h,v 1.26 2004/09/21 18:35:20 des Exp $ + */ + +#ifndef _FETCH_H_INCLUDED +#define _FETCH_H_INCLUDED + +#if __MOJOSETUP__ +#define _LIBFETCH_VER3(ver) "libfetch/2.0 (MojoSetup " #ver ")" +#define _LIBFETCH_VER2(ver) _LIBFETCH_VER3(ver) +#define _LIBFETCH_VER _LIBFETCH_VER2(APPREV) +#ifndef MAXHOSTNAMELEN +#define MAXHOSTNAMELEN 256 +#endif +#ifndef __BEGIN_DECLS +#define __BEGIN_DECLS +#endif +#ifndef __END_DECLS +#define __END_DECLS +#endif +#else +#define _LIBFETCH_VER "libfetch/2.0" +#endif + +#define URL_SCHEMELEN 16 +#define URL_USERLEN 256 +#define URL_PWDLEN 256 + +struct url { + char scheme[URL_SCHEMELEN+1]; + char user[URL_USERLEN+1]; + char pwd[URL_PWDLEN+1]; + char host[MAXHOSTNAMELEN+1]; + int port; + char *doc; + off_t offset; + size_t length; +}; + +struct url_stat { + off_t size; + time_t atime; + time_t mtime; +}; + +struct url_ent { + char name[PATH_MAX]; + struct url_stat stat; +}; + +/* Recognized schemes */ +#define SCHEME_FTP "ftp" +#define SCHEME_HTTP "http" +#define SCHEME_HTTPS "https" +#define SCHEME_FILE "file" + +/* Error codes */ +#define FETCH_ABORT 1 +#define FETCH_AUTH 2 +#define FETCH_DOWN 3 +#define FETCH_EXISTS 4 +#define FETCH_FULL 5 +#define FETCH_INFO 6 +#define FETCH_MEMORY 7 +#define FETCH_MOVED 8 +#define FETCH_NETWORK 9 +#define FETCH_OK 10 +#define FETCH_PROTO 11 +#define FETCH_RESOLV 12 +#define FETCH_SERVER 13 +#define FETCH_TEMP 14 +#define FETCH_TIMEOUT 15 +#define FETCH_UNAVAIL 16 +#define FETCH_UNKNOWN 17 +#define FETCH_URL 18 +#define FETCH_VERBOSE 19 + +__BEGIN_DECLS + +/* FILE-specific functions */ +#if !__MOJOSETUP__ +FILE *fetchXGetFile(struct url *, struct url_stat *, const char *); +FILE *fetchGetFile(struct url *, const char *); +FILE *fetchPutFile(struct url *, const char *); +int fetchStatFile(struct url *, struct url_stat *, const char *); +struct url_ent *fetchListFile(struct url *, const char *); +#endif + +/* HTTP-specific functions */ +#if __MOJOSETUP__ +MojoInput *fetchXGetHTTP(struct url *, struct url_stat *, const char *); +#else +FILE *fetchXGetHTTP(struct url *, struct url_stat *, const char *); +FILE *fetchGetHTTP(struct url *, const char *); +FILE *fetchPutHTTP(struct url *, const char *); +int fetchStatHTTP(struct url *, struct url_stat *, const char *); +struct url_ent *fetchListHTTP(struct url *, const char *); +#endif + +/* FTP-specific functions */ +#if __MOJOSETUP__ +MojoInput *fetchXGetFTP(struct url *, struct url_stat *, const char *); +#else +FILE *fetchXGetFTP(struct url *, struct url_stat *, const char *); +FILE *fetchGetFTP(struct url *, const char *); +FILE *fetchPutFTP(struct url *, const char *); +int fetchStatFTP(struct url *, struct url_stat *, const char *); +struct url_ent *fetchListFTP(struct url *, const char *); +#endif + +/* Generic functions */ +#if __MOJOSETUP__ +MojoInput *fetchXGetURL(const char *, struct url_stat *, const char *); +#else +FILE *fetchXGetURL(const char *, struct url_stat *, const char *); +FILE *fetchGetURL(const char *, const char *); +FILE *fetchPutURL(const char *, const char *); +int fetchStatURL(const char *, struct url_stat *, const char *); +struct url_ent *fetchListURL(const char *, const char *); +#endif + +#if __MOJOSETUP__ +MojoInput *fetchXGet(struct url *, struct url_stat *, const char *); +#else +FILE *fetchXGet(struct url *, struct url_stat *, const char *); +FILE *fetchGet(struct url *, const char *); +FILE *fetchPut(struct url *, const char *); +int fetchStat(struct url *, struct url_stat *, const char *); +struct url_ent *fetchList(struct url *, const char *); +#endif + +/* URL parsing */ +struct url *fetchMakeURL(const char *, const char *, int, + const char *, const char *, const char *); +struct url *fetchParseURL(const char *); +void fetchFreeURL(struct url *); + +__END_DECLS + +/* Authentication */ +typedef int (*auth_t)(struct url *); +extern auth_t fetchAuthMethod; + +/* Last error code */ +extern int fetchLastErrCode; +#define MAXERRSTRING 256 +extern char fetchLastErrString[MAXERRSTRING]; + +/* I/O timeout */ +extern int fetchTimeout; + +/* Restart interrupted syscalls */ +extern int fetchRestartCalls; + +/* Extra verbosity */ +extern int fetchDebug; + +#endif diff --git a/mk/linux/mojosetup/libfetch/ftp.c b/mk/linux/mojosetup/libfetch/ftp.c new file mode 100644 index 00000000..aefc724c --- /dev/null +++ b/mk/linux/mojosetup/libfetch/ftp.c @@ -0,0 +1,1394 @@ +/*- + * Copyright (c) 1998-2004 Dag-Erling Coïdan Smørgrav + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer + * in this position and unchanged. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "mojosetup_libfetch.h" + +#if SUPPORT_URL_FTP + +#if !sun /* __MOJOSETUP__ Solaris support... */ +#include +__FBSDID("$FreeBSD: src/lib/libfetch/ftp.c,v 1.96 2007/04/22 22:33:29 njl Exp $"); +#endif + +/* + * Portions of this code were taken from or based on ftpio.c: + * + * ---------------------------------------------------------------------------- + * "THE BEER-WARE LICENSE" (Revision 42): + * wrote this file. As long as you retain this notice you + * can do whatever you want with this stuff. If we meet some day, and you think + * this stuff is worth it, you can buy me a beer in return. Poul-Henning Kamp + * ---------------------------------------------------------------------------- + * + * Major Changelog: + * + * Dag-Erling Coïdan Smørgrav + * 9 Jun 1998 + * + * Incorporated into libfetch + * + * Jordan K. Hubbard + * 17 Jan 1996 + * + * Turned inside out. Now returns xfers as new file ids, not as a special + * `state' of FTP_t + * + * $ftpioId: ftpio.c,v 1.30 1998/04/11 07:28:53 phk Exp $ + * + */ + +#include +#include +#include + +#include +#if !sun /* __MOJOSETUP__ Solaris support... */ +#include +#endif +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "fetch.h" +#include "common.h" +#include "ftperr.h" + +#define FTP_ANONYMOUS_USER "anonymous" + +#define FTP_CONNECTION_ALREADY_OPEN 125 +#define FTP_OPEN_DATA_CONNECTION 150 +#define FTP_OK 200 +#define FTP_FILE_STATUS 213 +#define FTP_SERVICE_READY 220 +#define FTP_TRANSFER_COMPLETE 226 +#define FTP_PASSIVE_MODE 227 +#define FTP_LPASSIVE_MODE 228 +#define FTP_EPASSIVE_MODE 229 +#define FTP_LOGGED_IN 230 +#define FTP_FILE_ACTION_OK 250 +#define FTP_DIRECTORY_CREATED 257 /* multiple meanings */ +#define FTP_FILE_CREATED 257 /* multiple meanings */ +#define FTP_WORKING_DIRECTORY 257 /* multiple meanings */ +#define FTP_NEED_PASSWORD 331 +#define FTP_NEED_ACCOUNT 332 +#define FTP_FILE_OK 350 +#define FTP_SYNTAX_ERROR 500 +#define FTP_PROTOCOL_ERROR 999 + +static struct url cached_host; +static conn_t *cached_connection; + +#define isftpreply(foo) (isdigit(foo[0]) && isdigit(foo[1]) \ + && isdigit(foo[2]) \ + && (foo[3] == ' ' || foo[3] == '\0')) +#define isftpinfo(foo) (isdigit(foo[0]) && isdigit(foo[1]) \ + && isdigit(foo[2]) && foo[3] == '-') + +/* + * Translate IPv4 mapped IPv6 address to IPv4 address + */ +static void +unmappedaddr(struct sockaddr_in6 *sin6) +{ + struct sockaddr_in *sin4; + u_int32_t addr; + int port; + + if (sin6->sin6_family != AF_INET6 || + !IN6_IS_ADDR_V4MAPPED(&sin6->sin6_addr)) + return; + sin4 = (struct sockaddr_in *)sin6; + addr = *(u_int32_t *)&sin6->sin6_addr.s6_addr[12]; + port = sin6->sin6_port; + memset(sin4, 0, sizeof(struct sockaddr_in)); + sin4->sin_addr.s_addr = addr; + sin4->sin_port = port; + sin4->sin_family = AF_INET; +#if __MOJOSETUP__ +#if FREEBSD + sin4->sin_len = sizeof(struct sockaddr_in); +#endif +#endif +} + +/* + * Get server response + */ +static int +_ftp_chkerr(conn_t *conn) +{ + if (_fetch_getln(conn) == -1) { + _fetch_syserr(); + return (-1); + } + if (isftpinfo(conn->buf)) { + while (conn->buflen && !isftpreply(conn->buf)) { + if (_fetch_getln(conn) == -1) { + _fetch_syserr(); + return (-1); + } + } + } + + while (conn->buflen && isspace(conn->buf[conn->buflen - 1])) + conn->buflen--; + conn->buf[conn->buflen] = '\0'; + + if (!isftpreply(conn->buf)) { + _ftp_seterr(FTP_PROTOCOL_ERROR); + return (-1); + } + + conn->err = (conn->buf[0] - '0') * 100 + + (conn->buf[1] - '0') * 10 + + (conn->buf[2] - '0'); + + return (conn->err); +} + +/* + * Send a command and check reply + */ +#if __MOJOSETUP__ +static int _ftp_cmd(conn_t *conn, const char *fmt, ...) ISPRINTF(2,3); +#endif +static int +_ftp_cmd(conn_t *conn, const char *fmt, ...) +{ + va_list ap; + size_t len; + char *msg; + int r; + + va_start(ap, fmt); + len = vasprintf(&msg, fmt, ap); + va_end(ap); + + if (msg == NULL) { + errno = ENOMEM; + _fetch_syserr(); + return (-1); + } + + r = _fetch_putln(conn, msg, len); + free(msg); + + if (r == -1) { + _fetch_syserr(); + return (-1); + } + + return (_ftp_chkerr(conn)); +} + +/* + * Return a pointer to the filename part of a path + */ +static const char * +_ftp_filename(const char *file, int *len, int *type) +{ + const char *s; + + if ((s = strrchr(file, '/')) == NULL) + s = file; + else + s = s + 1; + *len = strlen(s); + if (*len > 7 && strncmp(s + *len - 7, ";type=", 6) == 0) { + *type = s[*len - 1]; + *len -= 7; + } else { + *type = '\0'; + } + return (s); +} + +/* + * Get current working directory from the reply to a CWD, PWD or CDUP + * command. + */ +static int +_ftp_pwd(conn_t *conn, char *pwd, size_t pwdlen) +{ + char *src, *dst, *end; + int q; + + if (conn->err != FTP_WORKING_DIRECTORY && + conn->err != FTP_FILE_ACTION_OK) + return (FTP_PROTOCOL_ERROR); + end = conn->buf + conn->buflen; + src = conn->buf + 4; + if (src >= end || *src++ != '"') + return (FTP_PROTOCOL_ERROR); + for (q = 0, dst = pwd; src < end && pwdlen--; ++src) { + if (!q && *src == '"') + q = 1; + else if (q && *src != '"') + break; + else if (q) + *dst++ = '"', q = 0; + else + *dst++ = *src; + } + if (!pwdlen) + return (FTP_PROTOCOL_ERROR); + *dst = '\0'; +#if 0 + DEBUG(fprintf(stderr, "pwd: [%s]\n", pwd)); +#endif + return (FTP_OK); +} + +/* + * Change working directory to the directory that contains the specified + * file. + */ +static int +_ftp_cwd(conn_t *conn, const char *file) +{ + const char *beg, *end; + char pwd[PATH_MAX]; + int e, i, len; + + /* If no slashes in name, no need to change dirs. */ + if ((end = strrchr(file, '/')) == NULL) + return (0); + if ((e = _ftp_cmd(conn, "PWD")) != FTP_WORKING_DIRECTORY || + (e = _ftp_pwd(conn, pwd, sizeof(pwd))) != FTP_OK) { + _ftp_seterr(e); + return (-1); + } + for (;;) { + len = strlen(pwd); + + /* Look for a common prefix between PWD and dir to fetch. */ + for (i = 0; i <= len && i <= end - file; ++i) + if (pwd[i] != file[i]) + break; +#if 0 + DEBUG(fprintf(stderr, "have: [%.*s|%s]\n", i, pwd, pwd + i)); + DEBUG(fprintf(stderr, "want: [%.*s|%s]\n", i, file, file + i)); +#endif + /* Keep going up a dir until we have a matching prefix. */ + if (pwd[i] == '\0' && (file[i - 1] == '/' || file[i] == '/')) + break; + if ((e = _ftp_cmd(conn, "CDUP")) != FTP_FILE_ACTION_OK || + (e = _ftp_cmd(conn, "PWD")) != FTP_WORKING_DIRECTORY || + (e = _ftp_pwd(conn, pwd, sizeof(pwd))) != FTP_OK) { + _ftp_seterr(e); + return (-1); + } + } + +#ifdef FTP_COMBINE_CWDS + /* Skip leading slashes, even "////". */ + for (beg = file + i; beg < end && *beg == '/'; ++beg, ++i) + /* nothing */ ; + + /* If there is no trailing dir, we're already there. */ + if (beg >= end) + return (0); + + /* Change to the directory all in one chunk (e.g., foo/bar/baz). */ + e = _ftp_cmd(conn, "CWD %.*s", (int)(end - beg), beg); + if (e == FTP_FILE_ACTION_OK) + return (0); +#endif /* FTP_COMBINE_CWDS */ + + /* That didn't work so go back to legacy behavior (multiple CWDs). */ + for (beg = file + i; beg < end; beg = file + i + 1) { + while (*beg == '/') + ++beg, ++i; + for (++i; file + i < end && file[i] != '/'; ++i) + /* nothing */ ; +#if __MOJOSETUP__ + e = _ftp_cmd(conn, "CWD %.*s", (int) (file + i - beg), beg); +#else + e = _ftp_cmd(conn, "CWD %.*s", file + i - beg, beg); +#endif + if (e != FTP_FILE_ACTION_OK) { + _ftp_seterr(e); + return (-1); + } + } + return (0); +} + +/* + * Set transfer mode and data type + */ +static int +_ftp_mode_type(conn_t *conn, int mode, int type) +{ + int e; + + switch (mode) { + case 0: + case 's': + mode = 'S'; + case 'S': + break; + default: + return (FTP_PROTOCOL_ERROR); + } + if ((e = _ftp_cmd(conn, "MODE %c", mode)) != FTP_OK) { + if (mode == 'S') { + /* + * Stream mode is supposed to be the default - so + * much so that some servers not only do not + * support any other mode, but do not support the + * MODE command at all. + * + * If "MODE S" fails, it is unlikely that we + * previously succeeded in setting a different + * mode. Therefore, we simply hope that the + * server is already in the correct mode, and + * silently ignore the failure. + */ + } else { + return (e); + } + } + + switch (type) { + case 0: + case 'i': + type = 'I'; + case 'I': + break; + case 'a': + type = 'A'; + case 'A': + break; + case 'd': + type = 'D'; + case 'D': + /* can't handle yet */ + default: + return (FTP_PROTOCOL_ERROR); + } + if ((e = _ftp_cmd(conn, "TYPE %c", type)) != FTP_OK) + return (e); + + return (FTP_OK); +} + +/* + * Request and parse file stats + */ +static int +_ftp_stat(conn_t *conn, const char *file, struct url_stat *us) +{ + char *ln; + const char *filename; + int filenamelen, type; + struct tm tm; + time_t t; + int e; + + us->size = -1; + us->atime = us->mtime = 0; + + filename = _ftp_filename(file, &filenamelen, &type); + + if ((e = _ftp_mode_type(conn, 0, type)) != FTP_OK) { + _ftp_seterr(e); + return (-1); + } + + e = _ftp_cmd(conn, "SIZE %.*s", filenamelen, filename); + if (e != FTP_FILE_STATUS) { + _ftp_seterr(e); + return (-1); + } + for (ln = conn->buf + 4; *ln && isspace(*ln); ln++) + /* nothing */ ; + for (us->size = 0; *ln && isdigit(*ln); ln++) + us->size = us->size * 10 + *ln - '0'; + if (*ln && !isspace(*ln)) { + _ftp_seterr(FTP_PROTOCOL_ERROR); + us->size = -1; + return (-1); + } + if (us->size == 0) + us->size = -1; + DEBUG(fprintf(stderr, "size: [%lld]\n", (long long)us->size)); + + e = _ftp_cmd(conn, "MDTM %.*s", filenamelen, filename); + if (e != FTP_FILE_STATUS) { + _ftp_seterr(e); + return (-1); + } + for (ln = conn->buf + 4; *ln && isspace(*ln); ln++) + /* nothing */ ; + switch (strspn(ln, "0123456789")) { + case 14: + break; + case 15: + ln++; + ln[0] = '2'; + ln[1] = '0'; + break; + default: + _ftp_seterr(FTP_PROTOCOL_ERROR); + return (-1); + } + if (sscanf(ln, "%04d%02d%02d%02d%02d%02d", + &tm.tm_year, &tm.tm_mon, &tm.tm_mday, + &tm.tm_hour, &tm.tm_min, &tm.tm_sec) != 6) { + _ftp_seterr(FTP_PROTOCOL_ERROR); + return (-1); + } + tm.tm_mon--; + tm.tm_year -= 1900; + tm.tm_isdst = -1; + t = timegm(&tm); + if (t == (time_t)-1) + t = time(NULL); + us->mtime = t; + us->atime = t; + DEBUG(fprintf(stderr, + "last modified: [%04d-%02d-%02d %02d:%02d:%02d]\n", + tm.tm_year + 1900, tm.tm_mon + 1, tm.tm_mday, + tm.tm_hour, tm.tm_min, tm.tm_sec)); + return (0); +} + +/* + * I/O functions for FTP + */ +struct ftpio { + conn_t *cconn; /* Control connection */ + conn_t *dconn; /* Data connection */ + int dir; /* Direction */ + int eof; /* EOF reached */ + int err; /* Error code */ +#if __MOJOSETUP__ + int64 bytes_read; + int64 length; +#endif +}; + + + +#if !__MOJOSETUP__ +static int _ftp_readfn(void *, char *, int); +static int _ftp_writefn(void *, const char *, int); +static fpos_t _ftp_seekfn(void *, fpos_t, int); +static int _ftp_closefn(void *); +#endif + + +#if __MOJOSETUP__ +static boolean MojoInput_ftp_ready(MojoInput *v) +{ + boolean retval = true; + struct ftpio *io = (struct ftpio *)v->opaque; + if (io->dconn != NULL) + { + fd_set rfds; + struct timeval tv; + tv.tv_sec = tv.tv_usec = 0; + FD_ZERO(&rfds); + FD_SET(io->dconn->sd, &rfds); + retval = (select(io->dconn->sd+1, &rfds, NULL, NULL, &tv) > 0); + } // if + return retval; +} +static int64 MojoInput_ftp_tell(MojoInput *v) +{ + struct ftpio *io = (struct ftpio *)v->opaque; + return io->bytes_read; +} +static int64 MojoInput_ftp_length(MojoInput *v) +{ + struct ftpio *io = (struct ftpio *)v->opaque; + return io->length; +} +static MojoInput* MojoInput_ftp_duplicate(MojoInput *v) +{ + return NULL; // !!! FIXME: fatal? +} +#endif + + +#if __MOJOSETUP__ +static int64 MojoInput_ftp_read(MojoInput *v, void *buf, uint32 len) +#else +static int +_ftp_readfn(void *v, char *buf, int len) +#endif +{ + struct ftpio *io; + int r; + +#if __MOJOSETUP__ + io = (struct ftpio *)v->opaque; +#else + io = (struct ftpio *)v; + if (io == NULL) { + errno = EBADF; + return (-1); + } +#endif + if (io->cconn == NULL || io->dconn == NULL || io->dir == O_WRONLY) { + errno = EBADF; + return (-1); + } + if (io->err) { + errno = io->err; + return (-1); + } + if (io->eof) + return (0); + r = _fetch_read(io->dconn, buf, len); +#if __MOJOSETUP__ + if (r > 0) { + io->bytes_read += r; + return (r); + } +#else + if (r > 0) + return (r); +#endif + if (r == 0) { + io->eof = 1; + return (0); + } + if (errno != EINTR) + io->err = errno; + return (-1); +} + +#if !__MOJOSETUP__ +static int +_ftp_writefn(void *v, const char *buf, int len) +{ + struct ftpio *io; + int w; + + io = (struct ftpio *)v; + if (io == NULL) { + errno = EBADF; + return (-1); + } + if (io->cconn == NULL || io->dconn == NULL || io->dir == O_RDONLY) { + errno = EBADF; + return (-1); + } + if (io->err) { + errno = io->err; + return (-1); + } + w = _fetch_write(io->dconn, buf, len); + if (w >= 0) + return (w); + if (errno != EINTR) + io->err = errno; + return (-1); +} +#endif + +#if __MOJOSETUP__ +static boolean MojoInput_ftp_seek(MojoInput *v, uint64 pos) +#else +static fpos_t +_ftp_seekfn(void *v, fpos_t pos __unused, int whence __unused) +#endif +{ + struct ftpio *io; + +#if __MOJOSETUP__ + io = (struct ftpio *)v->opaque; +#else + io = (struct ftpio *)v; + if (io == NULL) { + errno = EBADF; + return (-1); + } +#endif + errno = ESPIPE; + return (-1); +} + +static int +_ftp_closefn(void *v) +{ + struct ftpio *io; + int r; + +#if __MOJOSETUP__ + io = (struct ftpio *) ((MojoInput *)v)->opaque; +#else + io = (struct ftpio *)v; + if (io == NULL) { + errno = EBADF; + return (-1); + } +#endif + if (io->dir == -1) + return (0); + if (io->cconn == NULL || io->dconn == NULL) { + errno = EBADF; + return (-1); + } + _fetch_close(io->dconn); + io->dir = -1; + io->dconn = NULL; + DEBUG(fprintf(stderr, "Waiting for final status\n")); + r = _ftp_chkerr(io->cconn); + if (io->cconn == cached_connection && io->cconn->ref == 1) + cached_connection = NULL; + _fetch_close(io->cconn); + free(io); + +#if __MOJOSETUP__ + free(v); +#endif + + return (r == FTP_TRANSFER_COMPLETE) ? 0 : -1; +} + +#if __MOJOSETUP__ +static void MojoInput_ftp_close(MojoInput *v) +{ + _ftp_closefn(v); +} +#endif + + +#if __MOJOSETUP__ +static MojoInput * +#else +static FILE * +#endif +_ftp_setup(conn_t *cconn, conn_t *dconn, int mode) +{ + struct ftpio *io; +#if __MOJOSETUP__ + MojoInput *f = NULL; +#else + FILE *f; +#endif + + if (cconn == NULL || dconn == NULL) + return (NULL); + if ((io = malloc(sizeof(*io))) == NULL) + return (NULL); + io->cconn = cconn; + io->dconn = dconn; + io->dir = mode; + io->eof = io->err = 0; +#if __MOJOSETUP__ + io->bytes_read = 0; + io->length = -1; + f = (MojoInput *) xmalloc(sizeof (MojoInput)); + f->ready = MojoInput_ftp_ready; + f->read = MojoInput_ftp_read; + f->seek = MojoInput_ftp_seek; + f->tell = MojoInput_ftp_tell; + f->length = MojoInput_ftp_length; + f->duplicate = MojoInput_ftp_duplicate; + f->close = MojoInput_ftp_close; + f->opaque = io; +#else + f = funopen(io, _ftp_readfn, _ftp_writefn, _ftp_seekfn, _ftp_closefn); + if (f == NULL) + free(io); +#endif + + return (f); +} + +/* + * Transfer file + */ +#if __MOJOSETUP__ +static MojoInput * +#else +static FILE * +#endif +_ftp_transfer(conn_t *conn, const char *oper, const char *file, + int mode, off_t offset, const char *flags) +{ + struct sockaddr_storage sa; + struct sockaddr_in6 *sin6; + struct sockaddr_in *sin4; + const char *bindaddr; + const char *filename; + int filenamelen, type; + int low, pasv, verbose; + int e, sd = -1; + socklen_t l; + char *s; +#if __MOJOSETUP__ + MojoInput *df = NULL; +#else + FILE *df; +#endif + + /* check flags */ + low = CHECK_FLAG('l'); + pasv = CHECK_FLAG('p'); + verbose = CHECK_FLAG('v'); + + /* passive mode */ + if (!pasv) + pasv = ((s = getenv("FTP_PASSIVE_MODE")) != NULL && + strncasecmp(s, "no", 2) != 0); + + /* isolate filename */ + filename = _ftp_filename(file, &filenamelen, &type); + + /* set transfer mode and data type */ + if ((e = _ftp_mode_type(conn, 0, type)) != FTP_OK) + goto ouch; + + /* find our own address, bind, and listen */ + l = sizeof(sa); + if (getsockname(conn->sd, (struct sockaddr *)&sa, &l) == -1) + goto sysouch; + if (sa.ss_family == AF_INET6) + unmappedaddr((struct sockaddr_in6 *)&sa); + + /* open data socket */ + if ((sd = socket(sa.ss_family, SOCK_STREAM, IPPROTO_TCP)) == -1) { + _fetch_syserr(); + return (NULL); + } + + if (pasv) { + u_char addr[64]; + char *ln, *p; + unsigned int i; + int port; + + /* send PASV command */ + if (verbose) + _fetch_info("setting passive mode"); + switch (sa.ss_family) { + case AF_INET: + if ((e = _ftp_cmd(conn, "PASV")) != FTP_PASSIVE_MODE) + goto ouch; + break; + case AF_INET6: + if ((e = _ftp_cmd(conn, "EPSV")) != FTP_EPASSIVE_MODE) { + if (e == -1) + goto ouch; + if ((e = _ftp_cmd(conn, "LPSV")) != + FTP_LPASSIVE_MODE) + goto ouch; + } + break; + default: + e = FTP_PROTOCOL_ERROR; /* XXX: error code should be prepared */ + goto ouch; + } + + /* + * Find address and port number. The reply to the PASV command + * is IMHO the one and only weak point in the FTP protocol. + */ + ln = conn->buf; + switch (e) { + case FTP_PASSIVE_MODE: + case FTP_LPASSIVE_MODE: + for (p = ln + 3; *p && !isdigit(*p); p++) + /* nothing */ ; + if (!*p) { + e = FTP_PROTOCOL_ERROR; + goto ouch; + } + l = (e == FTP_PASSIVE_MODE ? 6 : 21); + for (i = 0; *p && i < l; i++, p++) + addr[i] = strtol(p, &p, 10); + if (i < l) { + e = FTP_PROTOCOL_ERROR; + goto ouch; + } + break; + case FTP_EPASSIVE_MODE: + for (p = ln + 3; *p && *p != '('; p++) + /* nothing */ ; + if (!*p) { + e = FTP_PROTOCOL_ERROR; + goto ouch; + } + ++p; + if (sscanf(p, "%c%c%c%d%c", &addr[0], &addr[1], &addr[2], + &port, &addr[3]) != 5 || + addr[0] != addr[1] || + addr[0] != addr[2] || addr[0] != addr[3]) { + e = FTP_PROTOCOL_ERROR; + goto ouch; + } + break; + } + + /* seek to required offset */ + if (offset) + if (_ftp_cmd(conn, "REST %lu", (u_long)offset) != FTP_FILE_OK) + goto sysouch; + + /* construct sockaddr for data socket */ + l = sizeof(sa); + if (getpeername(conn->sd, (struct sockaddr *)&sa, &l) == -1) + goto sysouch; + if (sa.ss_family == AF_INET6) + unmappedaddr((struct sockaddr_in6 *)&sa); + switch (sa.ss_family) { + case AF_INET6: + sin6 = (struct sockaddr_in6 *)&sa; + if (e == FTP_EPASSIVE_MODE) + sin6->sin6_port = htons(port); + else { +#if __MOJOSETUP__ + memmove((char *)&sin6->sin6_addr, addr + 2, 16); + memmove((char *)&sin6->sin6_port, addr + 19, 2); +#else + bcopy(addr + 2, (char *)&sin6->sin6_addr, 16); + bcopy(addr + 19, (char *)&sin6->sin6_port, 2); +#endif + } + break; + case AF_INET: + sin4 = (struct sockaddr_in *)&sa; + if (e == FTP_EPASSIVE_MODE) + sin4->sin_port = htons(port); + else { +#if __MOJOSETUP__ + memmove((char *)&sin4->sin_addr, addr, 4); + memmove((char *)&sin4->sin_port, addr + 4, 2); +#else + bcopy(addr, (char *)&sin4->sin_addr, 4); + bcopy(addr + 4, (char *)&sin4->sin_port, 2); +#endif + } + break; + default: + e = FTP_PROTOCOL_ERROR; /* XXX: error code should be prepared */ + break; + } + + /* connect to data port */ + if (verbose) + _fetch_info("opening data connection"); + bindaddr = getenv("FETCH_BIND_ADDRESS"); + if (bindaddr != NULL && *bindaddr != '\0' && + _fetch_bind(sd, sa.ss_family, bindaddr) != 0) + goto sysouch; +#if __MOJOSETUP__ + { + int socklen = sizeof (struct sockaddr_in); + if (sa.ss_family == AF_INET6) + socklen = sizeof (struct sockaddr_in6); + if (connect(sd, (struct sockaddr *)&sa, socklen) == -1) + goto sysouch; + } +#else + if (connect(sd, (struct sockaddr *)&sa, sa.ss_len) == -1) + goto sysouch; +#endif + + /* make the server initiate the transfer */ + if (verbose) + _fetch_info("initiating transfer"); + e = _ftp_cmd(conn, "%s %.*s", oper, filenamelen, filename); + if (e != FTP_CONNECTION_ALREADY_OPEN && e != FTP_OPEN_DATA_CONNECTION) + goto ouch; + + } else { + u_int32_t a; + u_short p; + int arg, d; + char *ap; + char hname[INET6_ADDRSTRLEN]; + +#if __MOJOSETUP__ + arg = 0; +#if FREEBSD + switch (sa.ss_family) { + case AF_INET6: + ((struct sockaddr_in6 *)&sa)->sin6_port = 0; +#ifdef IPV6_PORTRANGE + arg = low ? IPV6_PORTRANGE_DEFAULT : IPV6_PORTRANGE_HIGH; + if (setsockopt(sd, IPPROTO_IPV6, IPV6_PORTRANGE, + (char *)&arg, sizeof(arg)) == -1) + goto sysouch; +#endif + break; + case AF_INET: + ((struct sockaddr_in *)&sa)->sin_port = 0; + arg = low ? IP_PORTRANGE_DEFAULT : IP_PORTRANGE_HIGH; + if (setsockopt(sd, IPPROTO_IP, IP_PORTRANGE, + (char *)&arg, sizeof(arg)) == -1) + goto sysouch; + break; + } +#endif +#endif + + if (verbose) + _fetch_info("binding data socket"); +#if __MOJOSETUP__ + { + int socklen = sizeof (struct sockaddr_in); + if (sa.ss_family == AF_INET6) + socklen = sizeof (struct sockaddr_in6); + if (bind(sd, (struct sockaddr *)&sa, socklen) == -1) + goto sysouch; + } +#else + if (bind(sd, (struct sockaddr *)&sa, sa.ss_len) == -1) + goto sysouch; +#endif + if (listen(sd, 1) == -1) + goto sysouch; + + /* find what port we're on and tell the server */ + if (getsockname(sd, (struct sockaddr *)&sa, &l) == -1) + goto sysouch; + switch (sa.ss_family) { + case AF_INET: + sin4 = (struct sockaddr_in *)&sa; + a = ntohl(sin4->sin_addr.s_addr); + p = ntohs(sin4->sin_port); + e = _ftp_cmd(conn, "PORT %d,%d,%d,%d,%d,%d", + (a >> 24) & 0xff, (a >> 16) & 0xff, + (a >> 8) & 0xff, a & 0xff, + (p >> 8) & 0xff, p & 0xff); + break; + case AF_INET6: +#define UC(b) (((int)b)&0xff) + e = -1; + sin6 = (struct sockaddr_in6 *)&sa; + sin6->sin6_scope_id = 0; +#if __MOJOSETUP__ + if (getnameinfo((struct sockaddr *)&sa, sizeof (struct sockaddr_in6), +#else + if (getnameinfo((struct sockaddr *)&sa, sa.ss_len, +#endif + hname, sizeof(hname), + NULL, 0, NI_NUMERICHOST) == 0) { + e = _ftp_cmd(conn, "EPRT |%d|%s|%d|", 2, hname, + htons(sin6->sin6_port)); + if (e == -1) + goto ouch; + } + if (e != FTP_OK) { + ap = (char *)&sin6->sin6_addr; + e = _ftp_cmd(conn, + "LPRT %d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d", + 6, 16, + UC(ap[0]), UC(ap[1]), UC(ap[2]), UC(ap[3]), + UC(ap[4]), UC(ap[5]), UC(ap[6]), UC(ap[7]), + UC(ap[8]), UC(ap[9]), UC(ap[10]), UC(ap[11]), + UC(ap[12]), UC(ap[13]), UC(ap[14]), UC(ap[15]), + 2, + (ntohs(sin6->sin6_port) >> 8) & 0xff, + ntohs(sin6->sin6_port) & 0xff); + } + break; + default: + e = FTP_PROTOCOL_ERROR; /* XXX: error code should be prepared */ + goto ouch; + } + if (e != FTP_OK) + goto ouch; + + /* seek to required offset */ + if (offset) + if (_ftp_cmd(conn, "REST %ju", (uintmax_t)offset) != FTP_FILE_OK) + goto sysouch; + + /* make the server initiate the transfer */ + if (verbose) + _fetch_info("initiating transfer"); + e = _ftp_cmd(conn, "%s %.*s", oper, filenamelen, filename); + if (e != FTP_CONNECTION_ALREADY_OPEN && e != FTP_OPEN_DATA_CONNECTION) + goto ouch; + + /* accept the incoming connection and go to town */ + if ((d = accept(sd, NULL, NULL)) == -1) + goto sysouch; + close(sd); + sd = d; + } + + if ((df = _ftp_setup(conn, _fetch_reopen(sd), mode)) == NULL) + goto sysouch; + return (df); + +sysouch: + _fetch_syserr(); + if (sd >= 0) + close(sd); + return (NULL); + +ouch: + if (e != -1) + _ftp_seterr(e); + if (sd >= 0) + close(sd); + return (NULL); +} + +/* + * Authenticate + */ +static int +_ftp_authenticate(conn_t *conn, struct url *url, struct url *purl) +{ + const char *user, *pwd, *logname; + char pbuf[MAXHOSTNAMELEN + MAXLOGNAME + 1]; + int e, len; + + /* XXX FTP_AUTH, and maybe .netrc */ + + /* send user name and password */ + if (url->user[0] == '\0') + _fetch_netrc_auth(url); + user = url->user; + if (*user == '\0') + user = getenv("FTP_LOGIN"); + if (user == NULL || *user == '\0') + user = FTP_ANONYMOUS_USER; + if (purl && url->port == _fetch_default_port(url->scheme)) + e = _ftp_cmd(conn, "USER %s@%s", user, url->host); + else if (purl) + e = _ftp_cmd(conn, "USER %s@%s@%d", user, url->host, url->port); + else + e = _ftp_cmd(conn, "USER %s", user); + + /* did the server request a password? */ + if (e == FTP_NEED_PASSWORD) { + pwd = url->pwd; + if (*pwd == '\0') + pwd = getenv("FTP_PASSWORD"); + if (pwd == NULL || *pwd == '\0') { + if ((logname = getlogin()) == 0) + logname = FTP_ANONYMOUS_USER; + if ((len = snprintf(pbuf, MAXLOGNAME + 1, "%s@", logname)) < 0) + len = 0; + else if (len > MAXLOGNAME) + len = MAXLOGNAME; + gethostname(pbuf + len, sizeof(pbuf) - len); + pwd = pbuf; + } + e = _ftp_cmd(conn, "PASS %s", pwd); + } + + return (e); +} + +/* + * Log on to FTP server + */ +static conn_t * +_ftp_connect(struct url *url, struct url *purl, const char *flags) +{ + conn_t *conn; + int e, direct, verbose; +#ifdef INET6 + int af = AF_UNSPEC; +#else + int af = AF_INET; +#endif + + direct = CHECK_FLAG('d'); + verbose = CHECK_FLAG('v'); + if (CHECK_FLAG('4')) + af = AF_INET; + else if (CHECK_FLAG('6')) + af = AF_INET6; + + if (direct) + purl = NULL; + + /* check for proxy */ + if (purl) { + /* XXX proxy authentication! */ + conn = _fetch_connect(purl->host, purl->port, af, verbose); + } else { + /* no proxy, go straight to target */ + conn = _fetch_connect(url->host, url->port, af, verbose); + purl = NULL; + } + + /* check connection */ + if (conn == NULL) + /* _fetch_connect() has already set an error code */ + return (NULL); + + /* expect welcome message */ + if ((e = _ftp_chkerr(conn)) != FTP_SERVICE_READY) + goto fouch; + + /* authenticate */ + if ((e = _ftp_authenticate(conn, url, purl)) != FTP_LOGGED_IN) + goto fouch; + + /* TODO: Request extended features supported, if any (RFC 3659). */ + + /* done */ + return (conn); + +fouch: + if (e != -1) + _ftp_seterr(e); + _fetch_close(conn); + return (NULL); +} + +/* + * Disconnect from server + */ +static void +_ftp_disconnect(conn_t *conn) +{ + (void)_ftp_cmd(conn, "QUIT"); + if (conn == cached_connection && conn->ref == 1) + cached_connection = NULL; + _fetch_close(conn); +} + +/* + * Check if we're already connected + */ +static int +_ftp_isconnected(struct url *url) +{ + return (cached_connection + && (strcmp(url->host, cached_host.host) == 0) + && (strcmp(url->user, cached_host.user) == 0) + && (strcmp(url->pwd, cached_host.pwd) == 0) + && (url->port == cached_host.port)); +} + +/* + * Check the cache, reconnect if no luck + */ +static conn_t * +_ftp_cached_connect(struct url *url, struct url *purl, const char *flags) +{ + conn_t *conn; + int e; + + /* set default port */ + if (!url->port) + url->port = _fetch_default_port(url->scheme); + + /* try to use previously cached connection */ + if (_ftp_isconnected(url)) { + e = _ftp_cmd(cached_connection, "NOOP"); + if (e == FTP_OK || e == FTP_SYNTAX_ERROR) + return (_fetch_ref(cached_connection)); + } + + /* connect to server */ + if ((conn = _ftp_connect(url, purl, flags)) == NULL) + return (NULL); + if (cached_connection) + _ftp_disconnect(cached_connection); + cached_connection = _fetch_ref(conn); + memcpy(&cached_host, url, sizeof(*url)); + return (conn); +} + +/* + * Check the proxy settings + */ +static struct url * +_ftp_get_proxy(const char *flags) +{ + struct url *purl; + char *p; + + if (flags != NULL && strchr(flags, 'd') != NULL) + return (NULL); + if (((p = getenv("FTP_PROXY")) || (p = getenv("ftp_proxy")) || + (p = getenv("HTTP_PROXY")) || (p = getenv("http_proxy"))) && + *p && (purl = fetchParseURL(p)) != NULL) { + if (!*purl->scheme) { + if (getenv("FTP_PROXY") || getenv("ftp_proxy")) + strcpy(purl->scheme, SCHEME_FTP); + else + strcpy(purl->scheme, SCHEME_HTTP); + } + if (!purl->port) + purl->port = _fetch_default_proxy_port(purl->scheme); + if (strcasecmp(purl->scheme, SCHEME_FTP) == 0 || + strcasecmp(purl->scheme, SCHEME_HTTP) == 0) + return (purl); + fetchFreeURL(purl); + } + return (NULL); +} + +/* + * Process an FTP request + */ +#if __MOJOSETUP__ +MojoInput * +#else +FILE * +#endif +_ftp_request(struct url *url, const char *op, struct url_stat *us, + struct url *purl, const char *flags) +{ + conn_t *conn; + int oflag; + + /* check if we should use HTTP instead */ +#if !__MOJOSETUP__ + if (purl && strcasecmp(purl->scheme, SCHEME_HTTP) == 0) { + if (strcmp(op, "STAT") == 0) + return (_http_request(url, "HEAD", us, purl, flags)); + else if (strcmp(op, "RETR") == 0) + return (_http_request(url, "GET", us, purl, flags)); + /* + * Our HTTP code doesn't support PUT requests yet, so try + * a direct connection. + */ + } +#endif + + /* connect to server */ + conn = _ftp_cached_connect(url, purl, flags); + if (purl) + fetchFreeURL(purl); + if (conn == NULL) + return (NULL); + + /* change directory */ + if (_ftp_cwd(conn, url->doc) == -1) + return (NULL); + + /* stat file */ + if (us && _ftp_stat(conn, url->doc, us) == -1 + && fetchLastErrCode != FETCH_PROTO + && fetchLastErrCode != FETCH_UNAVAIL) + return (NULL); + + /* just a stat */ +#if __MOJOSETUP__ + if (strcmp(op, "STAT") == 0) + return (MojoInput *)1; /* bogus return value */ +#else + if (strcmp(op, "STAT") == 0) + return (FILE *)1; /* bogus return value */ +#endif + if (strcmp(op, "STOR") == 0 || strcmp(op, "APPE") == 0) + oflag = O_WRONLY; + else + oflag = O_RDONLY; + + /* initiate the transfer */ +#if __MOJOSETUP__ +{ + MojoInput *retval = _ftp_transfer(conn, op, url->doc, oflag, url->offset, flags); + if ((retval != NULL) && (us != NULL)) + { + struct ftpio *io = (struct ftpio *)retval->opaque; + io->length = us->size; + } // if + return retval; +} +#else + return (_ftp_transfer(conn, op, url->doc, oflag, url->offset, flags)); +#endif +} + +/* + * Get and stat file + */ +#if __MOJOSETUP__ +MojoInput * +#else +FILE * +#endif +fetchXGetFTP(struct url *url, struct url_stat *us, const char *flags) +{ + return (_ftp_request(url, "RETR", us, _ftp_get_proxy(flags), flags)); +} + +/* + * Get file + */ +#if !__MOJOSETUP__ +FILE * +fetchGetFTP(struct url *url, const char *flags) +{ + return (fetchXGetFTP(url, NULL, flags)); +} + +/* + * Put file + */ +FILE * +fetchPutFTP(struct url *url, const char *flags) +{ + + return (_ftp_request(url, CHECK_FLAG('a') ? "APPE" : "STOR", NULL, + _ftp_get_proxy(flags), flags)); +} + +/* + * Get file stats + */ +int +fetchStatFTP(struct url *url, struct url_stat *us, const char *flags) +{ + FILE *f; + + f = _ftp_request(url, "STAT", us, _ftp_get_proxy(flags), flags); + if (f == NULL) + return (-1); + return (0); +} + +/* + * List a directory + */ +struct url_ent * +fetchListFTP(struct url *url __unused, const char *flags __unused) +{ + warnx("fetchListFTP(): not implemented"); + return (NULL); +} + +#endif +#endif + diff --git a/mk/linux/mojosetup/libfetch/ftp.errors b/mk/linux/mojosetup/libfetch/ftp.errors new file mode 100644 index 00000000..9ce0277f --- /dev/null +++ b/mk/linux/mojosetup/libfetch/ftp.errors @@ -0,0 +1,47 @@ +# $FreeBSD: src/lib/libfetch/ftp.errors,v 1.6 2002/10/30 06:06:16 des Exp $ +# +# This list is taken from RFC 959. +# It probably needs a going over. +# +110 OK Restart marker reply +120 TEMP Service ready in a few minutes +125 OK Data connection already open; transfer starting +150 OK File status okay; about to open data connection +200 OK Command okay +202 PROTO Command not implemented, superfluous at this site +211 INFO System status, or system help reply +212 INFO Directory status +213 INFO File status +214 INFO Help message +215 INFO Set system type +220 OK Service ready for new user +221 OK Service closing control connection +225 OK Data connection open; no transfer in progress +226 OK Requested file action successful +227 OK Entering Passive Mode +229 OK Entering Extended Passive Mode +230 OK User logged in, proceed +250 OK Requested file action okay, completed +257 OK File/directory created +331 AUTH User name okay, need password +332 AUTH Need account for login +350 OK Requested file action pending further information +421 DOWN Service not available, closing control connection +425 NETWORK Can't open data connection +426 ABORT Connection closed; transfer aborted +450 UNAVAIL File unavailable (e.g., file busy) +451 SERVER Requested action aborted: local error in processing +452 FULL Insufficient storage space in system +500 PROTO Syntax error, command unrecognized +501 PROTO Syntax error in parameters or arguments +502 PROTO Command not implemented +503 PROTO Bad sequence of commands +504 PROTO Command not implemented for that parameter +530 AUTH Not logged in +532 AUTH Need account for storing files +535 PROTO Bug in MediaHawk Video Kernel FTP server +550 UNAVAIL File unavailable (e.g., file not found, no access) +551 PROTO Requested action aborted. Page type unknown +552 FULL Exceeded storage allocation +553 EXISTS File name not allowed +999 PROTO Protocol error diff --git a/mk/linux/mojosetup/libfetch/ftperr.h b/mk/linux/mojosetup/libfetch/ftperr.h new file mode 100644 index 00000000..e4800a05 --- /dev/null +++ b/mk/linux/mojosetup/libfetch/ftperr.h @@ -0,0 +1,46 @@ +static struct fetcherr _ftp_errlist[] = { + { 110, FETCH_OK, "Restart marker reply" }, + { 120, FETCH_TEMP, "Service ready in a few minutes" }, + { 125, FETCH_OK, "Data connection already open; transfer starting" }, + { 150, FETCH_OK, "File status okay; about to open data connection" }, + { 200, FETCH_OK, "Command okay" }, + { 202, FETCH_PROTO, "Command not implemented, superfluous at this site" }, + { 211, FETCH_INFO, "System status, or system help reply" }, + { 212, FETCH_INFO, "Directory status" }, + { 213, FETCH_INFO, "File status" }, + { 214, FETCH_INFO, "Help message" }, + { 215, FETCH_INFO, "Set system type" }, + { 220, FETCH_OK, "Service ready for new user" }, + { 221, FETCH_OK, "Service closing control connection" }, + { 225, FETCH_OK, "Data connection open; no transfer in progress" }, + { 226, FETCH_OK, "Requested file action successful" }, + { 227, FETCH_OK, "Entering Passive Mode" }, + { 229, FETCH_OK, "Entering Extended Passive Mode" }, + { 230, FETCH_OK, "User logged in, proceed" }, + { 250, FETCH_OK, "Requested file action okay, completed" }, + { 257, FETCH_OK, "File/directory created" }, + { 331, FETCH_AUTH, "User name okay, need password" }, + { 332, FETCH_AUTH, "Need account for login" }, + { 350, FETCH_OK, "Requested file action pending further information" }, + { 421, FETCH_DOWN, "Service not available, closing control connection" }, + { 425, FETCH_NETWORK, "Can't open data connection" }, + { 426, FETCH_ABORT, "Connection closed; transfer aborted" }, + { 450, FETCH_UNAVAIL, "File unavailable (e.g., file busy)" }, + { 451, FETCH_SERVER, "Requested action aborted: local error in processing" }, + { 452, FETCH_FULL, "Insufficient storage space in system" }, + { 500, FETCH_PROTO, "Syntax error, command unrecognized" }, + { 501, FETCH_PROTO, "Syntax error in parameters or arguments" }, + { 502, FETCH_PROTO, "Command not implemented" }, + { 503, FETCH_PROTO, "Bad sequence of commands" }, + { 504, FETCH_PROTO, "Command not implemented for that parameter" }, + { 530, FETCH_AUTH, "Not logged in" }, + { 532, FETCH_AUTH, "Need account for storing files" }, + { 535, FETCH_PROTO, "Bug in MediaHawk Video Kernel FTP server" }, + { 550, FETCH_UNAVAIL, "File unavailable (e.g., file not found, no access)" }, + { 551, FETCH_PROTO, "Requested action aborted. Page type unknown" }, + { 552, FETCH_FULL, "Exceeded storage allocation" }, + { 553, FETCH_EXISTS, "File name not allowed" }, + { 999, FETCH_PROTO, "Protocol error" }, + { -1, FETCH_UNKNOWN, "Unknown FTP error" } +}; + diff --git a/mk/linux/mojosetup/libfetch/http.c b/mk/linux/mojosetup/libfetch/http.c new file mode 100644 index 00000000..87205d8e --- /dev/null +++ b/mk/linux/mojosetup/libfetch/http.c @@ -0,0 +1,1373 @@ +/*- + * Copyright (c) 2000-2004 Dag-Erling Coïdan Smørgrav + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer + * in this position and unchanged. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#if __MOJOSETUP__ +#include "mojosetup_libfetch.h" +#endif + +#if SUPPORT_URL_HTTP || SUPPORT_URL_HTTPS + +#if !sun /* __MOJOSETUP__ Solaris support... */ +#include +__FBSDID("$FreeBSD: src/lib/libfetch/http.c,v 1.77 2005/08/24 12:28:05 des Exp $"); +#endif + +/* + * The following copyright applies to the base64 code: + * + *- + * Copyright 1997 Massachusetts Institute of Technology + * + * Permission to use, copy, modify, and distribute this software and + * its documentation for any purpose and without fee is hereby + * granted, provided that both the above copyright notice and this + * permission notice appear in all copies, that both the above + * copyright notice and this permission notice appear in all + * supporting documentation, and that the name of M.I.T. not be used + * in advertising or publicity pertaining to distribution of the + * software without specific, written prior permission. M.I.T. makes + * no representations about the suitability of this software for any + * purpose. It is provided "as is" without express or implied + * warranty. + * + * THIS SOFTWARE IS PROVIDED BY M.I.T. ``AS IS''. M.I.T. DISCLAIMS + * ALL EXPRESS OR IMPLIED WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT + * SHALL M.I.T. BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF + * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include +#include + +#include +#if !sun /* __MOJOSETUP__ Solaris support... */ +#include +#endif +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +#include "fetch.h" +#include "common.h" +#include "httperr.h" + +/* Maximum number of redirects to follow */ +#define MAX_REDIRECT 5 + +/* Symbolic names for reply codes we care about */ +#define HTTP_OK 200 +#define HTTP_PARTIAL 206 +#define HTTP_MOVED_PERM 301 +#define HTTP_MOVED_TEMP 302 +#define HTTP_SEE_OTHER 303 +#define HTTP_TEMP_REDIRECT 307 +#define HTTP_NEED_AUTH 401 +#define HTTP_NEED_PROXY_AUTH 407 +#define HTTP_BAD_RANGE 416 +#define HTTP_PROTOCOL_ERROR 999 + +#define HTTP_REDIRECT(xyz) ((xyz) == HTTP_MOVED_PERM \ + || (xyz) == HTTP_MOVED_TEMP \ + || (xyz) == HTTP_TEMP_REDIRECT \ + || (xyz) == HTTP_SEE_OTHER) + +#define HTTP_ERROR(xyz) ((xyz) > 400 && (xyz) < 599) + + +/***************************************************************************** + * I/O functions for decoding chunked streams + */ + +struct httpio +{ + conn_t *conn; /* connection */ + int chunked; /* chunked mode */ + char *buf; /* chunk buffer */ + size_t bufsize; /* size of chunk buffer */ + ssize_t buflen; /* amount of data currently in buffer */ + int bufpos; /* current read offset in buffer */ + int eof; /* end-of-file flag */ + int error; /* error flag */ + size_t chunksize; /* remaining size of current chunk */ +#ifndef NDEBUG + size_t total; +#endif + +#if __MOJOSETUP__ + int64 bytes_read; + int64 length; +#endif +}; + + +#if __MOJOSETUP__ +static boolean MojoInput_http_ready(MojoInput *v) +{ + boolean retval = false; + struct httpio *io = (struct httpio *)v->opaque; + if (io->conn != NULL) + { + fd_set rfds; + struct timeval tv; + tv.tv_sec = tv.tv_usec = 0; + FD_ZERO(&rfds); + FD_SET(io->conn->sd, &rfds); + retval = (select(io->conn->sd+1, &rfds, NULL, NULL, &tv) > 0); + } // if + return retval; +} +static boolean MojoInput_http_seek(MojoInput *v, uint64 pos) +{ + return -1; +} +static int64 MojoInput_http_tell(MojoInput *v) +{ + struct httpio *io = (struct httpio *)v->opaque; + return io->bytes_read; +} +static int64 MojoInput_http_length(MojoInput *v) +{ + struct httpio *io = (struct httpio *)v->opaque; + return io->length; +} +static MojoInput* MojoInput_http_duplicate(MojoInput *v) +{ + return NULL; // !!! FIXME: fatal? +} +#endif + + +/* + * Get next chunk header + */ +static int +_http_new_chunk(struct httpio *io) +{ + char *p; + + if (_fetch_getln(io->conn) == -1) + return (-1); + + if (io->conn->buflen < 2 || !ishexnumber(*io->conn->buf)) + return (-1); + + for (p = io->conn->buf; *p && !isspace(*p); ++p) { + if (*p == ';') + break; + if (!ishexnumber(*p)) + return (-1); + if (isdigit(*p)) { + io->chunksize = io->chunksize * 16 + + *p - '0'; + } else { + io->chunksize = io->chunksize * 16 + + 10 + tolower(*p) - 'a'; + } + } + +#ifndef NDEBUG + if (fetchDebug) { + io->total += io->chunksize; + if (io->chunksize == 0) + fprintf(stderr, "%s(): end of last chunk\n", __func__); + else + fprintf(stderr, "%s(): new chunk: %lu (%lu)\n", + __func__, (unsigned long)io->chunksize, + (unsigned long)io->total); + } +#endif + + return (io->chunksize); +} + +/* + * Grow the input buffer to at least len bytes + */ +static inline int +_http_growbuf(struct httpio *io, size_t len) +{ + char *tmp; + + if (io->bufsize >= len) + return (0); + + if ((tmp = realloc(io->buf, len)) == NULL) + return (-1); + io->buf = tmp; + io->bufsize = len; + return (0); +} + +/* + * Fill the input buffer, do chunk decoding on the fly + */ +static int +_http_fillbuf(struct httpio *io, size_t len) +{ + if (io->error) + return (-1); + if (io->eof) + return (0); + + if (io->chunked == 0) { + if (_http_growbuf(io, len) == -1) + return (-1); + if ((io->buflen = _fetch_read(io->conn, io->buf, len)) == -1) { + io->error = 1; + return (-1); + } + io->bufpos = 0; + return (io->buflen); + } + + if (io->chunksize == 0) { + switch (_http_new_chunk(io)) { + case -1: + io->error = 1; + return (-1); + case 0: + io->eof = 1; + return (0); + } + } + + if (len > io->chunksize) + len = io->chunksize; + if (_http_growbuf(io, len) == -1) + return (-1); + if ((io->buflen = _fetch_read(io->conn, io->buf, len)) == -1) { + io->error = 1; + return (-1); + } + io->chunksize -= io->buflen; + + if (io->chunksize == 0) { + char endl[2]; + + if (_fetch_read(io->conn, endl, 2) != 2 || + endl[0] != '\r' || endl[1] != '\n') + return (-1); + } + + io->bufpos = 0; + + return (io->buflen); +} + +/* + * Read function + */ +#if __MOJOSETUP__ +static int64 MojoInput_http_read(MojoInput *v, void *buf, uint32 len) +#else +static int +_http_readfn(void *v, char *buf, int len) +#endif +{ +#if __MOJOSETUP__ + struct httpio *io = (struct httpio *)v->opaque; +#else + struct httpio *io = (struct httpio *)v; +#endif + int l, pos; + + if (io->error) + return (-1); + if (io->eof) + return (0); + + for (pos = 0; len > 0; pos += l, len -= l) { + /* empty buffer */ + if (!io->buf || io->bufpos == io->buflen) + if (_http_fillbuf(io, len) < 1) + break; + l = io->buflen - io->bufpos; + if (len < l) + l = len; +#if __MOJOSETUP__ + memmove(((char *)buf) + pos, io->buf + io->bufpos, l); +#else + bcopy(io->buf + io->bufpos, buf + pos, l); +#endif + io->bufpos += l; +#if __MOJOSETUP__ + io->bytes_read += l; +#endif + } + + if (!pos && io->error) + return (-1); + return (pos); +} + +/* + * Write function + */ +#if !__MOJOSETUP__ +static int +_http_writefn(void *v, const char *buf, int len) +{ + struct httpio *io = (struct httpio *)v; + + return (_fetch_write(io->conn, buf, len)); +} +#endif + +/* + * Close function + */ +static int +_http_closefn(void *v) +{ +#if __MOJOSETUP__ + struct httpio *io = (struct httpio *) ((MojoInput *)v)->opaque; +#else + struct httpio *io = (struct httpio *)v; +#endif + int r; + + r = _fetch_close(io->conn); + if (io->buf) + free(io->buf); + free(io); +#if __MOJOSETUP__ + free(v); +#endif + return (r); +} + +#if __MOJOSETUP__ +static void MojoInput_http_close(MojoInput *v) +{ + _http_closefn(v); +} +#endif + +/* + * Wrap a file descriptor up + */ +#if __MOJOSETUP__ +static MojoInput * +#else +static FILE * +#endif +_http_funopen(conn_t *conn, int chunked) +{ + struct httpio *io; +#if __MOJOSETUP__ + MojoInput *f = NULL; +#else + FILE *f; +#endif + + if ((io = calloc(1, sizeof(*io))) == NULL) { + _fetch_syserr(); + return (NULL); + } + io->conn = conn; + io->chunked = chunked; +#if __MOJOSETUP__ + io->bytes_read = 0; + io->length = -1; + f = (MojoInput *) xmalloc(sizeof (MojoInput)); + f->ready = MojoInput_http_ready; + f->read = MojoInput_http_read; + f->seek = MojoInput_http_seek; + f->tell = MojoInput_http_tell; + f->length = MojoInput_http_length; + f->duplicate = MojoInput_http_duplicate; + f->close = MojoInput_http_close; + f->opaque = io; +#else + f = funopen(io, _http_readfn, _http_writefn, NULL, _http_closefn); + if (f == NULL) { + _fetch_syserr(); + free(io); + return (NULL); + } +#endif + return (f); +} + + +/***************************************************************************** + * Helper functions for talking to the server and parsing its replies + */ + +/* Header types */ +typedef enum { + hdr_syserror = -2, + hdr_error = -1, + hdr_end = 0, + hdr_unknown = 1, + hdr_content_length, + hdr_content_range, + hdr_last_modified, + hdr_location, + hdr_transfer_encoding, + hdr_www_authenticate +} hdr_t; + +/* Names of interesting headers */ +static struct { + hdr_t num; + const char *name; +} hdr_names[] = { + { hdr_content_length, "Content-Length" }, + { hdr_content_range, "Content-Range" }, + { hdr_last_modified, "Last-Modified" }, + { hdr_location, "Location" }, + { hdr_transfer_encoding, "Transfer-Encoding" }, + { hdr_www_authenticate, "WWW-Authenticate" }, + { hdr_unknown, NULL }, +}; + +/* + * Send a formatted line; optionally echo to terminal + */ +#if __MOJOSETUP__ +static int _http_cmd(conn_t *conn, const char *fmt, ...) ISPRINTF(2,3); +#endif +static int +_http_cmd(conn_t *conn, const char *fmt, ...) +{ + va_list ap; + size_t len; + char *msg; + int r; + + va_start(ap, fmt); + len = vasprintf(&msg, fmt, ap); + va_end(ap); + + if (msg == NULL) { + errno = ENOMEM; + _fetch_syserr(); + return (-1); + } + + r = _fetch_putln(conn, msg, len); + free(msg); + + if (r == -1) { + _fetch_syserr(); + return (-1); + } + + return (0); +} + +/* + * Get and parse status line + */ +static int +_http_get_reply(conn_t *conn) +{ + char *p; + + if (_fetch_getln(conn) == -1) + return (-1); + /* + * A valid status line looks like "HTTP/m.n xyz reason" where m + * and n are the major and minor protocol version numbers and xyz + * is the reply code. + * Unfortunately, there are servers out there (NCSA 1.5.1, to name + * just one) that do not send a version number, so we can't rely + * on finding one, but if we do, insist on it being 1.0 or 1.1. + * We don't care about the reason phrase. + */ + if (strncmp(conn->buf, "HTTP", 4) != 0) + return (HTTP_PROTOCOL_ERROR); + p = conn->buf + 4; + if (*p == '/') { + if (p[1] != '1' || p[2] != '.' || (p[3] != '0' && p[3] != '1')) + return (HTTP_PROTOCOL_ERROR); + p += 4; + } + if (*p != ' ' || !isdigit(p[1]) || !isdigit(p[2]) || !isdigit(p[3])) + return (HTTP_PROTOCOL_ERROR); + + conn->err = (p[1] - '0') * 100 + (p[2] - '0') * 10 + (p[3] - '0'); + return (conn->err); +} + +/* + * Check a header; if the type matches the given string, return a pointer + * to the beginning of the value. + */ +static const char * +_http_match(const char *str, const char *hdr) +{ + while (*str && *hdr && tolower(*str++) == tolower(*hdr++)) + /* nothing */; + if (*str || *hdr != ':') + return (NULL); + while (*hdr && isspace(*++hdr)) + /* nothing */; + return (hdr); +} + +/* + * Get the next header and return the appropriate symbolic code. + */ +static hdr_t +_http_next_header(conn_t *conn, const char **p) +{ + int i; + + if (_fetch_getln(conn) == -1) + return (hdr_syserror); + while (conn->buflen && isspace(conn->buf[conn->buflen - 1])) + conn->buflen--; + conn->buf[conn->buflen] = '\0'; + if (conn->buflen == 0) + return (hdr_end); + /* + * We could check for malformed headers but we don't really care. + * A valid header starts with a token immediately followed by a + * colon; a token is any sequence of non-control, non-whitespace + * characters except "()<>@,;:\\\"{}". + */ + for (i = 0; hdr_names[i].num != hdr_unknown; i++) + if ((*p = _http_match(hdr_names[i].name, conn->buf)) != NULL) + return (hdr_names[i].num); + return (hdr_unknown); +} + +/* + * Parse a last-modified header + */ +static int +_http_parse_mtime(const char *p, time_t *mtime) +{ + char locale[64], *r; + struct tm tm; + + strncpy(locale, setlocale(LC_TIME, NULL), sizeof(locale)); + setlocale(LC_TIME, "C"); + r = strptime(p, "%a, %d %b %Y %H:%M:%S GMT", &tm); + /* XXX should add support for date-2 and date-3 */ + setlocale(LC_TIME, locale); + if (r == NULL) + return (-1); + DEBUG(fprintf(stderr, "last modified: [%04d-%02d-%02d " + "%02d:%02d:%02d]\n", + tm.tm_year + 1900, tm.tm_mon + 1, tm.tm_mday, + tm.tm_hour, tm.tm_min, tm.tm_sec)); + *mtime = timegm(&tm); + return (0); +} + +/* + * Parse a content-length header + */ +static int +_http_parse_length(const char *p, off_t *length) +{ + off_t len; + + for (len = 0; *p && isdigit(*p); ++p) + len = len * 10 + (*p - '0'); + if (*p) + return (-1); + DEBUG(fprintf(stderr, "content length: [%lld]\n", + (long long)len)); + *length = len; + return (0); +} + +/* + * Parse a content-range header + */ +static int +_http_parse_range(const char *p, off_t *offset, off_t *length, off_t *size) +{ + off_t first, last, len; + + if (strncasecmp(p, "bytes ", 6) != 0) + return (-1); + p += 6; + if (*p == '*') { + first = last = -1; + ++p; + } else { + for (first = 0; *p && isdigit(*p); ++p) + first = first * 10 + *p - '0'; + if (*p != '-') + return (-1); + for (last = 0, ++p; *p && isdigit(*p); ++p) + last = last * 10 + *p - '0'; + } + if (first > last || *p != '/') + return (-1); + for (len = 0, ++p; *p && isdigit(*p); ++p) + len = len * 10 + *p - '0'; + if (*p || len < last - first + 1) + return (-1); + if (first == -1) { + DEBUG(fprintf(stderr, "content range: [*/%lld]\n", + (long long)len)); + *length = 0; + } else { + DEBUG(fprintf(stderr, "content range: [%lld-%lld/%lld]\n", + (long long)first, (long long)last, (long long)len)); + *length = last - first + 1; + } + *offset = first; + *size = len; + return (0); +} + + +/***************************************************************************** + * Helper functions for authorization + */ + +/* + * Base64 encoding + */ +static char * +_http_base64(const char *src) +{ + static const char base64[] = + "ABCDEFGHIJKLMNOPQRSTUVWXYZ" + "abcdefghijklmnopqrstuvwxyz" + "0123456789+/"; + char *str, *dst; + size_t l; + int t, r; + + l = strlen(src); + if ((str = malloc(((l + 2) / 3) * 4 + 1)) == NULL) + return (NULL); + dst = str; + r = 0; + + while (l >= 3) { + t = (src[0] << 16) | (src[1] << 8) | src[2]; + dst[0] = base64[(t >> 18) & 0x3f]; + dst[1] = base64[(t >> 12) & 0x3f]; + dst[2] = base64[(t >> 6) & 0x3f]; + dst[3] = base64[(t >> 0) & 0x3f]; + src += 3; l -= 3; + dst += 4; r += 4; + } + + switch (l) { + case 2: + t = (src[0] << 16) | (src[1] << 8); + dst[0] = base64[(t >> 18) & 0x3f]; + dst[1] = base64[(t >> 12) & 0x3f]; + dst[2] = base64[(t >> 6) & 0x3f]; + dst[3] = '='; + dst += 4; + r += 4; + break; + case 1: + t = src[0] << 16; + dst[0] = base64[(t >> 18) & 0x3f]; + dst[1] = base64[(t >> 12) & 0x3f]; + dst[2] = dst[3] = '='; + dst += 4; + r += 4; + break; + case 0: + break; + } + + *dst = 0; + return (str); +} + +/* + * Encode username and password + */ +static int +_http_basic_auth(conn_t *conn, const char *hdr, const char *usr, const char *pwd) +{ + char *upw, *auth; + int r; + + DEBUG(fprintf(stderr, "usr: [%s]\n", usr)); + DEBUG(fprintf(stderr, "pwd: [%s]\n", pwd)); + if (asprintf(&upw, "%s:%s", usr, pwd) == -1) + return (-1); + auth = _http_base64(upw); + free(upw); + if (auth == NULL) + return (-1); + r = _http_cmd(conn, "%s: Basic %s", hdr, auth); + free(auth); + return (r); +} + +/* + * Send an authorization header + */ +static int +_http_authorize(conn_t *conn, const char *hdr, const char *p) +{ + /* basic authorization */ + if (strncasecmp(p, "basic:", 6) == 0) { + char *user, *pwd, *str; + int r; + + /* skip realm */ + for (p += 6; *p && *p != ':'; ++p) + /* nothing */ ; + if (!*p || strchr(++p, ':') == NULL) + return (-1); + if ((str = strdup(p)) == NULL) + return (-1); /* XXX */ + user = str; + pwd = strchr(str, ':'); + *pwd++ = '\0'; + r = _http_basic_auth(conn, hdr, user, pwd); + free(str); + return (r); + } + return (-1); +} + + +/***************************************************************************** + * Helper functions for connecting to a server or proxy + */ + +/* + * Connect to the correct HTTP server or proxy. + */ +static conn_t * +_http_connect(struct url *URL, struct url *purl, const char *flags) +{ + conn_t *conn; + int verbose; + int af, val; + +#ifdef INET6 + af = AF_UNSPEC; +#else + af = AF_INET; +#endif + + verbose = CHECK_FLAG('v'); + if (CHECK_FLAG('4')) + af = AF_INET; +#ifdef INET6 + else if (CHECK_FLAG('6')) + af = AF_INET6; +#endif + + if (purl && strcasecmp(URL->scheme, SCHEME_HTTPS) != 0) { + URL = purl; + } else if (strcasecmp(URL->scheme, SCHEME_FTP) == 0) { + /* can't talk http to an ftp server */ + /* XXX should set an error code */ + return (NULL); + } + + if ((conn = _fetch_connect(URL->host, URL->port, af, verbose)) == NULL) + /* _fetch_connect() has already set an error code */ + return (NULL); + if (strcasecmp(URL->scheme, SCHEME_HTTPS) == 0 && + _fetch_ssl(conn, verbose) == -1) { + _fetch_close(conn); + /* grrr */ + errno = EAUTH; + _fetch_syserr(); + return (NULL); + } + + val = 1; + +#if !sun /* __MOJOSETUP__ Solaris support... */ + setsockopt(conn->sd, IPPROTO_TCP, TCP_NOPUSH, &val, sizeof(val)); +#endif + + return (conn); +} + +static struct url * +_http_get_proxy(const char *flags) +{ + struct url *purl; + char *p; + + if (flags != NULL && strchr(flags, 'd') != NULL) + return (NULL); + if (((p = getenv("HTTP_PROXY")) || (p = getenv("http_proxy"))) && + *p && (purl = fetchParseURL(p))) { + if (!*purl->scheme) + strcpy(purl->scheme, SCHEME_HTTP); + if (!purl->port) + purl->port = _fetch_default_proxy_port(purl->scheme); + if (strcasecmp(purl->scheme, SCHEME_HTTP) == 0) + return (purl); + fetchFreeURL(purl); + } + return (NULL); +} + +#if !__MOJOSETUP__ +static void +_http_print_html(FILE *out, FILE *in) +{ + size_t len; + char *line, *p, *q; + int comment, tag; + + comment = tag = 0; + while ((line = fgetln(in, &len)) != NULL) { + while (len && isspace(line[len - 1])) + --len; + for (p = q = line; q < line + len; ++q) { + if (comment && *q == '-') { + if (q + 2 < line + len && + strcmp(q, "-->") == 0) { + tag = comment = 0; + q += 2; + } + } else if (tag && !comment && *q == '>') { + p = q + 1; + tag = 0; + } else if (!tag && *q == '<') { + if (q > p) + fwrite(p, q - p, 1, out); + tag = 1; + if (q + 3 < line + len && + strcmp(q, " + + + diff --git a/mk/linux/mojosetup/lua/doc/cover.png b/mk/linux/mojosetup/lua/doc/cover.png new file mode 100644 index 00000000..2dbb1981 Binary files /dev/null and b/mk/linux/mojosetup/lua/doc/cover.png differ diff --git a/mk/linux/mojosetup/lua/doc/logo.gif b/mk/linux/mojosetup/lua/doc/logo.gif new file mode 100644 index 00000000..2f5e4ac2 Binary files /dev/null and b/mk/linux/mojosetup/lua/doc/logo.gif differ diff --git a/mk/linux/mojosetup/lua/doc/lua.1 b/mk/linux/mojosetup/lua/doc/lua.1 new file mode 100644 index 00000000..24809cc6 --- /dev/null +++ b/mk/linux/mojosetup/lua/doc/lua.1 @@ -0,0 +1,163 @@ +.\" $Id: lua.man,v 1.11 2006/01/06 16:03:34 lhf Exp $ +.TH LUA 1 "$Date: 2006/01/06 16:03:34 $" +.SH NAME +lua \- Lua interpreter +.SH SYNOPSIS +.B lua +[ +.I options +] +[ +.I script +[ +.I args +] +] +.SH DESCRIPTION +.B lua +is the stand-alone Lua interpreter. +It loads and executes Lua programs, +either in textual source form or +in precompiled binary form. +(Precompiled binaries are output by +.BR luac , +the Lua compiler.) +.B lua +can be used as a batch interpreter and also interactively. +.LP +The given +.I options +(see below) +are executed and then +the Lua program in file +.I script +is loaded and executed. +The given +.I args +are available to +.I script +as strings in a global table named +.BR arg . +If these arguments contain spaces or other characters special to the shell, +then they should be quoted +(but note that the quotes will be removed by the shell). +The arguments in +.B arg +start at 0, +which contains the string +.RI ' script '. +The index of the last argument is stored in +.BR arg.n . +The arguments given in the command line before +.IR script , +including the name of the interpreter, +are available in negative indices in +.BR arg . +.LP +At the very start, +before even handling the command line, +.B lua +executes the contents of the environment variable +.BR LUA_INIT , +if it is defined. +If the value of +.B LUA_INIT +is of the form +.RI '@ filename ', +then +.I filename +is executed. +Otherwise, the string is assumed to be a Lua statement and is executed. +.LP +Options start with +.B '\-' +and are described below. +You can use +.B "'\--'" +to signal the end of options. +.LP +If no arguments are given, +then +.B "\-v \-i" +is assumed when the standard input is a terminal; +otherwise, +.B "\-" +is assumed. +.LP +In interactive mode, +.B lua +prompts the user, +reads lines from the standard input, +and executes them as they are read. +If a line does not contain a complete statement, +then a secondary prompt is displayed and +lines are read until a complete statement is formed or +a syntax error is found. +So, one way to interrupt the reading of an incomplete statement is +to force a syntax error: +adding a +.B ';' +in the middle of a statement is a sure way of forcing a syntax error +(except inside multiline strings and comments; these must be closed explicitly). +If a line starts with +.BR '=' , +then +.B lua +displays the values of all the expressions in the remainder of the +line. The expressions must be separated by commas. +The primary prompt is the value of the global variable +.BR _PROMPT , +if this value is a string; +otherwise, the default prompt is used. +Similarly, the secondary prompt is the value of the global variable +.BR _PROMPT2 . +So, +to change the prompts, +set the corresponding variable to a string of your choice. +You can do that after calling the interpreter +or on the command line +(but in this case you have to be careful with quotes +if the prompt string contains a space; otherwise you may confuse the shell.) +The default prompts are "> " and ">> ". +.SH OPTIONS +.TP +.B \- +load and execute the standard input as a file, +that is, +not interactively, +even when the standard input is a terminal. +.TP +.BI \-e " stat" +execute statement +.IR stat . +You need to quote +.I stat +if it contains spaces, quotes, +or other characters special to the shell. +.TP +.B \-i +enter interactive mode after +.I script +is executed. +.TP +.BI \-l " name" +call +.BI require(' name ') +before executing +.IR script . +Typically used to load libraries. +.TP +.B \-v +show version information. +.SH "SEE ALSO" +.BR luac (1) +.br +http://www.lua.org/ +.SH DIAGNOSTICS +Error messages should be self explanatory. +.SH AUTHORS +R. Ierusalimschy, +L. H. de Figueiredo, +and +W. Celes +.\" EOF diff --git a/mk/linux/mojosetup/lua/doc/lua.css b/mk/linux/mojosetup/lua/doc/lua.css new file mode 100644 index 00000000..039cf116 --- /dev/null +++ b/mk/linux/mojosetup/lua/doc/lua.css @@ -0,0 +1,41 @@ +body { + color: #000000 ; + background-color: #FFFFFF ; + font-family: sans-serif ; + text-align: justify ; + margin-right: 20px ; + margin-left: 20px ; +} + +h1, h2, h3, h4 { + font-weight: normal ; + font-style: italic ; +} + +a:link { + color: #000080 ; + background-color: inherit ; + text-decoration: none ; +} + +a:visited { + background-color: inherit ; + text-decoration: none ; +} + +a:link:hover, a:visited:hover { + color: #000080 ; + background-color: #E0E0FF ; +} + +a:link:active, a:visited:active { + color: #FF0000 ; +} + +hr { + border: 0 ; + height: 1px ; + color: #a0a0a0 ; + background-color: #a0a0a0 ; +} + diff --git a/mk/linux/mojosetup/lua/doc/lua.html b/mk/linux/mojosetup/lua/doc/lua.html new file mode 100644 index 00000000..1d435ab0 --- /dev/null +++ b/mk/linux/mojosetup/lua/doc/lua.html @@ -0,0 +1,172 @@ + + + +LUA man page + + + + + +

NAME

+lua - Lua interpreter +

SYNOPSIS

+lua +[ +options +] +[ +script +[ +args +] +] +

DESCRIPTION

+lua +is the stand-alone Lua interpreter. +It loads and executes Lua programs, +either in textual source form or +in precompiled binary form. +(Precompiled binaries are output by +luac, +the Lua compiler.) +lua +can be used as a batch interpreter and also interactively. +

+The given +options +(see below) +are executed and then +the Lua program in file +script +is loaded and executed. +The given +args +are available to +script +as strings in a global table named +arg. +If these arguments contain spaces or other characters special to the shell, +then they should be quoted +(but note that the quotes will be removed by the shell). +The arguments in +arg +start at 0, +which contains the string +'script'. +The index of the last argument is stored in +arg.n. +The arguments given in the command line before +script, +including the name of the interpreter, +are available in negative indices in +arg. +

+At the very start, +before even handling the command line, +lua +executes the contents of the environment variable +LUA_INIT, +if it is defined. +If the value of +LUA_INIT +is of the form +'@filename', +then +filename +is executed. +Otherwise, the string is assumed to be a Lua statement and is executed. +

+Options start with +'-' +and are described below. +You can use +'--' +to signal the end of options. +

+If no arguments are given, +then +"-v -i" +is assumed when the standard input is a terminal; +otherwise, +"-" +is assumed. +

+In interactive mode, +lua +prompts the user, +reads lines from the standard input, +and executes them as they are read. +If a line does not contain a complete statement, +then a secondary prompt is displayed and +lines are read until a complete statement is formed or +a syntax error is found. +So, one way to interrupt the reading of an incomplete statement is +to force a syntax error: +adding a +';' +in the middle of a statement is a sure way of forcing a syntax error +(except inside multiline strings and comments; these must be closed explicitly). +If a line starts with +'=', +then +lua +displays the values of all the expressions in the remainder of the +line. The expressions must be separated by commas. +The primary prompt is the value of the global variable +_PROMPT, +if this value is a string; +otherwise, the default prompt is used. +Similarly, the secondary prompt is the value of the global variable +_PROMPT2. +So, +to change the prompts, +set the corresponding variable to a string of your choice. +You can do that after calling the interpreter +or on the command line +(but in this case you have to be careful with quotes +if the prompt string contains a space; otherwise you may confuse the shell.) +The default prompts are "> " and ">> ". +

OPTIONS

+

+- +load and execute the standard input as a file, +that is, +not interactively, +even when the standard input is a terminal. +

+-e stat +execute statement +stat. +You need to quote +stat +if it contains spaces, quotes, +or other characters special to the shell. +

+-i +enter interactive mode after +script +is executed. +

+-l name +call +require('name') +before executing +script. +Typically used to load libraries. +

+-v +show version information. +

SEE ALSO

+luac(1) +
+http://www.lua.org/ +

DIAGNOSTICS

+Error messages should be self explanatory. +

AUTHORS

+R. Ierusalimschy, +L. H. de Figueiredo, +and +W. Celes + + + diff --git a/mk/linux/mojosetup/lua/doc/luac.1 b/mk/linux/mojosetup/lua/doc/luac.1 new file mode 100644 index 00000000..d8146782 --- /dev/null +++ b/mk/linux/mojosetup/lua/doc/luac.1 @@ -0,0 +1,136 @@ +.\" $Id: luac.man,v 1.28 2006/01/06 16:03:34 lhf Exp $ +.TH LUAC 1 "$Date: 2006/01/06 16:03:34 $" +.SH NAME +luac \- Lua compiler +.SH SYNOPSIS +.B luac +[ +.I options +] [ +.I filenames +] +.SH DESCRIPTION +.B luac +is the Lua compiler. +It translates programs written in the Lua programming language +into binary files that can be later loaded and executed. +.LP +The main advantages of precompiling chunks are: +faster loading, +protecting source code from accidental user changes, +and +off-line syntax checking. +.LP +Pre-compiling does not imply faster execution +because in Lua chunks are always compiled into bytecodes before being executed. +.B luac +simply allows those bytecodes to be saved in a file for later execution. +.LP +Pre-compiled chunks are not necessarily smaller than the corresponding source. +The main goal in pre-compiling is faster loading. +.LP +The binary files created by +.B luac +are portable only among architectures with the same word size and byte order. +.LP +.B luac +produces a single output file containing the bytecodes +for all source files given. +By default, +the output file is named +.BR luac.out , +but you can change this with the +.B \-o +option. +.LP +In the command line, +you can mix +text files containing Lua source and +binary files containing precompiled chunks. +This is useful to combine several precompiled chunks, +even from different (but compatible) platforms, +into a single precompiled chunk. +.LP +You can use +.B "'\-'" +to indicate the standard input as a source file +and +.B "'\--'" +to signal the end of options +(that is, +all remaining arguments will be treated as files even if they start with +.BR "'\-'" ). +.LP +The internal format of the binary files produced by +.B luac +is likely to change when a new version of Lua is released. +So, +save the source files of all Lua programs that you precompile. +.LP +.SH OPTIONS +Options must be separate. +.TP +.B \-l +produce a listing of the compiled bytecode for Lua's virtual machine. +Listing bytecodes is useful to learn about Lua's virtual machine. +If no files are given, then +.B luac +loads +.B luac.out +and lists its contents. +.TP +.BI \-o " file" +output to +.IR file , +instead of the default +.BR luac.out . +(You can use +.B "'\-'" +for standard output, +but not on platforms that open standard output in text mode.) +The output file may be a source file because +all files are loaded before the output file is written. +Be careful not to overwrite precious files. +.TP +.B \-p +load files but do not generate any output file. +Used mainly for syntax checking and for testing precompiled chunks: +corrupted files will probably generate errors when loaded. +Lua always performs a thorough integrity test on precompiled chunks. +Bytecode that passes this test is completely safe, +in the sense that it will not break the interpreter. +However, +there is no guarantee that such code does anything sensible. +(None can be given, because the halting problem is unsolvable.) +If no files are given, then +.B luac +loads +.B luac.out +and tests its contents. +No messages are displayed if the file passes the integrity test. +.TP +.B \-s +strip debug information before writing the output file. +This saves some space in very large chunks, +but if errors occur when running a stripped chunk, +then the error messages may not contain the full information they usually do. +For instance, +line numbers and names of local variables are lost. +.TP +.B \-v +show version information. +.SH FILES +.TP 15 +.B luac.out +default output file +.SH "SEE ALSO" +.BR lua (1) +.br +http://www.lua.org/ +.SH DIAGNOSTICS +Error messages should be self explanatory. +.SH AUTHORS +L. H. de Figueiredo, +R. Ierusalimschy and +W. Celes +.\" EOF diff --git a/mk/linux/mojosetup/lua/doc/luac.html b/mk/linux/mojosetup/lua/doc/luac.html new file mode 100644 index 00000000..179ffe82 --- /dev/null +++ b/mk/linux/mojosetup/lua/doc/luac.html @@ -0,0 +1,145 @@ + + + +LUAC man page + + + + + +

NAME

+luac - Lua compiler +

SYNOPSIS

+luac +[ +options +] [ +filenames +] +

DESCRIPTION

+luac +is the Lua compiler. +It translates programs written in the Lua programming language +into binary files that can be later loaded and executed. +

+The main advantages of precompiling chunks are: +faster loading, +protecting source code from accidental user changes, +and +off-line syntax checking. +

+Precompiling does not imply faster execution +because in Lua chunks are always compiled into bytecodes before being executed. +luac +simply allows those bytecodes to be saved in a file for later execution. +

+Precompiled chunks are not necessarily smaller than the corresponding source. +The main goal in precompiling is faster loading. +

+The binary files created by +luac +are portable only among architectures with the same word size and byte order. +

+luac +produces a single output file containing the bytecodes +for all source files given. +By default, +the output file is named +luac.out, +but you can change this with the +-o +option. +

+In the command line, +you can mix +text files containing Lua source and +binary files containing precompiled chunks. +This is useful because several precompiled chunks, +even from different (but compatible) platforms, +can be combined into a single precompiled chunk. +

+You can use +'-' +to indicate the standard input as a source file +and +'--' +to signal the end of options +(that is, +all remaining arguments will be treated as files even if they start with +'-'). +

+The internal format of the binary files produced by +luac +is likely to change when a new version of Lua is released. +So, +save the source files of all Lua programs that you precompile. +

+

OPTIONS

+Options must be separate. +

+-l +produce a listing of the compiled bytecode for Lua's virtual machine. +Listing bytecodes is useful to learn about Lua's virtual machine. +If no files are given, then +luac +loads +luac.out +and lists its contents. +

+-o file +output to +file, +instead of the default +luac.out. +(You can use +'-' +for standard output, +but not on platforms that open standard output in text mode.) +The output file may be a source file because +all files are loaded before the output file is written. +Be careful not to overwrite precious files. +

+-p +load files but do not generate any output file. +Used mainly for syntax checking and for testing precompiled chunks: +corrupted files will probably generate errors when loaded. +Lua always performs a thorough integrity test on precompiled chunks. +Bytecode that passes this test is completely safe, +in the sense that it will not break the interpreter. +However, +there is no guarantee that such code does anything sensible. +(None can be given, because the halting problem is unsolvable.) +If no files are given, then +luac +loads +luac.out +and tests its contents. +No messages are displayed if the file passes the integrity test. +

+-s +strip debug information before writing the output file. +This saves some space in very large chunks, +but if errors occur when running a stripped chunk, +then the error messages may not contain the full information they usually do. +For instance, +line numbers and names of local variables are lost. +

+-v +show version information. +

FILES

+

+luac.out +default output file +

SEE ALSO

+lua(1) +
+http://www.lua.org/ +

DIAGNOSTICS

+Error messages should be self explanatory. +

AUTHORS

+L. H. de Figueiredo, +R. Ierusalimschy and +W. Celes + + + diff --git a/mk/linux/mojosetup/lua/doc/manual.css b/mk/linux/mojosetup/lua/doc/manual.css new file mode 100644 index 00000000..eed5afd9 --- /dev/null +++ b/mk/linux/mojosetup/lua/doc/manual.css @@ -0,0 +1,13 @@ +h3 code { + font-family: inherit ; +} + +pre { + font-size: 105% ; +} + +span.apii { + float: right ; + font-family: inherit ; +} + diff --git a/mk/linux/mojosetup/lua/doc/manual.html b/mk/linux/mojosetup/lua/doc/manual.html new file mode 100644 index 00000000..f46f17c8 --- /dev/null +++ b/mk/linux/mojosetup/lua/doc/manual.html @@ -0,0 +1,8801 @@ + + + + +Lua 5.1 Reference Manual + + + + + + + +
+

+ +Lua 5.1 Reference Manual +

+ +by Roberto Ierusalimschy, Luiz Henrique de Figueiredo, Waldemar Celes +

+ +Copyright © 2006-2008 Lua.org, PUC-Rio. +Freely available under the terms of the +Lua license. + +


+

+ +contents +· +index + + +

+ + + + + + +

1 - Introduction

+ +

+Lua is an extension programming language designed to support +general procedural programming with data description +facilities. +It also offers good support for object-oriented programming, +functional programming, and data-driven programming. +Lua is intended to be used as a powerful, light-weight +scripting language for any program that needs one. +Lua is implemented as a library, written in clean C +(that is, in the common subset of ANSI C and C++). + + +

+Being an extension language, Lua has no notion of a "main" program: +it only works embedded in a host client, +called the embedding program or simply the host. +This host program can invoke functions to execute a piece of Lua code, +can write and read Lua variables, +and can register C functions to be called by Lua code. +Through the use of C functions, Lua can be augmented to cope with +a wide range of different domains, +thus creating customized programming languages sharing a syntactical framework. +The Lua distribution includes a sample host program called lua, +which uses the Lua library to offer a complete, stand-alone Lua interpreter. + + +

+Lua is free software, +and is provided as usual with no guarantees, +as stated in its license. +The implementation described in this manual is available +at Lua's official web site, www.lua.org. + + +

+Like any other reference manual, +this document is dry in places. +For a discussion of the decisions behind the design of Lua, +see the technical papers available at Lua's web site. +For a detailed introduction to programming in Lua, +see Roberto's book, Programming in Lua (Second Edition). + + + +

2 - The Language

+ +

+This section describes the lexis, the syntax, and the semantics of Lua. +In other words, +this section describes +which tokens are valid, +how they can be combined, +and what their combinations mean. + + +

+The language constructs will be explained using the usual extended BNF notation, +in which +{a} means 0 or more a's, and +[a] means an optional a. +Non-terminals are shown like non-terminal, +keywords are shown like kword, +and other terminal symbols are shown like `=´. +The complete syntax of Lua can be found in §8 +at the end of this manual. + + + +

2.1 - Lexical Conventions

+ +

+Names +(also called identifiers) +in Lua can be any string of letters, +digits, and underscores, +not beginning with a digit. +This coincides with the definition of names in most languages. +(The definition of letter depends on the current locale: +any character considered alphabetic by the current locale +can be used in an identifier.) +Identifiers are used to name variables and table fields. + + +

+The following keywords are reserved +and cannot be used as names: + + +

+     and       break     do        else      elseif
+     end       false     for       function  if
+     in        local     nil       not       or
+     repeat    return    then      true      until     while
+
+ +

+Lua is a case-sensitive language: +and is a reserved word, but And and AND +are two different, valid names. +As a convention, names starting with an underscore followed by +uppercase letters (such as _VERSION) +are reserved for internal global variables used by Lua. + + +

+The following strings denote other tokens: + +

+     +     -     *     /     %     ^     #
+     ==    ~=    <=    >=    <     >     =
+     (     )     {     }     [     ]
+     ;     :     ,     .     ..    ...
+
+ +

+Literal strings +can be delimited by matching single or double quotes, +and can contain the following C-like escape sequences: +'\a' (bell), +'\b' (backspace), +'\f' (form feed), +'\n' (newline), +'\r' (carriage return), +'\t' (horizontal tab), +'\v' (vertical tab), +'\\' (backslash), +'\"' (quotation mark [double quote]), +and '\'' (apostrophe [single quote]). +Moreover, a backslash followed by a real newline +results in a newline in the string. +A character in a string can also be specified by its numerical value +using the escape sequence \ddd, +where ddd is a sequence of up to three decimal digits. +(Note that if a numerical escape is to be followed by a digit, +it must be expressed using exactly three digits.) +Strings in Lua can contain any 8-bit value, including embedded zeros, +which can be specified as '\0'. + + +

+Literal strings can also be defined using a long format +enclosed by long brackets. +We define an opening long bracket of level n as an opening +square bracket followed by n equal signs followed by another +opening square bracket. +So, an opening long bracket of level 0 is written as [[, +an opening long bracket of level 1 is written as [=[, +and so on. +A closing long bracket is defined similarly; +for instance, a closing long bracket of level 4 is written as ]====]. +A long string starts with an opening long bracket of any level and +ends at the first closing long bracket of the same level. +Literals in this bracketed form can run for several lines, +do not interpret any escape sequences, +and ignore long brackets of any other level. +They can contain anything except a closing bracket of the proper level. + + +

+For convenience, +when the opening long bracket is immediately followed by a newline, +the newline is not included in the string. +As an example, in a system using ASCII +(in which 'a' is coded as 97, +newline is coded as 10, and '1' is coded as 49), +the five literal strings below denote the same string: + +

+     a = 'alo\n123"'
+     a = "alo\n123\""
+     a = '\97lo\10\04923"'
+     a = [[alo
+     123"]]
+     a = [==[
+     alo
+     123"]==]
+
+ +

+A numerical constant can be written with an optional decimal part +and an optional decimal exponent. +Lua also accepts integer hexadecimal constants, +by prefixing them with 0x. +Examples of valid numerical constants are + +

+     3   3.0   3.1416   314.16e-2   0.31416E1   0xff   0x56
+
+ +

+A comment starts with a double hyphen (--) +anywhere outside a string. +If the text immediately after -- is not an opening long bracket, +the comment is a short comment, +which runs until the end of the line. +Otherwise, it is a long comment, +which runs until the corresponding closing long bracket. +Long comments are frequently used to disable code temporarily. + + + + + +

2.2 - Values and Types

+ +

+Lua is a dynamically typed language. +This means that +variables do not have types; only values do. +There are no type definitions in the language. +All values carry their own type. + + +

+All values in Lua are first-class values. +This means that all values can be stored in variables, +passed as arguments to other functions, and returned as results. + + +

+There are eight basic types in Lua: +nil, boolean, number, +string, function, userdata, +thread, and table. +Nil is the type of the value nil, +whose main property is to be different from any other value; +it usually represents the absence of a useful value. +Boolean is the type of the values false and true. +Both nil and false make a condition false; +any other value makes it true. +Number represents real (double-precision floating-point) numbers. +(It is easy to build Lua interpreters that use other +internal representations for numbers, +such as single-precision float or long integers; +see file luaconf.h.) +String represents arrays of characters. + +Lua is 8-bit clean: +strings can contain any 8-bit character, +including embedded zeros ('\0') (see §2.1). + + +

+Lua can call (and manipulate) functions written in Lua and +functions written in C +(see §2.5.8). + + +

+The type userdata is provided to allow arbitrary C data to +be stored in Lua variables. +This type corresponds to a block of raw memory +and has no pre-defined operations in Lua, +except assignment and identity test. +However, by using metatables, +the programmer can define operations for userdata values +(see §2.8). +Userdata values cannot be created or modified in Lua, +only through the C API. +This guarantees the integrity of data owned by the host program. + + +

+The type thread represents independent threads of execution +and it is used to implement coroutines (see §2.11). +Do not confuse Lua threads with operating-system threads. +Lua supports coroutines on all systems, +even those that do not support threads. + + +

+The type table implements associative arrays, +that is, arrays that can be indexed not only with numbers, +but with any value (except nil). +Tables can be heterogeneous; +that is, they can contain values of all types (except nil). +Tables are the sole data structuring mechanism in Lua; +they can be used to represent ordinary arrays, +symbol tables, sets, records, graphs, trees, etc. +To represent records, Lua uses the field name as an index. +The language supports this representation by +providing a.name as syntactic sugar for a["name"]. +There are several convenient ways to create tables in Lua +(see §2.5.7). + + +

+Like indices, +the value of a table field can be of any type (except nil). +In particular, +because functions are first-class values, +table fields can contain functions. +Thus tables can also carry methods (see §2.5.9). + + +

+Tables, functions, threads, and (full) userdata values are objects: +variables do not actually contain these values, +only references to them. +Assignment, parameter passing, and function returns +always manipulate references to such values; +these operations do not imply any kind of copy. + + +

+The library function type returns a string describing the type +of a given value. + + + +

2.2.1 - Coercion

+ +

+Lua provides automatic conversion between +string and number values at run time. +Any arithmetic operation applied to a string tries to convert +this string to a number, following the usual conversion rules. +Conversely, whenever a number is used where a string is expected, +the number is converted to a string, in a reasonable format. +For complete control over how numbers are converted to strings, +use the format function from the string library +(see string.format). + + + + + + + +

2.3 - Variables

+ +

+Variables are places that store values. + +There are three kinds of variables in Lua: +global variables, local variables, and table fields. + + +

+A single name can denote a global variable or a local variable +(or a function's formal parameter, +which is a particular kind of local variable): + +

+	var ::= Name
+

+Name denotes identifiers, as defined in §2.1. + + +

+Any variable is assumed to be global unless explicitly declared +as a local (see §2.4.7). +Local variables are lexically scoped: +local variables can be freely accessed by functions +defined inside their scope (see §2.6). + + +

+Before the first assignment to a variable, its value is nil. + + +

+Square brackets are used to index a table: + +

+	var ::= prefixexp `[´ exp `]´
+

+The meaning of accesses to global variables +and table fields can be changed via metatables. +An access to an indexed variable t[i] is equivalent to +a call gettable_event(t,i). +(See §2.8 for a complete description of the +gettable_event function. +This function is not defined or callable in Lua. +We use it here only for explanatory purposes.) + + +

+The syntax var.Name is just syntactic sugar for +var["Name"]: + +

+	var ::= prefixexp `.´ Name
+
+ +

+All global variables live as fields in ordinary Lua tables, +called environment tables or simply +environments (see §2.9). +Each function has its own reference to an environment, +so that all global variables in this function +will refer to this environment table. +When a function is created, +it inherits the environment from the function that created it. +To get the environment table of a Lua function, +you call getfenv. +To replace it, +you call setfenv. +(You can only manipulate the environment of C functions +through the debug library; (see §5.9).) + + +

+An access to a global variable x +is equivalent to _env.x, +which in turn is equivalent to + +

+     gettable_event(_env, "x")
+

+where _env is the environment of the running function. +(See §2.8 for a complete description of the +gettable_event function. +This function is not defined or callable in Lua. +Similarly, the _env variable is not defined in Lua. +We use them here only for explanatory purposes.) + + + + + +

2.4 - Statements

+ +

+Lua supports an almost conventional set of statements, +similar to those in Pascal or C. +This set includes +assignments, control structures, function calls, +and variable declarations. + + + +

2.4.1 - Chunks

+ +

+The unit of execution of Lua is called a chunk. +A chunk is simply a sequence of statements, +which are executed sequentially. +Each statement can be optionally followed by a semicolon: + +

+	chunk ::= {stat [`;´]}
+

+There are no empty statements and thus ';;' is not legal. + + +

+Lua handles a chunk as the body of an anonymous function +with a variable number of arguments +(see §2.5.9). +As such, chunks can define local variables, +receive arguments, and return values. + + +

+A chunk can be stored in a file or in a string inside the host program. +To execute a chunk, +Lua first pre-compiles the chunk into instructions for a virtual machine, +and then it executes the compiled code +with an interpreter for the virtual machine. + + +

+Chunks can also be pre-compiled into binary form; +see program luac for details. +Programs in source and compiled forms are interchangeable; +Lua automatically detects the file type and acts accordingly. + + + + + + +

2.4.2 - Blocks

+A block is a list of statements; +syntactically, a block is the same as a chunk: + +

+	block ::= chunk
+
+ +

+A block can be explicitly delimited to produce a single statement: + +

+	stat ::= do block end
+

+Explicit blocks are useful +to control the scope of variable declarations. +Explicit blocks are also sometimes used to +add a return or break statement in the middle +of another block (see §2.4.4). + + + + + +

2.4.3 - Assignment

+ +

+Lua allows multiple assignments. +Therefore, the syntax for assignment +defines a list of variables on the left side +and a list of expressions on the right side. +The elements in both lists are separated by commas: + +

+	stat ::= varlist `=´ explist
+	varlist ::= var {`,´ var}
+	explist ::= exp {`,´ exp}
+

+Expressions are discussed in §2.5. + + +

+Before the assignment, +the list of values is adjusted to the length of +the list of variables. +If there are more values than needed, +the excess values are thrown away. +If there are fewer values than needed, +the list is extended with as many nil's as needed. +If the list of expressions ends with a function call, +then all values returned by that call enter the list of values, +before the adjustment +(except when the call is enclosed in parentheses; see §2.5). + + +

+The assignment statement first evaluates all its expressions +and only then are the assignments performed. +Thus the code + +

+     i = 3
+     i, a[i] = i+1, 20
+

+sets a[3] to 20, without affecting a[4] +because the i in a[i] is evaluated (to 3) +before it is assigned 4. +Similarly, the line + +

+     x, y = y, x
+

+exchanges the values of x and y, +and + +

+     x, y, z = y, z, x
+

+cyclically permutes the values of x, y, and z. + + +

+The meaning of assignments to global variables +and table fields can be changed via metatables. +An assignment to an indexed variable t[i] = val is equivalent to +settable_event(t,i,val). +(See §2.8 for a complete description of the +settable_event function. +This function is not defined or callable in Lua. +We use it here only for explanatory purposes.) + + +

+An assignment to a global variable x = val +is equivalent to the assignment +_env.x = val, +which in turn is equivalent to + +

+     settable_event(_env, "x", val)
+

+where _env is the environment of the running function. +(The _env variable is not defined in Lua. +We use it here only for explanatory purposes.) + + + + + +

2.4.4 - Control Structures

+The control structures +if, while, and repeat have the usual meaning and +familiar syntax: + + + + +

+	stat ::= while exp do block end
+	stat ::= repeat block until exp
+	stat ::= if exp then block {elseif exp then block} [else block] end
+

+Lua also has a for statement, in two flavors (see §2.4.5). + + +

+The condition expression of a +control structure can return any value. +Both false and nil are considered false. +All values different from nil and false are considered true +(in particular, the number 0 and the empty string are also true). + + +

+In the repeatuntil loop, +the inner block does not end at the until keyword, +but only after the condition. +So, the condition can refer to local variables +declared inside the loop block. + + +

+The return statement is used to return values +from a function or a chunk (which is just a function). + +Functions and chunks can return more than one value, +and so the syntax for the return statement is + +

+	stat ::= return [explist]
+
+ +

+The break statement is used to terminate the execution of a +while, repeat, or for loop, +skipping to the next statement after the loop: + + +

+	stat ::= break
+

+A break ends the innermost enclosing loop. + + +

+The return and break +statements can only be written as the last statement of a block. +If it is really necessary to return or break in the +middle of a block, +then an explicit inner block can be used, +as in the idioms +do return end and do break end, +because now return and break are the last statements in +their (inner) blocks. + + + + + +

2.4.5 - For Statement

+ +

+ +The for statement has two forms: +one numeric and one generic. + + +

+The numeric for loop repeats a block of code while a +control variable runs through an arithmetic progression. +It has the following syntax: + +

+	stat ::= for Name `=´ exp `,´ exp [`,´ exp] do block end
+

+The block is repeated for name starting at the value of +the first exp, until it passes the second exp by steps of the +third exp. +More precisely, a for statement like + +

+     for v = e1, e2, e3 do block end
+

+is equivalent to the code: + +

+     do
+       local var, limit, step = tonumber(e1), tonumber(e2), tonumber(e3)
+       if not (var and limit and step) then error() end
+       while (step > 0 and var <= limit) or (step <= 0 and var >= limit) do
+         local v = var
+         block
+         var = var + step
+       end
+     end
+

+Note the following: + +

    + +
  • +All three control expressions are evaluated only once, +before the loop starts. +They must all result in numbers. +
  • + +
  • +var, limit, and step are invisible variables. +The names shown here are for explanatory purposes only. +
  • + +
  • +If the third expression (the step) is absent, +then a step of 1 is used. +
  • + +
  • +You can use break to exit a for loop. +
  • + +
  • +The loop variable v is local to the loop; +you cannot use its value after the for ends or is broken. +If you need this value, +assign it to another variable before breaking or exiting the loop. +
  • + +
+ +

+The generic for statement works over functions, +called iterators. +On each iteration, the iterator function is called to produce a new value, +stopping when this new value is nil. +The generic for loop has the following syntax: + +

+	stat ::= for namelist in explist do block end
+	namelist ::= Name {`,´ Name}
+

+A for statement like + +

+     for var_1, ···, var_n in explist do block end
+

+is equivalent to the code: + +

+     do
+       local f, s, var = explist
+       while true do
+         local var_1, ···, var_n = f(s, var)
+         var = var_1
+         if var == nil then break end
+         block
+       end
+     end
+

+Note the following: + +

    + +
  • +explist is evaluated only once. +Its results are an iterator function, +a state, +and an initial value for the first iterator variable. +
  • + +
  • +f, s, and var are invisible variables. +The names are here for explanatory purposes only. +
  • + +
  • +You can use break to exit a for loop. +
  • + +
  • +The loop variables var_i are local to the loop; +you cannot use their values after the for ends. +If you need these values, +then assign them to other variables before breaking or exiting the loop. +
  • + +
+ + + + +

2.4.6 - Function Calls as Statements

+To allow possible side-effects, +function calls can be executed as statements: + +

+	stat ::= functioncall
+

+In this case, all returned values are thrown away. +Function calls are explained in §2.5.8. + + + + + +

2.4.7 - Local Declarations

+Local variables can be declared anywhere inside a block. +The declaration can include an initial assignment: + +

+	stat ::= local namelist [`=´ explist]
+

+If present, an initial assignment has the same semantics +of a multiple assignment (see §2.4.3). +Otherwise, all variables are initialized with nil. + + +

+A chunk is also a block (see §2.4.1), +and so local variables can be declared in a chunk outside any explicit block. +The scope of such local variables extends until the end of the chunk. + + +

+The visibility rules for local variables are explained in §2.6. + + + + + + + +

2.5 - Expressions

+ +

+The basic expressions in Lua are the following: + +

+	exp ::= prefixexp
+	exp ::= nil | false | true
+	exp ::= Number
+	exp ::= String
+	exp ::= function
+	exp ::= tableconstructor
+	exp ::= `...´
+	exp ::= exp binop exp
+	exp ::= unop exp
+	prefixexp ::= var | functioncall | `(´ exp `)´
+
+ +

+Numbers and literal strings are explained in §2.1; +variables are explained in §2.3; +function definitions are explained in §2.5.9; +function calls are explained in §2.5.8; +table constructors are explained in §2.5.7. +Vararg expressions, +denoted by three dots ('...'), can only be used when +directly inside a vararg function; +they are explained in §2.5.9. + + +

+Binary operators comprise arithmetic operators (see §2.5.1), +relational operators (see §2.5.2), logical operators (see §2.5.3), +and the concatenation operator (see §2.5.4). +Unary operators comprise the unary minus (see §2.5.1), +the unary not (see §2.5.3), +and the unary length operator (see §2.5.5). + + +

+Both function calls and vararg expressions can result in multiple values. +If an expression is used as a statement +(only possible for function calls (see §2.4.6)), +then its return list is adjusted to zero elements, +thus discarding all returned values. +If an expression is used as the last (or the only) element +of a list of expressions, +then no adjustment is made +(unless the call is enclosed in parentheses). +In all other contexts, +Lua adjusts the result list to one element, +discarding all values except the first one. + + +

+Here are some examples: + +

+     f()                -- adjusted to 0 results
+     g(f(), x)          -- f() is adjusted to 1 result
+     g(x, f())          -- g gets x plus all results from f()
+     a,b,c = f(), x     -- f() is adjusted to 1 result (c gets nil)
+     a,b = ...          -- a gets the first vararg parameter, b gets
+                        -- the second (both a and b can get nil if there
+                        -- is no corresponding vararg parameter)
+     
+     a,b,c = x, f()     -- f() is adjusted to 2 results
+     a,b,c = f()        -- f() is adjusted to 3 results
+     return f()         -- returns all results from f()
+     return ...         -- returns all received vararg parameters
+     return x,y,f()     -- returns x, y, and all results from f()
+     {f()}              -- creates a list with all results from f()
+     {...}              -- creates a list with all vararg parameters
+     {f(), nil}         -- f() is adjusted to 1 result
+
+ +

+Any expression enclosed in parentheses always results in only one value. +Thus, +(f(x,y,z)) is always a single value, +even if f returns several values. +(The value of (f(x,y,z)) is the first value returned by f +or nil if f does not return any values.) + + + +

2.5.1 - Arithmetic Operators

+Lua supports the usual arithmetic operators: +the binary + (addition), +- (subtraction), * (multiplication), +/ (division), % (modulo), and ^ (exponentiation); +and unary - (negation). +If the operands are numbers, or strings that can be converted to +numbers (see §2.2.1), +then all operations have the usual meaning. +Exponentiation works for any exponent. +For instance, x^(-0.5) computes the inverse of the square root of x. +Modulo is defined as + +

+     a % b == a - math.floor(a/b)*b
+

+That is, it is the remainder of a division that rounds +the quotient towards minus infinity. + + + + + +

2.5.2 - Relational Operators

+The relational operators in Lua are + +

+     ==    ~=    <     >     <=    >=
+

+These operators always result in false or true. + + +

+Equality (==) first compares the type of its operands. +If the types are different, then the result is false. +Otherwise, the values of the operands are compared. +Numbers and strings are compared in the usual way. +Objects (tables, userdata, threads, and functions) +are compared by reference: +two objects are considered equal only if they are the same object. +Every time you create a new object +(a table, userdata, thread, or function), +this new object is different from any previously existing object. + + +

+You can change the way that Lua compares tables and userdata +by using the "eq" metamethod (see §2.8). + + +

+The conversion rules of §2.2.1 +do not apply to equality comparisons. +Thus, "0"==0 evaluates to false, +and t[0] and t["0"] denote different +entries in a table. + + +

+The operator ~= is exactly the negation of equality (==). + + +

+The order operators work as follows. +If both arguments are numbers, then they are compared as such. +Otherwise, if both arguments are strings, +then their values are compared according to the current locale. +Otherwise, Lua tries to call the "lt" or the "le" +metamethod (see §2.8). +A comparison a > b is translated to b < a +and a >= b is translated to b <= a. + + + + + +

2.5.3 - Logical Operators

+The logical operators in Lua are +and, or, and not. +Like the control structures (see §2.4.4), +all logical operators consider both false and nil as false +and anything else as true. + + +

+The negation operator not always returns false or true. +The conjunction operator and returns its first argument +if this value is false or nil; +otherwise, and returns its second argument. +The disjunction operator or returns its first argument +if this value is different from nil and false; +otherwise, or returns its second argument. +Both and and or use short-cut evaluation; +that is, +the second operand is evaluated only if necessary. +Here are some examples: + +

+     10 or 20            --> 10
+     10 or error()       --> 10
+     nil or "a"          --> "a"
+     nil and 10          --> nil
+     false and error()   --> false
+     false and nil       --> false
+     false or nil        --> nil
+     10 and 20           --> 20
+

+(In this manual, +--> indicates the result of the preceding expression.) + + + + + +

2.5.4 - Concatenation

+The string concatenation operator in Lua is +denoted by two dots ('..'). +If both operands are strings or numbers, then they are converted to +strings according to the rules mentioned in §2.2.1. +Otherwise, the "concat" metamethod is called (see §2.8). + + + + + +

2.5.5 - The Length Operator

+ +

+The length operator is denoted by the unary operator #. +The length of a string is its number of bytes +(that is, the usual meaning of string length when each +character is one byte). + + +

+The length of a table t is defined to be any +integer index n +such that t[n] is not nil and t[n+1] is nil; +moreover, if t[1] is nil, n can be zero. +For a regular array, with non-nil values from 1 to a given n, +its length is exactly that n, +the index of its last value. +If the array has "holes" +(that is, nil values between other non-nil values), +then #t can be any of the indices that +directly precedes a nil value +(that is, it may consider any such nil value as the end of +the array). + + + + + +

2.5.6 - Precedence

+Operator precedence in Lua follows the table below, +from lower to higher priority: + +

+     or
+     and
+     <     >     <=    >=    ~=    ==
+     ..
+     +     -
+     *     /     %
+     not   #     - (unary)
+     ^
+

+As usual, +you can use parentheses to change the precedences of an expression. +The concatenation ('..') and exponentiation ('^') +operators are right associative. +All other binary operators are left associative. + + + + + +

2.5.7 - Table Constructors

+Table constructors are expressions that create tables. +Every time a constructor is evaluated, a new table is created. +A constructor can be used to create an empty table +or to create a table and initialize some of its fields. +The general syntax for constructors is + +

+	tableconstructor ::= `{´ [fieldlist] `}´
+	fieldlist ::= field {fieldsep field} [fieldsep]
+	field ::= `[´ exp `]´ `=´ exp | Name `=´ exp | exp
+	fieldsep ::= `,´ | `;´
+
+ +

+Each field of the form [exp1] = exp2 adds to the new table an entry +with key exp1 and value exp2. +A field of the form name = exp is equivalent to +["name"] = exp. +Finally, fields of the form exp are equivalent to +[i] = exp, where i are consecutive numerical integers, +starting with 1. +Fields in the other formats do not affect this counting. +For example, + +

+     a = { [f(1)] = g; "x", "y"; x = 1, f(x), [30] = 23; 45 }
+

+is equivalent to + +

+     do
+       local t = {}
+       t[f(1)] = g
+       t[1] = "x"         -- 1st exp
+       t[2] = "y"         -- 2nd exp
+       t.x = 1            -- t["x"] = 1
+       t[3] = f(x)        -- 3rd exp
+       t[30] = 23
+       t[4] = 45          -- 4th exp
+       a = t
+     end
+
+ +

+If the last field in the list has the form exp +and the expression is a function call or a vararg expression, +then all values returned by this expression enter the list consecutively +(see §2.5.8). +To avoid this, +enclose the function call or the vararg expression +in parentheses (see §2.5). + + +

+The field list can have an optional trailing separator, +as a convenience for machine-generated code. + + + + + +

2.5.8 - Function Calls

+A function call in Lua has the following syntax: + +

+	functioncall ::= prefixexp args
+

+In a function call, +first prefixexp and args are evaluated. +If the value of prefixexp has type function, +then this function is called +with the given arguments. +Otherwise, the prefixexp "call" metamethod is called, +having as first parameter the value of prefixexp, +followed by the original call arguments +(see §2.8). + + +

+The form + +

+	functioncall ::= prefixexp `:´ Name args
+

+can be used to call "methods". +A call v:name(args) +is syntactic sugar for v.name(v,args), +except that v is evaluated only once. + + +

+Arguments have the following syntax: + +

+	args ::= `(´ [explist] `)´
+	args ::= tableconstructor
+	args ::= String
+

+All argument expressions are evaluated before the call. +A call of the form f{fields} is +syntactic sugar for f({fields}); +that is, the argument list is a single new table. +A call of the form f'string' +(or f"string" or f[[string]]) +is syntactic sugar for f('string'); +that is, the argument list is a single literal string. + + +

+As an exception to the free-format syntax of Lua, +you cannot put a line break before the '(' in a function call. +This restriction avoids some ambiguities in the language. +If you write + +

+     a = f
+     (g).x(a)
+

+Lua would see that as a single statement, a = f(g).x(a). +So, if you want two statements, you must add a semi-colon between them. +If you actually want to call f, +you must remove the line break before (g). + + +

+A call of the form return functioncall is called +a tail call. +Lua implements proper tail calls +(or proper tail recursion): +in a tail call, +the called function reuses the stack entry of the calling function. +Therefore, there is no limit on the number of nested tail calls that +a program can execute. +However, a tail call erases any debug information about the +calling function. +Note that a tail call only happens with a particular syntax, +where the return has one single function call as argument; +this syntax makes the calling function return exactly +the returns of the called function. +So, none of the following examples are tail calls: + +

+     return (f(x))        -- results adjusted to 1
+     return 2 * f(x)
+     return x, f(x)       -- additional results
+     f(x); return         -- results discarded
+     return x or f(x)     -- results adjusted to 1
+
+ + + + +

2.5.9 - Function Definitions

+ +

+The syntax for function definition is + +

+	function ::= function funcbody
+	funcbody ::= `(´ [parlist] `)´ block end
+
+ +

+The following syntactic sugar simplifies function definitions: + +

+	stat ::= function funcname funcbody
+	stat ::= local function Name funcbody
+	funcname ::= Name {`.´ Name} [`:´ Name]
+

+The statement + +

+     function f () body end
+

+translates to + +

+     f = function () body end
+

+The statement + +

+     function t.a.b.c.f () body end
+

+translates to + +

+     t.a.b.c.f = function () body end
+

+The statement + +

+     local function f () body end
+

+translates to + +

+     local f; f = function () body end
+

+not to + +

+     local f = function () body end
+

+(This only makes a difference when the body of the function +contains references to f.) + + +

+A function definition is an executable expression, +whose value has type function. +When Lua pre-compiles a chunk, +all its function bodies are pre-compiled too. +Then, whenever Lua executes the function definition, +the function is instantiated (or closed). +This function instance (or closure) +is the final value of the expression. +Different instances of the same function +can refer to different external local variables +and can have different environment tables. + + +

+Parameters act as local variables that are +initialized with the argument values: + +

+	parlist ::= namelist [`,´ `...´] | `...´
+

+When a function is called, +the list of arguments is adjusted to +the length of the list of parameters, +unless the function is a variadic or vararg function, +which is +indicated by three dots ('...') at the end of its parameter list. +A vararg function does not adjust its argument list; +instead, it collects all extra arguments and supplies them +to the function through a vararg expression, +which is also written as three dots. +The value of this expression is a list of all actual extra arguments, +similar to a function with multiple results. +If a vararg expression is used inside another expression +or in the middle of a list of expressions, +then its return list is adjusted to one element. +If the expression is used as the last element of a list of expressions, +then no adjustment is made +(unless that last expression is enclosed in parentheses). + + +

+As an example, consider the following definitions: + +

+     function f(a, b) end
+     function g(a, b, ...) end
+     function r() return 1,2,3 end
+

+Then, we have the following mapping from arguments to parameters and +to the vararg expression: + +

+     CALL            PARAMETERS
+     
+     f(3)             a=3, b=nil
+     f(3, 4)          a=3, b=4
+     f(3, 4, 5)       a=3, b=4
+     f(r(), 10)       a=1, b=10
+     f(r())           a=1, b=2
+     
+     g(3)             a=3, b=nil, ... -->  (nothing)
+     g(3, 4)          a=3, b=4,   ... -->  (nothing)
+     g(3, 4, 5, 8)    a=3, b=4,   ... -->  5  8
+     g(5, r())        a=5, b=1,   ... -->  2  3
+
+ +

+Results are returned using the return statement (see §2.4.4). +If control reaches the end of a function +without encountering a return statement, +then the function returns with no results. + + +

+The colon syntax +is used for defining methods, +that is, functions that have an implicit extra parameter self. +Thus, the statement + +

+     function t.a.b.c:f (params) body end
+

+is syntactic sugar for + +

+     t.a.b.c.f = function (self, params) body end
+
+ + + + + + +

2.6 - Visibility Rules

+ +

+ +Lua is a lexically scoped language. +The scope of variables begins at the first statement after +their declaration and lasts until the end of the innermost block that +includes the declaration. +Consider the following example: + +

+     x = 10                -- global variable
+     do                    -- new block
+       local x = x         -- new 'x', with value 10
+       print(x)            --> 10
+       x = x+1
+       do                  -- another block
+         local x = x+1     -- another 'x'
+         print(x)          --> 12
+       end
+       print(x)            --> 11
+     end
+     print(x)              --> 10  (the global one)
+
+ +

+Notice that, in a declaration like local x = x, +the new x being declared is not in scope yet, +and so the second x refers to the outside variable. + + +

+Because of the lexical scoping rules, +local variables can be freely accessed by functions +defined inside their scope. +A local variable used by an inner function is called +an upvalue, or external local variable, +inside the inner function. + + +

+Notice that each execution of a local statement +defines new local variables. +Consider the following example: + +

+     a = {}
+     local x = 20
+     for i=1,10 do
+       local y = 0
+       a[i] = function () y=y+1; return x+y end
+     end
+

+The loop creates ten closures +(that is, ten instances of the anonymous function). +Each of these closures uses a different y variable, +while all of them share the same x. + + + + + +

2.7 - Error Handling

+ +

+Because Lua is an embedded extension language, +all Lua actions start from C code in the host program +calling a function from the Lua library (see lua_pcall). +Whenever an error occurs during Lua compilation or execution, +control returns to C, +which can take appropriate measures +(such as printing an error message). + + +

+Lua code can explicitly generate an error by calling the +error function. +If you need to catch errors in Lua, +you can use the pcall function. + + + + + +

2.8 - Metatables

+ +

+Every value in Lua can have a metatable. +This metatable is an ordinary Lua table +that defines the behavior of the original value +under certain special operations. +You can change several aspects of the behavior +of operations over a value by setting specific fields in its metatable. +For instance, when a non-numeric value is the operand of an addition, +Lua checks for a function in the field "__add" in its metatable. +If it finds one, +Lua calls this function to perform the addition. + + +

+We call the keys in a metatable events +and the values metamethods. +In the previous example, the event is "add" +and the metamethod is the function that performs the addition. + + +

+You can query the metatable of any value +through the getmetatable function. + + +

+You can replace the metatable of tables +through the setmetatable +function. +You cannot change the metatable of other types from Lua +(except by using the debug library); +you must use the C API for that. + + +

+Tables and full userdata have individual metatables +(although multiple tables and userdata can share their metatables). +Values of all other types share one single metatable per type; +that is, there is one single metatable for all numbers, +one for all strings, etc. + + +

+A metatable controls how an object behaves in arithmetic operations, +order comparisons, concatenation, length operation, and indexing. +A metatable also can define a function to be called when a userdata +is garbage collected. +For each of these operations Lua associates a specific key +called an event. +When Lua performs one of these operations over a value, +it checks whether this value has a metatable with the corresponding event. +If so, the value associated with that key (the metamethod) +controls how Lua will perform the operation. + + +

+Metatables control the operations listed next. +Each operation is identified by its corresponding name. +The key for each operation is a string with its name prefixed by +two underscores, '__'; +for instance, the key for operation "add" is the +string "__add". +The semantics of these operations is better explained by a Lua function +describing how the interpreter executes the operation. + + +

+The code shown here in Lua is only illustrative; +the real behavior is hard coded in the interpreter +and it is much more efficient than this simulation. +All functions used in these descriptions +(rawget, tonumber, etc.) +are described in §5.1. +In particular, to retrieve the metamethod of a given object, +we use the expression + +

+     metatable(obj)[event]
+

+This should be read as + +

+     rawget(getmetatable(obj) or {}, event)
+

+ +That is, the access to a metamethod does not invoke other metamethods, +and the access to objects with no metatables does not fail +(it simply results in nil). + + + +

    + +
  • "add": +the + operation. + + + +

    +The function getbinhandler below defines how Lua chooses a handler +for a binary operation. +First, Lua tries the first operand. +If its type does not define a handler for the operation, +then Lua tries the second operand. + +

    +     function getbinhandler (op1, op2, event)
    +       return metatable(op1)[event] or metatable(op2)[event]
    +     end
    +

    +By using this function, +the behavior of the op1 + op2 is + +

    +     function add_event (op1, op2)
    +       local o1, o2 = tonumber(op1), tonumber(op2)
    +       if o1 and o2 then  -- both operands are numeric?
    +         return o1 + o2   -- '+' here is the primitive 'add'
    +       else  -- at least one of the operands is not numeric
    +         local h = getbinhandler(op1, op2, "__add")
    +         if h then
    +           -- call the handler with both operands
    +           return (h(op1, op2))
    +         else  -- no handler available: default behavior
    +           error(···)
    +         end
    +       end
    +     end
    +

    +

  • + +
  • "sub": +the - operation. + +Behavior similar to the "add" operation. +
  • + +
  • "mul": +the * operation. + +Behavior similar to the "add" operation. +
  • + +
  • "div": +the / operation. + +Behavior similar to the "add" operation. +
  • + +
  • "mod": +the % operation. + +Behavior similar to the "add" operation, +with the operation +o1 - floor(o1/o2)*o2 as the primitive operation. +
  • + +
  • "pow": +the ^ (exponentiation) operation. + +Behavior similar to the "add" operation, +with the function pow (from the C math library) +as the primitive operation. +
  • + +
  • "unm": +the unary - operation. + + +
    +     function unm_event (op)
    +       local o = tonumber(op)
    +       if o then  -- operand is numeric?
    +         return -o  -- '-' here is the primitive 'unm'
    +       else  -- the operand is not numeric.
    +         -- Try to get a handler from the operand
    +         local h = metatable(op).__unm
    +         if h then
    +           -- call the handler with the operand
    +           return (h(op))
    +         else  -- no handler available: default behavior
    +           error(···)
    +         end
    +       end
    +     end
    +

    +

  • + +
  • "concat": +the .. (concatenation) operation. + + +
    +     function concat_event (op1, op2)
    +       if (type(op1) == "string" or type(op1) == "number") and
    +          (type(op2) == "string" or type(op2) == "number") then
    +         return op1 .. op2  -- primitive string concatenation
    +       else
    +         local h = getbinhandler(op1, op2, "__concat")
    +         if h then
    +           return (h(op1, op2))
    +         else
    +           error(···)
    +         end
    +       end
    +     end
    +

    +

  • + +
  • "len": +the # operation. + + +
    +     function len_event (op)
    +       if type(op) == "string" then
    +         return strlen(op)         -- primitive string length
    +       elseif type(op) == "table" then
    +         return #op                -- primitive table length
    +       else
    +         local h = metatable(op).__len
    +         if h then
    +           -- call the handler with the operand
    +           return (h(op))
    +         else  -- no handler available: default behavior
    +           error(···)
    +         end
    +       end
    +     end
    +

    +See §2.5.5 for a description of the length of a table. +

  • + +
  • "eq": +the == operation. + +The function getcomphandler defines how Lua chooses a metamethod +for comparison operators. +A metamethod only is selected when both objects +being compared have the same type +and the same metamethod for the selected operation. + +
    +     function getcomphandler (op1, op2, event)
    +       if type(op1) ~= type(op2) then return nil end
    +       local mm1 = metatable(op1)[event]
    +       local mm2 = metatable(op2)[event]
    +       if mm1 == mm2 then return mm1 else return nil end
    +     end
    +

    +The "eq" event is defined as follows: + +

    +     function eq_event (op1, op2)
    +       if type(op1) ~= type(op2) then  -- different types?
    +         return false   -- different objects
    +       end
    +       if op1 == op2 then   -- primitive equal?
    +         return true   -- objects are equal
    +       end
    +       -- try metamethod
    +       local h = getcomphandler(op1, op2, "__eq")
    +       if h then
    +         return (h(op1, op2))
    +       else
    +         return false
    +       end
    +     end
    +

    +a ~= b is equivalent to not (a == b). +

  • + +
  • "lt": +the < operation. + + +
    +     function lt_event (op1, op2)
    +       if type(op1) == "number" and type(op2) == "number" then
    +         return op1 < op2   -- numeric comparison
    +       elseif type(op1) == "string" and type(op2) == "string" then
    +         return op1 < op2   -- lexicographic comparison
    +       else
    +         local h = getcomphandler(op1, op2, "__lt")
    +         if h then
    +           return (h(op1, op2))
    +         else
    +           error(···)
    +         end
    +       end
    +     end
    +

    +a > b is equivalent to b < a. +

  • + +
  • "le": +the <= operation. + + +
    +     function le_event (op1, op2)
    +       if type(op1) == "number" and type(op2) == "number" then
    +         return op1 <= op2   -- numeric comparison
    +       elseif type(op1) == "string" and type(op2) == "string" then
    +         return op1 <= op2   -- lexicographic comparison
    +       else
    +         local h = getcomphandler(op1, op2, "__le")
    +         if h then
    +           return (h(op1, op2))
    +         else
    +           h = getcomphandler(op1, op2, "__lt")
    +           if h then
    +             return not h(op2, op1)
    +           else
    +             error(···)
    +           end
    +         end
    +       end
    +     end
    +

    +a >= b is equivalent to b <= a. +Note that, in the absence of a "le" metamethod, +Lua tries the "lt", assuming that a <= b is +equivalent to not (b < a). +

  • + +
  • "index": +The indexing access table[key]. + + +
    +     function gettable_event (table, key)
    +       local h
    +       if type(table) == "table" then
    +         local v = rawget(table, key)
    +         if v ~= nil then return v end
    +         h = metatable(table).__index
    +         if h == nil then return nil end
    +       else
    +         h = metatable(table).__index
    +         if h == nil then
    +           error(···)
    +         end
    +       end
    +       if type(h) == "function" then
    +         return (h(table, key))     -- call the handler
    +       else return h[key]           -- or repeat operation on it
    +       end
    +     end
    +

    +

  • + +
  • "newindex": +The indexing assignment table[key] = value. + + +
    +     function settable_event (table, key, value)
    +       local h
    +       if type(table) == "table" then
    +         local v = rawget(table, key)
    +         if v ~= nil then rawset(table, key, value); return end
    +         h = metatable(table).__newindex
    +         if h == nil then rawset(table, key, value); return end
    +       else
    +         h = metatable(table).__newindex
    +         if h == nil then
    +           error(···)
    +         end
    +       end
    +       if type(h) == "function" then
    +         h(table, key,value)           -- call the handler
    +       else h[key] = value             -- or repeat operation on it
    +       end
    +     end
    +

    +

  • + +
  • "call": +called when Lua calls a value. + + +
    +     function function_event (func, ...)
    +       if type(func) == "function" then
    +         return func(...)   -- primitive call
    +       else
    +         local h = metatable(func).__call
    +         if h then
    +           return h(func, ...)
    +         else
    +           error(···)
    +         end
    +       end
    +     end
    +

    +

  • + +
+ + + + +

2.9 - Environments

+ +

+Besides metatables, +objects of types thread, function, and userdata +have another table associated with them, +called their environment. +Like metatables, environments are regular tables and +multiple objects can share the same environment. + + +

+Threads are created sharing the environment of the creating thread. +Userdata and C functions are created sharing the environment +of the creating C function. +Non-nested Lua functions +(created by loadfile, loadstring or load) +are created sharing the environment of the creating thread. +Nested Lua functions are created sharing the environment of +the creating Lua function. + + +

+Environments associated with userdata have no meaning for Lua. +It is only a convenience feature for programmers to associate a table to +a userdata. + + +

+Environments associated with threads are called +global environments. +They are used as the default environment for threads and +non-nested Lua functions created by the thread +and can be directly accessed by C code (see §3.3). + + +

+The environment associated with a C function can be directly +accessed by C code (see §3.3). +It is used as the default environment for other C functions +and userdata created by the function. + + +

+Environments associated with Lua functions are used to resolve +all accesses to global variables within the function (see §2.3). +They are used as the default environment for nested Lua functions +created by the function. + + +

+You can change the environment of a Lua function or the +running thread by calling setfenv. +You can get the environment of a Lua function or the running thread +by calling getfenv. +To manipulate the environment of other objects +(userdata, C functions, other threads) you must +use the C API. + + + + + +

2.10 - Garbage Collection

+ +

+Lua performs automatic memory management. +This means that +you have to worry neither about allocating memory for new objects +nor about freeing it when the objects are no longer needed. +Lua manages memory automatically by running +a garbage collector from time to time +to collect all dead objects +(that is, objects that are no longer accessible from Lua). +All memory used by Lua is subject to automatic management: +tables, userdata, functions, threads, strings, etc. + + +

+Lua implements an incremental mark-and-sweep collector. +It uses two numbers to control its garbage-collection cycles: +the garbage-collector pause and +the garbage-collector step multiplier. +Both use percentage points as units +(so that a value of 100 means an internal value of 1). + + +

+The garbage-collector pause +controls how long the collector waits before starting a new cycle. +Larger values make the collector less aggressive. +Values smaller than 100 mean the collector will not wait to +start a new cycle. +A value of 200 means that the collector waits for the total memory in use +to double before starting a new cycle. + + +

+The step multiplier +controls the relative speed of the collector relative to +memory allocation. +Larger values make the collector more aggressive but also increase +the size of each incremental step. +Values smaller than 100 make the collector too slow and +can result in the collector never finishing a cycle. +The default, 200, means that the collector runs at "twice" +the speed of memory allocation. + + +

+You can change these numbers by calling lua_gc in C +or collectgarbage in Lua. +With these functions you can also control +the collector directly (e.g., stop and restart it). + + + +

2.10.1 - Garbage-Collection Metamethods

+ +

+Using the C API, +you can set garbage-collector metamethods for userdata (see §2.8). +These metamethods are also called finalizers. +Finalizers allow you to coordinate Lua's garbage collection +with external resource management +(such as closing files, network or database connections, +or freeing your own memory). + + +

+Garbage userdata with a field __gc in their metatables are not +collected immediately by the garbage collector. +Instead, Lua puts them in a list. +After the collection, +Lua does the equivalent of the following function +for each userdata in that list: + +

+     function gc_event (udata)
+       local h = metatable(udata).__gc
+       if h then
+         h(udata)
+       end
+     end
+
+ +

+At the end of each garbage-collection cycle, +the finalizers for userdata are called in reverse +order of their creation, +among those collected in that cycle. +That is, the first finalizer to be called is the one associated +with the userdata created last in the program. +The userdata itself is freed only in the next garbage-collection cycle. + + + + + +

2.10.2 - Weak Tables

+ +

+A weak table is a table whose elements are +weak references. +A weak reference is ignored by the garbage collector. +In other words, +if the only references to an object are weak references, +then the garbage collector will collect this object. + + +

+A weak table can have weak keys, weak values, or both. +A table with weak keys allows the collection of its keys, +but prevents the collection of its values. +A table with both weak keys and weak values allows the collection of +both keys and values. +In any case, if either the key or the value is collected, +the whole pair is removed from the table. +The weakness of a table is controlled by the +__mode field of its metatable. +If the __mode field is a string containing the character 'k', +the keys in the table are weak. +If __mode contains 'v', +the values in the table are weak. + + +

+After you use a table as a metatable, +you should not change the value of its __mode field. +Otherwise, the weak behavior of the tables controlled by this +metatable is undefined. + + + + + + + +

2.11 - Coroutines

+ +

+Lua supports coroutines, +also called collaborative multithreading. +A coroutine in Lua represents an independent thread of execution. +Unlike threads in multithread systems, however, +a coroutine only suspends its execution by explicitly calling +a yield function. + + +

+You create a coroutine with a call to coroutine.create. +Its sole argument is a function +that is the main function of the coroutine. +The create function only creates a new coroutine and +returns a handle to it (an object of type thread); +it does not start the coroutine execution. + + +

+When you first call coroutine.resume, +passing as its first argument +a thread returned by coroutine.create, +the coroutine starts its execution, +at the first line of its main function. +Extra arguments passed to coroutine.resume are passed on +to the coroutine main function. +After the coroutine starts running, +it runs until it terminates or yields. + + +

+A coroutine can terminate its execution in two ways: +normally, when its main function returns +(explicitly or implicitly, after the last instruction); +and abnormally, if there is an unprotected error. +In the first case, coroutine.resume returns true, +plus any values returned by the coroutine main function. +In case of errors, coroutine.resume returns false +plus an error message. + + +

+A coroutine yields by calling coroutine.yield. +When a coroutine yields, +the corresponding coroutine.resume returns immediately, +even if the yield happens inside nested function calls +(that is, not in the main function, +but in a function directly or indirectly called by the main function). +In the case of a yield, coroutine.resume also returns true, +plus any values passed to coroutine.yield. +The next time you resume the same coroutine, +it continues its execution from the point where it yielded, +with the call to coroutine.yield returning any extra +arguments passed to coroutine.resume. + + +

+Like coroutine.create, +the coroutine.wrap function also creates a coroutine, +but instead of returning the coroutine itself, +it returns a function that, when called, resumes the coroutine. +Any arguments passed to this function +go as extra arguments to coroutine.resume. +coroutine.wrap returns all the values returned by coroutine.resume, +except the first one (the boolean error code). +Unlike coroutine.resume, +coroutine.wrap does not catch errors; +any error is propagated to the caller. + + +

+As an example, +consider the following code: + +

+     function foo (a)
+       print("foo", a)
+       return coroutine.yield(2*a)
+     end
+     
+     co = coroutine.create(function (a,b)
+           print("co-body", a, b)
+           local r = foo(a+1)
+           print("co-body", r)
+           local r, s = coroutine.yield(a+b, a-b)
+           print("co-body", r, s)
+           return b, "end"
+     end)
+            
+     print("main", coroutine.resume(co, 1, 10))
+     print("main", coroutine.resume(co, "r"))
+     print("main", coroutine.resume(co, "x", "y"))
+     print("main", coroutine.resume(co, "x", "y"))
+

+When you run it, it produces the following output: + +

+     co-body 1       10
+     foo     2
+     
+     main    true    4
+     co-body r
+     main    true    11      -9
+     co-body x       y
+     main    true    10      end
+     main    false   cannot resume dead coroutine
+
+ + + + +

3 - The Application Program Interface

+ +

+ +This section describes the C API for Lua, that is, +the set of C functions available to the host program to communicate +with Lua. +All API functions and related types and constants +are declared in the header file lua.h. + + +

+Even when we use the term "function", +any facility in the API may be provided as a macro instead. +All such macros use each of their arguments exactly once +(except for the first argument, which is always a Lua state), +and so do not generate any hidden side-effects. + + +

+As in most C libraries, +the Lua API functions do not check their arguments for validity or consistency. +However, you can change this behavior by compiling Lua +with a proper definition for the macro luai_apicheck, +in file luaconf.h. + + + +

3.1 - The Stack

+ +

+Lua uses a virtual stack to pass values to and from C. +Each element in this stack represents a Lua value +(nil, number, string, etc.). + + +

+Whenever Lua calls C, the called function gets a new stack, +which is independent of previous stacks and of stacks of +C functions that are still active. +This stack initially contains any arguments to the C function +and it is where the C function pushes its results +to be returned to the caller (see lua_CFunction). + + +

+For convenience, +most query operations in the API do not follow a strict stack discipline. +Instead, they can refer to any element in the stack +by using an index: +A positive index represents an absolute stack position +(starting at 1); +a negative index represents an offset relative to the top of the stack. +More specifically, if the stack has n elements, +then index 1 represents the first element +(that is, the element that was pushed onto the stack first) +and +index n represents the last element; +index -1 also represents the last element +(that is, the element at the top) +and index -n represents the first element. +We say that an index is valid +if it lies between 1 and the stack top +(that is, if 1 ≤ abs(index) ≤ top). + + + + + + +

3.2 - Stack Size

+ +

+When you interact with Lua API, +you are responsible for ensuring consistency. +In particular, +you are responsible for controlling stack overflow. +You can use the function lua_checkstack +to grow the stack size. + + +

+Whenever Lua calls C, +it ensures that at least LUA_MINSTACK stack positions are available. +LUA_MINSTACK is defined as 20, +so that usually you do not have to worry about stack space +unless your code has loops pushing elements onto the stack. + + +

+Most query functions accept as indices any value inside the +available stack space, that is, indices up to the maximum stack size +you have set through lua_checkstack. +Such indices are called acceptable indices. +More formally, we define an acceptable index +as follows: + +

+     (index < 0 && abs(index) <= top) ||
+     (index > 0 && index <= stackspace)
+

+Note that 0 is never an acceptable index. + + + + + +

3.3 - Pseudo-Indices

+ +

+Unless otherwise noted, +any function that accepts valid indices can also be called with +pseudo-indices, +which represent some Lua values that are accessible to C code +but which are not in the stack. +Pseudo-indices are used to access the thread environment, +the function environment, +the registry, +and the upvalues of a C function (see §3.4). + + +

+The thread environment (where global variables live) is +always at pseudo-index LUA_GLOBALSINDEX. +The environment of the running C function is always +at pseudo-index LUA_ENVIRONINDEX. + + +

+To access and change the value of global variables, +you can use regular table operations over an environment table. +For instance, to access the value of a global variable, do + +

+     lua_getfield(L, LUA_GLOBALSINDEX, varname);
+
+ + + + +

3.4 - C Closures

+ +

+When a C function is created, +it is possible to associate some values with it, +thus creating a C closure; +these values are called upvalues and are +accessible to the function whenever it is called +(see lua_pushcclosure). + + +

+Whenever a C function is called, +its upvalues are located at specific pseudo-indices. +These pseudo-indices are produced by the macro +lua_upvalueindex. +The first value associated with a function is at position +lua_upvalueindex(1), and so on. +Any access to lua_upvalueindex(n), +where n is greater than the number of upvalues of the +current function (but not greater than 256), +produces an acceptable (but invalid) index. + + + + + +

3.5 - Registry

+ +

+Lua provides a registry, +a pre-defined table that can be used by any C code to +store whatever Lua value it needs to store. +This table is always located at pseudo-index +LUA_REGISTRYINDEX. +Any C library can store data into this table, +but it should take care to choose keys different from those used +by other libraries, to avoid collisions. +Typically, you should use as key a string containing your library name +or a light userdata with the address of a C object in your code. + + +

+The integer keys in the registry are used by the reference mechanism, +implemented by the auxiliary library, +and therefore should not be used for other purposes. + + + + + +

3.6 - Error Handling in C

+ +

+Internally, Lua uses the C longjmp facility to handle errors. +(You can also choose to use exceptions if you use C++; +see file luaconf.h.) +When Lua faces any error +(such as memory allocation errors, type errors, syntax errors, +and runtime errors) +it raises an error; +that is, it does a long jump. +A protected environment uses setjmp +to set a recover point; +any error jumps to the most recent active recover point. + + +

+Most functions in the API can throw an error, +for instance due to a memory allocation error. +The documentation for each function indicates whether +it can throw errors. + + +

+Inside a C function you can throw an error by calling lua_error. + + + + + +

3.7 - Functions and Types

+ +

+Here we list all functions and types from the C API in +alphabetical order. +Each function has an indicator like this: +[-o, +p, x] + + +

+The first field, o, +is how many elements the function pops from the stack. +The second field, p, +is how many elements the function pushes onto the stack. +(Any function always pushes its results after popping its arguments.) +A field in the form x|y means the function can push (or pop) +x or y elements, +depending on the situation; +an interrogation mark '?' means that +we cannot know how many elements the function pops/pushes +by looking only at its arguments +(e.g., they may depend on what is on the stack). +The third field, x, +tells whether the function may throw errors: +'-' means the function never throws any error; +'m' means the function may throw an error +only due to not enough memory; +'e' means the function may throw other kinds of errors; +'v' means the function may throw an error on purpose. + + + +


lua_Alloc

+
typedef void * (*lua_Alloc) (void *ud,
+                             void *ptr,
+                             size_t osize,
+                             size_t nsize);
+ +

+The type of the memory-allocation function used by Lua states. +The allocator function must provide a +functionality similar to realloc, +but not exactly the same. +Its arguments are +ud, an opaque pointer passed to lua_newstate; +ptr, a pointer to the block being allocated/reallocated/freed; +osize, the original size of the block; +nsize, the new size of the block. +ptr is NULL if and only if osize is zero. +When nsize is zero, the allocator must return NULL; +if osize is not zero, +it should free the block pointed to by ptr. +When nsize is not zero, the allocator returns NULL +if and only if it cannot fill the request. +When nsize is not zero and osize is zero, +the allocator should behave like malloc. +When nsize and osize are not zero, +the allocator behaves like realloc. +Lua assumes that the allocator never fails when +osize >= nsize. + + +

+Here is a simple implementation for the allocator function. +It is used in the auxiliary library by luaL_newstate. + +

+     static void *l_alloc (void *ud, void *ptr, size_t osize,
+                                                size_t nsize) {
+       (void)ud;  (void)osize;  /* not used */
+       if (nsize == 0) {
+         free(ptr);
+         return NULL;
+       }
+       else
+         return realloc(ptr, nsize);
+     }
+

+This code assumes +that free(NULL) has no effect and that +realloc(NULL, size) is equivalent to malloc(size). +ANSI C ensures both behaviors. + + + + + +


lua_atpanic

+[-0, +0, -] +

lua_CFunction lua_atpanic (lua_State *L, lua_CFunction panicf);
+ +

+Sets a new panic function and returns the old one. + + +

+If an error happens outside any protected environment, +Lua calls a panic function +and then calls exit(EXIT_FAILURE), +thus exiting the host application. +Your panic function can avoid this exit by +never returning (e.g., doing a long jump). + + +

+The panic function can access the error message at the top of the stack. + + + + + +


lua_call

+[-(nargs + 1), +nresults, e] +

void lua_call (lua_State *L, int nargs, int nresults);
+ +

+Calls a function. + + +

+To call a function you must use the following protocol: +first, the function to be called is pushed onto the stack; +then, the arguments to the function are pushed +in direct order; +that is, the first argument is pushed first. +Finally you call lua_call; +nargs is the number of arguments that you pushed onto the stack. +All arguments and the function value are popped from the stack +when the function is called. +The function results are pushed onto the stack when the function returns. +The number of results is adjusted to nresults, +unless nresults is LUA_MULTRET. +In this case, all results from the function are pushed. +Lua takes care that the returned values fit into the stack space. +The function results are pushed onto the stack in direct order +(the first result is pushed first), +so that after the call the last result is on the top of the stack. + + +

+Any error inside the called function is propagated upwards +(with a longjmp). + + +

+The following example shows how the host program can do the +equivalent to this Lua code: + +

+     a = f("how", t.x, 14)
+

+Here it is in C: + +

+     lua_getfield(L, LUA_GLOBALSINDEX, "f"); /* function to be called */
+     lua_pushstring(L, "how");                        /* 1st argument */
+     lua_getfield(L, LUA_GLOBALSINDEX, "t");   /* table to be indexed */
+     lua_getfield(L, -1, "x");        /* push result of t.x (2nd arg) */
+     lua_remove(L, -2);                  /* remove 't' from the stack */
+     lua_pushinteger(L, 14);                          /* 3rd argument */
+     lua_call(L, 3, 1);     /* call 'f' with 3 arguments and 1 result */
+     lua_setfield(L, LUA_GLOBALSINDEX, "a");        /* set global 'a' */
+

+Note that the code above is "balanced": +at its end, the stack is back to its original configuration. +This is considered good programming practice. + + + + + +


lua_CFunction

+
typedef int (*lua_CFunction) (lua_State *L);
+ +

+Type for C functions. + + +

+In order to communicate properly with Lua, +a C function must use the following protocol, +which defines the way parameters and results are passed: +a C function receives its arguments from Lua in its stack +in direct order (the first argument is pushed first). +So, when the function starts, +lua_gettop(L) returns the number of arguments received by the function. +The first argument (if any) is at index 1 +and its last argument is at index lua_gettop(L). +To return values to Lua, a C function just pushes them onto the stack, +in direct order (the first result is pushed first), +and returns the number of results. +Any other value in the stack below the results will be properly +discarded by Lua. +Like a Lua function, a C function called by Lua can also return +many results. + + +

+As an example, the following function receives a variable number +of numerical arguments and returns their average and sum: + +

+     static int foo (lua_State *L) {
+       int n = lua_gettop(L);    /* number of arguments */
+       lua_Number sum = 0;
+       int i;
+       for (i = 1; i <= n; i++) {
+         if (!lua_isnumber(L, i)) {
+           lua_pushstring(L, "incorrect argument");
+           lua_error(L);
+         }
+         sum += lua_tonumber(L, i);
+       }
+       lua_pushnumber(L, sum/n);        /* first result */
+       lua_pushnumber(L, sum);         /* second result */
+       return 2;                   /* number of results */
+     }
+
+ + + + +

lua_checkstack

+[-0, +0, m] +

int lua_checkstack (lua_State *L, int extra);
+ +

+Ensures that there are at least extra free stack slots in the stack. +It returns false if it cannot grow the stack to that size. +This function never shrinks the stack; +if the stack is already larger than the new size, +it is left unchanged. + + + + + +


lua_close

+[-0, +0, -] +

void lua_close (lua_State *L);
+ +

+Destroys all objects in the given Lua state +(calling the corresponding garbage-collection metamethods, if any) +and frees all dynamic memory used by this state. +On several platforms, you may not need to call this function, +because all resources are naturally released when the host program ends. +On the other hand, long-running programs, +such as a daemon or a web server, +might need to release states as soon as they are not needed, +to avoid growing too large. + + + + + +


lua_concat

+[-n, +1, e] +

void lua_concat (lua_State *L, int n);
+ +

+Concatenates the n values at the top of the stack, +pops them, and leaves the result at the top. +If n is 1, the result is the single value on the stack +(that is, the function does nothing); +if n is 0, the result is the empty string. +Concatenation is performed following the usual semantics of Lua +(see §2.5.4). + + + + + +


lua_cpcall

+[-0, +(0|1), -] +

int lua_cpcall (lua_State *L, lua_CFunction func, void *ud);
+ +

+Calls the C function func in protected mode. +func starts with only one element in its stack, +a light userdata containing ud. +In case of errors, +lua_cpcall returns the same error codes as lua_pcall, +plus the error object on the top of the stack; +otherwise, it returns zero, and does not change the stack. +All values returned by func are discarded. + + + + + +


lua_createtable

+[-0, +1, m] +

void lua_createtable (lua_State *L, int narr, int nrec);
+ +

+Creates a new empty table and pushes it onto the stack. +The new table has space pre-allocated +for narr array elements and nrec non-array elements. +This pre-allocation is useful when you know exactly how many elements +the table will have. +Otherwise you can use the function lua_newtable. + + + + + +


lua_dump

+[-0, +0, m] +

int lua_dump (lua_State *L, lua_Writer writer, void *data);
+ +

+Dumps a function as a binary chunk. +Receives a Lua function on the top of the stack +and produces a binary chunk that, +if loaded again, +results in a function equivalent to the one dumped. +As it produces parts of the chunk, +lua_dump calls function writer (see lua_Writer) +with the given data +to write them. + + +

+The value returned is the error code returned by the last +call to the writer; +0 means no errors. + + +

+This function does not pop the Lua function from the stack. + + + + + +


lua_equal

+[-0, +0, e] +

int lua_equal (lua_State *L, int index1, int index2);
+ +

+Returns 1 if the two values in acceptable indices index1 and +index2 are equal, +following the semantics of the Lua == operator +(that is, may call metamethods). +Otherwise returns 0. +Also returns 0 if any of the indices is non valid. + + + + + +


lua_error

+[-1, +0, v] +

int lua_error (lua_State *L);
+ +

+Generates a Lua error. +The error message (which can actually be a Lua value of any type) +must be on the stack top. +This function does a long jump, +and therefore never returns. +(see luaL_error). + + + + + +


lua_gc

+[-0, +0, e] +

int lua_gc (lua_State *L, int what, int data);
+ +

+Controls the garbage collector. + + +

+This function performs several tasks, +according to the value of the parameter what: + +

    + +
  • LUA_GCSTOP: +stops the garbage collector. +
  • + +
  • LUA_GCRESTART: +restarts the garbage collector. +
  • + +
  • LUA_GCCOLLECT: +performs a full garbage-collection cycle. +
  • + +
  • LUA_GCCOUNT: +returns the current amount of memory (in Kbytes) in use by Lua. +
  • + +
  • LUA_GCCOUNTB: +returns the remainder of dividing the current amount of bytes of +memory in use by Lua by 1024. +
  • + +
  • LUA_GCSTEP: +performs an incremental step of garbage collection. +The step "size" is controlled by data +(larger values mean more steps) in a non-specified way. +If you want to control the step size +you must experimentally tune the value of data. +The function returns 1 if the step finished a +garbage-collection cycle. +
  • + +
  • LUA_GCSETPAUSE: +sets data as the new value +for the pause of the collector (see §2.10). +The function returns the previous value of the pause. +
  • + +
  • LUA_GCSETSTEPMUL: +sets data as the new value for the step multiplier of +the collector (see §2.10). +The function returns the previous value of the step multiplier. +
  • + +
+ + + + +

lua_getallocf

+[-0, +0, -] +

lua_Alloc lua_getallocf (lua_State *L, void **ud);
+ +

+Returns the memory-allocation function of a given state. +If ud is not NULL, Lua stores in *ud the +opaque pointer passed to lua_newstate. + + + + + +


lua_getfenv

+[-0, +1, -] +

void lua_getfenv (lua_State *L, int index);
+ +

+Pushes onto the stack the environment table of +the value at the given index. + + + + + +


lua_getfield

+[-0, +1, e] +

void lua_getfield (lua_State *L, int index, const char *k);
+ +

+Pushes onto the stack the value t[k], +where t is the value at the given valid index. +As in Lua, this function may trigger a metamethod +for the "index" event (see §2.8). + + + + + +


lua_getglobal

+[-0, +1, e] +

void lua_getglobal (lua_State *L, const char *name);
+ +

+Pushes onto the stack the value of the global name. +It is defined as a macro: + +

+     #define lua_getglobal(L,s)  lua_getfield(L, LUA_GLOBALSINDEX, s)
+
+ + + + +

lua_getmetatable

+[-0, +(0|1), -] +

int lua_getmetatable (lua_State *L, int index);
+ +

+Pushes onto the stack the metatable of the value at the given +acceptable index. +If the index is not valid, +or if the value does not have a metatable, +the function returns 0 and pushes nothing on the stack. + + + + + +


lua_gettable

+[-1, +1, e] +

void lua_gettable (lua_State *L, int index);
+ +

+Pushes onto the stack the value t[k], +where t is the value at the given valid index +and k is the value at the top of the stack. + + +

+This function pops the key from the stack +(putting the resulting value in its place). +As in Lua, this function may trigger a metamethod +for the "index" event (see §2.8). + + + + + +


lua_gettop

+[-0, +0, -] +

int lua_gettop (lua_State *L);
+ +

+Returns the index of the top element in the stack. +Because indices start at 1, +this result is equal to the number of elements in the stack +(and so 0 means an empty stack). + + + + + +


lua_insert

+[-1, +1, -] +

void lua_insert (lua_State *L, int index);
+ +

+Moves the top element into the given valid index, +shifting up the elements above this index to open space. +Cannot be called with a pseudo-index, +because a pseudo-index is not an actual stack position. + + + + + +


lua_Integer

+
typedef ptrdiff_t lua_Integer;
+ +

+The type used by the Lua API to represent integral values. + + +

+By default it is a ptrdiff_t, +which is usually the largest signed integral type the machine handles +"comfortably". + + + + + +


lua_isboolean

+[-0, +0, -] +

int lua_isboolean (lua_State *L, int index);
+ +

+Returns 1 if the value at the given acceptable index has type boolean, +and 0 otherwise. + + + + + +


lua_iscfunction

+[-0, +0, -] +

int lua_iscfunction (lua_State *L, int index);
+ +

+Returns 1 if the value at the given acceptable index is a C function, +and 0 otherwise. + + + + + +


lua_isfunction

+[-0, +0, -] +

int lua_isfunction (lua_State *L, int index);
+ +

+Returns 1 if the value at the given acceptable index is a function +(either C or Lua), and 0 otherwise. + + + + + +


lua_islightuserdata

+[-0, +0, -] +

int lua_islightuserdata (lua_State *L, int index);
+ +

+Returns 1 if the value at the given acceptable index is a light userdata, +and 0 otherwise. + + + + + +


lua_isnil

+[-0, +0, -] +

int lua_isnil (lua_State *L, int index);
+ +

+Returns 1 if the value at the given acceptable index is nil, +and 0 otherwise. + + + + + +


lua_isnone

+[-0, +0, -] +

int lua_isnone (lua_State *L, int index);
+ +

+Returns 1 if the given acceptable index is not valid +(that is, it refers to an element outside the current stack), +and 0 otherwise. + + + + + +


lua_isnoneornil

+[-0, +0, -] +

int lua_isnoneornil (lua_State *L, int index);
+ +

+Returns 1 if the given acceptable index is not valid +(that is, it refers to an element outside the current stack) +or if the value at this index is nil, +and 0 otherwise. + + + + + +


lua_isnumber

+[-0, +0, -] +

int lua_isnumber (lua_State *L, int index);
+ +

+Returns 1 if the value at the given acceptable index is a number +or a string convertible to a number, +and 0 otherwise. + + + + + +


lua_isstring

+[-0, +0, -] +

int lua_isstring (lua_State *L, int index);
+ +

+Returns 1 if the value at the given acceptable index is a string +or a number (which is always convertible to a string), +and 0 otherwise. + + + + + +


lua_istable

+[-0, +0, -] +

int lua_istable (lua_State *L, int index);
+ +

+Returns 1 if the value at the given acceptable index is a table, +and 0 otherwise. + + + + + +


lua_isthread

+[-0, +0, -] +

int lua_isthread (lua_State *L, int index);
+ +

+Returns 1 if the value at the given acceptable index is a thread, +and 0 otherwise. + + + + + +


lua_isuserdata

+[-0, +0, -] +

int lua_isuserdata (lua_State *L, int index);
+ +

+Returns 1 if the value at the given acceptable index is a userdata +(either full or light), and 0 otherwise. + + + + + +


lua_lessthan

+[-0, +0, e] +

int lua_lessthan (lua_State *L, int index1, int index2);
+ +

+Returns 1 if the value at acceptable index index1 is smaller +than the value at acceptable index index2, +following the semantics of the Lua < operator +(that is, may call metamethods). +Otherwise returns 0. +Also returns 0 if any of the indices is non valid. + + + + + +


lua_load

+[-0, +1, -] +

int lua_load (lua_State *L,
+              lua_Reader reader,
+              void *data,
+              const char *chunkname);
+ +

+Loads a Lua chunk. +If there are no errors, +lua_load pushes the compiled chunk as a Lua +function on top of the stack. +Otherwise, it pushes an error message. +The return values of lua_load are: + +

    + +
  • 0: no errors;
  • + +
  • LUA_ERRSYNTAX: +syntax error during pre-compilation;
  • + +
  • LUA_ERRMEM: +memory allocation error.
  • + +
+ +

+This function only loads a chunk; +it does not run it. + + +

+lua_load automatically detects whether the chunk is text or binary, +and loads it accordingly (see program luac). + + +

+The lua_load function uses a user-supplied reader function +to read the chunk (see lua_Reader). +The data argument is an opaque value passed to the reader function. + + +

+The chunkname argument gives a name to the chunk, +which is used for error messages and in debug information (see §3.8). + + + + + +


lua_newstate

+[-0, +0, -] +

lua_State *lua_newstate (lua_Alloc f, void *ud);
+ +

+Creates a new, independent state. +Returns NULL if cannot create the state +(due to lack of memory). +The argument f is the allocator function; +Lua does all memory allocation for this state through this function. +The second argument, ud, is an opaque pointer that Lua +simply passes to the allocator in every call. + + + + + +


lua_newtable

+[-0, +1, m] +

void lua_newtable (lua_State *L);
+ +

+Creates a new empty table and pushes it onto the stack. +It is equivalent to lua_createtable(L, 0, 0). + + + + + +


lua_newthread

+[-0, +1, m] +

lua_State *lua_newthread (lua_State *L);
+ +

+Creates a new thread, pushes it on the stack, +and returns a pointer to a lua_State that represents this new thread. +The new state returned by this function shares with the original state +all global objects (such as tables), +but has an independent execution stack. + + +

+There is no explicit function to close or to destroy a thread. +Threads are subject to garbage collection, +like any Lua object. + + + + + +


lua_newuserdata

+[-0, +1, m] +

void *lua_newuserdata (lua_State *L, size_t size);
+ +

+This function allocates a new block of memory with the given size, +pushes onto the stack a new full userdata with the block address, +and returns this address. + + +

+Userdata represent C values in Lua. +A full userdata represents a block of memory. +It is an object (like a table): +you must create it, it can have its own metatable, +and you can detect when it is being collected. +A full userdata is only equal to itself (under raw equality). + + +

+When Lua collects a full userdata with a gc metamethod, +Lua calls the metamethod and marks the userdata as finalized. +When this userdata is collected again then +Lua frees its corresponding memory. + + + + + +


lua_next

+[-1, +(2|0), e] +

int lua_next (lua_State *L, int index);
+ +

+Pops a key from the stack, +and pushes a key-value pair from the table at the given index +(the "next" pair after the given key). +If there are no more elements in the table, +then lua_next returns 0 (and pushes nothing). + + +

+A typical traversal looks like this: + +

+     /* table is in the stack at index 't' */
+     lua_pushnil(L);  /* first key */
+     while (lua_next(L, t) != 0) {
+       /* uses 'key' (at index -2) and 'value' (at index -1) */
+       printf("%s - %s\n",
+              lua_typename(L, lua_type(L, -2)),
+              lua_typename(L, lua_type(L, -1)));
+       /* removes 'value'; keeps 'key' for next iteration */
+       lua_pop(L, 1);
+     }
+
+ +

+While traversing a table, +do not call lua_tolstring directly on a key, +unless you know that the key is actually a string. +Recall that lua_tolstring changes +the value at the given index; +this confuses the next call to lua_next. + + + + + +


lua_Number

+
typedef double lua_Number;
+ +

+The type of numbers in Lua. +By default, it is double, but that can be changed in luaconf.h. + + +

+Through the configuration file you can change +Lua to operate with another type for numbers (e.g., float or long). + + + + + +


lua_objlen

+[-0, +0, -] +

size_t lua_objlen (lua_State *L, int index);
+ +

+Returns the "length" of the value at the given acceptable index: +for strings, this is the string length; +for tables, this is the result of the length operator ('#'); +for userdata, this is the size of the block of memory allocated +for the userdata; +for other values, it is 0. + + + + + +


lua_pcall

+[-(nargs + 1), +(nresults|1), -] +

int lua_pcall (lua_State *L, int nargs, int nresults, int errfunc);
+ +

+Calls a function in protected mode. + + +

+Both nargs and nresults have the same meaning as +in lua_call. +If there are no errors during the call, +lua_pcall behaves exactly like lua_call. +However, if there is any error, +lua_pcall catches it, +pushes a single value on the stack (the error message), +and returns an error code. +Like lua_call, +lua_pcall always removes the function +and its arguments from the stack. + + +

+If errfunc is 0, +then the error message returned on the stack +is exactly the original error message. +Otherwise, errfunc is the stack index of an +error handler function. +(In the current implementation, this index cannot be a pseudo-index.) +In case of runtime errors, +this function will be called with the error message +and its return value will be the message returned on the stack by lua_pcall. + + +

+Typically, the error handler function is used to add more debug +information to the error message, such as a stack traceback. +Such information cannot be gathered after the return of lua_pcall, +since by then the stack has unwound. + + +

+The lua_pcall function returns 0 in case of success +or one of the following error codes +(defined in lua.h): + +

    + +
  • LUA_ERRRUN: +a runtime error. +
  • + +
  • LUA_ERRMEM: +memory allocation error. +For such errors, Lua does not call the error handler function. +
  • + +
  • LUA_ERRERR: +error while running the error handler function. +
  • + +
+ + + + +

lua_pop

+[-n, +0, -] +

void lua_pop (lua_State *L, int n);
+ +

+Pops n elements from the stack. + + + + + +


lua_pushboolean

+[-0, +1, -] +

void lua_pushboolean (lua_State *L, int b);
+ +

+Pushes a boolean value with value b onto the stack. + + + + + +


lua_pushcclosure

+[-n, +1, m] +

void lua_pushcclosure (lua_State *L, lua_CFunction fn, int n);
+ +

+Pushes a new C closure onto the stack. + + +

+When a C function is created, +it is possible to associate some values with it, +thus creating a C closure (see §3.4); +these values are then accessible to the function whenever it is called. +To associate values with a C function, +first these values should be pushed onto the stack +(when there are multiple values, the first value is pushed first). +Then lua_pushcclosure +is called to create and push the C function onto the stack, +with the argument n telling how many values should be +associated with the function. +lua_pushcclosure also pops these values from the stack. + + +

+The maximum value for n is 255. + + + + + +


lua_pushcfunction

+[-0, +1, m] +

void lua_pushcfunction (lua_State *L, lua_CFunction f);
+ +

+Pushes a C function onto the stack. +This function receives a pointer to a C function +and pushes onto the stack a Lua value of type function that, +when called, invokes the corresponding C function. + + +

+Any function to be registered in Lua must +follow the correct protocol to receive its parameters +and return its results (see lua_CFunction). + + +

+lua_pushcfunction is defined as a macro: + +

+     #define lua_pushcfunction(L,f)  lua_pushcclosure(L,f,0)
+
+ + + + +

lua_pushfstring

+[-0, +1, m] +

const char *lua_pushfstring (lua_State *L, const char *fmt, ...);
+ +

+Pushes onto the stack a formatted string +and returns a pointer to this string. +It is similar to the C function sprintf, +but has some important differences: + +

    + +
  • +You do not have to allocate space for the result: +the result is a Lua string and Lua takes care of memory allocation +(and deallocation, through garbage collection). +
  • + +
  • +The conversion specifiers are quite restricted. +There are no flags, widths, or precisions. +The conversion specifiers can only be +'%%' (inserts a '%' in the string), +'%s' (inserts a zero-terminated string, with no size restrictions), +'%f' (inserts a lua_Number), +'%p' (inserts a pointer as a hexadecimal numeral), +'%d' (inserts an int), and +'%c' (inserts an int as a character). +
  • + +
+ + + + +

lua_pushinteger

+[-0, +1, -] +

void lua_pushinteger (lua_State *L, lua_Integer n);
+ +

+Pushes a number with value n onto the stack. + + + + + +


lua_pushlightuserdata

+[-0, +1, -] +

void lua_pushlightuserdata (lua_State *L, void *p);
+ +

+Pushes a light userdata onto the stack. + + +

+Userdata represent C values in Lua. +A light userdata represents a pointer. +It is a value (like a number): +you do not create it, it has no individual metatable, +and it is not collected (as it was never created). +A light userdata is equal to "any" +light userdata with the same C address. + + + + + +


lua_pushliteral

+[-0, +1, m] +

void lua_pushliteral (lua_State *L, const char *s);
+ +

+This macro is equivalent to lua_pushlstring, +but can be used only when s is a literal string. +In these cases, it automatically provides the string length. + + + + + +


lua_pushlstring

+[-0, +1, m] +

void lua_pushlstring (lua_State *L, const char *s, size_t len);
+ +

+Pushes the string pointed to by s with size len +onto the stack. +Lua makes (or reuses) an internal copy of the given string, +so the memory at s can be freed or reused immediately after +the function returns. +The string can contain embedded zeros. + + + + + +


lua_pushnil

+[-0, +1, -] +

void lua_pushnil (lua_State *L);
+ +

+Pushes a nil value onto the stack. + + + + + +


lua_pushnumber

+[-0, +1, -] +

void lua_pushnumber (lua_State *L, lua_Number n);
+ +

+Pushes a number with value n onto the stack. + + + + + +


lua_pushstring

+[-0, +1, m] +

void lua_pushstring (lua_State *L, const char *s);
+ +

+Pushes the zero-terminated string pointed to by s +onto the stack. +Lua makes (or reuses) an internal copy of the given string, +so the memory at s can be freed or reused immediately after +the function returns. +The string cannot contain embedded zeros; +it is assumed to end at the first zero. + + + + + +


lua_pushthread

+[-0, +1, -] +

int lua_pushthread (lua_State *L);
+ +

+Pushes the thread represented by L onto the stack. +Returns 1 if this thread is the main thread of its state. + + + + + +


lua_pushvalue

+[-0, +1, -] +

void lua_pushvalue (lua_State *L, int index);
+ +

+Pushes a copy of the element at the given valid index +onto the stack. + + + + + +


lua_pushvfstring

+[-0, +1, m] +

const char *lua_pushvfstring (lua_State *L,
+                              const char *fmt,
+                              va_list argp);
+ +

+Equivalent to lua_pushfstring, except that it receives a va_list +instead of a variable number of arguments. + + + + + +


lua_rawequal

+[-0, +0, -] +

int lua_rawequal (lua_State *L, int index1, int index2);
+ +

+Returns 1 if the two values in acceptable indices index1 and +index2 are primitively equal +(that is, without calling metamethods). +Otherwise returns 0. +Also returns 0 if any of the indices are non valid. + + + + + +


lua_rawget

+[-1, +1, -] +

void lua_rawget (lua_State *L, int index);
+ +

+Similar to lua_gettable, but does a raw access +(i.e., without metamethods). + + + + + +


lua_rawgeti

+[-0, +1, -] +

void lua_rawgeti (lua_State *L, int index, int n);
+ +

+Pushes onto the stack the value t[n], +where t is the value at the given valid index. +The access is raw; +that is, it does not invoke metamethods. + + + + + +


lua_rawset

+[-2, +0, m] +

void lua_rawset (lua_State *L, int index);
+ +

+Similar to lua_settable, but does a raw assignment +(i.e., without metamethods). + + + + + +


lua_rawseti

+[-1, +0, m] +

void lua_rawseti (lua_State *L, int index, int n);
+ +

+Does the equivalent of t[n] = v, +where t is the value at the given valid index +and v is the value at the top of the stack. + + +

+This function pops the value from the stack. +The assignment is raw; +that is, it does not invoke metamethods. + + + + + +


lua_Reader

+
typedef const char * (*lua_Reader) (lua_State *L,
+                                    void *data,
+                                    size_t *size);
+ +

+The reader function used by lua_load. +Every time it needs another piece of the chunk, +lua_load calls the reader, +passing along its data parameter. +The reader must return a pointer to a block of memory +with a new piece of the chunk +and set size to the block size. +The block must exist until the reader function is called again. +To signal the end of the chunk, +the reader must return NULL or set size to zero. +The reader function may return pieces of any size greater than zero. + + + + + +


lua_register

+[-0, +0, e] +

void lua_register (lua_State *L,
+                   const char *name,
+                   lua_CFunction f);
+ +

+Sets the C function f as the new value of global name. +It is defined as a macro: + +

+     #define lua_register(L,n,f) \
+            (lua_pushcfunction(L, f), lua_setglobal(L, n))
+
+ + + + +

lua_remove

+[-1, +0, -] +

void lua_remove (lua_State *L, int index);
+ +

+Removes the element at the given valid index, +shifting down the elements above this index to fill the gap. +Cannot be called with a pseudo-index, +because a pseudo-index is not an actual stack position. + + + + + +


lua_replace

+[-1, +0, -] +

void lua_replace (lua_State *L, int index);
+ +

+Moves the top element into the given position (and pops it), +without shifting any element +(therefore replacing the value at the given position). + + + + + +


lua_resume

+[-?, +?, -] +

int lua_resume (lua_State *L, int narg);
+ +

+Starts and resumes a coroutine in a given thread. + + +

+To start a coroutine, you first create a new thread +(see lua_newthread); +then you push onto its stack the main function plus any arguments; +then you call lua_resume, +with narg being the number of arguments. +This call returns when the coroutine suspends or finishes its execution. +When it returns, the stack contains all values passed to lua_yield, +or all values returned by the body function. +lua_resume returns +LUA_YIELD if the coroutine yields, +0 if the coroutine finishes its execution +without errors, +or an error code in case of errors (see lua_pcall). +In case of errors, +the stack is not unwound, +so you can use the debug API over it. +The error message is on the top of the stack. +To restart a coroutine, you put on its stack only the values to +be passed as results from yield, +and then call lua_resume. + + + + + +


lua_setallocf

+[-0, +0, -] +

void lua_setallocf (lua_State *L, lua_Alloc f, void *ud);
+ +

+Changes the allocator function of a given state to f +with user data ud. + + + + + +


lua_setfenv

+[-1, +0, -] +

int lua_setfenv (lua_State *L, int index);
+ +

+Pops a table from the stack and sets it as +the new environment for the value at the given index. +If the value at the given index is +neither a function nor a thread nor a userdata, +lua_setfenv returns 0. +Otherwise it returns 1. + + + + + +


lua_setfield

+[-1, +0, e] +

void lua_setfield (lua_State *L, int index, const char *k);
+ +

+Does the equivalent to t[k] = v, +where t is the value at the given valid index +and v is the value at the top of the stack. + + +

+This function pops the value from the stack. +As in Lua, this function may trigger a metamethod +for the "newindex" event (see §2.8). + + + + + +


lua_setglobal

+[-1, +0, e] +

void lua_setglobal (lua_State *L, const char *name);
+ +

+Pops a value from the stack and +sets it as the new value of global name. +It is defined as a macro: + +

+     #define lua_setglobal(L,s)   lua_setfield(L, LUA_GLOBALSINDEX, s)
+
+ + + + +

lua_setmetatable

+[-1, +0, -] +

int lua_setmetatable (lua_State *L, int index);
+ +

+Pops a table from the stack and +sets it as the new metatable for the value at the given +acceptable index. + + + + + +


lua_settable

+[-2, +0, e] +

void lua_settable (lua_State *L, int index);
+ +

+Does the equivalent to t[k] = v, +where t is the value at the given valid index, +v is the value at the top of the stack, +and k is the value just below the top. + + +

+This function pops both the key and the value from the stack. +As in Lua, this function may trigger a metamethod +for the "newindex" event (see §2.8). + + + + + +


lua_settop

+[-?, +?, -] +

void lua_settop (lua_State *L, int index);
+ +

+Accepts any acceptable index, or 0, +and sets the stack top to this index. +If the new top is larger than the old one, +then the new elements are filled with nil. +If index is 0, then all stack elements are removed. + + + + + +


lua_State

+
typedef struct lua_State lua_State;
+ +

+Opaque structure that keeps the whole state of a Lua interpreter. +The Lua library is fully reentrant: +it has no global variables. +All information about a state is kept in this structure. + + +

+A pointer to this state must be passed as the first argument to +every function in the library, except to lua_newstate, +which creates a Lua state from scratch. + + + + + +


lua_status

+[-0, +0, -] +

int lua_status (lua_State *L);
+ +

+Returns the status of the thread L. + + +

+The status can be 0 for a normal thread, +an error code if the thread finished its execution with an error, +or LUA_YIELD if the thread is suspended. + + + + + +


lua_toboolean

+[-0, +0, -] +

int lua_toboolean (lua_State *L, int index);
+ +

+Converts the Lua value at the given acceptable index to a C boolean +value (0 or 1). +Like all tests in Lua, +lua_toboolean returns 1 for any Lua value +different from false and nil; +otherwise it returns 0. +It also returns 0 when called with a non-valid index. +(If you want to accept only actual boolean values, +use lua_isboolean to test the value's type.) + + + + + +


lua_tocfunction

+[-0, +0, -] +

lua_CFunction lua_tocfunction (lua_State *L, int index);
+ +

+Converts a value at the given acceptable index to a C function. +That value must be a C function; +otherwise, returns NULL. + + + + + +


lua_tointeger

+[-0, +0, -] +

lua_Integer lua_tointeger (lua_State *L, int index);
+ +

+Converts the Lua value at the given acceptable index +to the signed integral type lua_Integer. +The Lua value must be a number or a string convertible to a number +(see §2.2.1); +otherwise, lua_tointeger returns 0. + + +

+If the number is not an integer, +it is truncated in some non-specified way. + + + + + +


lua_tolstring

+[-0, +0, m] +

const char *lua_tolstring (lua_State *L, int index, size_t *len);
+ +

+Converts the Lua value at the given acceptable index to a C string. +If len is not NULL, +it also sets *len with the string length. +The Lua value must be a string or a number; +otherwise, the function returns NULL. +If the value is a number, +then lua_tolstring also +changes the actual value in the stack to a string. +(This change confuses lua_next +when lua_tolstring is applied to keys during a table traversal.) + + +

+lua_tolstring returns a fully aligned pointer +to a string inside the Lua state. +This string always has a zero ('\0') +after its last character (as in C), +but can contain other zeros in its body. +Because Lua has garbage collection, +there is no guarantee that the pointer returned by lua_tolstring +will be valid after the corresponding value is removed from the stack. + + + + + +


lua_tonumber

+[-0, +0, -] +

lua_Number lua_tonumber (lua_State *L, int index);
+ +

+Converts the Lua value at the given acceptable index +to the C type lua_Number (see lua_Number). +The Lua value must be a number or a string convertible to a number +(see §2.2.1); +otherwise, lua_tonumber returns 0. + + + + + +


lua_topointer

+[-0, +0, -] +

const void *lua_topointer (lua_State *L, int index);
+ +

+Converts the value at the given acceptable index to a generic +C pointer (void*). +The value can be a userdata, a table, a thread, or a function; +otherwise, lua_topointer returns NULL. +Different objects will give different pointers. +There is no way to convert the pointer back to its original value. + + +

+Typically this function is used only for debug information. + + + + + +


lua_tostring

+[-0, +0, m] +

const char *lua_tostring (lua_State *L, int index);
+ +

+Equivalent to lua_tolstring with len equal to NULL. + + + + + +


lua_tothread

+[-0, +0, -] +

lua_State *lua_tothread (lua_State *L, int index);
+ +

+Converts the value at the given acceptable index to a Lua thread +(represented as lua_State*). +This value must be a thread; +otherwise, the function returns NULL. + + + + + +


lua_touserdata

+[-0, +0, -] +

void *lua_touserdata (lua_State *L, int index);
+ +

+If the value at the given acceptable index is a full userdata, +returns its block address. +If the value is a light userdata, +returns its pointer. +Otherwise, returns NULL. + + + + + +


lua_type

+[-0, +0, -] +

int lua_type (lua_State *L, int index);
+ +

+Returns the type of the value in the given acceptable index, +or LUA_TNONE for a non-valid index +(that is, an index to an "empty" stack position). +The types returned by lua_type are coded by the following constants +defined in lua.h: +LUA_TNIL, +LUA_TNUMBER, +LUA_TBOOLEAN, +LUA_TSTRING, +LUA_TTABLE, +LUA_TFUNCTION, +LUA_TUSERDATA, +LUA_TTHREAD, +and +LUA_TLIGHTUSERDATA. + + + + + +


lua_typename

+[-0, +0, -] +

const char *lua_typename  (lua_State *L, int tp);
+ +

+Returns the name of the type encoded by the value tp, +which must be one the values returned by lua_type. + + + + + +


lua_Writer

+
typedef int (*lua_Writer) (lua_State *L,
+                           const void* p,
+                           size_t sz,
+                           void* ud);
+ +

+The type of the writer function used by lua_dump. +Every time it produces another piece of chunk, +lua_dump calls the writer, +passing along the buffer to be written (p), +its size (sz), +and the data parameter supplied to lua_dump. + + +

+The writer returns an error code: +0 means no errors; +any other value means an error and stops lua_dump from +calling the writer again. + + + + + +


lua_xmove

+[-?, +?, -] +

void lua_xmove (lua_State *from, lua_State *to, int n);
+ +

+Exchange values between different threads of the same global state. + + +

+This function pops n values from the stack from, +and pushes them onto the stack to. + + + + + +


lua_yield

+[-?, +?, -] +

int lua_yield  (lua_State *L, int nresults);
+ +

+Yields a coroutine. + + +

+This function should only be called as the +return expression of a C function, as follows: + +

+     return lua_yield (L, nresults);
+

+When a C function calls lua_yield in that way, +the running coroutine suspends its execution, +and the call to lua_resume that started this coroutine returns. +The parameter nresults is the number of values from the stack +that are passed as results to lua_resume. + + + + + + + +

3.8 - The Debug Interface

+ +

+Lua has no built-in debugging facilities. +Instead, it offers a special interface +by means of functions and hooks. +This interface allows the construction of different +kinds of debuggers, profilers, and other tools +that need "inside information" from the interpreter. + + + +


lua_Debug

+
typedef struct lua_Debug {
+  int event;
+  const char *name;           /* (n) */
+  const char *namewhat;       /* (n) */
+  const char *what;           /* (S) */
+  const char *source;         /* (S) */
+  int currentline;            /* (l) */
+  int nups;                   /* (u) number of upvalues */
+  int linedefined;            /* (S) */
+  int lastlinedefined;        /* (S) */
+  char short_src[LUA_IDSIZE]; /* (S) */
+  /* private part */
+  other fields
+} lua_Debug;
+ +

+A structure used to carry different pieces of +information about an active function. +lua_getstack fills only the private part +of this structure, for later use. +To fill the other fields of lua_Debug with useful information, +call lua_getinfo. + + +

+The fields of lua_Debug have the following meaning: + +

    + +
  • source: +If the function was defined in a string, +then source is that string. +If the function was defined in a file, +then source starts with a '@' followed by the file name. +
  • + +
  • short_src: +a "printable" version of source, to be used in error messages. +
  • + +
  • linedefined: +the line number where the definition of the function starts. +
  • + +
  • lastlinedefined: +the line number where the definition of the function ends. +
  • + +
  • what: +the string "Lua" if the function is a Lua function, +"C" if it is a C function, +"main" if it is the main part of a chunk, +and "tail" if it was a function that did a tail call. +In the latter case, +Lua has no other information about the function. +
  • + +
  • currentline: +the current line where the given function is executing. +When no line information is available, +currentline is set to -1. +
  • + +
  • name: +a reasonable name for the given function. +Because functions in Lua are first-class values, +they do not have a fixed name: +some functions can be the value of multiple global variables, +while others can be stored only in a table field. +The lua_getinfo function checks how the function was +called to find a suitable name. +If it cannot find a name, +then name is set to NULL. +
  • + +
  • namewhat: +explains the name field. +The value of namewhat can be +"global", "local", "method", +"field", "upvalue", or "" (the empty string), +according to how the function was called. +(Lua uses the empty string when no other option seems to apply.) +
  • + +
  • nups: +the number of upvalues of the function. +
  • + +
+ + + + +

lua_gethook

+[-0, +0, -] +

lua_Hook lua_gethook (lua_State *L);
+ +

+Returns the current hook function. + + + + + +


lua_gethookcount

+[-0, +0, -] +

int lua_gethookcount (lua_State *L);
+ +

+Returns the current hook count. + + + + + +


lua_gethookmask

+[-0, +0, -] +

int lua_gethookmask (lua_State *L);
+ +

+Returns the current hook mask. + + + + + +


lua_getinfo

+[-(0|1), +(0|1|2), m] +

int lua_getinfo (lua_State *L, const char *what, lua_Debug *ar);
+ +

+Returns information about a specific function or function invocation. + + +

+To get information about a function invocation, +the parameter ar must be a valid activation record that was +filled by a previous call to lua_getstack or +given as argument to a hook (see lua_Hook). + + +

+To get information about a function you push it onto the stack +and start the what string with the character '>'. +(In that case, +lua_getinfo pops the function in the top of the stack.) +For instance, to know in which line a function f was defined, +you can write the following code: + +

+     lua_Debug ar;
+     lua_getfield(L, LUA_GLOBALSINDEX, "f");  /* get global 'f' */
+     lua_getinfo(L, ">S", &ar);
+     printf("%d\n", ar.linedefined);
+
+ +

+Each character in the string what +selects some fields of the structure ar to be filled or +a value to be pushed on the stack: + +

    + +
  • 'n': fills in the field name and namewhat; +
  • + +
  • 'S': +fills in the fields source, short_src, +linedefined, lastlinedefined, and what; +
  • + +
  • 'l': fills in the field currentline; +
  • + +
  • 'u': fills in the field nups; +
  • + +
  • 'f': +pushes onto the stack the function that is +running at the given level; +
  • + +
  • 'L': +pushes onto the stack a table whose indices are the +numbers of the lines that are valid on the function. +(A valid line is a line with some associated code, +that is, a line where you can put a break point. +Non-valid lines include empty lines and comments.) +
  • + +
+ +

+This function returns 0 on error +(for instance, an invalid option in what). + + + + + +


lua_getlocal

+[-0, +(0|1), -] +

const char *lua_getlocal (lua_State *L, lua_Debug *ar, int n);
+ +

+Gets information about a local variable of a given activation record. +The parameter ar must be a valid activation record that was +filled by a previous call to lua_getstack or +given as argument to a hook (see lua_Hook). +The index n selects which local variable to inspect +(1 is the first parameter or active local variable, and so on, +until the last active local variable). +lua_getlocal pushes the variable's value onto the stack +and returns its name. + + +

+Variable names starting with '(' (open parentheses) +represent internal variables +(loop control variables, temporaries, and C function locals). + + +

+Returns NULL (and pushes nothing) +when the index is greater than +the number of active local variables. + + + + + +


lua_getstack

+[-0, +0, -] +

int lua_getstack (lua_State *L, int level, lua_Debug *ar);
+ +

+Get information about the interpreter runtime stack. + + +

+This function fills parts of a lua_Debug structure with +an identification of the activation record +of the function executing at a given level. +Level 0 is the current running function, +whereas level n+1 is the function that has called level n. +When there are no errors, lua_getstack returns 1; +when called with a level greater than the stack depth, +it returns 0. + + + + + +


lua_getupvalue

+[-0, +(0|1), -] +

const char *lua_getupvalue (lua_State *L, int funcindex, int n);
+ +

+Gets information about a closure's upvalue. +(For Lua functions, +upvalues are the external local variables that the function uses, +and that are consequently included in its closure.) +lua_getupvalue gets the index n of an upvalue, +pushes the upvalue's value onto the stack, +and returns its name. +funcindex points to the closure in the stack. +(Upvalues have no particular order, +as they are active through the whole function. +So, they are numbered in an arbitrary order.) + + +

+Returns NULL (and pushes nothing) +when the index is greater than the number of upvalues. +For C functions, this function uses the empty string "" +as a name for all upvalues. + + + + + +


lua_Hook

+
typedef void (*lua_Hook) (lua_State *L, lua_Debug *ar);
+ +

+Type for debugging hook functions. + + +

+Whenever a hook is called, its ar argument has its field +event set to the specific event that triggered the hook. +Lua identifies these events with the following constants: +LUA_HOOKCALL, LUA_HOOKRET, +LUA_HOOKTAILRET, LUA_HOOKLINE, +and LUA_HOOKCOUNT. +Moreover, for line events, the field currentline is also set. +To get the value of any other field in ar, +the hook must call lua_getinfo. +For return events, event can be LUA_HOOKRET, +the normal value, or LUA_HOOKTAILRET. +In the latter case, Lua is simulating a return from +a function that did a tail call; +in this case, it is useless to call lua_getinfo. + + +

+While Lua is running a hook, it disables other calls to hooks. +Therefore, if a hook calls back Lua to execute a function or a chunk, +this execution occurs without any calls to hooks. + + + + + +


lua_sethook

+[-0, +0, -] +

int lua_sethook (lua_State *L, lua_Hook f, int mask, int count);
+ +

+Sets the debugging hook function. + + +

+Argument f is the hook function. +mask specifies on which events the hook will be called: +it is formed by a bitwise or of the constants +LUA_MASKCALL, +LUA_MASKRET, +LUA_MASKLINE, +and LUA_MASKCOUNT. +The count argument is only meaningful when the mask +includes LUA_MASKCOUNT. +For each event, the hook is called as explained below: + +

    + +
  • The call hook: is called when the interpreter calls a function. +The hook is called just after Lua enters the new function, +before the function gets its arguments. +
  • + +
  • The return hook: is called when the interpreter returns from a function. +The hook is called just before Lua leaves the function. +You have no access to the values to be returned by the function. +
  • + +
  • The line hook: is called when the interpreter is about to +start the execution of a new line of code, +or when it jumps back in the code (even to the same line). +(This event only happens while Lua is executing a Lua function.) +
  • + +
  • The count hook: is called after the interpreter executes every +count instructions. +(This event only happens while Lua is executing a Lua function.) +
  • + +
+ +

+A hook is disabled by setting mask to zero. + + + + + +


lua_setlocal

+[-(0|1), +0, -] +

const char *lua_setlocal (lua_State *L, lua_Debug *ar, int n);
+ +

+Sets the value of a local variable of a given activation record. +Parameters ar and n are as in lua_getlocal +(see lua_getlocal). +lua_setlocal assigns the value at the top of the stack +to the variable and returns its name. +It also pops the value from the stack. + + +

+Returns NULL (and pops nothing) +when the index is greater than +the number of active local variables. + + + + + +


lua_setupvalue

+[-(0|1), +0, -] +

const char *lua_setupvalue (lua_State *L, int funcindex, int n);
+ +

+Sets the value of a closure's upvalue. +It assigns the value at the top of the stack +to the upvalue and returns its name. +It also pops the value from the stack. +Parameters funcindex and n are as in the lua_getupvalue +(see lua_getupvalue). + + +

+Returns NULL (and pops nothing) +when the index is greater than the number of upvalues. + + + + + + + +

4 - The Auxiliary Library

+ +

+ +The auxiliary library provides several convenient functions +to interface C with Lua. +While the basic API provides the primitive functions for all +interactions between C and Lua, +the auxiliary library provides higher-level functions for some +common tasks. + + +

+All functions from the auxiliary library +are defined in header file lauxlib.h and +have a prefix luaL_. + + +

+All functions in the auxiliary library are built on +top of the basic API, +and so they provide nothing that cannot be done with this API. + + +

+Several functions in the auxiliary library are used to +check C function arguments. +Their names are always luaL_check* or luaL_opt*. +All of these functions throw an error if the check is not satisfied. +Because the error message is formatted for arguments +(e.g., "bad argument #1"), +you should not use these functions for other stack values. + + + +

4.1 - Functions and Types

+ +

+Here we list all functions and types from the auxiliary library +in alphabetical order. + + + +


luaL_addchar

+[-0, +0, m] +

void luaL_addchar (luaL_Buffer *B, char c);
+ +

+Adds the character c to the buffer B +(see luaL_Buffer). + + + + + +


luaL_addlstring

+[-0, +0, m] +

void luaL_addlstring (luaL_Buffer *B, const char *s, size_t l);
+ +

+Adds the string pointed to by s with length l to +the buffer B +(see luaL_Buffer). +The string may contain embedded zeros. + + + + + +


luaL_addsize

+[-0, +0, m] +

void luaL_addsize (luaL_Buffer *B, size_t n);
+ +

+Adds to the buffer B (see luaL_Buffer) +a string of length n previously copied to the +buffer area (see luaL_prepbuffer). + + + + + +


luaL_addstring

+[-0, +0, m] +

void luaL_addstring (luaL_Buffer *B, const char *s);
+ +

+Adds the zero-terminated string pointed to by s +to the buffer B +(see luaL_Buffer). +The string may not contain embedded zeros. + + + + + +


luaL_addvalue

+[-1, +0, m] +

void luaL_addvalue (luaL_Buffer *B);
+ +

+Adds the value at the top of the stack +to the buffer B +(see luaL_Buffer). +Pops the value. + + +

+This is the only function on string buffers that can (and must) +be called with an extra element on the stack, +which is the value to be added to the buffer. + + + + + +


luaL_argcheck

+[-0, +0, v] +

void luaL_argcheck (lua_State *L,
+                    int cond,
+                    int narg,
+                    const char *extramsg);
+ +

+Checks whether cond is true. +If not, raises an error with the following message, +where func is retrieved from the call stack: + +

+     bad argument #<narg> to <func> (<extramsg>)
+
+ + + + +

luaL_argerror

+[-0, +0, v] +

int luaL_argerror (lua_State *L, int narg, const char *extramsg);
+ +

+Raises an error with the following message, +where func is retrieved from the call stack: + +

+     bad argument #<narg> to <func> (<extramsg>)
+
+ +

+This function never returns, +but it is an idiom to use it in C functions +as return luaL_argerror(args). + + + + + +


luaL_Buffer

+
typedef struct luaL_Buffer luaL_Buffer;
+ +

+Type for a string buffer. + + +

+A string buffer allows C code to build Lua strings piecemeal. +Its pattern of use is as follows: + +

    + +
  • First you declare a variable b of type luaL_Buffer.
  • + +
  • Then you initialize it with a call luaL_buffinit(L, &b).
  • + +
  • +Then you add string pieces to the buffer calling any of +the luaL_add* functions. +
  • + +
  • +You finish by calling luaL_pushresult(&b). +This call leaves the final string on the top of the stack. +
  • + +
+ +

+During its normal operation, +a string buffer uses a variable number of stack slots. +So, while using a buffer, you cannot assume that you know where +the top of the stack is. +You can use the stack between successive calls to buffer operations +as long as that use is balanced; +that is, +when you call a buffer operation, +the stack is at the same level +it was immediately after the previous buffer operation. +(The only exception to this rule is luaL_addvalue.) +After calling luaL_pushresult the stack is back to its +level when the buffer was initialized, +plus the final string on its top. + + + + + +


luaL_buffinit

+[-0, +0, -] +

void luaL_buffinit (lua_State *L, luaL_Buffer *B);
+ +

+Initializes a buffer B. +This function does not allocate any space; +the buffer must be declared as a variable +(see luaL_Buffer). + + + + + +


luaL_callmeta

+[-0, +(0|1), e] +

int luaL_callmeta (lua_State *L, int obj, const char *e);
+ +

+Calls a metamethod. + + +

+If the object at index obj has a metatable and this +metatable has a field e, +this function calls this field and passes the object as its only argument. +In this case this function returns 1 and pushes onto the +stack the value returned by the call. +If there is no metatable or no metamethod, +this function returns 0 (without pushing any value on the stack). + + + + + +


luaL_checkany

+[-0, +0, v] +

void luaL_checkany (lua_State *L, int narg);
+ +

+Checks whether the function has an argument +of any type (including nil) at position narg. + + + + + +


luaL_checkint

+[-0, +0, v] +

int luaL_checkint (lua_State *L, int narg);
+ +

+Checks whether the function argument narg is a number +and returns this number cast to an int. + + + + + +


luaL_checkinteger

+[-0, +0, v] +

lua_Integer luaL_checkinteger (lua_State *L, int narg);
+ +

+Checks whether the function argument narg is a number +and returns this number cast to a lua_Integer. + + + + + +


luaL_checklong

+[-0, +0, v] +

long luaL_checklong (lua_State *L, int narg);
+ +

+Checks whether the function argument narg is a number +and returns this number cast to a long. + + + + + +


luaL_checklstring

+[-0, +0, v] +

const char *luaL_checklstring (lua_State *L, int narg, size_t *l);
+ +

+Checks whether the function argument narg is a string +and returns this string; +if l is not NULL fills *l +with the string's length. + + +

+This function uses lua_tolstring to get its result, +so all conversions and caveats of that function apply here. + + + + + +


luaL_checknumber

+[-0, +0, v] +

lua_Number luaL_checknumber (lua_State *L, int narg);
+ +

+Checks whether the function argument narg is a number +and returns this number. + + + + + +


luaL_checkoption

+[-0, +0, v] +

int luaL_checkoption (lua_State *L,
+                      int narg,
+                      const char *def,
+                      const char *const lst[]);
+ +

+Checks whether the function argument narg is a string and +searches for this string in the array lst +(which must be NULL-terminated). +Returns the index in the array where the string was found. +Raises an error if the argument is not a string or +if the string cannot be found. + + +

+If def is not NULL, +the function uses def as a default value when +there is no argument narg or if this argument is nil. + + +

+This is a useful function for mapping strings to C enums. +(The usual convention in Lua libraries is +to use strings instead of numbers to select options.) + + + + + +


luaL_checkstack

+[-0, +0, v] +

void luaL_checkstack (lua_State *L, int sz, const char *msg);
+ +

+Grows the stack size to top + sz elements, +raising an error if the stack cannot grow to that size. +msg is an additional text to go into the error message. + + + + + +


luaL_checkstring

+[-0, +0, v] +

const char *luaL_checkstring (lua_State *L, int narg);
+ +

+Checks whether the function argument narg is a string +and returns this string. + + +

+This function uses lua_tolstring to get its result, +so all conversions and caveats of that function apply here. + + + + + +


luaL_checktype

+[-0, +0, v] +

void luaL_checktype (lua_State *L, int narg, int t);
+ +

+Checks whether the function argument narg has type t. +See lua_type for the encoding of types for t. + + + + + +


luaL_checkudata

+[-0, +0, v] +

void *luaL_checkudata (lua_State *L, int narg, const char *tname);
+ +

+Checks whether the function argument narg is a userdata +of the type tname (see luaL_newmetatable). + + + + + +


luaL_dofile

+[-0, +?, m] +

int luaL_dofile (lua_State *L, const char *filename);
+ +

+Loads and runs the given file. +It is defined as the following macro: + +

+     (luaL_loadfile(L, filename) || lua_pcall(L, 0, LUA_MULTRET, 0))
+

+It returns 0 if there are no errors +or 1 in case of errors. + + + + + +


luaL_dostring

+[-0, +?, m] +

int luaL_dostring (lua_State *L, const char *str);
+ +

+Loads and runs the given string. +It is defined as the following macro: + +

+     (luaL_loadstring(L, str) || lua_pcall(L, 0, LUA_MULTRET, 0))
+

+It returns 0 if there are no errors +or 1 in case of errors. + + + + + +


luaL_error

+[-0, +0, v] +

int luaL_error (lua_State *L, const char *fmt, ...);
+ +

+Raises an error. +The error message format is given by fmt +plus any extra arguments, +following the same rules of lua_pushfstring. +It also adds at the beginning of the message the file name and +the line number where the error occurred, +if this information is available. + + +

+This function never returns, +but it is an idiom to use it in C functions +as return luaL_error(args). + + + + + +


luaL_getmetafield

+[-0, +(0|1), m] +

int luaL_getmetafield (lua_State *L, int obj, const char *e);
+ +

+Pushes onto the stack the field e from the metatable +of the object at index obj. +If the object does not have a metatable, +or if the metatable does not have this field, +returns 0 and pushes nothing. + + + + + +


luaL_getmetatable

+[-0, +1, -] +

void luaL_getmetatable (lua_State *L, const char *tname);
+ +

+Pushes onto the stack the metatable associated with name tname +in the registry (see luaL_newmetatable). + + + + + +


luaL_gsub

+[-0, +1, m] +

const char *luaL_gsub (lua_State *L,
+                       const char *s,
+                       const char *p,
+                       const char *r);
+ +

+Creates a copy of string s by replacing +any occurrence of the string p +with the string r. +Pushes the resulting string on the stack and returns it. + + + + + +


luaL_loadbuffer

+[-0, +1, m] +

int luaL_loadbuffer (lua_State *L,
+                     const char *buff,
+                     size_t sz,
+                     const char *name);
+ +

+Loads a buffer as a Lua chunk. +This function uses lua_load to load the chunk in the +buffer pointed to by buff with size sz. + + +

+This function returns the same results as lua_load. +name is the chunk name, +used for debug information and error messages. + + + + + +


luaL_loadfile

+[-0, +1, m] +

int luaL_loadfile (lua_State *L, const char *filename);
+ +

+Loads a file as a Lua chunk. +This function uses lua_load to load the chunk in the file +named filename. +If filename is NULL, +then it loads from the standard input. +The first line in the file is ignored if it starts with a #. + + +

+This function returns the same results as lua_load, +but it has an extra error code LUA_ERRFILE +if it cannot open/read the file. + + +

+As lua_load, this function only loads the chunk; +it does not run it. + + + + + +


luaL_loadstring

+[-0, +1, m] +

int luaL_loadstring (lua_State *L, const char *s);
+ +

+Loads a string as a Lua chunk. +This function uses lua_load to load the chunk in +the zero-terminated string s. + + +

+This function returns the same results as lua_load. + + +

+Also as lua_load, this function only loads the chunk; +it does not run it. + + + + + +


luaL_newmetatable

+[-0, +1, m] +

int luaL_newmetatable (lua_State *L, const char *tname);
+ +

+If the registry already has the key tname, +returns 0. +Otherwise, +creates a new table to be used as a metatable for userdata, +adds it to the registry with key tname, +and returns 1. + + +

+In both cases pushes onto the stack the final value associated +with tname in the registry. + + + + + +


luaL_newstate

+[-0, +0, -] +

lua_State *luaL_newstate (void);
+ +

+Creates a new Lua state. +It calls lua_newstate with an +allocator based on the standard C realloc function +and then sets a panic function (see lua_atpanic) that prints +an error message to the standard error output in case of fatal +errors. + + +

+Returns the new state, +or NULL if there is a memory allocation error. + + + + + +


luaL_openlibs

+[-0, +0, m] +

void luaL_openlibs (lua_State *L);
+ +

+Opens all standard Lua libraries into the given state. + + + + + +


luaL_optint

+[-0, +0, v] +

int luaL_optint (lua_State *L, int narg, int d);
+ +

+If the function argument narg is a number, +returns this number cast to an int. +If this argument is absent or is nil, +returns d. +Otherwise, raises an error. + + + + + +


luaL_optinteger

+[-0, +0, v] +

lua_Integer luaL_optinteger (lua_State *L,
+                             int narg,
+                             lua_Integer d);
+ +

+If the function argument narg is a number, +returns this number cast to a lua_Integer. +If this argument is absent or is nil, +returns d. +Otherwise, raises an error. + + + + + +


luaL_optlong

+[-0, +0, v] +

long luaL_optlong (lua_State *L, int narg, long d);
+ +

+If the function argument narg is a number, +returns this number cast to a long. +If this argument is absent or is nil, +returns d. +Otherwise, raises an error. + + + + + +


luaL_optlstring

+[-0, +0, v] +

const char *luaL_optlstring (lua_State *L,
+                             int narg,
+                             const char *d,
+                             size_t *l);
+ +

+If the function argument narg is a string, +returns this string. +If this argument is absent or is nil, +returns d. +Otherwise, raises an error. + + +

+If l is not NULL, +fills the position *l with the results's length. + + + + + +


luaL_optnumber

+[-0, +0, v] +

lua_Number luaL_optnumber (lua_State *L, int narg, lua_Number d);
+ +

+If the function argument narg is a number, +returns this number. +If this argument is absent or is nil, +returns d. +Otherwise, raises an error. + + + + + +


luaL_optstring

+[-0, +0, v] +

const char *luaL_optstring (lua_State *L,
+                            int narg,
+                            const char *d);
+ +

+If the function argument narg is a string, +returns this string. +If this argument is absent or is nil, +returns d. +Otherwise, raises an error. + + + + + +


luaL_prepbuffer

+[-0, +0, -] +

char *luaL_prepbuffer (luaL_Buffer *B);
+ +

+Returns an address to a space of size LUAL_BUFFERSIZE +where you can copy a string to be added to buffer B +(see luaL_Buffer). +After copying the string into this space you must call +luaL_addsize with the size of the string to actually add +it to the buffer. + + + + + +


luaL_pushresult

+[-?, +1, m] +

void luaL_pushresult (luaL_Buffer *B);
+ +

+Finishes the use of buffer B leaving the final string on +the top of the stack. + + + + + +


luaL_ref

+[-1, +0, m] +

int luaL_ref (lua_State *L, int t);
+ +

+Creates and returns a reference, +in the table at index t, +for the object at the top of the stack (and pops the object). + + +

+A reference is a unique integer key. +As long as you do not manually add integer keys into table t, +luaL_ref ensures the uniqueness of the key it returns. +You can retrieve an object referred by reference r +by calling lua_rawgeti(L, t, r). +Function luaL_unref frees a reference and its associated object. + + +

+If the object at the top of the stack is nil, +luaL_ref returns the constant LUA_REFNIL. +The constant LUA_NOREF is guaranteed to be different +from any reference returned by luaL_ref. + + + + + +


luaL_Reg

+
typedef struct luaL_Reg {
+  const char *name;
+  lua_CFunction func;
+} luaL_Reg;
+ +

+Type for arrays of functions to be registered by +luaL_register. +name is the function name and func is a pointer to +the function. +Any array of luaL_Reg must end with an sentinel entry +in which both name and func are NULL. + + + + + +


luaL_register

+[-(0|1), +1, m] +

void luaL_register (lua_State *L,
+                    const char *libname,
+                    const luaL_Reg *l);
+ +

+Opens a library. + + +

+When called with libname equal to NULL, +it simply registers all functions in the list l +(see luaL_Reg) into the table on the top of the stack. + + +

+When called with a non-null libname, +luaL_register creates a new table t, +sets it as the value of the global variable libname, +sets it as the value of package.loaded[libname], +and registers on it all functions in the list l. +If there is a table in package.loaded[libname] or in +variable libname, +reuses this table instead of creating a new one. + + +

+In any case the function leaves the table +on the top of the stack. + + + + + +


luaL_typename

+[-0, +0, -] +

const char *luaL_typename (lua_State *L, int index);
+ +

+Returns the name of the type of the value at the given index. + + + + + +


luaL_typerror

+[-0, +0, v] +

int luaL_typerror (lua_State *L, int narg, const char *tname);
+ +

+Generates an error with a message like the following: + +

+     location: bad argument narg to 'func' (tname expected, got rt)
+

+where location is produced by luaL_where, +func is the name of the current function, +and rt is the type name of the actual argument. + + + + + +


luaL_unref

+[-0, +0, -] +

void luaL_unref (lua_State *L, int t, int ref);
+ +

+Releases reference ref from the table at index t +(see luaL_ref). +The entry is removed from the table, +so that the referred object can be collected. +The reference ref is also freed to be used again. + + +

+If ref is LUA_NOREF or LUA_REFNIL, +luaL_unref does nothing. + + + + + +


luaL_where

+[-0, +1, m] +

void luaL_where (lua_State *L, int lvl);
+ +

+Pushes onto the stack a string identifying the current position +of the control at level lvl in the call stack. +Typically this string has the following format: + +

+     chunkname:currentline:
+

+Level 0 is the running function, +level 1 is the function that called the running function, +etc. + + +

+This function is used to build a prefix for error messages. + + + + + + + +

5 - Standard Libraries

+ +

+The standard Lua libraries provide useful functions +that are implemented directly through the C API. +Some of these functions provide essential services to the language +(e.g., type and getmetatable); +others provide access to "outside" services (e.g., I/O); +and others could be implemented in Lua itself, +but are quite useful or have critical performance requirements that +deserve an implementation in C (e.g., table.sort). + + +

+All libraries are implemented through the official C API +and are provided as separate C modules. +Currently, Lua has the following standard libraries: + +

    + +
  • basic library,
  • which includes the coroutine sub-library; + +
  • package library;
  • + +
  • string manipulation;
  • + +
  • table manipulation;
  • + +
  • mathematical functions (sin, log, etc.);
  • + +
  • input and output;
  • + +
  • operating system facilities;
  • + +
  • debug facilities.
  • + +

+Except for the basic and package libraries, +each library provides all its functions as fields of a global table +or as methods of its objects. + + +

+To have access to these libraries, +the C host program should call the luaL_openlibs function, +which opens all standard libraries. +Alternatively, +it can open them individually by calling +luaopen_base (for the basic library), +luaopen_package (for the package library), +luaopen_string (for the string library), +luaopen_table (for the table library), +luaopen_math (for the mathematical library), +luaopen_io (for the I/O library), +luaopen_os (for the Operating System library), +and luaopen_debug (for the debug library). +These functions are declared in lualib.h +and should not be called directly: +you must call them like any other Lua C function, +e.g., by using lua_call. + + + +

5.1 - Basic Functions

+ +

+The basic library provides some core functions to Lua. +If you do not include this library in your application, +you should check carefully whether you need to provide +implementations for some of its facilities. + + +

+


assert (v [, message])

+Issues an error when +the value of its argument v is false (i.e., nil or false); +otherwise, returns all its arguments. +message is an error message; +when absent, it defaults to "assertion failed!" + + + + +

+


collectgarbage (opt [, arg])

+ + +

+This function is a generic interface to the garbage collector. +It performs different functions according to its first argument, opt: + +

    + +
  • "stop": +stops the garbage collector. +
  • + +
  • "restart": +restarts the garbage collector. +
  • + +
  • "collect": +performs a full garbage-collection cycle. +
  • + +
  • "count": +returns the total memory in use by Lua (in Kbytes). +
  • + +
  • "step": +performs a garbage-collection step. +The step "size" is controlled by arg +(larger values mean more steps) in a non-specified way. +If you want to control the step size +you must experimentally tune the value of arg. +Returns true if the step finished a collection cycle. +
  • + +
  • "setpause": +sets arg as the new value for the pause of +the collector (see §2.10). +Returns the previous value for pause. +
  • + +
  • "setstepmul": +sets arg as the new value for the step multiplier of +the collector (see §2.10). +Returns the previous value for step. +
  • + +
+ + + +

+


dofile (filename)

+Opens the named file and executes its contents as a Lua chunk. +When called without arguments, +dofile executes the contents of the standard input (stdin). +Returns all values returned by the chunk. +In case of errors, dofile propagates the error +to its caller (that is, dofile does not run in protected mode). + + + + +

+


error (message [, level])

+Terminates the last protected function called +and returns message as the error message. +Function error never returns. + + +

+Usually, error adds some information about the error position +at the beginning of the message. +The level argument specifies how to get the error position. +With level 1 (the default), the error position is where the +error function was called. +Level 2 points the error to where the function +that called error was called; and so on. +Passing a level 0 avoids the addition of error position information +to the message. + + + + +

+


_G

+A global variable (not a function) that +holds the global environment (that is, _G._G = _G). +Lua itself does not use this variable; +changing its value does not affect any environment, +nor vice-versa. +(Use setfenv to change environments.) + + + + +

+


getfenv ([f])

+Returns the current environment in use by the function. +f can be a Lua function or a number +that specifies the function at that stack level: +Level 1 is the function calling getfenv. +If the given function is not a Lua function, +or if f is 0, +getfenv returns the global environment. +The default for f is 1. + + + + +

+


getmetatable (object)

+ + +

+If object does not have a metatable, returns nil. +Otherwise, +if the object's metatable has a "__metatable" field, +returns the associated value. +Otherwise, returns the metatable of the given object. + + + + +

+


ipairs (t)

+ + +

+Returns three values: an iterator function, the table t, and 0, +so that the construction + +

+     for i,v in ipairs(t) do body end
+

+will iterate over the pairs (1,t[1]), (2,t[2]), ···, +up to the first integer key absent from the table. + + + + +

+


load (func [, chunkname])

+ + +

+Loads a chunk using function func to get its pieces. +Each call to func must return a string that concatenates +with previous results. +A return of an empty string, nil, or no value signals the end of the chunk. + + +

+If there are no errors, +returns the compiled chunk as a function; +otherwise, returns nil plus the error message. +The environment of the returned function is the global environment. + + +

+chunkname is used as the chunk name for error messages +and debug information. +When absent, +it defaults to "=(load)". + + + + +

+


loadfile ([filename])

+ + +

+Similar to load, +but gets the chunk from file filename +or from the standard input, +if no file name is given. + + + + +

+


loadstring (string [, chunkname])

+ + +

+Similar to load, +but gets the chunk from the given string. + + +

+To load and run a given string, use the idiom + +

+     assert(loadstring(s))()
+
+ +

+When absent, +chunkname defaults to the given string. + + + + +

+


next (table [, index])

+ + +

+Allows a program to traverse all fields of a table. +Its first argument is a table and its second argument +is an index in this table. +next returns the next index of the table +and its associated value. +When called with nil as its second argument, +next returns an initial index +and its associated value. +When called with the last index, +or with nil in an empty table, +next returns nil. +If the second argument is absent, then it is interpreted as nil. +In particular, +you can use next(t) to check whether a table is empty. + + +

+The order in which the indices are enumerated is not specified, +even for numeric indices. +(To traverse a table in numeric order, +use a numerical for or the ipairs function.) + + +

+The behavior of next is undefined if, +during the traversal, +you assign any value to a non-existent field in the table. +You may however modify existing fields. +In particular, you may clear existing fields. + + + + +

+


pairs (t)

+ + +

+Returns three values: the next function, the table t, and nil, +so that the construction + +

+     for k,v in pairs(t) do body end
+

+will iterate over all key–value pairs of table t. + + +

+See function next for the caveats of modifying +the table during its traversal. + + + + +

+


pcall (f, arg1, ···)

+ + +

+Calls function f with +the given arguments in protected mode. +This means that any error inside f is not propagated; +instead, pcall catches the error +and returns a status code. +Its first result is the status code (a boolean), +which is true if the call succeeds without errors. +In such case, pcall also returns all results from the call, +after this first result. +In case of any error, pcall returns false plus the error message. + + + + +

+


print (···)

+Receives any number of arguments, +and prints their values to stdout, +using the tostring function to convert them to strings. +print is not intended for formatted output, +but only as a quick way to show a value, +typically for debugging. +For formatted output, use string.format. + + + + +

+


rawequal (v1, v2)

+Checks whether v1 is equal to v2, +without invoking any metamethod. +Returns a boolean. + + + + +

+


rawget (table, index)

+Gets the real value of table[index], +without invoking any metamethod. +table must be a table; +index may be any value. + + + + +

+


rawset (table, index, value)

+Sets the real value of table[index] to value, +without invoking any metamethod. +table must be a table, +index any value different from nil, +and value any Lua value. + + +

+This function returns table. + + + + +

+


select (index, ···)

+ + +

+If index is a number, +returns all arguments after argument number index. +Otherwise, index must be the string "#", +and select returns the total number of extra arguments it received. + + + + +

+


setfenv (f, table)

+ + +

+Sets the environment to be used by the given function. +f can be a Lua function or a number +that specifies the function at that stack level: +Level 1 is the function calling setfenv. +setfenv returns the given function. + + +

+As a special case, when f is 0 setfenv changes +the environment of the running thread. +In this case, setfenv returns no values. + + + + +

+


setmetatable (table, metatable)

+ + +

+Sets the metatable for the given table. +(You cannot change the metatable of other types from Lua, only from C.) +If metatable is nil, +removes the metatable of the given table. +If the original metatable has a "__metatable" field, +raises an error. + + +

+This function returns table. + + + + +

+


tonumber (e [, base])

+Tries to convert its argument to a number. +If the argument is already a number or a string convertible +to a number, then tonumber returns this number; +otherwise, it returns nil. + + +

+An optional argument specifies the base to interpret the numeral. +The base may be any integer between 2 and 36, inclusive. +In bases above 10, the letter 'A' (in either upper or lower case) +represents 10, 'B' represents 11, and so forth, +with 'Z' representing 35. +In base 10 (the default), the number can have a decimal part, +as well as an optional exponent part (see §2.1). +In other bases, only unsigned integers are accepted. + + + + +

+


tostring (e)

+Receives an argument of any type and +converts it to a string in a reasonable format. +For complete control of how numbers are converted, +use string.format. + + +

+If the metatable of e has a "__tostring" field, +then tostring calls the corresponding value +with e as argument, +and uses the result of the call as its result. + + + + +

+


type (v)

+Returns the type of its only argument, coded as a string. +The possible results of this function are +"nil" (a string, not the value nil), +"number", +"string", +"boolean", +"table", +"function", +"thread", +and "userdata". + + + + +

+


unpack (list [, i [, j]])

+Returns the elements from the given table. +This function is equivalent to + +
+     return list[i], list[i+1], ···, list[j]
+

+except that the above code can be written only for a fixed number +of elements. +By default, i is 1 and j is the length of the list, +as defined by the length operator (see §2.5.5). + + + + +

+


_VERSION

+A global variable (not a function) that +holds a string containing the current interpreter version. +The current contents of this variable is "Lua 5.1". + + + + +

+


xpcall (f, err)

+ + +

+This function is similar to pcall, +except that you can set a new error handler. + + +

+xpcall calls function f in protected mode, +using err as the error handler. +Any error inside f is not propagated; +instead, xpcall catches the error, +calls the err function with the original error object, +and returns a status code. +Its first result is the status code (a boolean), +which is true if the call succeeds without errors. +In this case, xpcall also returns all results from the call, +after this first result. +In case of any error, +xpcall returns false plus the result from err. + + + + + + + +

5.2 - Coroutine Manipulation

+ +

+The operations related to coroutines comprise a sub-library of +the basic library and come inside the table coroutine. +See §2.11 for a general description of coroutines. + + +

+


coroutine.create (f)

+ + +

+Creates a new coroutine, with body f. +f must be a Lua function. +Returns this new coroutine, +an object with type "thread". + + + + +

+


coroutine.resume (co [, val1, ···])

+ + +

+Starts or continues the execution of coroutine co. +The first time you resume a coroutine, +it starts running its body. +The values val1, ··· are passed +as the arguments to the body function. +If the coroutine has yielded, +resume restarts it; +the values val1, ··· are passed +as the results from the yield. + + +

+If the coroutine runs without any errors, +resume returns true plus any values passed to yield +(if the coroutine yields) or any values returned by the body function +(if the coroutine terminates). +If there is any error, +resume returns false plus the error message. + + + + +

+


coroutine.running ()

+ + +

+Returns the running coroutine, +or nil when called by the main thread. + + + + +

+


coroutine.status (co)

+ + +

+Returns the status of coroutine co, as a string: +"running", +if the coroutine is running (that is, it called status); +"suspended", if the coroutine is suspended in a call to yield, +or if it has not started running yet; +"normal" if the coroutine is active but not running +(that is, it has resumed another coroutine); +and "dead" if the coroutine has finished its body function, +or if it has stopped with an error. + + + + +

+


coroutine.wrap (f)

+ + +

+Creates a new coroutine, with body f. +f must be a Lua function. +Returns a function that resumes the coroutine each time it is called. +Any arguments passed to the function behave as the +extra arguments to resume. +Returns the same values returned by resume, +except the first boolean. +In case of error, propagates the error. + + + + +

+


coroutine.yield (···)

+ + +

+Suspends the execution of the calling coroutine. +The coroutine cannot be running a C function, +a metamethod, or an iterator. +Any arguments to yield are passed as extra results to resume. + + + + + + + +

5.3 - Modules

+ +

+The package library provides basic +facilities for loading and building modules in Lua. +It exports two of its functions directly in the global environment: +require and module. +Everything else is exported in a table package. + + +

+


module (name [, ···])

+ + +

+Creates a module. +If there is a table in package.loaded[name], +this table is the module. +Otherwise, if there is a global table t with the given name, +this table is the module. +Otherwise creates a new table t and +sets it as the value of the global name and +the value of package.loaded[name]. +This function also initializes t._NAME with the given name, +t._M with the module (t itself), +and t._PACKAGE with the package name +(the full module name minus last component; see below). +Finally, module sets t as the new environment +of the current function and the new value of package.loaded[name], +so that require returns t. + + +

+If name is a compound name +(that is, one with components separated by dots), +module creates (or reuses, if they already exist) +tables for each component. +For instance, if name is a.b.c, +then module stores the module table in field c of +field b of global a. + + +

+This function can receive optional options after +the module name, +where each option is a function to be applied over the module. + + + + +

+


require (modname)

+ + +

+Loads the given module. +The function starts by looking into the package.loaded table +to determine whether modname is already loaded. +If it is, then require returns the value stored +at package.loaded[modname]. +Otherwise, it tries to find a loader for the module. + + +

+To find a loader, +require is guided by the package.loaders array. +By changing this array, +we can change how require looks for a module. +The following explanation is based on the default configuration +for package.loaders. + + +

+First require queries package.preload[modname]. +If it has a value, +this value (which should be a function) is the loader. +Otherwise require searches for a Lua loader using the +path stored in package.path. +If that also fails, it searches for a C loader using the +path stored in package.cpath. +If that also fails, +it tries an all-in-one loader (see package.loaders). + + +

+Once a loader is found, +require calls the loader with a single argument, modname. +If the loader returns any value, +require assigns the returned value to package.loaded[modname]. +If the loader returns no value and +has not assigned any value to package.loaded[modname], +then require assigns true to this entry. +In any case, require returns the +final value of package.loaded[modname]. + + +

+If there is any error loading or running the module, +or if it cannot find any loader for the module, +then require signals an error. + + + + +

+


package.cpath

+ + +

+The path used by require to search for a C loader. + + +

+Lua initializes the C path package.cpath in the same way +it initializes the Lua path package.path, +using the environment variable LUA_CPATH +or a default path defined in luaconf.h. + + + + +

+ +


package.loaded

+ + +

+A table used by require to control which +modules are already loaded. +When you require a module modname and +package.loaded[modname] is not false, +require simply returns the value stored there. + + + + +

+


package.loaders

+ + +

+A table used by require to control how to load modules. + + +

+Each entry in this table is a searcher function. +When looking for a module, +require calls each of these searchers in ascending order, +with the module name (the argument given to require) as its +sole parameter. +The function can return another function (the module loader) +or a string explaining why it did not find that module +(or nil if it has nothing to say). +Lua initializes this table with four functions. + + +

+The first searcher simply looks for a loader in the +package.preload table. + + +

+The second searcher looks for a loader as a Lua library, +using the path stored at package.path. +A path is a sequence of templates separated by semicolons. +For each template, +the searcher will change each interrogation +mark in the template by filename, +which is the module name with each dot replaced by a +"directory separator" (such as "/" in Unix); +then it will try to open the resulting file name. +So, for instance, if the Lua path is the string + +

+     "./?.lua;./?.lc;/usr/local/?/init.lua"
+

+the search for a Lua file for module foo +will try to open the files +./foo.lua, ./foo.lc, and +/usr/local/foo/init.lua, in that order. + + +

+The third searcher looks for a loader as a C library, +using the path given by the variable package.cpath. +For instance, +if the C path is the string + +

+     "./?.so;./?.dll;/usr/local/?/init.so"
+

+the searcher for module foo +will try to open the files ./foo.so, ./foo.dll, +and /usr/local/foo/init.so, in that order. +Once it finds a C library, +this searcher first uses a dynamic link facility to link the +application with the library. +Then it tries to find a C function inside the library to +be used as the loader. +The name of this C function is the string "luaopen_" +concatenated with a copy of the module name where each dot +is replaced by an underscore. +Moreover, if the module name has a hyphen, +its prefix up to (and including) the first hyphen is removed. +For instance, if the module name is a.v1-b.c, +the function name will be luaopen_b_c. + + +

+The fourth searcher tries an all-in-one loader. +It searches the C path for a library for +the root name of the given module. +For instance, when requiring a.b.c, +it will search for a C library for a. +If found, it looks into it for an open function for +the submodule; +in our example, that would be luaopen_a_b_c. +With this facility, a package can pack several C submodules +into one single library, +with each submodule keeping its original open function. + + + + +

+


package.loadlib (libname, funcname)

+ + +

+Dynamically links the host program with the C library libname. +Inside this library, looks for a function funcname +and returns this function as a C function. +(So, funcname must follow the protocol (see lua_CFunction)). + + +

+This is a low-level function. +It completely bypasses the package and module system. +Unlike require, +it does not perform any path searching and +does not automatically adds extensions. +libname must be the complete file name of the C library, +including if necessary a path and extension. +funcname must be the exact name exported by the C library +(which may depend on the C compiler and linker used). + + +

+This function is not supported by ANSI C. +As such, it is only available on some platforms +(Windows, Linux, Mac OS X, Solaris, BSD, +plus other Unix systems that support the dlfcn standard). + + + + +

+


package.path

+ + +

+The path used by require to search for a Lua loader. + + +

+At start-up, Lua initializes this variable with +the value of the environment variable LUA_PATH or +with a default path defined in luaconf.h, +if the environment variable is not defined. +Any ";;" in the value of the environment variable +is replaced by the default path. + + + + +

+


package.preload

+ + +

+A table to store loaders for specific modules +(see require). + + + + +

+


package.seeall (module)

+ + +

+Sets a metatable for module with +its __index field referring to the global environment, +so that this module inherits values +from the global environment. +To be used as an option to function module. + + + + + + + +

5.4 - String Manipulation

+ +

+This library provides generic functions for string manipulation, +such as finding and extracting substrings, and pattern matching. +When indexing a string in Lua, the first character is at position 1 +(not at 0, as in C). +Indices are allowed to be negative and are interpreted as indexing backwards, +from the end of the string. +Thus, the last character is at position -1, and so on. + + +

+The string library provides all its functions inside the table +string. +It also sets a metatable for strings +where the __index field points to the string table. +Therefore, you can use the string functions in object-oriented style. +For instance, string.byte(s, i) +can be written as s:byte(i). + + +

+The string library assumes one-byte character encodings. + + +

+


string.byte (s [, i [, j]])

+Returns the internal numerical codes of the characters s[i], +s[i+1], ···, s[j]. +The default value for i is 1; +the default value for j is i. + + +

+Note that numerical codes are not necessarily portable across platforms. + + + + +

+


string.char (···)

+Receives zero or more integers. +Returns a string with length equal to the number of arguments, +in which each character has the internal numerical code equal +to its corresponding argument. + + +

+Note that numerical codes are not necessarily portable across platforms. + + + + +

+


string.dump (function)

+ + +

+Returns a string containing a binary representation of the given function, +so that a later loadstring on this string returns +a copy of the function. +function must be a Lua function without upvalues. + + + + +

+


string.find (s, pattern [, init [, plain]])

+Looks for the first match of +pattern in the string s. +If it finds a match, then find returns the indices of s +where this occurrence starts and ends; +otherwise, it returns nil. +A third, optional numerical argument init specifies +where to start the search; +its default value is 1 and can be negative. +A value of true as a fourth, optional argument plain +turns off the pattern matching facilities, +so the function does a plain "find substring" operation, +with no characters in pattern being considered "magic". +Note that if plain is given, then init must be given as well. + + +

+If the pattern has captures, +then in a successful match +the captured values are also returned, +after the two indices. + + + + +

+


string.format (formatstring, ···)

+Returns a formatted version of its variable number of arguments +following the description given in its first argument (which must be a string). +The format string follows the same rules as the printf family of +standard C functions. +The only differences are that the options/modifiers +*, l, L, n, p, +and h are not supported +and that there is an extra option, q. +The q option formats a string in a form suitable to be safely read +back by the Lua interpreter: +the string is written between double quotes, +and all double quotes, newlines, embedded zeros, +and backslashes in the string +are correctly escaped when written. +For instance, the call + +
+     string.format('%q', 'a string with "quotes" and \n new line')
+

+will produce the string: + +

+     "a string with \"quotes\" and \
+      new line"
+
+ +

+The options c, d, E, e, f, +g, G, i, o, u, X, and x all +expect a number as argument, +whereas q and s expect a string. + + +

+This function does not accept string values +containing embedded zeros, +except as arguments to the q option. + + + + +

+


string.gmatch (s, pattern)

+Returns an iterator function that, +each time it is called, +returns the next captures from pattern over string s. +If pattern specifies no captures, +then the whole match is produced in each call. + + +

+As an example, the following loop + +

+     s = "hello world from Lua"
+     for w in string.gmatch(s, "%a+") do
+       print(w)
+     end
+

+will iterate over all the words from string s, +printing one per line. +The next example collects all pairs key=value from the +given string into a table: + +

+     t = {}
+     s = "from=world, to=Lua"
+     for k, v in string.gmatch(s, "(%w+)=(%w+)") do
+       t[k] = v
+     end
+
+ +

+For this function, a '^' at the start of a pattern does not +work as an anchor, as this would prevent the iteration. + + + + +

+


string.gsub (s, pattern, repl [, n])

+Returns a copy of s +in which all (or the first n, if given) +occurrences of the pattern have been +replaced by a replacement string specified by repl, +which can be a string, a table, or a function. +gsub also returns, as its second value, +the total number of matches that occurred. + + +

+If repl is a string, then its value is used for replacement. +The character % works as an escape character: +any sequence in repl of the form %n, +with n between 1 and 9, +stands for the value of the n-th captured substring (see below). +The sequence %0 stands for the whole match. +The sequence %% stands for a single %. + + +

+If repl is a table, then the table is queried for every match, +using the first capture as the key; +if the pattern specifies no captures, +then the whole match is used as the key. + + +

+If repl is a function, then this function is called every time a +match occurs, with all captured substrings passed as arguments, +in order; +if the pattern specifies no captures, +then the whole match is passed as a sole argument. + + +

+If the value returned by the table query or by the function call +is a string or a number, +then it is used as the replacement string; +otherwise, if it is false or nil, +then there is no replacement +(that is, the original match is kept in the string). + + +

+Here are some examples: + +

+     x = string.gsub("hello world", "(%w+)", "%1 %1")
+     --> x="hello hello world world"
+     
+     x = string.gsub("hello world", "%w+", "%0 %0", 1)
+     --> x="hello hello world"
+     
+     x = string.gsub("hello world from Lua", "(%w+)%s*(%w+)", "%2 %1")
+     --> x="world hello Lua from"
+     
+     x = string.gsub("home = $HOME, user = $USER", "%$(%w+)", os.getenv)
+     --> x="home = /home/roberto, user = roberto"
+     
+     x = string.gsub("4+5 = $return 4+5$", "%$(.-)%$", function (s)
+           return loadstring(s)()
+         end)
+     --> x="4+5 = 9"
+     
+     local t = {name="lua", version="5.1"}
+     x = string.gsub("$name-$version.tar.gz", "%$(%w+)", t)
+     --> x="lua-5.1.tar.gz"
+
+ + + +

+


string.len (s)

+Receives a string and returns its length. +The empty string "" has length 0. +Embedded zeros are counted, +so "a\000bc\000" has length 5. + + + + +

+


string.lower (s)

+Receives a string and returns a copy of this string with all +uppercase letters changed to lowercase. +All other characters are left unchanged. +The definition of what an uppercase letter is depends on the current locale. + + + + +

+


string.match (s, pattern [, init])

+Looks for the first match of +pattern in the string s. +If it finds one, then match returns +the captures from the pattern; +otherwise it returns nil. +If pattern specifies no captures, +then the whole match is returned. +A third, optional numerical argument init specifies +where to start the search; +its default value is 1 and can be negative. + + + + +

+


string.rep (s, n)

+Returns a string that is the concatenation of n copies of +the string s. + + + + +

+


string.reverse (s)

+Returns a string that is the string s reversed. + + + + +

+


string.sub (s, i [, j])

+Returns the substring of s that +starts at i and continues until j; +i and j can be negative. +If j is absent, then it is assumed to be equal to -1 +(which is the same as the string length). +In particular, +the call string.sub(s,1,j) returns a prefix of s +with length j, +and string.sub(s, -i) returns a suffix of s +with length i. + + + + +

+


string.upper (s)

+Receives a string and returns a copy of this string with all +lowercase letters changed to uppercase. +All other characters are left unchanged. +The definition of what a lowercase letter is depends on the current locale. + + + +

5.4.1 - Patterns

+ + +

Character Class:

+A character class is used to represent a set of characters. +The following combinations are allowed in describing a character class: + +

    + +
  • x: +(where x is not one of the magic characters +^$()%.[]*+-?) +represents the character x itself. +
  • + +
  • .: (a dot) represents all characters.
  • + +
  • %a: represents all letters.
  • + +
  • %c: represents all control characters.
  • + +
  • %d: represents all digits.
  • + +
  • %l: represents all lowercase letters.
  • + +
  • %p: represents all punctuation characters.
  • + +
  • %s: represents all space characters.
  • + +
  • %u: represents all uppercase letters.
  • + +
  • %w: represents all alphanumeric characters.
  • + +
  • %x: represents all hexadecimal digits.
  • + +
  • %z: represents the character with representation 0.
  • + +
  • %x: (where x is any non-alphanumeric character) +represents the character x. +This is the standard way to escape the magic characters. +Any punctuation character (even the non magic) +can be preceded by a '%' +when used to represent itself in a pattern. +
  • + +
  • [set]: +represents the class which is the union of all +characters in set. +A range of characters can be specified by +separating the end characters of the range with a '-'. +All classes %x described above can also be used as +components in set. +All other characters in set represent themselves. +For example, [%w_] (or [_%w]) +represents all alphanumeric characters plus the underscore, +[0-7] represents the octal digits, +and [0-7%l%-] represents the octal digits plus +the lowercase letters plus the '-' character. + + +

    +The interaction between ranges and classes is not defined. +Therefore, patterns like [%a-z] or [a-%%] +have no meaning. +

  • + +
  • [^set]: +represents the complement of set, +where set is interpreted as above. +
  • + +

+For all classes represented by single letters (%a, %c, etc.), +the corresponding uppercase letter represents the complement of the class. +For instance, %S represents all non-space characters. + + +

+The definitions of letter, space, and other character groups +depend on the current locale. +In particular, the class [a-z] may not be equivalent to %l. + + + + + +

Pattern Item:

+A pattern item can be + +

    + +
  • +a single character class, +which matches any single character in the class; +
  • + +
  • +a single character class followed by '*', +which matches 0 or more repetitions of characters in the class. +These repetition items will always match the longest possible sequence; +
  • + +
  • +a single character class followed by '+', +which matches 1 or more repetitions of characters in the class. +These repetition items will always match the longest possible sequence; +
  • + +
  • +a single character class followed by '-', +which also matches 0 or more repetitions of characters in the class. +Unlike '*', +these repetition items will always match the shortest possible sequence; +
  • + +
  • +a single character class followed by '?', +which matches 0 or 1 occurrence of a character in the class; +
  • + +
  • +%n, for n between 1 and 9; +such item matches a substring equal to the n-th captured string +(see below); +
  • + +
  • +%bxy, where x and y are two distinct characters; +such item matches strings that start with x, end with y, +and where the x and y are balanced. +This means that, if one reads the string from left to right, +counting +1 for an x and -1 for a y, +the ending y is the first y where the count reaches 0. +For instance, the item %b() matches expressions with +balanced parentheses. +
  • + +
+ + + + +

Pattern:

+A pattern is a sequence of pattern items. +A '^' at the beginning of a pattern anchors the match at the +beginning of the subject string. +A '$' at the end of a pattern anchors the match at the +end of the subject string. +At other positions, +'^' and '$' have no special meaning and represent themselves. + + + + + +

Captures:

+A pattern can contain sub-patterns enclosed in parentheses; +they describe captures. +When a match succeeds, the substrings of the subject string +that match captures are stored (captured) for future use. +Captures are numbered according to their left parentheses. +For instance, in the pattern "(a*(.)%w(%s*))", +the part of the string matching "a*(.)%w(%s*)" is +stored as the first capture (and therefore has number 1); +the character matching "." is captured with number 2, +and the part matching "%s*" has number 3. + + +

+As a special case, the empty capture () captures +the current string position (a number). +For instance, if we apply the pattern "()aa()" on the +string "flaaap", there will be two captures: 3 and 5. + + +

+A pattern cannot contain embedded zeros. Use %z instead. + + + + + + + + + + + +

5.5 - Table Manipulation

+This library provides generic functions for table manipulation. +It provides all its functions inside the table table. + + +

+Most functions in the table library assume that the table +represents an array or a list. +For these functions, when we talk about the "length" of a table +we mean the result of the length operator. + + +

+


table.concat (table [, sep [, i [, j]]])

+Given an array where all elements are strings or numbers, +returns table[i]..sep..table[i+1] ··· sep..table[j]. +The default value for sep is the empty string, +the default for i is 1, +and the default for j is the length of the table. +If i is greater than j, returns the empty string. + + + + +

+


table.insert (table, [pos,] value)

+ + +

+Inserts element value at position pos in table, +shifting up other elements to open space, if necessary. +The default value for pos is n+1, +where n is the length of the table (see §2.5.5), +so that a call table.insert(t,x) inserts x at the end +of table t. + + + + +

+


table.maxn (table)

+ + +

+Returns the largest positive numerical index of the given table, +or zero if the table has no positive numerical indices. +(To do its job this function does a linear traversal of +the whole table.) + + + + +

+


table.remove (table [, pos])

+ + +

+Removes from table the element at position pos, +shifting down other elements to close the space, if necessary. +Returns the value of the removed element. +The default value for pos is n, +where n is the length of the table, +so that a call table.remove(t) removes the last element +of table t. + + + + +

+


table.sort (table [, comp])

+Sorts table elements in a given order, in-place, +from table[1] to table[n], +where n is the length of the table. +If comp is given, +then it must be a function that receives two table elements, +and returns true +when the first is less than the second +(so that not comp(a[i+1],a[i]) will be true after the sort). +If comp is not given, +then the standard Lua operator < is used instead. + + +

+The sort algorithm is not stable; +that is, elements considered equal by the given order +may have their relative positions changed by the sort. + + + + + + + +

5.6 - Mathematical Functions

+ +

+This library is an interface to the standard C math library. +It provides all its functions inside the table math. + + +

+


math.abs (x)

+ + +

+Returns the absolute value of x. + + + + +

+


math.acos (x)

+ + +

+Returns the arc cosine of x (in radians). + + + + +

+


math.asin (x)

+ + +

+Returns the arc sine of x (in radians). + + + + +

+


math.atan (x)

+ + +

+Returns the arc tangent of x (in radians). + + + + +

+


math.atan2 (y, x)

+ + +

+Returns the arc tangent of y/x (in radians), +but uses the signs of both parameters to find the +quadrant of the result. +(It also handles correctly the case of x being zero.) + + + + +

+


math.ceil (x)

+ + +

+Returns the smallest integer larger than or equal to x. + + + + +

+


math.cos (x)

+ + +

+Returns the cosine of x (assumed to be in radians). + + + + +

+


math.cosh (x)

+ + +

+Returns the hyperbolic cosine of x. + + + + +

+


math.deg (x)

+ + +

+Returns the angle x (given in radians) in degrees. + + + + +

+


math.exp (x)

+ + +

+Returns the value ex. + + + + +

+


math.floor (x)

+ + +

+Returns the largest integer smaller than or equal to x. + + + + +

+


math.fmod (x, y)

+ + +

+Returns the remainder of the division of x by y +that rounds the quotient towards zero. + + + + +

+


math.frexp (x)

+ + +

+Returns m and e such that x = m2e, +e is an integer and the absolute value of m is +in the range [0.5, 1) +(or zero when x is zero). + + + + +

+


math.huge

+ + +

+The value HUGE_VAL, +a value larger than or equal to any other numerical value. + + + + +

+


math.ldexp (m, e)

+ + +

+Returns m2e (e should be an integer). + + + + +

+


math.log (x)

+ + +

+Returns the natural logarithm of x. + + + + +

+


math.log10 (x)

+ + +

+Returns the base-10 logarithm of x. + + + + +

+


math.max (x, ···)

+ + +

+Returns the maximum value among its arguments. + + + + +

+


math.min (x, ···)

+ + +

+Returns the minimum value among its arguments. + + + + +

+


math.modf (x)

+ + +

+Returns two numbers, +the integral part of x and the fractional part of x. + + + + +

+


math.pi

+ + +

+The value of pi. + + + + +

+


math.pow (x, y)

+ + +

+Returns xy. +(You can also use the expression x^y to compute this value.) + + + + +

+


math.rad (x)

+ + +

+Returns the angle x (given in degrees) in radians. + + + + +

+


math.random ([m [, n]])

+ + +

+This function is an interface to the simple +pseudo-random generator function rand provided by ANSI C. +(No guarantees can be given for its statistical properties.) + + +

+When called without arguments, +returns a uniform pseudo-random real number +in the range [0,1). +When called with an integer number m, +math.random returns +a uniform pseudo-random integer in the range [1, m]. +When called with two integer numbers m and n, +math.random returns a uniform pseudo-random +integer in the range [m, n]. + + + + +

+


math.randomseed (x)

+ + +

+Sets x as the "seed" +for the pseudo-random generator: +equal seeds produce equal sequences of numbers. + + + + +

+


math.sin (x)

+ + +

+Returns the sine of x (assumed to be in radians). + + + + +

+


math.sinh (x)

+ + +

+Returns the hyperbolic sine of x. + + + + +

+


math.sqrt (x)

+ + +

+Returns the square root of x. +(You can also use the expression x^0.5 to compute this value.) + + + + +

+


math.tan (x)

+ + +

+Returns the tangent of x (assumed to be in radians). + + + + +

+


math.tanh (x)

+ + +

+Returns the hyperbolic tangent of x. + + + + + + + +

5.7 - Input and Output Facilities

+ +

+The I/O library provides two different styles for file manipulation. +The first one uses implicit file descriptors; +that is, there are operations to set a default input file and a +default output file, +and all input/output operations are over these default files. +The second style uses explicit file descriptors. + + +

+When using implicit file descriptors, +all operations are supplied by table io. +When using explicit file descriptors, +the operation io.open returns a file descriptor +and then all operations are supplied as methods of the file descriptor. + + +

+The table io also provides +three predefined file descriptors with their usual meanings from C: +io.stdin, io.stdout, and io.stderr. +The I/O library never closes these files. + + +

+Unless otherwise stated, +all I/O functions return nil on failure +(plus an error message as a second result and +a system-dependent error code as a third result) +and some value different from nil on success. + + +

+


io.close ([file])

+ + +

+Equivalent to file:close(). +Without a file, closes the default output file. + + + + +

+


io.flush ()

+ + +

+Equivalent to file:flush over the default output file. + + + + +

+


io.input ([file])

+ + +

+When called with a file name, it opens the named file (in text mode), +and sets its handle as the default input file. +When called with a file handle, +it simply sets this file handle as the default input file. +When called without parameters, +it returns the current default input file. + + +

+In case of errors this function raises the error, +instead of returning an error code. + + + + +

+


io.lines ([filename])

+ + +

+Opens the given file name in read mode +and returns an iterator function that, +each time it is called, +returns a new line from the file. +Therefore, the construction + +

+     for line in io.lines(filename) do body end
+

+will iterate over all lines of the file. +When the iterator function detects the end of file, +it returns nil (to finish the loop) and automatically closes the file. + + +

+The call io.lines() (with no file name) is equivalent +to io.input():lines(); +that is, it iterates over the lines of the default input file. +In this case it does not close the file when the loop ends. + + + + +

+


io.open (filename [, mode])

+ + +

+This function opens a file, +in the mode specified in the string mode. +It returns a new file handle, +or, in case of errors, nil plus an error message. + + +

+The mode string can be any of the following: + +

    +
  • "r": read mode (the default);
  • +
  • "w": write mode;
  • +
  • "a": append mode;
  • +
  • "r+": update mode, all previous data is preserved;
  • +
  • "w+": update mode, all previous data is erased;
  • +
  • "a+": append update mode, previous data is preserved, + writing is only allowed at the end of file.
  • +

+The mode string can also have a 'b' at the end, +which is needed in some systems to open the file in binary mode. +This string is exactly what is used in the +standard C function fopen. + + + + +

+


io.output ([file])

+ + +

+Similar to io.input, but operates over the default output file. + + + + +

+


io.popen (prog [, mode])

+ + +

+Starts program prog in a separated process and returns +a file handle that you can use to read data from this program +(if mode is "r", the default) +or to write data to this program +(if mode is "w"). + + +

+This function is system dependent and is not available +on all platforms. + + + + +

+


io.read (···)

+ + +

+Equivalent to io.input():read. + + + + +

+


io.tmpfile ()

+ + +

+Returns a handle for a temporary file. +This file is opened in update mode +and it is automatically removed when the program ends. + + + + +

+


io.type (obj)

+ + +

+Checks whether obj is a valid file handle. +Returns the string "file" if obj is an open file handle, +"closed file" if obj is a closed file handle, +or nil if obj is not a file handle. + + + + +

+


io.write (···)

+ + +

+Equivalent to io.output():write. + + + + +

+


file:close ()

+ + +

+Closes file. +Note that files are automatically closed when +their handles are garbage collected, +but that takes an unpredictable amount of time to happen. + + + + +

+


file:flush ()

+ + +

+Saves any written data to file. + + + + +

+


file:lines ()

+ + +

+Returns an iterator function that, +each time it is called, +returns a new line from the file. +Therefore, the construction + +

+     for line in file:lines() do body end
+

+will iterate over all lines of the file. +(Unlike io.lines, this function does not close the file +when the loop ends.) + + + + +

+


file:read (···)

+ + +

+Reads the file file, +according to the given formats, which specify what to read. +For each format, +the function returns a string (or a number) with the characters read, +or nil if it cannot read data with the specified format. +When called without formats, +it uses a default format that reads the entire next line +(see below). + + +

+The available formats are + +

    + +
  • "*n": +reads a number; +this is the only format that returns a number instead of a string. +
  • + +
  • "*a": +reads the whole file, starting at the current position. +On end of file, it returns the empty string. +
  • + +
  • "*l": +reads the next line (skipping the end of line), +returning nil on end of file. +This is the default format. +
  • + +
  • number: +reads a string with up to this number of characters, +returning nil on end of file. +If number is zero, +it reads nothing and returns an empty string, +or nil on end of file. +
  • + +
+ + + +

+


file:seek ([whence] [, offset])

+ + +

+Sets and gets the file position, +measured from the beginning of the file, +to the position given by offset plus a base +specified by the string whence, as follows: + +

    +
  • "set": base is position 0 (beginning of the file);
  • +
  • "cur": base is current position;
  • +
  • "end": base is end of file;
  • +

+In case of success, function seek returns the final file position, +measured in bytes from the beginning of the file. +If this function fails, it returns nil, +plus a string describing the error. + + +

+The default value for whence is "cur", +and for offset is 0. +Therefore, the call file:seek() returns the current +file position, without changing it; +the call file:seek("set") sets the position to the +beginning of the file (and returns 0); +and the call file:seek("end") sets the position to the +end of the file, and returns its size. + + + + +

+


file:setvbuf (mode [, size])

+ + +

+Sets the buffering mode for an output file. +There are three available modes: + +

    + +
  • "no": +no buffering; the result of any output operation appears immediately. +
  • + +
  • "full": +full buffering; output operation is performed only +when the buffer is full (or when you explicitly flush the file +(see io.flush)). +
  • + +
  • "line": +line buffering; output is buffered until a newline is output +or there is any input from some special files +(such as a terminal device). +
  • + +

+For the last two cases, size +specifies the size of the buffer, in bytes. +The default is an appropriate size. + + + + +

+


file:write (···)

+ + +

+Writes the value of each of its arguments to +the file. +The arguments must be strings or numbers. +To write other values, +use tostring or string.format before write. + + + + + + + +

5.8 - Operating System Facilities

+ +

+This library is implemented through table os. + + +

+


os.clock ()

+ + +

+Returns an approximation of the amount in seconds of CPU time +used by the program. + + + + +

+


os.date ([format [, time]])

+ + +

+Returns a string or a table containing date and time, +formatted according to the given string format. + + +

+If the time argument is present, +this is the time to be formatted +(see the os.time function for a description of this value). +Otherwise, date formats the current time. + + +

+If format starts with '!', +then the date is formatted in Coordinated Universal Time. +After this optional character, +if format is the string "*t", +then date returns a table with the following fields: +year (four digits), month (1--12), day (1--31), +hour (0--23), min (0--59), sec (0--61), +wday (weekday, Sunday is 1), +yday (day of the year), +and isdst (daylight saving flag, a boolean). + + +

+If format is not "*t", +then date returns the date as a string, +formatted according to the same rules as the C function strftime. + + +

+When called without arguments, +date returns a reasonable date and time representation that depends on +the host system and on the current locale +(that is, os.date() is equivalent to os.date("%c")). + + + + +

+


os.difftime (t2, t1)

+ + +

+Returns the number of seconds from time t1 to time t2. +In POSIX, Windows, and some other systems, +this value is exactly t2-t1. + + + + +

+


os.execute ([command])

+ + +

+This function is equivalent to the C function system. +It passes command to be executed by an operating system shell. +It returns a status code, which is system-dependent. +If command is absent, then it returns nonzero if a shell is available +and zero otherwise. + + + + +

+


os.exit ([code])

+ + +

+Calls the C function exit, +with an optional code, +to terminate the host program. +The default value for code is the success code. + + + + +

+


os.getenv (varname)

+ + +

+Returns the value of the process environment variable varname, +or nil if the variable is not defined. + + + + +

+


os.remove (filename)

+ + +

+Deletes the file or directory with the given name. +Directories must be empty to be removed. +If this function fails, it returns nil, +plus a string describing the error. + + + + +

+


os.rename (oldname, newname)

+ + +

+Renames file or directory named oldname to newname. +If this function fails, it returns nil, +plus a string describing the error. + + + + +

+


os.setlocale (locale [, category])

+ + +

+Sets the current locale of the program. +locale is a string specifying a locale; +category is an optional string describing which category to change: +"all", "collate", "ctype", +"monetary", "numeric", or "time"; +the default category is "all". +The function returns the name of the new locale, +or nil if the request cannot be honored. + + +

+If locale is the empty string, +the current locale is set to an implementation-defined native locale. +If locale is the string "C", +the current locale is set to the standard C locale. + + +

+When called with nil as the first argument, +this function only returns the name of the current locale +for the given category. + + + + +

+


os.time ([table])

+ + +

+Returns the current time when called without arguments, +or a time representing the date and time specified by the given table. +This table must have fields year, month, and day, +and may have fields hour, min, sec, and isdst +(for a description of these fields, see the os.date function). + + +

+The returned value is a number, whose meaning depends on your system. +In POSIX, Windows, and some other systems, this number counts the number +of seconds since some given start time (the "epoch"). +In other systems, the meaning is not specified, +and the number returned by time can be used only as an argument to +date and difftime. + + + + +

+


os.tmpname ()

+ + +

+Returns a string with a file name that can +be used for a temporary file. +The file must be explicitly opened before its use +and explicitly removed when no longer needed. + + +

+On some systems (POSIX), +this function also creates a file with that name, +to avoid security risks. +(Someone else might create the file with wrong permissions +in the time between getting the name and creating the file.) +You still have to open the file to use it +and to remove it (even if you do not use it). + + +

+When possible, +you may prefer to use io.tmpfile, +which automatically removes the file when the program ends. + + + + + + + +

5.9 - The Debug Library

+ +

+This library provides +the functionality of the debug interface to Lua programs. +You should exert care when using this library. +The functions provided here should be used exclusively for debugging +and similar tasks, such as profiling. +Please resist the temptation to use them as a +usual programming tool: +they can be very slow. +Moreover, several of these functions +violate some assumptions about Lua code +(e.g., that variables local to a function +cannot be accessed from outside or +that userdata metatables cannot be changed by Lua code) +and therefore can compromise otherwise secure code. + + +

+All functions in this library are provided +inside the debug table. +All functions that operate over a thread +have an optional first argument which is the +thread to operate over. +The default is always the current thread. + + +

+


debug.debug ()

+ + +

+Enters an interactive mode with the user, +running each string that the user enters. +Using simple commands and other debug facilities, +the user can inspect global and local variables, +change their values, evaluate expressions, and so on. +A line containing only the word cont finishes this function, +so that the caller continues its execution. + + +

+Note that commands for debug.debug are not lexically nested +within any function, and so have no direct access to local variables. + + + + +

+


debug.getfenv (o)

+Returns the environment of object o. + + + + +

+


debug.gethook ([thread])

+ + +

+Returns the current hook settings of the thread, as three values: +the current hook function, the current hook mask, +and the current hook count +(as set by the debug.sethook function). + + + + +

+


debug.getinfo ([thread,] function [, what])

+ + +

+Returns a table with information about a function. +You can give the function directly, +or you can give a number as the value of function, +which means the function running at level function of the call stack +of the given thread: +level 0 is the current function (getinfo itself); +level 1 is the function that called getinfo; +and so on. +If function is a number larger than the number of active functions, +then getinfo returns nil. + + +

+The returned table can contain all the fields returned by lua_getinfo, +with the string what describing which fields to fill in. +The default for what is to get all information available, +except the table of valid lines. +If present, +the option 'f' +adds a field named func with the function itself. +If present, +the option 'L' +adds a field named activelines with the table of +valid lines. + + +

+For instance, the expression debug.getinfo(1,"n").name returns +a table with a name for the current function, +if a reasonable name can be found, +and the expression debug.getinfo(print) +returns a table with all available information +about the print function. + + + + +

+


debug.getlocal ([thread,] level, local)

+ + +

+This function returns the name and the value of the local variable +with index local of the function at level level of the stack. +(The first parameter or local variable has index 1, and so on, +until the last active local variable.) +The function returns nil if there is no local +variable with the given index, +and raises an error when called with a level out of range. +(You can call debug.getinfo to check whether the level is valid.) + + +

+Variable names starting with '(' (open parentheses) +represent internal variables +(loop control variables, temporaries, and C function locals). + + + + +

+


debug.getmetatable (object)

+ + +

+Returns the metatable of the given object +or nil if it does not have a metatable. + + + + +

+


debug.getregistry ()

+ + +

+Returns the registry table (see §3.5). + + + + +

+


debug.getupvalue (func, up)

+ + +

+This function returns the name and the value of the upvalue +with index up of the function func. +The function returns nil if there is no upvalue with the given index. + + + + +

+


debug.setfenv (object, table)

+ + +

+Sets the environment of the given object to the given table. +Returns object. + + + + +

+


debug.sethook ([thread,] hook, mask [, count])

+ + +

+Sets the given function as a hook. +The string mask and the number count describe +when the hook will be called. +The string mask may have the following characters, +with the given meaning: + +

    +
  • "c": the hook is called every time Lua calls a function;
  • +
  • "r": the hook is called every time Lua returns from a function;
  • +
  • "l": the hook is called every time Lua enters a new line of code.
  • +

+With a count different from zero, +the hook is called after every count instructions. + + +

+When called without arguments, +debug.sethook turns off the hook. + + +

+When the hook is called, its first parameter is a string +describing the event that has triggered its call: +"call", "return" (or "tail return", +when simulating a return from a tail call), +"line", and "count". +For line events, +the hook also gets the new line number as its second parameter. +Inside a hook, +you can call getinfo with level 2 to get more information about +the running function +(level 0 is the getinfo function, +and level 1 is the hook function), +unless the event is "tail return". +In this case, Lua is only simulating the return, +and a call to getinfo will return invalid data. + + + + +

+


debug.setlocal ([thread,] level, local, value)

+ + +

+This function assigns the value value to the local variable +with index local of the function at level level of the stack. +The function returns nil if there is no local +variable with the given index, +and raises an error when called with a level out of range. +(You can call getinfo to check whether the level is valid.) +Otherwise, it returns the name of the local variable. + + + + +

+


debug.setmetatable (object, table)

+ + +

+Sets the metatable for the given object to the given table +(which can be nil). + + + + +

+


debug.setupvalue (func, up, value)

+ + +

+This function assigns the value value to the upvalue +with index up of the function func. +The function returns nil if there is no upvalue +with the given index. +Otherwise, it returns the name of the upvalue. + + + + +

+


debug.traceback ([thread,] [message] [, level])

+ + +

+Returns a string with a traceback of the call stack. +An optional message string is appended +at the beginning of the traceback. +An optional level number tells at which level +to start the traceback +(default is 1, the function calling traceback). + + + + + + + +

6 - Lua Stand-alone

+ +

+Although Lua has been designed as an extension language, +to be embedded in a host C program, +it is also frequently used as a stand-alone language. +An interpreter for Lua as a stand-alone language, +called simply lua, +is provided with the standard distribution. +The stand-alone interpreter includes +all standard libraries, including the debug library. +Its usage is: + +

+     lua [options] [script [args]]
+

+The options are: + +

    +
  • -e stat: executes string stat;
  • +
  • -l mod: "requires" mod;
  • +
  • -i: enters interactive mode after running script;
  • +
  • -v: prints version information;
  • +
  • --: stops handling options;
  • +
  • -: executes stdin as a file and stops handling options.
  • +

+After handling its options, lua runs the given script, +passing to it the given args as string arguments. +When called without arguments, +lua behaves as lua -v -i +when the standard input (stdin) is a terminal, +and as lua - otherwise. + + +

+Before running any argument, +the interpreter checks for an environment variable LUA_INIT. +If its format is @filename, +then lua executes the file. +Otherwise, lua executes the string itself. + + +

+All options are handled in order, except -i. +For instance, an invocation like + +

+     $ lua -e'a=1' -e 'print(a)' script.lua
+

+will first set a to 1, then print the value of a (which is '1'), +and finally run the file script.lua with no arguments. +(Here $ is the shell prompt. Your prompt may be different.) + + +

+Before starting to run the script, +lua collects all arguments in the command line +in a global table called arg. +The script name is stored at index 0, +the first argument after the script name goes to index 1, +and so on. +Any arguments before the script name +(that is, the interpreter name plus the options) +go to negative indices. +For instance, in the call + +

+     $ lua -la b.lua t1 t2
+

+the interpreter first runs the file a.lua, +then creates a table + +

+     arg = { [-2] = "lua", [-1] = "-la",
+             [0] = "b.lua",
+             [1] = "t1", [2] = "t2" }
+

+and finally runs the file b.lua. +The script is called with arg[1], arg[2], ··· +as arguments; +it can also access these arguments with the vararg expression '...'. + + +

+In interactive mode, +if you write an incomplete statement, +the interpreter waits for its completion +by issuing a different prompt. + + +

+If the global variable _PROMPT contains a string, +then its value is used as the prompt. +Similarly, if the global variable _PROMPT2 contains a string, +its value is used as the secondary prompt +(issued during incomplete statements). +Therefore, both prompts can be changed directly on the command line +or in any Lua programs by assigning to _PROMPT. +See the next example: + +

+     $ lua -e"_PROMPT='myprompt> '" -i
+

+(The outer pair of quotes is for the shell, +the inner pair is for Lua.) +Note the use of -i to enter interactive mode; +otherwise, +the program would just end silently +right after the assignment to _PROMPT. + + +

+To allow the use of Lua as a +script interpreter in Unix systems, +the stand-alone interpreter skips +the first line of a chunk if it starts with #. +Therefore, Lua scripts can be made into executable programs +by using chmod +x and the #! form, +as in + +

+     #!/usr/local/bin/lua
+

+(Of course, +the location of the Lua interpreter may be different in your machine. +If lua is in your PATH, +then + +

+     #!/usr/bin/env lua
+

+is a more portable solution.) + + + +

7 - Incompatibilities with the Previous Version

+ +

+Here we list the incompatibilities that you may find when moving a program +from Lua 5.0 to Lua 5.1. +You can avoid most of the incompatibilities compiling Lua with +appropriate options (see file luaconf.h). +However, +all these compatibility options will be removed in the next version of Lua. + + + +

7.1 - Changes in the Language

+
    + +
  • +The vararg system changed from the pseudo-argument arg with a +table with the extra arguments to the vararg expression. +(See compile-time option LUA_COMPAT_VARARG in luaconf.h.) +
  • + +
  • +There was a subtle change in the scope of the implicit +variables of the for statement and for the repeat statement. +
  • + +
  • +The long string/long comment syntax ([[string]]) +does not allow nesting. +You can use the new syntax ([=[string]=]) in these cases. +(See compile-time option LUA_COMPAT_LSTR in luaconf.h.) +
  • + +
+ + + + +

7.2 - Changes in the Libraries

+
    + +
  • +Function string.gfind was renamed string.gmatch. +(See compile-time option LUA_COMPAT_GFIND in luaconf.h.) +
  • + +
  • +When string.gsub is called with a function as its +third argument, +whenever this function returns nil or false the +replacement string is the whole match, +instead of the empty string. +
  • + +
  • +Function table.setn was deprecated. +Function table.getn corresponds +to the new length operator (#); +use the operator instead of the function. +(See compile-time option LUA_COMPAT_GETN in luaconf.h.) +
  • + +
  • +Function loadlib was renamed package.loadlib. +(See compile-time option LUA_COMPAT_LOADLIB in luaconf.h.) +
  • + +
  • +Function math.mod was renamed math.fmod. +(See compile-time option LUA_COMPAT_MOD in luaconf.h.) +
  • + +
  • +Functions table.foreach and table.foreachi are deprecated. +You can use a for loop with pairs or ipairs instead. +
  • + +
  • +There were substantial changes in function require due to +the new module system. +However, the new behavior is mostly compatible with the old, +but require gets the path from package.path instead +of from LUA_PATH. +
  • + +
  • +Function collectgarbage has different arguments. +Function gcinfo is deprecated; +use collectgarbage("count") instead. +
  • + +
+ + + + +

7.3 - Changes in the API

+
    + +
  • +The luaopen_* functions (to open libraries) +cannot be called directly, +like a regular C function. +They must be called through Lua, +like a Lua function. +
  • + +
  • +Function lua_open was replaced by lua_newstate to +allow the user to set a memory-allocation function. +You can use luaL_newstate from the standard library to +create a state with a standard allocation function +(based on realloc). +
  • + +
  • +Functions luaL_getn and luaL_setn +(from the auxiliary library) are deprecated. +Use lua_objlen instead of luaL_getn +and nothing instead of luaL_setn. +
  • + +
  • +Function luaL_openlib was replaced by luaL_register. +
  • + +
  • +Function luaL_checkudata now throws an error when the given value +is not a userdata of the expected type. +(In Lua 5.0 it returned NULL.) +
  • + +
+ + + + +

8 - The Complete Syntax of Lua

+ +

+Here is the complete syntax of Lua in extended BNF. +(It does not describe operator precedences.) + + + + +

+
+	chunk ::= {stat [`;´]} [laststat [`;´]]
+
+	block ::= chunk
+
+	stat ::=  varlist `=´ explist | 
+		 functioncall | 
+		 do block end | 
+		 while exp do block end | 
+		 repeat block until exp | 
+		 if exp then block {elseif exp then block} [else block] end | 
+		 for Name `=´ exp `,´ exp [`,´ exp] do block end | 
+		 for namelist in explist do block end | 
+		 function funcname funcbody | 
+		 local function Name funcbody | 
+		 local namelist [`=´ explist] 
+
+	laststat ::= return [explist] | break
+
+	funcname ::= Name {`.´ Name} [`:´ Name]
+
+	varlist ::= var {`,´ var}
+
+	var ::=  Name | prefixexp `[´ exp `]´ | prefixexp `.´ Name 
+
+	namelist ::= Name {`,´ Name}
+
+	explist ::= {exp `,´} exp
+
+	exp ::=  nil | false | true | Number | String | `...´ | function | 
+		 prefixexp | tableconstructor | exp binop exp | unop exp 
+
+	prefixexp ::= var | functioncall | `(´ exp `)´
+
+	functioncall ::=  prefixexp args | prefixexp `:´ Name args 
+
+	args ::=  `(´ [explist] `)´ | tableconstructor | String 
+
+	function ::= function funcbody
+
+	funcbody ::= `(´ [parlist] `)´ block end
+
+	parlist ::= namelist [`,´ `...´] | `...´
+
+	tableconstructor ::= `{´ [fieldlist] `}´
+
+	fieldlist ::= field {fieldsep field} [fieldsep]
+
+	field ::= `[´ exp `]´ `=´ exp | Name `=´ exp | exp
+
+	fieldsep ::= `,´ | `;´
+
+	binop ::= `+´ | `-´ | `*´ | `/´ | `^´ | `%´ | `..´ | 
+		 `<´ | `<=´ | `>´ | `>=´ | `==´ | `~=´ | 
+		 and | or
+
+	unop ::= `-´ | not | `#´
+
+
+ +

+ + + + + + + +


+ +Last update: +Mon Aug 18 13:25:46 BRT 2008 + + + + + diff --git a/mk/linux/mojosetup/lua/doc/readme.html b/mk/linux/mojosetup/lua/doc/readme.html new file mode 100644 index 00000000..38be6dbb --- /dev/null +++ b/mk/linux/mojosetup/lua/doc/readme.html @@ -0,0 +1,40 @@ + + +Lua documentation + + + + + +
+

+Lua +Documentation +

+ +This is the documentation included in the source distribution of Lua 5.1.4. + + + +Lua's +official web site +contains updated documentation, +especially the +reference manual. +

+ +


+ +Last update: +Tue Aug 12 14:46:07 BRT 2008 + + + + diff --git a/mk/linux/mojosetup/lua/etc/Makefile b/mk/linux/mojosetup/lua/etc/Makefile new file mode 100644 index 00000000..6d00008d --- /dev/null +++ b/mk/linux/mojosetup/lua/etc/Makefile @@ -0,0 +1,44 @@ +# makefile for Lua etc + +TOP= .. +LIB= $(TOP)/src +INC= $(TOP)/src +BIN= $(TOP)/src +SRC= $(TOP)/src +TST= $(TOP)/test + +CC= gcc +CFLAGS= -O2 -Wall -I$(INC) $(MYCFLAGS) +MYCFLAGS= +MYLDFLAGS= -Wl,-E +MYLIBS= -lm +#MYLIBS= -lm -Wl,-E -ldl -lreadline -lhistory -lncurses +RM= rm -f + +default: + @echo 'Please choose a target: min noparser one strict clean' + +min: min.c + $(CC) $(CFLAGS) $@.c -L$(LIB) -llua $(MYLIBS) + echo 'print"Hello there!"' | ./a.out + +noparser: noparser.o + $(CC) noparser.o $(SRC)/lua.o -L$(LIB) -llua $(MYLIBS) + $(BIN)/luac $(TST)/hello.lua + -./a.out luac.out + -./a.out -e'a=1' + +one: + $(CC) $(CFLAGS) all.c $(MYLIBS) + ./a.out $(TST)/hello.lua + +strict: + -$(BIN)/lua -e 'print(a);b=2' + -$(BIN)/lua -lstrict -e 'print(a)' + -$(BIN)/lua -e 'function f() b=2 end f()' + -$(BIN)/lua -lstrict -e 'function f() b=2 end f()' + +clean: + $(RM) a.out core core.* *.o luac.out + +.PHONY: default min noparser one strict clean diff --git a/mk/linux/mojosetup/lua/etc/README b/mk/linux/mojosetup/lua/etc/README new file mode 100644 index 00000000..5149fc91 --- /dev/null +++ b/mk/linux/mojosetup/lua/etc/README @@ -0,0 +1,37 @@ +This directory contains some useful files and code. +Unlike the code in ../src, everything here is in the public domain. + +If any of the makes fail, you're probably not using the same libraries +used to build Lua. Set MYLIBS in Makefile accordingly. + +all.c + Full Lua interpreter in a single file. + Do "make one" for a demo. + +lua.hpp + Lua header files for C++ using 'extern "C"'. + +lua.ico + A Lua icon for Windows (and web sites: save as favicon.ico). + Drawn by hand by Markus Gritsch . + +lua.pc + pkg-config data for Lua + +luavs.bat + Script to build Lua under "Visual Studio .NET Command Prompt". + Run it from the toplevel as etc\luavs.bat. + +min.c + A minimal Lua interpreter. + Good for learning and for starting your own. + Do "make min" for a demo. + +noparser.c + Linking with noparser.o avoids loading the parsing modules in lualib.a. + Do "make noparser" for a demo. + +strict.lua + Traps uses of undeclared global variables. + Do "make strict" for a demo. + diff --git a/mk/linux/mojosetup/lua/etc/all.c b/mk/linux/mojosetup/lua/etc/all.c new file mode 100644 index 00000000..dab68fac --- /dev/null +++ b/mk/linux/mojosetup/lua/etc/all.c @@ -0,0 +1,38 @@ +/* +* all.c -- Lua core, libraries and interpreter in a single file +*/ + +#define luaall_c + +#include "lapi.c" +#include "lcode.c" +#include "ldebug.c" +#include "ldo.c" +#include "ldump.c" +#include "lfunc.c" +#include "lgc.c" +#include "llex.c" +#include "lmem.c" +#include "lobject.c" +#include "lopcodes.c" +#include "lparser.c" +#include "lstate.c" +#include "lstring.c" +#include "ltable.c" +#include "ltm.c" +#include "lundump.c" +#include "lvm.c" +#include "lzio.c" + +#include "lauxlib.c" +#include "lbaselib.c" +#include "ldblib.c" +#include "liolib.c" +#include "linit.c" +#include "lmathlib.c" +#include "loadlib.c" +#include "loslib.c" +#include "lstrlib.c" +#include "ltablib.c" + +#include "lua.c" diff --git a/mk/linux/mojosetup/lua/etc/lua.hpp b/mk/linux/mojosetup/lua/etc/lua.hpp new file mode 100644 index 00000000..ec417f59 --- /dev/null +++ b/mk/linux/mojosetup/lua/etc/lua.hpp @@ -0,0 +1,9 @@ +// lua.hpp +// Lua header files for C++ +// <> not supplied automatically because Lua also compiles as C++ + +extern "C" { +#include "lua.h" +#include "lualib.h" +#include "lauxlib.h" +} diff --git a/mk/linux/mojosetup/lua/etc/lua.ico b/mk/linux/mojosetup/lua/etc/lua.ico new file mode 100644 index 00000000..ccbabc4e Binary files /dev/null and b/mk/linux/mojosetup/lua/etc/lua.ico differ diff --git a/mk/linux/mojosetup/lua/etc/lua.pc b/mk/linux/mojosetup/lua/etc/lua.pc new file mode 100644 index 00000000..f52f55b0 --- /dev/null +++ b/mk/linux/mojosetup/lua/etc/lua.pc @@ -0,0 +1,31 @@ +# lua.pc -- pkg-config data for Lua + +# vars from install Makefile + +# grep '^V=' ../Makefile +V= 5.1 +# grep '^R=' ../Makefile +R= 5.1.4 + +# grep '^INSTALL_.*=' ../Makefile | sed 's/INSTALL_TOP/prefix/' +prefix= /usr/local +INSTALL_BIN= ${prefix}/bin +INSTALL_INC= ${prefix}/include +INSTALL_LIB= ${prefix}/lib +INSTALL_MAN= ${prefix}/man/man1 +INSTALL_LMOD= ${prefix}/share/lua/${V} +INSTALL_CMOD= ${prefix}/lib/lua/${V} + +# canonical vars +exec_prefix=${prefix} +libdir=${exec_prefix}/lib +includedir=${prefix}/include + +Name: Lua +Description: An Extensible Extension Language +Version: ${R} +Requires: +Libs: -L${libdir} -llua -lm +Cflags: -I${includedir} + +# (end of lua.pc) diff --git a/mk/linux/mojosetup/lua/etc/luavs.bat b/mk/linux/mojosetup/lua/etc/luavs.bat new file mode 100644 index 00000000..08c2bedd --- /dev/null +++ b/mk/linux/mojosetup/lua/etc/luavs.bat @@ -0,0 +1,28 @@ +@rem Script to build Lua under "Visual Studio .NET Command Prompt". +@rem Do not run from this directory; run it from the toplevel: etc\luavs.bat . +@rem It creates lua51.dll, lua51.lib, lua.exe, and luac.exe in src. +@rem (contributed by David Manura and Mike Pall) + +@setlocal +@set MYCOMPILE=cl /nologo /MD /O2 /W3 /c /D_CRT_SECURE_NO_DEPRECATE +@set MYLINK=link /nologo +@set MYMT=mt /nologo + +cd src +%MYCOMPILE% /DLUA_BUILD_AS_DLL l*.c +del lua.obj luac.obj +%MYLINK% /DLL /out:lua51.dll l*.obj +if exist lua51.dll.manifest^ + %MYMT% -manifest lua51.dll.manifest -outputresource:lua51.dll;2 +%MYCOMPILE% /DLUA_BUILD_AS_DLL lua.c +%MYLINK% /out:lua.exe lua.obj lua51.lib +if exist lua.exe.manifest^ + %MYMT% -manifest lua.exe.manifest -outputresource:lua.exe +%MYCOMPILE% l*.c print.c +del lua.obj linit.obj lbaselib.obj ldblib.obj liolib.obj lmathlib.obj^ + loslib.obj ltablib.obj lstrlib.obj loadlib.obj +%MYLINK% /out:luac.exe *.obj +if exist luac.exe.manifest^ + %MYMT% -manifest luac.exe.manifest -outputresource:luac.exe +del *.obj *.manifest +cd .. diff --git a/mk/linux/mojosetup/lua/etc/min.c b/mk/linux/mojosetup/lua/etc/min.c new file mode 100644 index 00000000..6a85a4d1 --- /dev/null +++ b/mk/linux/mojosetup/lua/etc/min.c @@ -0,0 +1,39 @@ +/* +* min.c -- a minimal Lua interpreter +* loads stdin only with minimal error handling. +* no interaction, and no standard library, only a "print" function. +*/ + +#include + +#include "lua.h" +#include "lauxlib.h" + +static int print(lua_State *L) +{ + int n=lua_gettop(L); + int i; + for (i=1; i<=n; i++) + { + if (i>1) printf("\t"); + if (lua_isstring(L,i)) + printf("%s",lua_tostring(L,i)); + else if (lua_isnil(L,i)) + printf("%s","nil"); + else if (lua_isboolean(L,i)) + printf("%s",lua_toboolean(L,i) ? "true" : "false"); + else + printf("%s:%p",luaL_typename(L,i),lua_topointer(L,i)); + } + printf("\n"); + return 0; +} + +int main(void) +{ + lua_State *L=lua_open(); + lua_register(L,"print",print); + if (luaL_dofile(L,NULL)!=0) fprintf(stderr,"%s\n",lua_tostring(L,-1)); + lua_close(L); + return 0; +} diff --git a/mk/linux/mojosetup/lua/etc/noparser.c b/mk/linux/mojosetup/lua/etc/noparser.c new file mode 100644 index 00000000..13ba5462 --- /dev/null +++ b/mk/linux/mojosetup/lua/etc/noparser.c @@ -0,0 +1,50 @@ +/* +* The code below can be used to make a Lua core that does not contain the +* parsing modules (lcode, llex, lparser), which represent 35% of the total core. +* You'll only be able to load binary files and strings, precompiled with luac. +* (Of course, you'll have to build luac with the original parsing modules!) +* +* To use this module, simply compile it ("make noparser" does that) and list +* its object file before the Lua libraries. The linker should then not load +* the parsing modules. To try it, do "make luab". +* +* If you also want to avoid the dump module (ldump.o), define NODUMP. +* #define NODUMP +*/ + +#define LUA_CORE + +#include "llex.h" +#include "lparser.h" +#include "lzio.h" + +LUAI_FUNC void luaX_init (lua_State *L) { + UNUSED(L); +} + +LUAI_FUNC Proto *luaY_parser (lua_State *L, ZIO *z, Mbuffer *buff, const char *name) { + UNUSED(z); + UNUSED(buff); + UNUSED(name); + lua_pushliteral(L,"parser not loaded"); + lua_error(L); + return NULL; +} + +#ifdef NODUMP +#include "lundump.h" + +LUAI_FUNC int luaU_dump (lua_State* L, const Proto* f, lua_Writer w, void* data, int strip) { + UNUSED(f); + UNUSED(w); + UNUSED(data); + UNUSED(strip); +#if 1 + UNUSED(L); + return 0; +#else + lua_pushliteral(L,"dumper not loaded"); + lua_error(L); +#endif +} +#endif diff --git a/mk/linux/mojosetup/lua/etc/strict.lua b/mk/linux/mojosetup/lua/etc/strict.lua new file mode 100644 index 00000000..604619dd --- /dev/null +++ b/mk/linux/mojosetup/lua/etc/strict.lua @@ -0,0 +1,41 @@ +-- +-- strict.lua +-- checks uses of undeclared global variables +-- All global variables must be 'declared' through a regular assignment +-- (even assigning nil will do) in a main chunk before being used +-- anywhere or assigned to inside a function. +-- + +local getinfo, error, rawset, rawget = debug.getinfo, error, rawset, rawget + +local mt = getmetatable(_G) +if mt == nil then + mt = {} + setmetatable(_G, mt) +end + +mt.__declared = {} + +local function what () + local d = getinfo(3, "S") + return d and d.what or "C" +end + +mt.__newindex = function (t, n, v) + if not mt.__declared[n] then + local w = what() + if w ~= "main" and w ~= "C" then + error("assign to undeclared variable '"..n.."'", 2) + end + mt.__declared[n] = true + end + rawset(t, n, v) +end + +mt.__index = function (t, n) + if not mt.__declared[n] and what() ~= "C" then + error("variable '"..n.."' is not declared", 2) + end + return rawget(t, n) +end + diff --git a/mk/linux/mojosetup/lua/src/Makefile b/mk/linux/mojosetup/lua/src/Makefile new file mode 100644 index 00000000..e4a3cd61 --- /dev/null +++ b/mk/linux/mojosetup/lua/src/Makefile @@ -0,0 +1,182 @@ +# makefile for building Lua +# see ../INSTALL for installation instructions +# see ../Makefile and luaconf.h for further customization + +# == CHANGE THE SETTINGS BELOW TO SUIT YOUR ENVIRONMENT ======================= + +# Your platform. See PLATS for possible values. +PLAT= none + +CC= gcc +CFLAGS= -O2 -Wall $(MYCFLAGS) +AR= ar rcu +RANLIB= ranlib +RM= rm -f +LIBS= -lm $(MYLIBS) + +MYCFLAGS= +MYLDFLAGS= +MYLIBS= + +# == END OF USER SETTINGS. NO NEED TO CHANGE ANYTHING BELOW THIS LINE ========= + +PLATS= aix ansi bsd freebsd generic linux macosx mingw posix solaris + +LUA_A= liblua.a +CORE_O= lapi.o lcode.o ldebug.o ldo.o ldump.o lfunc.o lgc.o llex.o lmem.o \ + lobject.o lopcodes.o lparser.o lstate.o lstring.o ltable.o ltm.o \ + lundump.o lvm.o lzio.o +LIB_O= lauxlib.o lbaselib.o ldblib.o liolib.o lmathlib.o loslib.o ltablib.o \ + lstrlib.o loadlib.o linit.o + +LUA_T= lua +LUA_O= lua.o + +LUAC_T= luac +LUAC_O= luac.o print.o + +ALL_O= $(CORE_O) $(LIB_O) $(LUA_O) $(LUAC_O) +ALL_T= $(LUA_A) $(LUA_T) $(LUAC_T) +ALL_A= $(LUA_A) + +default: $(PLAT) + +all: $(ALL_T) + +o: $(ALL_O) + +a: $(ALL_A) + +$(LUA_A): $(CORE_O) $(LIB_O) + $(AR) $@ $? + $(RANLIB) $@ + +$(LUA_T): $(LUA_O) $(LUA_A) + $(CC) -o $@ $(MYLDFLAGS) $(LUA_O) $(LUA_A) $(LIBS) + +$(LUAC_T): $(LUAC_O) $(LUA_A) + $(CC) -o $@ $(MYLDFLAGS) $(LUAC_O) $(LUA_A) $(LIBS) + +clean: + $(RM) $(ALL_T) $(ALL_O) + +depend: + @$(CC) $(CFLAGS) -MM l*.c print.c + +echo: + @echo "PLAT = $(PLAT)" + @echo "CC = $(CC)" + @echo "CFLAGS = $(CFLAGS)" + @echo "AR = $(AR)" + @echo "RANLIB = $(RANLIB)" + @echo "RM = $(RM)" + @echo "MYCFLAGS = $(MYCFLAGS)" + @echo "MYLDFLAGS = $(MYLDFLAGS)" + @echo "MYLIBS = $(MYLIBS)" + +# convenience targets for popular platforms + +none: + @echo "Please choose a platform:" + @echo " $(PLATS)" + +aix: + $(MAKE) all CC="xlc" CFLAGS="-O2 -DLUA_USE_POSIX -DLUA_USE_DLOPEN" MYLIBS="-ldl" MYLDFLAGS="-brtl -bexpall" + +ansi: + $(MAKE) all MYCFLAGS=-DLUA_ANSI + +bsd: + $(MAKE) all MYCFLAGS="-DLUA_USE_POSIX -DLUA_USE_DLOPEN" MYLIBS="-Wl,-E" + +freebsd: + $(MAKE) all MYCFLAGS="-DLUA_USE_LINUX" MYLIBS="-Wl,-E -lreadline" + +generic: + $(MAKE) all MYCFLAGS= + +linux: + $(MAKE) all MYCFLAGS=-DLUA_USE_LINUX MYLIBS="-Wl,-E -ldl -lreadline -lhistory -lncurses" + +macosx: + $(MAKE) all MYCFLAGS=-DLUA_USE_LINUX MYLIBS="-lreadline" +# use this on Mac OS X 10.3- +# $(MAKE) all MYCFLAGS=-DLUA_USE_MACOSX + +mingw: + $(MAKE) "LUA_A=lua51.dll" "LUA_T=lua.exe" \ + "AR=$(CC) -shared -o" "RANLIB=strip --strip-unneeded" \ + "MYCFLAGS=-DLUA_BUILD_AS_DLL" "MYLIBS=" "MYLDFLAGS=-s" lua.exe + $(MAKE) "LUAC_T=luac.exe" luac.exe + +posix: + $(MAKE) all MYCFLAGS=-DLUA_USE_POSIX + +solaris: + $(MAKE) all MYCFLAGS="-DLUA_USE_POSIX -DLUA_USE_DLOPEN" MYLIBS="-ldl" + +# list targets that do not create files (but not all makes understand .PHONY) +.PHONY: all $(PLATS) default o a clean depend echo none + +# DO NOT DELETE + +lapi.o: lapi.c lua.h luaconf.h lapi.h lobject.h llimits.h ldebug.h \ + lstate.h ltm.h lzio.h lmem.h ldo.h lfunc.h lgc.h lstring.h ltable.h \ + lundump.h lvm.h +lauxlib.o: lauxlib.c lua.h luaconf.h lauxlib.h +lbaselib.o: lbaselib.c lua.h luaconf.h lauxlib.h lualib.h +lcode.o: lcode.c lua.h luaconf.h lcode.h llex.h lobject.h llimits.h \ + lzio.h lmem.h lopcodes.h lparser.h ldebug.h lstate.h ltm.h ldo.h lgc.h \ + ltable.h +ldblib.o: ldblib.c lua.h luaconf.h lauxlib.h lualib.h +ldebug.o: ldebug.c lua.h luaconf.h lapi.h lobject.h llimits.h lcode.h \ + llex.h lzio.h lmem.h lopcodes.h lparser.h ldebug.h lstate.h ltm.h ldo.h \ + lfunc.h lstring.h lgc.h ltable.h lvm.h +ldo.o: ldo.c lua.h luaconf.h ldebug.h lstate.h lobject.h llimits.h ltm.h \ + lzio.h lmem.h ldo.h lfunc.h lgc.h lopcodes.h lparser.h lstring.h \ + ltable.h lundump.h lvm.h +ldump.o: ldump.c lua.h luaconf.h lobject.h llimits.h lstate.h ltm.h \ + lzio.h lmem.h lundump.h +lfunc.o: lfunc.c lua.h luaconf.h lfunc.h lobject.h llimits.h lgc.h lmem.h \ + lstate.h ltm.h lzio.h +lgc.o: lgc.c lua.h luaconf.h ldebug.h lstate.h lobject.h llimits.h ltm.h \ + lzio.h lmem.h ldo.h lfunc.h lgc.h lstring.h ltable.h +linit.o: linit.c lua.h luaconf.h lualib.h lauxlib.h +liolib.o: liolib.c lua.h luaconf.h lauxlib.h lualib.h +llex.o: llex.c lua.h luaconf.h ldo.h lobject.h llimits.h lstate.h ltm.h \ + lzio.h lmem.h llex.h lparser.h lstring.h lgc.h ltable.h +lmathlib.o: lmathlib.c lua.h luaconf.h lauxlib.h lualib.h +lmem.o: lmem.c lua.h luaconf.h ldebug.h lstate.h lobject.h llimits.h \ + ltm.h lzio.h lmem.h ldo.h +loadlib.o: loadlib.c lua.h luaconf.h lauxlib.h lualib.h +lobject.o: lobject.c lua.h luaconf.h ldo.h lobject.h llimits.h lstate.h \ + ltm.h lzio.h lmem.h lstring.h lgc.h lvm.h +lopcodes.o: lopcodes.c lopcodes.h llimits.h lua.h luaconf.h +loslib.o: loslib.c lua.h luaconf.h lauxlib.h lualib.h +lparser.o: lparser.c lua.h luaconf.h lcode.h llex.h lobject.h llimits.h \ + lzio.h lmem.h lopcodes.h lparser.h ldebug.h lstate.h ltm.h ldo.h \ + lfunc.h lstring.h lgc.h ltable.h +lstate.o: lstate.c lua.h luaconf.h ldebug.h lstate.h lobject.h llimits.h \ + ltm.h lzio.h lmem.h ldo.h lfunc.h lgc.h llex.h lstring.h ltable.h +lstring.o: lstring.c lua.h luaconf.h lmem.h llimits.h lobject.h lstate.h \ + ltm.h lzio.h lstring.h lgc.h +lstrlib.o: lstrlib.c lua.h luaconf.h lauxlib.h lualib.h +ltable.o: ltable.c lua.h luaconf.h ldebug.h lstate.h lobject.h llimits.h \ + ltm.h lzio.h lmem.h ldo.h lgc.h ltable.h +ltablib.o: ltablib.c lua.h luaconf.h lauxlib.h lualib.h +ltm.o: ltm.c lua.h luaconf.h lobject.h llimits.h lstate.h ltm.h lzio.h \ + lmem.h lstring.h lgc.h ltable.h +lua.o: lua.c lua.h luaconf.h lauxlib.h lualib.h +luac.o: luac.c lua.h luaconf.h lauxlib.h ldo.h lobject.h llimits.h \ + lstate.h ltm.h lzio.h lmem.h lfunc.h lopcodes.h lstring.h lgc.h \ + lundump.h +lundump.o: lundump.c lua.h luaconf.h ldebug.h lstate.h lobject.h \ + llimits.h ltm.h lzio.h lmem.h ldo.h lfunc.h lstring.h lgc.h lundump.h +lvm.o: lvm.c lua.h luaconf.h ldebug.h lstate.h lobject.h llimits.h ltm.h \ + lzio.h lmem.h ldo.h lfunc.h lgc.h lopcodes.h lstring.h ltable.h lvm.h +lzio.o: lzio.c lua.h luaconf.h llimits.h lmem.h lstate.h lobject.h ltm.h \ + lzio.h +print.o: print.c ldebug.h lstate.h lua.h luaconf.h lobject.h llimits.h \ + ltm.h lzio.h lmem.h lopcodes.h lundump.h + +# (end of Makefile) diff --git a/mk/linux/mojosetup/lua/src/lapi.c b/mk/linux/mojosetup/lua/src/lapi.c new file mode 100644 index 00000000..5d5145d2 --- /dev/null +++ b/mk/linux/mojosetup/lua/src/lapi.c @@ -0,0 +1,1087 @@ +/* +** $Id: lapi.c,v 2.55.1.5 2008/07/04 18:41:18 roberto Exp $ +** Lua API +** See Copyright Notice in lua.h +*/ + + +#include +#include +#include +#include + +#define lapi_c +#define LUA_CORE + +#include "lua.h" + +#include "lapi.h" +#include "ldebug.h" +#include "ldo.h" +#include "lfunc.h" +#include "lgc.h" +#include "lmem.h" +#include "lobject.h" +#include "lstate.h" +#include "lstring.h" +#include "ltable.h" +#include "ltm.h" +#include "lundump.h" +#include "lvm.h" + + + +const char lua_ident[] = + "$Lua: " LUA_RELEASE " " LUA_COPYRIGHT " $\n" + "$Authors: " LUA_AUTHORS " $\n" + "$URL: www.lua.org $\n"; + + + +#define api_checknelems(L, n) api_check(L, (n) <= (L->top - L->base)) + +#define api_checkvalidindex(L, i) api_check(L, (i) != luaO_nilobject) + +#define api_incr_top(L) {api_check(L, L->top < L->ci->top); L->top++;} + + + +static TValue *index2adr (lua_State *L, int idx) { + if (idx > 0) { + TValue *o = L->base + (idx - 1); + api_check(L, idx <= L->ci->top - L->base); + if (o >= L->top) return cast(TValue *, luaO_nilobject); + else return o; + } + else if (idx > LUA_REGISTRYINDEX) { + api_check(L, idx != 0 && -idx <= L->top - L->base); + return L->top + idx; + } + else switch (idx) { /* pseudo-indices */ + case LUA_REGISTRYINDEX: return registry(L); + case LUA_ENVIRONINDEX: { + Closure *func = curr_func(L); + sethvalue(L, &L->env, func->c.env); + return &L->env; + } + case LUA_GLOBALSINDEX: return gt(L); + default: { + Closure *func = curr_func(L); + idx = LUA_GLOBALSINDEX - idx; + return (idx <= func->c.nupvalues) + ? &func->c.upvalue[idx-1] + : cast(TValue *, luaO_nilobject); + } + } +} + + +static Table *getcurrenv (lua_State *L) { + if (L->ci == L->base_ci) /* no enclosing function? */ + return hvalue(gt(L)); /* use global table as environment */ + else { + Closure *func = curr_func(L); + return func->c.env; + } +} + + +void luaA_pushobject (lua_State *L, const TValue *o) { + setobj2s(L, L->top, o); + api_incr_top(L); +} + + +LUA_API int lua_checkstack (lua_State *L, int size) { + int res = 1; + lua_lock(L); + if (size > LUAI_MAXCSTACK || (L->top - L->base + size) > LUAI_MAXCSTACK) + res = 0; /* stack overflow */ + else if (size > 0) { + luaD_checkstack(L, size); + if (L->ci->top < L->top + size) + L->ci->top = L->top + size; + } + lua_unlock(L); + return res; +} + + +LUA_API void lua_xmove (lua_State *from, lua_State *to, int n) { + int i; + if (from == to) return; + lua_lock(to); + api_checknelems(from, n); + api_check(from, G(from) == G(to)); + api_check(from, to->ci->top - to->top >= n); + from->top -= n; + for (i = 0; i < n; i++) { + setobj2s(to, to->top++, from->top + i); + } + lua_unlock(to); +} + + +LUA_API void lua_setlevel (lua_State *from, lua_State *to) { + to->nCcalls = from->nCcalls; +} + + +LUA_API lua_CFunction lua_atpanic (lua_State *L, lua_CFunction panicf) { + lua_CFunction old; + lua_lock(L); + old = G(L)->panic; + G(L)->panic = panicf; + lua_unlock(L); + return old; +} + + +LUA_API lua_State *lua_newthread (lua_State *L) { + lua_State *L1; + lua_lock(L); + luaC_checkGC(L); + L1 = luaE_newthread(L); + setthvalue(L, L->top, L1); + api_incr_top(L); + lua_unlock(L); + luai_userstatethread(L, L1); + return L1; +} + + + +/* +** basic stack manipulation +*/ + + +LUA_API int lua_gettop (lua_State *L) { + return cast_int(L->top - L->base); +} + + +LUA_API void lua_settop (lua_State *L, int idx) { + lua_lock(L); + if (idx >= 0) { + api_check(L, idx <= L->stack_last - L->base); + while (L->top < L->base + idx) + setnilvalue(L->top++); + L->top = L->base + idx; + } + else { + api_check(L, -(idx+1) <= (L->top - L->base)); + L->top += idx+1; /* `subtract' index (index is negative) */ + } + lua_unlock(L); +} + + +LUA_API void lua_remove (lua_State *L, int idx) { + StkId p; + lua_lock(L); + p = index2adr(L, idx); + api_checkvalidindex(L, p); + while (++p < L->top) setobjs2s(L, p-1, p); + L->top--; + lua_unlock(L); +} + + +LUA_API void lua_insert (lua_State *L, int idx) { + StkId p; + StkId q; + lua_lock(L); + p = index2adr(L, idx); + api_checkvalidindex(L, p); + for (q = L->top; q>p; q--) setobjs2s(L, q, q-1); + setobjs2s(L, p, L->top); + lua_unlock(L); +} + + +LUA_API void lua_replace (lua_State *L, int idx) { + StkId o; + lua_lock(L); + /* explicit test for incompatible code */ + if (idx == LUA_ENVIRONINDEX && L->ci == L->base_ci) + luaG_runerror(L, "no calling environment"); + api_checknelems(L, 1); + o = index2adr(L, idx); + api_checkvalidindex(L, o); + if (idx == LUA_ENVIRONINDEX) { + Closure *func = curr_func(L); + api_check(L, ttistable(L->top - 1)); + func->c.env = hvalue(L->top - 1); + luaC_barrier(L, func, L->top - 1); + } + else { + setobj(L, o, L->top - 1); + if (idx < LUA_GLOBALSINDEX) /* function upvalue? */ + luaC_barrier(L, curr_func(L), L->top - 1); + } + L->top--; + lua_unlock(L); +} + + +LUA_API void lua_pushvalue (lua_State *L, int idx) { + lua_lock(L); + setobj2s(L, L->top, index2adr(L, idx)); + api_incr_top(L); + lua_unlock(L); +} + + + +/* +** access functions (stack -> C) +*/ + + +LUA_API int lua_type (lua_State *L, int idx) { + StkId o = index2adr(L, idx); + return (o == luaO_nilobject) ? LUA_TNONE : ttype(o); +} + + +LUA_API const char *lua_typename (lua_State *L, int t) { + UNUSED(L); + return (t == LUA_TNONE) ? "no value" : luaT_typenames[t]; +} + + +LUA_API int lua_iscfunction (lua_State *L, int idx) { + StkId o = index2adr(L, idx); + return iscfunction(o); +} + + +LUA_API int lua_isnumber (lua_State *L, int idx) { + TValue n; + const TValue *o = index2adr(L, idx); + return tonumber(o, &n); +} + + +LUA_API int lua_isstring (lua_State *L, int idx) { + int t = lua_type(L, idx); + return (t == LUA_TSTRING || t == LUA_TNUMBER); +} + + +LUA_API int lua_isuserdata (lua_State *L, int idx) { + const TValue *o = index2adr(L, idx); + return (ttisuserdata(o) || ttislightuserdata(o)); +} + + +LUA_API int lua_rawequal (lua_State *L, int index1, int index2) { + StkId o1 = index2adr(L, index1); + StkId o2 = index2adr(L, index2); + return (o1 == luaO_nilobject || o2 == luaO_nilobject) ? 0 + : luaO_rawequalObj(o1, o2); +} + + +LUA_API int lua_equal (lua_State *L, int index1, int index2) { + StkId o1, o2; + int i; + lua_lock(L); /* may call tag method */ + o1 = index2adr(L, index1); + o2 = index2adr(L, index2); + i = (o1 == luaO_nilobject || o2 == luaO_nilobject) ? 0 : equalobj(L, o1, o2); + lua_unlock(L); + return i; +} + + +LUA_API int lua_lessthan (lua_State *L, int index1, int index2) { + StkId o1, o2; + int i; + lua_lock(L); /* may call tag method */ + o1 = index2adr(L, index1); + o2 = index2adr(L, index2); + i = (o1 == luaO_nilobject || o2 == luaO_nilobject) ? 0 + : luaV_lessthan(L, o1, o2); + lua_unlock(L); + return i; +} + + + +LUA_API lua_Number lua_tonumber (lua_State *L, int idx) { + TValue n; + const TValue *o = index2adr(L, idx); + if (tonumber(o, &n)) + return nvalue(o); + else + return 0; +} + + +LUA_API lua_Integer lua_tointeger (lua_State *L, int idx) { + TValue n; + const TValue *o = index2adr(L, idx); + if (tonumber(o, &n)) { + lua_Integer res; + lua_Number num = nvalue(o); + lua_number2integer(res, num); + return res; + } + else + return 0; +} + + +LUA_API int lua_toboolean (lua_State *L, int idx) { + const TValue *o = index2adr(L, idx); + return !l_isfalse(o); +} + + +LUA_API const char *lua_tolstring (lua_State *L, int idx, size_t *len) { + StkId o = index2adr(L, idx); + if (!ttisstring(o)) { + lua_lock(L); /* `luaV_tostring' may create a new string */ + if (!luaV_tostring(L, o)) { /* conversion failed? */ + if (len != NULL) *len = 0; + lua_unlock(L); + return NULL; + } + luaC_checkGC(L); + o = index2adr(L, idx); /* previous call may reallocate the stack */ + lua_unlock(L); + } + if (len != NULL) *len = tsvalue(o)->len; + return svalue(o); +} + + +LUA_API size_t lua_objlen (lua_State *L, int idx) { + StkId o = index2adr(L, idx); + switch (ttype(o)) { + case LUA_TSTRING: return tsvalue(o)->len; + case LUA_TUSERDATA: return uvalue(o)->len; + case LUA_TTABLE: return luaH_getn(hvalue(o)); + case LUA_TNUMBER: { + size_t l; + lua_lock(L); /* `luaV_tostring' may create a new string */ + l = (luaV_tostring(L, o) ? tsvalue(o)->len : 0); + lua_unlock(L); + return l; + } + default: return 0; + } +} + + +LUA_API lua_CFunction lua_tocfunction (lua_State *L, int idx) { + StkId o = index2adr(L, idx); + return (!iscfunction(o)) ? NULL : clvalue(o)->c.f; +} + + +LUA_API void *lua_touserdata (lua_State *L, int idx) { + StkId o = index2adr(L, idx); + switch (ttype(o)) { + case LUA_TUSERDATA: return (rawuvalue(o) + 1); + case LUA_TLIGHTUSERDATA: return pvalue(o); + default: return NULL; + } +} + + +LUA_API lua_State *lua_tothread (lua_State *L, int idx) { + StkId o = index2adr(L, idx); + return (!ttisthread(o)) ? NULL : thvalue(o); +} + + +LUA_API const void *lua_topointer (lua_State *L, int idx) { + StkId o = index2adr(L, idx); + switch (ttype(o)) { + case LUA_TTABLE: return hvalue(o); + case LUA_TFUNCTION: return clvalue(o); + case LUA_TTHREAD: return thvalue(o); + case LUA_TUSERDATA: + case LUA_TLIGHTUSERDATA: + return lua_touserdata(L, idx); + default: return NULL; + } +} + + + +/* +** push functions (C -> stack) +*/ + + +LUA_API void lua_pushnil (lua_State *L) { + lua_lock(L); + setnilvalue(L->top); + api_incr_top(L); + lua_unlock(L); +} + + +LUA_API void lua_pushnumber (lua_State *L, lua_Number n) { + lua_lock(L); + setnvalue(L->top, n); + api_incr_top(L); + lua_unlock(L); +} + + +LUA_API void lua_pushinteger (lua_State *L, lua_Integer n) { + lua_lock(L); + setnvalue(L->top, cast_num(n)); + api_incr_top(L); + lua_unlock(L); +} + + +LUA_API void lua_pushlstring (lua_State *L, const char *s, size_t len) { + lua_lock(L); + luaC_checkGC(L); + setsvalue2s(L, L->top, luaS_newlstr(L, s, len)); + api_incr_top(L); + lua_unlock(L); +} + + +LUA_API void lua_pushstring (lua_State *L, const char *s) { + if (s == NULL) + lua_pushnil(L); + else + lua_pushlstring(L, s, strlen(s)); +} + + +LUA_API const char *lua_pushvfstring (lua_State *L, const char *fmt, + va_list argp) { + const char *ret; + lua_lock(L); + luaC_checkGC(L); + ret = luaO_pushvfstring(L, fmt, argp); + lua_unlock(L); + return ret; +} + + +LUA_API const char *lua_pushfstring (lua_State *L, const char *fmt, ...) { + const char *ret; + va_list argp; + lua_lock(L); + luaC_checkGC(L); + va_start(argp, fmt); + ret = luaO_pushvfstring(L, fmt, argp); + va_end(argp); + lua_unlock(L); + return ret; +} + + +LUA_API void lua_pushcclosure (lua_State *L, lua_CFunction fn, int n) { + Closure *cl; + lua_lock(L); + luaC_checkGC(L); + api_checknelems(L, n); + cl = luaF_newCclosure(L, n, getcurrenv(L)); + cl->c.f = fn; + L->top -= n; + while (n--) + setobj2n(L, &cl->c.upvalue[n], L->top+n); + setclvalue(L, L->top, cl); + lua_assert(iswhite(obj2gco(cl))); + api_incr_top(L); + lua_unlock(L); +} + + +LUA_API void lua_pushboolean (lua_State *L, int b) { + lua_lock(L); + setbvalue(L->top, (b != 0)); /* ensure that true is 1 */ + api_incr_top(L); + lua_unlock(L); +} + + +LUA_API void lua_pushlightuserdata (lua_State *L, void *p) { + lua_lock(L); + setpvalue(L->top, p); + api_incr_top(L); + lua_unlock(L); +} + + +LUA_API int lua_pushthread (lua_State *L) { + lua_lock(L); + setthvalue(L, L->top, L); + api_incr_top(L); + lua_unlock(L); + return (G(L)->mainthread == L); +} + + + +/* +** get functions (Lua -> stack) +*/ + + +LUA_API void lua_gettable (lua_State *L, int idx) { + StkId t; + lua_lock(L); + t = index2adr(L, idx); + api_checkvalidindex(L, t); + luaV_gettable(L, t, L->top - 1, L->top - 1); + lua_unlock(L); +} + + +LUA_API void lua_getfield (lua_State *L, int idx, const char *k) { + StkId t; + TValue key; + lua_lock(L); + t = index2adr(L, idx); + api_checkvalidindex(L, t); + setsvalue(L, &key, luaS_new(L, k)); + luaV_gettable(L, t, &key, L->top); + api_incr_top(L); + lua_unlock(L); +} + + +LUA_API void lua_rawget (lua_State *L, int idx) { + StkId t; + lua_lock(L); + t = index2adr(L, idx); + api_check(L, ttistable(t)); + setobj2s(L, L->top - 1, luaH_get(hvalue(t), L->top - 1)); + lua_unlock(L); +} + + +LUA_API void lua_rawgeti (lua_State *L, int idx, int n) { + StkId o; + lua_lock(L); + o = index2adr(L, idx); + api_check(L, ttistable(o)); + setobj2s(L, L->top, luaH_getnum(hvalue(o), n)); + api_incr_top(L); + lua_unlock(L); +} + + +LUA_API void lua_createtable (lua_State *L, int narray, int nrec) { + lua_lock(L); + luaC_checkGC(L); + sethvalue(L, L->top, luaH_new(L, narray, nrec)); + api_incr_top(L); + lua_unlock(L); +} + + +LUA_API int lua_getmetatable (lua_State *L, int objindex) { + const TValue *obj; + Table *mt = NULL; + int res; + lua_lock(L); + obj = index2adr(L, objindex); + switch (ttype(obj)) { + case LUA_TTABLE: + mt = hvalue(obj)->metatable; + break; + case LUA_TUSERDATA: + mt = uvalue(obj)->metatable; + break; + default: + mt = G(L)->mt[ttype(obj)]; + break; + } + if (mt == NULL) + res = 0; + else { + sethvalue(L, L->top, mt); + api_incr_top(L); + res = 1; + } + lua_unlock(L); + return res; +} + + +LUA_API void lua_getfenv (lua_State *L, int idx) { + StkId o; + lua_lock(L); + o = index2adr(L, idx); + api_checkvalidindex(L, o); + switch (ttype(o)) { + case LUA_TFUNCTION: + sethvalue(L, L->top, clvalue(o)->c.env); + break; + case LUA_TUSERDATA: + sethvalue(L, L->top, uvalue(o)->env); + break; + case LUA_TTHREAD: + setobj2s(L, L->top, gt(thvalue(o))); + break; + default: + setnilvalue(L->top); + break; + } + api_incr_top(L); + lua_unlock(L); +} + + +/* +** set functions (stack -> Lua) +*/ + + +LUA_API void lua_settable (lua_State *L, int idx) { + StkId t; + lua_lock(L); + api_checknelems(L, 2); + t = index2adr(L, idx); + api_checkvalidindex(L, t); + luaV_settable(L, t, L->top - 2, L->top - 1); + L->top -= 2; /* pop index and value */ + lua_unlock(L); +} + + +LUA_API void lua_setfield (lua_State *L, int idx, const char *k) { + StkId t; + TValue key; + lua_lock(L); + api_checknelems(L, 1); + t = index2adr(L, idx); + api_checkvalidindex(L, t); + setsvalue(L, &key, luaS_new(L, k)); + luaV_settable(L, t, &key, L->top - 1); + L->top--; /* pop value */ + lua_unlock(L); +} + + +LUA_API void lua_rawset (lua_State *L, int idx) { + StkId t; + lua_lock(L); + api_checknelems(L, 2); + t = index2adr(L, idx); + api_check(L, ttistable(t)); + setobj2t(L, luaH_set(L, hvalue(t), L->top-2), L->top-1); + luaC_barriert(L, hvalue(t), L->top-1); + L->top -= 2; + lua_unlock(L); +} + + +LUA_API void lua_rawseti (lua_State *L, int idx, int n) { + StkId o; + lua_lock(L); + api_checknelems(L, 1); + o = index2adr(L, idx); + api_check(L, ttistable(o)); + setobj2t(L, luaH_setnum(L, hvalue(o), n), L->top-1); + luaC_barriert(L, hvalue(o), L->top-1); + L->top--; + lua_unlock(L); +} + + +LUA_API int lua_setmetatable (lua_State *L, int objindex) { + TValue *obj; + Table *mt; + lua_lock(L); + api_checknelems(L, 1); + obj = index2adr(L, objindex); + api_checkvalidindex(L, obj); + if (ttisnil(L->top - 1)) + mt = NULL; + else { + api_check(L, ttistable(L->top - 1)); + mt = hvalue(L->top - 1); + } + switch (ttype(obj)) { + case LUA_TTABLE: { + hvalue(obj)->metatable = mt; + if (mt) + luaC_objbarriert(L, hvalue(obj), mt); + break; + } + case LUA_TUSERDATA: { + uvalue(obj)->metatable = mt; + if (mt) + luaC_objbarrier(L, rawuvalue(obj), mt); + break; + } + default: { + G(L)->mt[ttype(obj)] = mt; + break; + } + } + L->top--; + lua_unlock(L); + return 1; +} + + +LUA_API int lua_setfenv (lua_State *L, int idx) { + StkId o; + int res = 1; + lua_lock(L); + api_checknelems(L, 1); + o = index2adr(L, idx); + api_checkvalidindex(L, o); + api_check(L, ttistable(L->top - 1)); + switch (ttype(o)) { + case LUA_TFUNCTION: + clvalue(o)->c.env = hvalue(L->top - 1); + break; + case LUA_TUSERDATA: + uvalue(o)->env = hvalue(L->top - 1); + break; + case LUA_TTHREAD: + sethvalue(L, gt(thvalue(o)), hvalue(L->top - 1)); + break; + default: + res = 0; + break; + } + if (res) luaC_objbarrier(L, gcvalue(o), hvalue(L->top - 1)); + L->top--; + lua_unlock(L); + return res; +} + + +/* +** `load' and `call' functions (run Lua code) +*/ + + +#define adjustresults(L,nres) \ + { if (nres == LUA_MULTRET && L->top >= L->ci->top) L->ci->top = L->top; } + + +#define checkresults(L,na,nr) \ + api_check(L, (nr) == LUA_MULTRET || (L->ci->top - L->top >= (nr) - (na))) + + +LUA_API void lua_call (lua_State *L, int nargs, int nresults) { + StkId func; + lua_lock(L); + api_checknelems(L, nargs+1); + checkresults(L, nargs, nresults); + func = L->top - (nargs+1); + luaD_call(L, func, nresults); + adjustresults(L, nresults); + lua_unlock(L); +} + + + +/* +** Execute a protected call. +*/ +struct CallS { /* data to `f_call' */ + StkId func; + int nresults; +}; + + +static void f_call (lua_State *L, void *ud) { + struct CallS *c = cast(struct CallS *, ud); + luaD_call(L, c->func, c->nresults); +} + + + +LUA_API int lua_pcall (lua_State *L, int nargs, int nresults, int errfunc) { + struct CallS c; + int status; + ptrdiff_t func; + lua_lock(L); + api_checknelems(L, nargs+1); + checkresults(L, nargs, nresults); + if (errfunc == 0) + func = 0; + else { + StkId o = index2adr(L, errfunc); + api_checkvalidindex(L, o); + func = savestack(L, o); + } + c.func = L->top - (nargs+1); /* function to be called */ + c.nresults = nresults; + status = luaD_pcall(L, f_call, &c, savestack(L, c.func), func); + adjustresults(L, nresults); + lua_unlock(L); + return status; +} + + +/* +** Execute a protected C call. +*/ +struct CCallS { /* data to `f_Ccall' */ + lua_CFunction func; + void *ud; +}; + + +static void f_Ccall (lua_State *L, void *ud) { + struct CCallS *c = cast(struct CCallS *, ud); + Closure *cl; + cl = luaF_newCclosure(L, 0, getcurrenv(L)); + cl->c.f = c->func; + setclvalue(L, L->top, cl); /* push function */ + api_incr_top(L); + setpvalue(L->top, c->ud); /* push only argument */ + api_incr_top(L); + luaD_call(L, L->top - 2, 0); +} + + +LUA_API int lua_cpcall (lua_State *L, lua_CFunction func, void *ud) { + struct CCallS c; + int status; + lua_lock(L); + c.func = func; + c.ud = ud; + status = luaD_pcall(L, f_Ccall, &c, savestack(L, L->top), 0); + lua_unlock(L); + return status; +} + + +LUA_API int lua_load (lua_State *L, lua_Reader reader, void *data, + const char *chunkname) { + ZIO z; + int status; + lua_lock(L); + if (!chunkname) chunkname = "?"; + luaZ_init(L, &z, reader, data); + status = luaD_protectedparser(L, &z, chunkname); + lua_unlock(L); + return status; +} + + +LUA_API int lua_dump (lua_State *L, lua_Writer writer, void *data) { + int status; + TValue *o; + lua_lock(L); + api_checknelems(L, 1); + o = L->top - 1; + if (isLfunction(o)) + status = luaU_dump(L, clvalue(o)->l.p, writer, data, 0); + else + status = 1; + lua_unlock(L); + return status; +} + + +LUA_API int lua_status (lua_State *L) { + return L->status; +} + + +/* +** Garbage-collection function +*/ + +LUA_API int lua_gc (lua_State *L, int what, int data) { + int res = 0; + global_State *g; + lua_lock(L); + g = G(L); + switch (what) { + case LUA_GCSTOP: { + g->GCthreshold = MAX_LUMEM; + break; + } + case LUA_GCRESTART: { + g->GCthreshold = g->totalbytes; + break; + } + case LUA_GCCOLLECT: { + luaC_fullgc(L); + break; + } + case LUA_GCCOUNT: { + /* GC values are expressed in Kbytes: #bytes/2^10 */ + res = cast_int(g->totalbytes >> 10); + break; + } + case LUA_GCCOUNTB: { + res = cast_int(g->totalbytes & 0x3ff); + break; + } + case LUA_GCSTEP: { + lu_mem a = (cast(lu_mem, data) << 10); + if (a <= g->totalbytes) + g->GCthreshold = g->totalbytes - a; + else + g->GCthreshold = 0; + while (g->GCthreshold <= g->totalbytes) { + luaC_step(L); + if (g->gcstate == GCSpause) { /* end of cycle? */ + res = 1; /* signal it */ + break; + } + } + break; + } + case LUA_GCSETPAUSE: { + res = g->gcpause; + g->gcpause = data; + break; + } + case LUA_GCSETSTEPMUL: { + res = g->gcstepmul; + g->gcstepmul = data; + break; + } + default: res = -1; /* invalid option */ + } + lua_unlock(L); + return res; +} + + + +/* +** miscellaneous functions +*/ + + +LUA_API int lua_error (lua_State *L) { + lua_lock(L); + api_checknelems(L, 1); + luaG_errormsg(L); + lua_unlock(L); + return 0; /* to avoid warnings */ +} + + +LUA_API int lua_next (lua_State *L, int idx) { + StkId t; + int more; + lua_lock(L); + t = index2adr(L, idx); + api_check(L, ttistable(t)); + more = luaH_next(L, hvalue(t), L->top - 1); + if (more) { + api_incr_top(L); + } + else /* no more elements */ + L->top -= 1; /* remove key */ + lua_unlock(L); + return more; +} + + +LUA_API void lua_concat (lua_State *L, int n) { + lua_lock(L); + api_checknelems(L, n); + if (n >= 2) { + luaC_checkGC(L); + luaV_concat(L, n, cast_int(L->top - L->base) - 1); + L->top -= (n-1); + } + else if (n == 0) { /* push empty string */ + setsvalue2s(L, L->top, luaS_newlstr(L, "", 0)); + api_incr_top(L); + } + /* else n == 1; nothing to do */ + lua_unlock(L); +} + + +LUA_API lua_Alloc lua_getallocf (lua_State *L, void **ud) { + lua_Alloc f; + lua_lock(L); + if (ud) *ud = G(L)->ud; + f = G(L)->frealloc; + lua_unlock(L); + return f; +} + + +LUA_API void lua_setallocf (lua_State *L, lua_Alloc f, void *ud) { + lua_lock(L); + G(L)->ud = ud; + G(L)->frealloc = f; + lua_unlock(L); +} + + +LUA_API void *lua_newuserdata (lua_State *L, size_t size) { + Udata *u; + lua_lock(L); + luaC_checkGC(L); + u = luaS_newudata(L, size, getcurrenv(L)); + setuvalue(L, L->top, u); + api_incr_top(L); + lua_unlock(L); + return u + 1; +} + + + + +static const char *aux_upvalue (StkId fi, int n, TValue **val) { + Closure *f; + if (!ttisfunction(fi)) return NULL; + f = clvalue(fi); + if (f->c.isC) { + if (!(1 <= n && n <= f->c.nupvalues)) return NULL; + *val = &f->c.upvalue[n-1]; + return ""; + } + else { + Proto *p = f->l.p; + if (!(1 <= n && n <= p->sizeupvalues)) return NULL; + *val = f->l.upvals[n-1]->v; + return getstr(p->upvalues[n-1]); + } +} + + +LUA_API const char *lua_getupvalue (lua_State *L, int funcindex, int n) { + const char *name; + TValue *val; + lua_lock(L); + name = aux_upvalue(index2adr(L, funcindex), n, &val); + if (name) { + setobj2s(L, L->top, val); + api_incr_top(L); + } + lua_unlock(L); + return name; +} + + +LUA_API const char *lua_setupvalue (lua_State *L, int funcindex, int n) { + const char *name; + TValue *val; + StkId fi; + lua_lock(L); + fi = index2adr(L, funcindex); + api_checknelems(L, 1); + name = aux_upvalue(fi, n, &val); + if (name) { + L->top--; + setobj(L, val, L->top); + luaC_barrier(L, clvalue(fi), L->top); + } + lua_unlock(L); + return name; +} + diff --git a/mk/linux/mojosetup/lua/src/lapi.h b/mk/linux/mojosetup/lua/src/lapi.h new file mode 100644 index 00000000..2c3fab24 --- /dev/null +++ b/mk/linux/mojosetup/lua/src/lapi.h @@ -0,0 +1,16 @@ +/* +** $Id: lapi.h,v 2.2.1.1 2007/12/27 13:02:25 roberto Exp $ +** Auxiliary functions from Lua API +** See Copyright Notice in lua.h +*/ + +#ifndef lapi_h +#define lapi_h + + +#include "lobject.h" + + +LUAI_FUNC void luaA_pushobject (lua_State *L, const TValue *o); + +#endif diff --git a/mk/linux/mojosetup/lua/src/lauxlib.c b/mk/linux/mojosetup/lua/src/lauxlib.c new file mode 100644 index 00000000..10f14e2c --- /dev/null +++ b/mk/linux/mojosetup/lua/src/lauxlib.c @@ -0,0 +1,652 @@ +/* +** $Id: lauxlib.c,v 1.159.1.3 2008/01/21 13:20:51 roberto Exp $ +** Auxiliary functions for building Lua libraries +** See Copyright Notice in lua.h +*/ + + +#include +#include +#include +#include +#include +#include + + +/* This file uses only the official API of Lua. +** Any function declared here could be written as an application function. +*/ + +#define lauxlib_c +#define LUA_LIB + +#include "lua.h" + +#include "lauxlib.h" + + +#define FREELIST_REF 0 /* free list of references */ + + +/* convert a stack index to positive */ +#define abs_index(L, i) ((i) > 0 || (i) <= LUA_REGISTRYINDEX ? (i) : \ + lua_gettop(L) + (i) + 1) + + +/* +** {====================================================== +** Error-report functions +** ======================================================= +*/ + + +LUALIB_API int luaL_argerror (lua_State *L, int narg, const char *extramsg) { + lua_Debug ar; + if (!lua_getstack(L, 0, &ar)) /* no stack frame? */ + return luaL_error(L, "bad argument #%d (%s)", narg, extramsg); + lua_getinfo(L, "n", &ar); + if (strcmp(ar.namewhat, "method") == 0) { + narg--; /* do not count `self' */ + if (narg == 0) /* error is in the self argument itself? */ + return luaL_error(L, "calling " LUA_QS " on bad self (%s)", + ar.name, extramsg); + } + if (ar.name == NULL) + ar.name = "?"; + return luaL_error(L, "bad argument #%d to " LUA_QS " (%s)", + narg, ar.name, extramsg); +} + + +LUALIB_API int luaL_typerror (lua_State *L, int narg, const char *tname) { + const char *msg = lua_pushfstring(L, "%s expected, got %s", + tname, luaL_typename(L, narg)); + return luaL_argerror(L, narg, msg); +} + + +static void tag_error (lua_State *L, int narg, int tag) { + luaL_typerror(L, narg, lua_typename(L, tag)); +} + + +LUALIB_API void luaL_where (lua_State *L, int level) { + lua_Debug ar; + if (lua_getstack(L, level, &ar)) { /* check function at level */ + lua_getinfo(L, "Sl", &ar); /* get info about it */ + if (ar.currentline > 0) { /* is there info? */ + lua_pushfstring(L, "%s:%d: ", ar.short_src, ar.currentline); + return; + } + } + lua_pushliteral(L, ""); /* else, no information available... */ +} + + +LUALIB_API int luaL_error (lua_State *L, const char *fmt, ...) { + va_list argp; + va_start(argp, fmt); + luaL_where(L, 1); + lua_pushvfstring(L, fmt, argp); + va_end(argp); + lua_concat(L, 2); + return lua_error(L); +} + +/* }====================================================== */ + + +LUALIB_API int luaL_checkoption (lua_State *L, int narg, const char *def, + const char *const lst[]) { + const char *name = (def) ? luaL_optstring(L, narg, def) : + luaL_checkstring(L, narg); + int i; + for (i=0; lst[i]; i++) + if (strcmp(lst[i], name) == 0) + return i; + return luaL_argerror(L, narg, + lua_pushfstring(L, "invalid option " LUA_QS, name)); +} + + +LUALIB_API int luaL_newmetatable (lua_State *L, const char *tname) { + lua_getfield(L, LUA_REGISTRYINDEX, tname); /* get registry.name */ + if (!lua_isnil(L, -1)) /* name already in use? */ + return 0; /* leave previous value on top, but return 0 */ + lua_pop(L, 1); + lua_newtable(L); /* create metatable */ + lua_pushvalue(L, -1); + lua_setfield(L, LUA_REGISTRYINDEX, tname); /* registry.name = metatable */ + return 1; +} + + +LUALIB_API void *luaL_checkudata (lua_State *L, int ud, const char *tname) { + void *p = lua_touserdata(L, ud); + if (p != NULL) { /* value is a userdata? */ + if (lua_getmetatable(L, ud)) { /* does it have a metatable? */ + lua_getfield(L, LUA_REGISTRYINDEX, tname); /* get correct metatable */ + if (lua_rawequal(L, -1, -2)) { /* does it have the correct mt? */ + lua_pop(L, 2); /* remove both metatables */ + return p; + } + } + } + luaL_typerror(L, ud, tname); /* else error */ + return NULL; /* to avoid warnings */ +} + + +LUALIB_API void luaL_checkstack (lua_State *L, int space, const char *mes) { + if (!lua_checkstack(L, space)) + luaL_error(L, "stack overflow (%s)", mes); +} + + +LUALIB_API void luaL_checktype (lua_State *L, int narg, int t) { + if (lua_type(L, narg) != t) + tag_error(L, narg, t); +} + + +LUALIB_API void luaL_checkany (lua_State *L, int narg) { + if (lua_type(L, narg) == LUA_TNONE) + luaL_argerror(L, narg, "value expected"); +} + + +LUALIB_API const char *luaL_checklstring (lua_State *L, int narg, size_t *len) { + const char *s = lua_tolstring(L, narg, len); + if (!s) tag_error(L, narg, LUA_TSTRING); + return s; +} + + +LUALIB_API const char *luaL_optlstring (lua_State *L, int narg, + const char *def, size_t *len) { + if (lua_isnoneornil(L, narg)) { + if (len) + *len = (def ? strlen(def) : 0); + return def; + } + else return luaL_checklstring(L, narg, len); +} + + +LUALIB_API lua_Number luaL_checknumber (lua_State *L, int narg) { + lua_Number d = lua_tonumber(L, narg); + if (d == 0 && !lua_isnumber(L, narg)) /* avoid extra test when d is not 0 */ + tag_error(L, narg, LUA_TNUMBER); + return d; +} + + +LUALIB_API lua_Number luaL_optnumber (lua_State *L, int narg, lua_Number def) { + return luaL_opt(L, luaL_checknumber, narg, def); +} + + +LUALIB_API lua_Integer luaL_checkinteger (lua_State *L, int narg) { + lua_Integer d = lua_tointeger(L, narg); + if (d == 0 && !lua_isnumber(L, narg)) /* avoid extra test when d is not 0 */ + tag_error(L, narg, LUA_TNUMBER); + return d; +} + + +LUALIB_API lua_Integer luaL_optinteger (lua_State *L, int narg, + lua_Integer def) { + return luaL_opt(L, luaL_checkinteger, narg, def); +} + + +LUALIB_API int luaL_getmetafield (lua_State *L, int obj, const char *event) { + if (!lua_getmetatable(L, obj)) /* no metatable? */ + return 0; + lua_pushstring(L, event); + lua_rawget(L, -2); + if (lua_isnil(L, -1)) { + lua_pop(L, 2); /* remove metatable and metafield */ + return 0; + } + else { + lua_remove(L, -2); /* remove only metatable */ + return 1; + } +} + + +LUALIB_API int luaL_callmeta (lua_State *L, int obj, const char *event) { + obj = abs_index(L, obj); + if (!luaL_getmetafield(L, obj, event)) /* no metafield? */ + return 0; + lua_pushvalue(L, obj); + lua_call(L, 1, 1); + return 1; +} + + +LUALIB_API void (luaL_register) (lua_State *L, const char *libname, + const luaL_Reg *l) { + luaI_openlib(L, libname, l, 0); +} + + +static int libsize (const luaL_Reg *l) { + int size = 0; + for (; l->name; l++) size++; + return size; +} + + +LUALIB_API void luaI_openlib (lua_State *L, const char *libname, + const luaL_Reg *l, int nup) { + if (libname) { + int size = libsize(l); + /* check whether lib already exists */ + luaL_findtable(L, LUA_REGISTRYINDEX, "_LOADED", 1); + lua_getfield(L, -1, libname); /* get _LOADED[libname] */ + if (!lua_istable(L, -1)) { /* not found? */ + lua_pop(L, 1); /* remove previous result */ + /* try global variable (and create one if it does not exist) */ + if (luaL_findtable(L, LUA_GLOBALSINDEX, libname, size) != NULL) + luaL_error(L, "name conflict for module " LUA_QS, libname); + lua_pushvalue(L, -1); + lua_setfield(L, -3, libname); /* _LOADED[libname] = new table */ + } + lua_remove(L, -2); /* remove _LOADED table */ + lua_insert(L, -(nup+1)); /* move library table to below upvalues */ + } + for (; l->name; l++) { + int i; + for (i=0; ifunc, nup); + lua_setfield(L, -(nup+2), l->name); + } + lua_pop(L, nup); /* remove upvalues */ +} + + + +/* +** {====================================================== +** getn-setn: size for arrays +** ======================================================= +*/ + +#if defined(LUA_COMPAT_GETN) + +static int checkint (lua_State *L, int topop) { + int n = (lua_type(L, -1) == LUA_TNUMBER) ? lua_tointeger(L, -1) : -1; + lua_pop(L, topop); + return n; +} + + +static void getsizes (lua_State *L) { + lua_getfield(L, LUA_REGISTRYINDEX, "LUA_SIZES"); + if (lua_isnil(L, -1)) { /* no `size' table? */ + lua_pop(L, 1); /* remove nil */ + lua_newtable(L); /* create it */ + lua_pushvalue(L, -1); /* `size' will be its own metatable */ + lua_setmetatable(L, -2); + lua_pushliteral(L, "kv"); + lua_setfield(L, -2, "__mode"); /* metatable(N).__mode = "kv" */ + lua_pushvalue(L, -1); + lua_setfield(L, LUA_REGISTRYINDEX, "LUA_SIZES"); /* store in register */ + } +} + + +LUALIB_API void luaL_setn (lua_State *L, int t, int n) { + t = abs_index(L, t); + lua_pushliteral(L, "n"); + lua_rawget(L, t); + if (checkint(L, 1) >= 0) { /* is there a numeric field `n'? */ + lua_pushliteral(L, "n"); /* use it */ + lua_pushinteger(L, n); + lua_rawset(L, t); + } + else { /* use `sizes' */ + getsizes(L); + lua_pushvalue(L, t); + lua_pushinteger(L, n); + lua_rawset(L, -3); /* sizes[t] = n */ + lua_pop(L, 1); /* remove `sizes' */ + } +} + + +LUALIB_API int luaL_getn (lua_State *L, int t) { + int n; + t = abs_index(L, t); + lua_pushliteral(L, "n"); /* try t.n */ + lua_rawget(L, t); + if ((n = checkint(L, 1)) >= 0) return n; + getsizes(L); /* else try sizes[t] */ + lua_pushvalue(L, t); + lua_rawget(L, -2); + if ((n = checkint(L, 2)) >= 0) return n; + return (int)lua_objlen(L, t); +} + +#endif + +/* }====================================================== */ + + + +LUALIB_API const char *luaL_gsub (lua_State *L, const char *s, const char *p, + const char *r) { + const char *wild; + size_t l = strlen(p); + luaL_Buffer b; + luaL_buffinit(L, &b); + while ((wild = strstr(s, p)) != NULL) { + luaL_addlstring(&b, s, wild - s); /* push prefix */ + luaL_addstring(&b, r); /* push replacement in place of pattern */ + s = wild + l; /* continue after `p' */ + } + luaL_addstring(&b, s); /* push last suffix */ + luaL_pushresult(&b); + return lua_tostring(L, -1); +} + + +LUALIB_API const char *luaL_findtable (lua_State *L, int idx, + const char *fname, int szhint) { + const char *e; + lua_pushvalue(L, idx); + do { + e = strchr(fname, '.'); + if (e == NULL) e = fname + strlen(fname); + lua_pushlstring(L, fname, e - fname); + lua_rawget(L, -2); + if (lua_isnil(L, -1)) { /* no such field? */ + lua_pop(L, 1); /* remove this nil */ + lua_createtable(L, 0, (*e == '.' ? 1 : szhint)); /* new table for field */ + lua_pushlstring(L, fname, e - fname); + lua_pushvalue(L, -2); + lua_settable(L, -4); /* set new table into field */ + } + else if (!lua_istable(L, -1)) { /* field has a non-table value? */ + lua_pop(L, 2); /* remove table and value */ + return fname; /* return problematic part of the name */ + } + lua_remove(L, -2); /* remove previous table */ + fname = e + 1; + } while (*e == '.'); + return NULL; +} + + + +/* +** {====================================================== +** Generic Buffer manipulation +** ======================================================= +*/ + + +#define bufflen(B) ((B)->p - (B)->buffer) +#define bufffree(B) ((size_t)(LUAL_BUFFERSIZE - bufflen(B))) + +#define LIMIT (LUA_MINSTACK/2) + + +static int emptybuffer (luaL_Buffer *B) { + size_t l = bufflen(B); + if (l == 0) return 0; /* put nothing on stack */ + else { + lua_pushlstring(B->L, B->buffer, l); + B->p = B->buffer; + B->lvl++; + return 1; + } +} + + +static void adjuststack (luaL_Buffer *B) { + if (B->lvl > 1) { + lua_State *L = B->L; + int toget = 1; /* number of levels to concat */ + size_t toplen = lua_strlen(L, -1); + do { + size_t l = lua_strlen(L, -(toget+1)); + if (B->lvl - toget + 1 >= LIMIT || toplen > l) { + toplen += l; + toget++; + } + else break; + } while (toget < B->lvl); + lua_concat(L, toget); + B->lvl = B->lvl - toget + 1; + } +} + + +LUALIB_API char *luaL_prepbuffer (luaL_Buffer *B) { + if (emptybuffer(B)) + adjuststack(B); + return B->buffer; +} + + +LUALIB_API void luaL_addlstring (luaL_Buffer *B, const char *s, size_t l) { + while (l--) + luaL_addchar(B, *s++); +} + + +LUALIB_API void luaL_addstring (luaL_Buffer *B, const char *s) { + luaL_addlstring(B, s, strlen(s)); +} + + +LUALIB_API void luaL_pushresult (luaL_Buffer *B) { + emptybuffer(B); + lua_concat(B->L, B->lvl); + B->lvl = 1; +} + + +LUALIB_API void luaL_addvalue (luaL_Buffer *B) { + lua_State *L = B->L; + size_t vl; + const char *s = lua_tolstring(L, -1, &vl); + if (vl <= bufffree(B)) { /* fit into buffer? */ + memcpy(B->p, s, vl); /* put it there */ + B->p += vl; + lua_pop(L, 1); /* remove from stack */ + } + else { + if (emptybuffer(B)) + lua_insert(L, -2); /* put buffer before new value */ + B->lvl++; /* add new value into B stack */ + adjuststack(B); + } +} + + +LUALIB_API void luaL_buffinit (lua_State *L, luaL_Buffer *B) { + B->L = L; + B->p = B->buffer; + B->lvl = 0; +} + +/* }====================================================== */ + + +LUALIB_API int luaL_ref (lua_State *L, int t) { + int ref; + t = abs_index(L, t); + if (lua_isnil(L, -1)) { + lua_pop(L, 1); /* remove from stack */ + return LUA_REFNIL; /* `nil' has a unique fixed reference */ + } + lua_rawgeti(L, t, FREELIST_REF); /* get first free element */ + ref = (int)lua_tointeger(L, -1); /* ref = t[FREELIST_REF] */ + lua_pop(L, 1); /* remove it from stack */ + if (ref != 0) { /* any free element? */ + lua_rawgeti(L, t, ref); /* remove it from list */ + lua_rawseti(L, t, FREELIST_REF); /* (t[FREELIST_REF] = t[ref]) */ + } + else { /* no free elements */ + ref = (int)lua_objlen(L, t); + ref++; /* create new reference */ + } + lua_rawseti(L, t, ref); + return ref; +} + + +LUALIB_API void luaL_unref (lua_State *L, int t, int ref) { + if (ref >= 0) { + t = abs_index(L, t); + lua_rawgeti(L, t, FREELIST_REF); + lua_rawseti(L, t, ref); /* t[ref] = t[FREELIST_REF] */ + lua_pushinteger(L, ref); + lua_rawseti(L, t, FREELIST_REF); /* t[FREELIST_REF] = ref */ + } +} + + + +/* +** {====================================================== +** Load functions +** ======================================================= +*/ + +typedef struct LoadF { + int extraline; + FILE *f; + char buff[LUAL_BUFFERSIZE]; +} LoadF; + + +static const char *getF (lua_State *L, void *ud, size_t *size) { + LoadF *lf = (LoadF *)ud; + (void)L; + if (lf->extraline) { + lf->extraline = 0; + *size = 1; + return "\n"; + } + if (feof(lf->f)) return NULL; + *size = fread(lf->buff, 1, sizeof(lf->buff), lf->f); + return (*size > 0) ? lf->buff : NULL; +} + + +static int errfile (lua_State *L, const char *what, int fnameindex) { + const char *serr = strerror(errno); + const char *filename = lua_tostring(L, fnameindex) + 1; + lua_pushfstring(L, "cannot %s %s: %s", what, filename, serr); + lua_remove(L, fnameindex); + return LUA_ERRFILE; +} + + +LUALIB_API int luaL_loadfile (lua_State *L, const char *filename) { + LoadF lf; + int status, readstatus; + int c; + int fnameindex = lua_gettop(L) + 1; /* index of filename on the stack */ + lf.extraline = 0; + if (filename == NULL) { + lua_pushliteral(L, "=stdin"); + lf.f = stdin; + } + else { + lua_pushfstring(L, "@%s", filename); + lf.f = fopen(filename, "r"); + if (lf.f == NULL) return errfile(L, "open", fnameindex); + } + c = getc(lf.f); + if (c == '#') { /* Unix exec. file? */ + lf.extraline = 1; + while ((c = getc(lf.f)) != EOF && c != '\n') ; /* skip first line */ + if (c == '\n') c = getc(lf.f); + } + if (c == LUA_SIGNATURE[0] && filename) { /* binary file? */ + lf.f = freopen(filename, "rb", lf.f); /* reopen in binary mode */ + if (lf.f == NULL) return errfile(L, "reopen", fnameindex); + /* skip eventual `#!...' */ + while ((c = getc(lf.f)) != EOF && c != LUA_SIGNATURE[0]) ; + lf.extraline = 0; + } + ungetc(c, lf.f); + status = lua_load(L, getF, &lf, lua_tostring(L, -1)); + readstatus = ferror(lf.f); + if (filename) fclose(lf.f); /* close file (even in case of errors) */ + if (readstatus) { + lua_settop(L, fnameindex); /* ignore results from `lua_load' */ + return errfile(L, "read", fnameindex); + } + lua_remove(L, fnameindex); + return status; +} + + +typedef struct LoadS { + const char *s; + size_t size; +} LoadS; + + +static const char *getS (lua_State *L, void *ud, size_t *size) { + LoadS *ls = (LoadS *)ud; + (void)L; + if (ls->size == 0) return NULL; + *size = ls->size; + ls->size = 0; + return ls->s; +} + + +LUALIB_API int luaL_loadbuffer (lua_State *L, const char *buff, size_t size, + const char *name) { + LoadS ls; + ls.s = buff; + ls.size = size; + return lua_load(L, getS, &ls, name); +} + + +LUALIB_API int (luaL_loadstring) (lua_State *L, const char *s) { + return luaL_loadbuffer(L, s, strlen(s), s); +} + + + +/* }====================================================== */ + + +static void *l_alloc (void *ud, void *ptr, size_t osize, size_t nsize) { + (void)ud; + (void)osize; + if (nsize == 0) { + free(ptr); + return NULL; + } + else + return realloc(ptr, nsize); +} + + +static int panic (lua_State *L) { + (void)L; /* to avoid warnings */ + fprintf(stderr, "PANIC: unprotected error in call to Lua API (%s)\n", + lua_tostring(L, -1)); + return 0; +} + + +LUALIB_API lua_State *luaL_newstate (void) { + lua_State *L = lua_newstate(l_alloc, NULL); + if (L) lua_atpanic(L, &panic); + return L; +} + diff --git a/mk/linux/mojosetup/lua/src/lauxlib.h b/mk/linux/mojosetup/lua/src/lauxlib.h new file mode 100644 index 00000000..34258235 --- /dev/null +++ b/mk/linux/mojosetup/lua/src/lauxlib.h @@ -0,0 +1,174 @@ +/* +** $Id: lauxlib.h,v 1.88.1.1 2007/12/27 13:02:25 roberto Exp $ +** Auxiliary functions for building Lua libraries +** See Copyright Notice in lua.h +*/ + + +#ifndef lauxlib_h +#define lauxlib_h + + +#include +#include + +#include "lua.h" + + +#if defined(LUA_COMPAT_GETN) +LUALIB_API int (luaL_getn) (lua_State *L, int t); +LUALIB_API void (luaL_setn) (lua_State *L, int t, int n); +#else +#define luaL_getn(L,i) ((int)lua_objlen(L, i)) +#define luaL_setn(L,i,j) ((void)0) /* no op! */ +#endif + +#if defined(LUA_COMPAT_OPENLIB) +#define luaI_openlib luaL_openlib +#endif + + +/* extra error code for `luaL_load' */ +#define LUA_ERRFILE (LUA_ERRERR+1) + + +typedef struct luaL_Reg { + const char *name; + lua_CFunction func; +} luaL_Reg; + + + +LUALIB_API void (luaI_openlib) (lua_State *L, const char *libname, + const luaL_Reg *l, int nup); +LUALIB_API void (luaL_register) (lua_State *L, const char *libname, + const luaL_Reg *l); +LUALIB_API int (luaL_getmetafield) (lua_State *L, int obj, const char *e); +LUALIB_API int (luaL_callmeta) (lua_State *L, int obj, const char *e); +LUALIB_API int (luaL_typerror) (lua_State *L, int narg, const char *tname); +LUALIB_API int (luaL_argerror) (lua_State *L, int numarg, const char *extramsg); +LUALIB_API const char *(luaL_checklstring) (lua_State *L, int numArg, + size_t *l); +LUALIB_API const char *(luaL_optlstring) (lua_State *L, int numArg, + const char *def, size_t *l); +LUALIB_API lua_Number (luaL_checknumber) (lua_State *L, int numArg); +LUALIB_API lua_Number (luaL_optnumber) (lua_State *L, int nArg, lua_Number def); + +LUALIB_API lua_Integer (luaL_checkinteger) (lua_State *L, int numArg); +LUALIB_API lua_Integer (luaL_optinteger) (lua_State *L, int nArg, + lua_Integer def); + +LUALIB_API void (luaL_checkstack) (lua_State *L, int sz, const char *msg); +LUALIB_API void (luaL_checktype) (lua_State *L, int narg, int t); +LUALIB_API void (luaL_checkany) (lua_State *L, int narg); + +LUALIB_API int (luaL_newmetatable) (lua_State *L, const char *tname); +LUALIB_API void *(luaL_checkudata) (lua_State *L, int ud, const char *tname); + +LUALIB_API void (luaL_where) (lua_State *L, int lvl); +LUALIB_API int (luaL_error) (lua_State *L, const char *fmt, ...); + +LUALIB_API int (luaL_checkoption) (lua_State *L, int narg, const char *def, + const char *const lst[]); + +LUALIB_API int (luaL_ref) (lua_State *L, int t); +LUALIB_API void (luaL_unref) (lua_State *L, int t, int ref); + +LUALIB_API int (luaL_loadfile) (lua_State *L, const char *filename); +LUALIB_API int (luaL_loadbuffer) (lua_State *L, const char *buff, size_t sz, + const char *name); +LUALIB_API int (luaL_loadstring) (lua_State *L, const char *s); + +LUALIB_API lua_State *(luaL_newstate) (void); + + +LUALIB_API const char *(luaL_gsub) (lua_State *L, const char *s, const char *p, + const char *r); + +LUALIB_API const char *(luaL_findtable) (lua_State *L, int idx, + const char *fname, int szhint); + + + + +/* +** =============================================================== +** some useful macros +** =============================================================== +*/ + +#define luaL_argcheck(L, cond,numarg,extramsg) \ + ((void)((cond) || luaL_argerror(L, (numarg), (extramsg)))) +#define luaL_checkstring(L,n) (luaL_checklstring(L, (n), NULL)) +#define luaL_optstring(L,n,d) (luaL_optlstring(L, (n), (d), NULL)) +#define luaL_checkint(L,n) ((int)luaL_checkinteger(L, (n))) +#define luaL_optint(L,n,d) ((int)luaL_optinteger(L, (n), (d))) +#define luaL_checklong(L,n) ((long)luaL_checkinteger(L, (n))) +#define luaL_optlong(L,n,d) ((long)luaL_optinteger(L, (n), (d))) + +#define luaL_typename(L,i) lua_typename(L, lua_type(L,(i))) + +#define luaL_dofile(L, fn) \ + (luaL_loadfile(L, fn) || lua_pcall(L, 0, LUA_MULTRET, 0)) + +#define luaL_dostring(L, s) \ + (luaL_loadstring(L, s) || lua_pcall(L, 0, LUA_MULTRET, 0)) + +#define luaL_getmetatable(L,n) (lua_getfield(L, LUA_REGISTRYINDEX, (n))) + +#define luaL_opt(L,f,n,d) (lua_isnoneornil(L,(n)) ? (d) : f(L,(n))) + +/* +** {====================================================== +** Generic Buffer manipulation +** ======================================================= +*/ + + + +typedef struct luaL_Buffer { + char *p; /* current position in buffer */ + int lvl; /* number of strings in the stack (level) */ + lua_State *L; + char buffer[LUAL_BUFFERSIZE]; +} luaL_Buffer; + +#define luaL_addchar(B,c) \ + ((void)((B)->p < ((B)->buffer+LUAL_BUFFERSIZE) || luaL_prepbuffer(B)), \ + (*(B)->p++ = (char)(c))) + +/* compatibility only */ +#define luaL_putchar(B,c) luaL_addchar(B,c) + +#define luaL_addsize(B,n) ((B)->p += (n)) + +LUALIB_API void (luaL_buffinit) (lua_State *L, luaL_Buffer *B); +LUALIB_API char *(luaL_prepbuffer) (luaL_Buffer *B); +LUALIB_API void (luaL_addlstring) (luaL_Buffer *B, const char *s, size_t l); +LUALIB_API void (luaL_addstring) (luaL_Buffer *B, const char *s); +LUALIB_API void (luaL_addvalue) (luaL_Buffer *B); +LUALIB_API void (luaL_pushresult) (luaL_Buffer *B); + + +/* }====================================================== */ + + +/* compatibility with ref system */ + +/* pre-defined references */ +#define LUA_NOREF (-2) +#define LUA_REFNIL (-1) + +#define lua_ref(L,lock) ((lock) ? luaL_ref(L, LUA_REGISTRYINDEX) : \ + (lua_pushstring(L, "unlocked references are obsolete"), lua_error(L), 0)) + +#define lua_unref(L,ref) luaL_unref(L, LUA_REGISTRYINDEX, (ref)) + +#define lua_getref(L,ref) lua_rawgeti(L, LUA_REGISTRYINDEX, (ref)) + + +#define luaL_reg luaL_Reg + +#endif + + diff --git a/mk/linux/mojosetup/lua/src/lbaselib.c b/mk/linux/mojosetup/lua/src/lbaselib.c new file mode 100644 index 00000000..2a4c079d --- /dev/null +++ b/mk/linux/mojosetup/lua/src/lbaselib.c @@ -0,0 +1,653 @@ +/* +** $Id: lbaselib.c,v 1.191.1.6 2008/02/14 16:46:22 roberto Exp $ +** Basic library +** See Copyright Notice in lua.h +*/ + + + +#include +#include +#include +#include + +#define lbaselib_c +#define LUA_LIB + +#include "lua.h" + +#include "lauxlib.h" +#include "lualib.h" + + + + +/* +** If your system does not support `stdout', you can just remove this function. +** If you need, you can define your own `print' function, following this +** model but changing `fputs' to put the strings at a proper place +** (a console window or a log file, for instance). +*/ +static int luaB_print (lua_State *L) { + int n = lua_gettop(L); /* number of arguments */ + int i; + lua_getglobal(L, "tostring"); + for (i=1; i<=n; i++) { + const char *s; + lua_pushvalue(L, -1); /* function to be called */ + lua_pushvalue(L, i); /* value to print */ + lua_call(L, 1, 1); + s = lua_tostring(L, -1); /* get result */ + if (s == NULL) + return luaL_error(L, LUA_QL("tostring") " must return a string to " + LUA_QL("print")); + if (i>1) fputs("\t", stdout); + fputs(s, stdout); + lua_pop(L, 1); /* pop result */ + } + fputs("\n", stdout); + return 0; +} + + +static int luaB_tonumber (lua_State *L) { + int base = luaL_optint(L, 2, 10); + if (base == 10) { /* standard conversion */ + luaL_checkany(L, 1); + if (lua_isnumber(L, 1)) { + lua_pushnumber(L, lua_tonumber(L, 1)); + return 1; + } + } + else { + const char *s1 = luaL_checkstring(L, 1); + char *s2; + unsigned long n; + luaL_argcheck(L, 2 <= base && base <= 36, 2, "base out of range"); + n = strtoul(s1, &s2, base); + if (s1 != s2) { /* at least one valid digit? */ + while (isspace((unsigned char)(*s2))) s2++; /* skip trailing spaces */ + if (*s2 == '\0') { /* no invalid trailing characters? */ + lua_pushnumber(L, (lua_Number)n); + return 1; + } + } + } + lua_pushnil(L); /* else not a number */ + return 1; +} + + +static int luaB_error (lua_State *L) { + int level = luaL_optint(L, 2, 1); + lua_settop(L, 1); + if (lua_isstring(L, 1) && level > 0) { /* add extra information? */ + luaL_where(L, level); + lua_pushvalue(L, 1); + lua_concat(L, 2); + } + return lua_error(L); +} + + +static int luaB_getmetatable (lua_State *L) { + luaL_checkany(L, 1); + if (!lua_getmetatable(L, 1)) { + lua_pushnil(L); + return 1; /* no metatable */ + } + luaL_getmetafield(L, 1, "__metatable"); + return 1; /* returns either __metatable field (if present) or metatable */ +} + + +static int luaB_setmetatable (lua_State *L) { + int t = lua_type(L, 2); + luaL_checktype(L, 1, LUA_TTABLE); + luaL_argcheck(L, t == LUA_TNIL || t == LUA_TTABLE, 2, + "nil or table expected"); + if (luaL_getmetafield(L, 1, "__metatable")) + luaL_error(L, "cannot change a protected metatable"); + lua_settop(L, 2); + lua_setmetatable(L, 1); + return 1; +} + + +static void getfunc (lua_State *L, int opt) { + if (lua_isfunction(L, 1)) lua_pushvalue(L, 1); + else { + lua_Debug ar; + int level = opt ? luaL_optint(L, 1, 1) : luaL_checkint(L, 1); + luaL_argcheck(L, level >= 0, 1, "level must be non-negative"); + if (lua_getstack(L, level, &ar) == 0) + luaL_argerror(L, 1, "invalid level"); + lua_getinfo(L, "f", &ar); + if (lua_isnil(L, -1)) + luaL_error(L, "no function environment for tail call at level %d", + level); + } +} + + +static int luaB_getfenv (lua_State *L) { + getfunc(L, 1); + if (lua_iscfunction(L, -1)) /* is a C function? */ + lua_pushvalue(L, LUA_GLOBALSINDEX); /* return the thread's global env. */ + else + lua_getfenv(L, -1); + return 1; +} + + +static int luaB_setfenv (lua_State *L) { + luaL_checktype(L, 2, LUA_TTABLE); + getfunc(L, 0); + lua_pushvalue(L, 2); + if (lua_isnumber(L, 1) && lua_tonumber(L, 1) == 0) { + /* change environment of current thread */ + lua_pushthread(L); + lua_insert(L, -2); + lua_setfenv(L, -2); + return 0; + } + else if (lua_iscfunction(L, -2) || lua_setfenv(L, -2) == 0) + luaL_error(L, + LUA_QL("setfenv") " cannot change environment of given object"); + return 1; +} + + +static int luaB_rawequal (lua_State *L) { + luaL_checkany(L, 1); + luaL_checkany(L, 2); + lua_pushboolean(L, lua_rawequal(L, 1, 2)); + return 1; +} + + +static int luaB_rawget (lua_State *L) { + luaL_checktype(L, 1, LUA_TTABLE); + luaL_checkany(L, 2); + lua_settop(L, 2); + lua_rawget(L, 1); + return 1; +} + +static int luaB_rawset (lua_State *L) { + luaL_checktype(L, 1, LUA_TTABLE); + luaL_checkany(L, 2); + luaL_checkany(L, 3); + lua_settop(L, 3); + lua_rawset(L, 1); + return 1; +} + + +static int luaB_gcinfo (lua_State *L) { + lua_pushinteger(L, lua_getgccount(L)); + return 1; +} + + +static int luaB_collectgarbage (lua_State *L) { + static const char *const opts[] = {"stop", "restart", "collect", + "count", "step", "setpause", "setstepmul", NULL}; + static const int optsnum[] = {LUA_GCSTOP, LUA_GCRESTART, LUA_GCCOLLECT, + LUA_GCCOUNT, LUA_GCSTEP, LUA_GCSETPAUSE, LUA_GCSETSTEPMUL}; + int o = luaL_checkoption(L, 1, "collect", opts); + int ex = luaL_optint(L, 2, 0); + int res = lua_gc(L, optsnum[o], ex); + switch (optsnum[o]) { + case LUA_GCCOUNT: { + int b = lua_gc(L, LUA_GCCOUNTB, 0); + lua_pushnumber(L, res + ((lua_Number)b/1024)); + return 1; + } + case LUA_GCSTEP: { + lua_pushboolean(L, res); + return 1; + } + default: { + lua_pushnumber(L, res); + return 1; + } + } +} + + +static int luaB_type (lua_State *L) { + luaL_checkany(L, 1); + lua_pushstring(L, luaL_typename(L, 1)); + return 1; +} + + +static int luaB_next (lua_State *L) { + luaL_checktype(L, 1, LUA_TTABLE); + lua_settop(L, 2); /* create a 2nd argument if there isn't one */ + if (lua_next(L, 1)) + return 2; + else { + lua_pushnil(L); + return 1; + } +} + + +static int luaB_pairs (lua_State *L) { + luaL_checktype(L, 1, LUA_TTABLE); + lua_pushvalue(L, lua_upvalueindex(1)); /* return generator, */ + lua_pushvalue(L, 1); /* state, */ + lua_pushnil(L); /* and initial value */ + return 3; +} + + +static int ipairsaux (lua_State *L) { + int i = luaL_checkint(L, 2); + luaL_checktype(L, 1, LUA_TTABLE); + i++; /* next value */ + lua_pushinteger(L, i); + lua_rawgeti(L, 1, i); + return (lua_isnil(L, -1)) ? 0 : 2; +} + + +static int luaB_ipairs (lua_State *L) { + luaL_checktype(L, 1, LUA_TTABLE); + lua_pushvalue(L, lua_upvalueindex(1)); /* return generator, */ + lua_pushvalue(L, 1); /* state, */ + lua_pushinteger(L, 0); /* and initial value */ + return 3; +} + + +static int load_aux (lua_State *L, int status) { + if (status == 0) /* OK? */ + return 1; + else { + lua_pushnil(L); + lua_insert(L, -2); /* put before error message */ + return 2; /* return nil plus error message */ + } +} + + +static int luaB_loadstring (lua_State *L) { + size_t l; + const char *s = luaL_checklstring(L, 1, &l); + const char *chunkname = luaL_optstring(L, 2, s); + return load_aux(L, luaL_loadbuffer(L, s, l, chunkname)); +} + + +static int luaB_loadfile (lua_State *L) { + const char *fname = luaL_optstring(L, 1, NULL); + return load_aux(L, luaL_loadfile(L, fname)); +} + + +/* +** Reader for generic `load' function: `lua_load' uses the +** stack for internal stuff, so the reader cannot change the +** stack top. Instead, it keeps its resulting string in a +** reserved slot inside the stack. +*/ +static const char *generic_reader (lua_State *L, void *ud, size_t *size) { + (void)ud; /* to avoid warnings */ + luaL_checkstack(L, 2, "too many nested functions"); + lua_pushvalue(L, 1); /* get function */ + lua_call(L, 0, 1); /* call it */ + if (lua_isnil(L, -1)) { + *size = 0; + return NULL; + } + else if (lua_isstring(L, -1)) { + lua_replace(L, 3); /* save string in a reserved stack slot */ + return lua_tolstring(L, 3, size); + } + else luaL_error(L, "reader function must return a string"); + return NULL; /* to avoid warnings */ +} + + +static int luaB_load (lua_State *L) { + int status; + const char *cname = luaL_optstring(L, 2, "=(load)"); + luaL_checktype(L, 1, LUA_TFUNCTION); + lua_settop(L, 3); /* function, eventual name, plus one reserved slot */ + status = lua_load(L, generic_reader, NULL, cname); + return load_aux(L, status); +} + + +static int luaB_dofile (lua_State *L) { + const char *fname = luaL_optstring(L, 1, NULL); + int n = lua_gettop(L); + if (luaL_loadfile(L, fname) != 0) lua_error(L); + lua_call(L, 0, LUA_MULTRET); + return lua_gettop(L) - n; +} + + +static int luaB_assert (lua_State *L) { + luaL_checkany(L, 1); + if (!lua_toboolean(L, 1)) + return luaL_error(L, "%s", luaL_optstring(L, 2, "assertion failed!")); + return lua_gettop(L); +} + + +static int luaB_unpack (lua_State *L) { + int i, e, n; + luaL_checktype(L, 1, LUA_TTABLE); + i = luaL_optint(L, 2, 1); + e = luaL_opt(L, luaL_checkint, 3, luaL_getn(L, 1)); + if (i > e) return 0; /* empty range */ + n = e - i + 1; /* number of elements */ + if (n <= 0 || !lua_checkstack(L, n)) /* n <= 0 means arith. overflow */ + return luaL_error(L, "too many results to unpack"); + lua_rawgeti(L, 1, i); /* push arg[i] (avoiding overflow problems) */ + while (i++ < e) /* push arg[i + 1...e] */ + lua_rawgeti(L, 1, i); + return n; +} + + +static int luaB_select (lua_State *L) { + int n = lua_gettop(L); + if (lua_type(L, 1) == LUA_TSTRING && *lua_tostring(L, 1) == '#') { + lua_pushinteger(L, n-1); + return 1; + } + else { + int i = luaL_checkint(L, 1); + if (i < 0) i = n + i; + else if (i > n) i = n; + luaL_argcheck(L, 1 <= i, 1, "index out of range"); + return n - i; + } +} + + +static int luaB_pcall (lua_State *L) { + int status; + luaL_checkany(L, 1); + status = lua_pcall(L, lua_gettop(L) - 1, LUA_MULTRET, 0); + lua_pushboolean(L, (status == 0)); + lua_insert(L, 1); + return lua_gettop(L); /* return status + all results */ +} + + +static int luaB_xpcall (lua_State *L) { + int status; + luaL_checkany(L, 2); + lua_settop(L, 2); + lua_insert(L, 1); /* put error function under function to be called */ + status = lua_pcall(L, 0, LUA_MULTRET, 1); + lua_pushboolean(L, (status == 0)); + lua_replace(L, 1); + return lua_gettop(L); /* return status + all results */ +} + + +static int luaB_tostring (lua_State *L) { + luaL_checkany(L, 1); + if (luaL_callmeta(L, 1, "__tostring")) /* is there a metafield? */ + return 1; /* use its value */ + switch (lua_type(L, 1)) { + case LUA_TNUMBER: + lua_pushstring(L, lua_tostring(L, 1)); + break; + case LUA_TSTRING: + lua_pushvalue(L, 1); + break; + case LUA_TBOOLEAN: + lua_pushstring(L, (lua_toboolean(L, 1) ? "true" : "false")); + break; + case LUA_TNIL: + lua_pushliteral(L, "nil"); + break; + default: + lua_pushfstring(L, "%s: %p", luaL_typename(L, 1), lua_topointer(L, 1)); + break; + } + return 1; +} + + +static int luaB_newproxy (lua_State *L) { + lua_settop(L, 1); + lua_newuserdata(L, 0); /* create proxy */ + if (lua_toboolean(L, 1) == 0) + return 1; /* no metatable */ + else if (lua_isboolean(L, 1)) { + lua_newtable(L); /* create a new metatable `m' ... */ + lua_pushvalue(L, -1); /* ... and mark `m' as a valid metatable */ + lua_pushboolean(L, 1); + lua_rawset(L, lua_upvalueindex(1)); /* weaktable[m] = true */ + } + else { + int validproxy = 0; /* to check if weaktable[metatable(u)] == true */ + if (lua_getmetatable(L, 1)) { + lua_rawget(L, lua_upvalueindex(1)); + validproxy = lua_toboolean(L, -1); + lua_pop(L, 1); /* remove value */ + } + luaL_argcheck(L, validproxy, 1, "boolean or proxy expected"); + lua_getmetatable(L, 1); /* metatable is valid; get it */ + } + lua_setmetatable(L, 2); + return 1; +} + + +static const luaL_Reg base_funcs[] = { + {"assert", luaB_assert}, + {"collectgarbage", luaB_collectgarbage}, + {"dofile", luaB_dofile}, + {"error", luaB_error}, + {"gcinfo", luaB_gcinfo}, + {"getfenv", luaB_getfenv}, + {"getmetatable", luaB_getmetatable}, + {"loadfile", luaB_loadfile}, + {"load", luaB_load}, + {"loadstring", luaB_loadstring}, + {"next", luaB_next}, + {"pcall", luaB_pcall}, + {"print", luaB_print}, + {"rawequal", luaB_rawequal}, + {"rawget", luaB_rawget}, + {"rawset", luaB_rawset}, + {"select", luaB_select}, + {"setfenv", luaB_setfenv}, + {"setmetatable", luaB_setmetatable}, + {"tonumber", luaB_tonumber}, + {"tostring", luaB_tostring}, + {"type", luaB_type}, + {"unpack", luaB_unpack}, + {"xpcall", luaB_xpcall}, + {NULL, NULL} +}; + + +/* +** {====================================================== +** Coroutine library +** ======================================================= +*/ + +#define CO_RUN 0 /* running */ +#define CO_SUS 1 /* suspended */ +#define CO_NOR 2 /* 'normal' (it resumed another coroutine) */ +#define CO_DEAD 3 + +static const char *const statnames[] = + {"running", "suspended", "normal", "dead"}; + +static int costatus (lua_State *L, lua_State *co) { + if (L == co) return CO_RUN; + switch (lua_status(co)) { + case LUA_YIELD: + return CO_SUS; + case 0: { + lua_Debug ar; + if (lua_getstack(co, 0, &ar) > 0) /* does it have frames? */ + return CO_NOR; /* it is running */ + else if (lua_gettop(co) == 0) + return CO_DEAD; + else + return CO_SUS; /* initial state */ + } + default: /* some error occured */ + return CO_DEAD; + } +} + + +static int luaB_costatus (lua_State *L) { + lua_State *co = lua_tothread(L, 1); + luaL_argcheck(L, co, 1, "coroutine expected"); + lua_pushstring(L, statnames[costatus(L, co)]); + return 1; +} + + +static int auxresume (lua_State *L, lua_State *co, int narg) { + int status = costatus(L, co); + if (!lua_checkstack(co, narg)) + luaL_error(L, "too many arguments to resume"); + if (status != CO_SUS) { + lua_pushfstring(L, "cannot resume %s coroutine", statnames[status]); + return -1; /* error flag */ + } + lua_xmove(L, co, narg); + lua_setlevel(L, co); + status = lua_resume(co, narg); + if (status == 0 || status == LUA_YIELD) { + int nres = lua_gettop(co); + if (!lua_checkstack(L, nres + 1)) + luaL_error(L, "too many results to resume"); + lua_xmove(co, L, nres); /* move yielded values */ + return nres; + } + else { + lua_xmove(co, L, 1); /* move error message */ + return -1; /* error flag */ + } +} + + +static int luaB_coresume (lua_State *L) { + lua_State *co = lua_tothread(L, 1); + int r; + luaL_argcheck(L, co, 1, "coroutine expected"); + r = auxresume(L, co, lua_gettop(L) - 1); + if (r < 0) { + lua_pushboolean(L, 0); + lua_insert(L, -2); + return 2; /* return false + error message */ + } + else { + lua_pushboolean(L, 1); + lua_insert(L, -(r + 1)); + return r + 1; /* return true + `resume' returns */ + } +} + + +static int luaB_auxwrap (lua_State *L) { + lua_State *co = lua_tothread(L, lua_upvalueindex(1)); + int r = auxresume(L, co, lua_gettop(L)); + if (r < 0) { + if (lua_isstring(L, -1)) { /* error object is a string? */ + luaL_where(L, 1); /* add extra info */ + lua_insert(L, -2); + lua_concat(L, 2); + } + lua_error(L); /* propagate error */ + } + return r; +} + + +static int luaB_cocreate (lua_State *L) { + lua_State *NL = lua_newthread(L); + luaL_argcheck(L, lua_isfunction(L, 1) && !lua_iscfunction(L, 1), 1, + "Lua function expected"); + lua_pushvalue(L, 1); /* move function to top */ + lua_xmove(L, NL, 1); /* move function from L to NL */ + return 1; +} + + +static int luaB_cowrap (lua_State *L) { + luaB_cocreate(L); + lua_pushcclosure(L, luaB_auxwrap, 1); + return 1; +} + + +static int luaB_yield (lua_State *L) { + return lua_yield(L, lua_gettop(L)); +} + + +static int luaB_corunning (lua_State *L) { + if (lua_pushthread(L)) + lua_pushnil(L); /* main thread is not a coroutine */ + return 1; +} + + +static const luaL_Reg co_funcs[] = { + {"create", luaB_cocreate}, + {"resume", luaB_coresume}, + {"running", luaB_corunning}, + {"status", luaB_costatus}, + {"wrap", luaB_cowrap}, + {"yield", luaB_yield}, + {NULL, NULL} +}; + +/* }====================================================== */ + + +static void auxopen (lua_State *L, const char *name, + lua_CFunction f, lua_CFunction u) { + lua_pushcfunction(L, u); + lua_pushcclosure(L, f, 1); + lua_setfield(L, -2, name); +} + + +static void base_open (lua_State *L) { + /* set global _G */ + lua_pushvalue(L, LUA_GLOBALSINDEX); + lua_setglobal(L, "_G"); + /* open lib into global table */ + luaL_register(L, "_G", base_funcs); + lua_pushliteral(L, LUA_VERSION); + lua_setglobal(L, "_VERSION"); /* set global _VERSION */ + /* `ipairs' and `pairs' need auxliliary functions as upvalues */ + auxopen(L, "ipairs", luaB_ipairs, ipairsaux); + auxopen(L, "pairs", luaB_pairs, luaB_next); + /* `newproxy' needs a weaktable as upvalue */ + lua_createtable(L, 0, 1); /* new table `w' */ + lua_pushvalue(L, -1); /* `w' will be its own metatable */ + lua_setmetatable(L, -2); + lua_pushliteral(L, "kv"); + lua_setfield(L, -2, "__mode"); /* metatable(w).__mode = "kv" */ + lua_pushcclosure(L, luaB_newproxy, 1); + lua_setglobal(L, "newproxy"); /* set global `newproxy' */ +} + + +LUALIB_API int luaopen_base (lua_State *L) { + base_open(L); + luaL_register(L, LUA_COLIBNAME, co_funcs); + return 2; +} + diff --git a/mk/linux/mojosetup/lua/src/lcode.c b/mk/linux/mojosetup/lua/src/lcode.c new file mode 100644 index 00000000..cff626b7 --- /dev/null +++ b/mk/linux/mojosetup/lua/src/lcode.c @@ -0,0 +1,839 @@ +/* +** $Id: lcode.c,v 2.25.1.3 2007/12/28 15:32:23 roberto Exp $ +** Code generator for Lua +** See Copyright Notice in lua.h +*/ + + +#include + +#define lcode_c +#define LUA_CORE + +#include "lua.h" + +#include "lcode.h" +#include "ldebug.h" +#include "ldo.h" +#include "lgc.h" +#include "llex.h" +#include "lmem.h" +#include "lobject.h" +#include "lopcodes.h" +#include "lparser.h" +#include "ltable.h" + + +#define hasjumps(e) ((e)->t != (e)->f) + + +static int isnumeral(expdesc *e) { + return (e->k == VKNUM && e->t == NO_JUMP && e->f == NO_JUMP); +} + + +void luaK_nil (FuncState *fs, int from, int n) { + Instruction *previous; + if (fs->pc > fs->lasttarget) { /* no jumps to current position? */ + if (fs->pc == 0) { /* function start? */ + if (from >= fs->nactvar) + return; /* positions are already clean */ + } + else { + previous = &fs->f->code[fs->pc-1]; + if (GET_OPCODE(*previous) == OP_LOADNIL) { + int pfrom = GETARG_A(*previous); + int pto = GETARG_B(*previous); + if (pfrom <= from && from <= pto+1) { /* can connect both? */ + if (from+n-1 > pto) + SETARG_B(*previous, from+n-1); + return; + } + } + } + } + luaK_codeABC(fs, OP_LOADNIL, from, from+n-1, 0); /* else no optimization */ +} + + +int luaK_jump (FuncState *fs) { + int jpc = fs->jpc; /* save list of jumps to here */ + int j; + fs->jpc = NO_JUMP; + j = luaK_codeAsBx(fs, OP_JMP, 0, NO_JUMP); + luaK_concat(fs, &j, jpc); /* keep them on hold */ + return j; +} + + +void luaK_ret (FuncState *fs, int first, int nret) { + luaK_codeABC(fs, OP_RETURN, first, nret+1, 0); +} + + +static int condjump (FuncState *fs, OpCode op, int A, int B, int C) { + luaK_codeABC(fs, op, A, B, C); + return luaK_jump(fs); +} + + +static void fixjump (FuncState *fs, int pc, int dest) { + Instruction *jmp = &fs->f->code[pc]; + int offset = dest-(pc+1); + lua_assert(dest != NO_JUMP); + if (abs(offset) > MAXARG_sBx) + luaX_syntaxerror(fs->ls, "control structure too long"); + SETARG_sBx(*jmp, offset); +} + + +/* +** returns current `pc' and marks it as a jump target (to avoid wrong +** optimizations with consecutive instructions not in the same basic block). +*/ +int luaK_getlabel (FuncState *fs) { + fs->lasttarget = fs->pc; + return fs->pc; +} + + +static int getjump (FuncState *fs, int pc) { + int offset = GETARG_sBx(fs->f->code[pc]); + if (offset == NO_JUMP) /* point to itself represents end of list */ + return NO_JUMP; /* end of list */ + else + return (pc+1)+offset; /* turn offset into absolute position */ +} + + +static Instruction *getjumpcontrol (FuncState *fs, int pc) { + Instruction *pi = &fs->f->code[pc]; + if (pc >= 1 && testTMode(GET_OPCODE(*(pi-1)))) + return pi-1; + else + return pi; +} + + +/* +** check whether list has any jump that do not produce a value +** (or produce an inverted value) +*/ +static int need_value (FuncState *fs, int list) { + for (; list != NO_JUMP; list = getjump(fs, list)) { + Instruction i = *getjumpcontrol(fs, list); + if (GET_OPCODE(i) != OP_TESTSET) return 1; + } + return 0; /* not found */ +} + + +static int patchtestreg (FuncState *fs, int node, int reg) { + Instruction *i = getjumpcontrol(fs, node); + if (GET_OPCODE(*i) != OP_TESTSET) + return 0; /* cannot patch other instructions */ + if (reg != NO_REG && reg != GETARG_B(*i)) + SETARG_A(*i, reg); + else /* no register to put value or register already has the value */ + *i = CREATE_ABC(OP_TEST, GETARG_B(*i), 0, GETARG_C(*i)); + + return 1; +} + + +static void removevalues (FuncState *fs, int list) { + for (; list != NO_JUMP; list = getjump(fs, list)) + patchtestreg(fs, list, NO_REG); +} + + +static void patchlistaux (FuncState *fs, int list, int vtarget, int reg, + int dtarget) { + while (list != NO_JUMP) { + int next = getjump(fs, list); + if (patchtestreg(fs, list, reg)) + fixjump(fs, list, vtarget); + else + fixjump(fs, list, dtarget); /* jump to default target */ + list = next; + } +} + + +static void dischargejpc (FuncState *fs) { + patchlistaux(fs, fs->jpc, fs->pc, NO_REG, fs->pc); + fs->jpc = NO_JUMP; +} + + +void luaK_patchlist (FuncState *fs, int list, int target) { + if (target == fs->pc) + luaK_patchtohere(fs, list); + else { + lua_assert(target < fs->pc); + patchlistaux(fs, list, target, NO_REG, target); + } +} + + +void luaK_patchtohere (FuncState *fs, int list) { + luaK_getlabel(fs); + luaK_concat(fs, &fs->jpc, list); +} + + +void luaK_concat (FuncState *fs, int *l1, int l2) { + if (l2 == NO_JUMP) return; + else if (*l1 == NO_JUMP) + *l1 = l2; + else { + int list = *l1; + int next; + while ((next = getjump(fs, list)) != NO_JUMP) /* find last element */ + list = next; + fixjump(fs, list, l2); + } +} + + +void luaK_checkstack (FuncState *fs, int n) { + int newstack = fs->freereg + n; + if (newstack > fs->f->maxstacksize) { + if (newstack >= MAXSTACK) + luaX_syntaxerror(fs->ls, "function or expression too complex"); + fs->f->maxstacksize = cast_byte(newstack); + } +} + + +void luaK_reserveregs (FuncState *fs, int n) { + luaK_checkstack(fs, n); + fs->freereg += n; +} + + +static void freereg (FuncState *fs, int reg) { + if (!ISK(reg) && reg >= fs->nactvar) { + fs->freereg--; + lua_assert(reg == fs->freereg); + } +} + + +static void freeexp (FuncState *fs, expdesc *e) { + if (e->k == VNONRELOC) + freereg(fs, e->u.s.info); +} + + +static int addk (FuncState *fs, TValue *k, TValue *v) { + lua_State *L = fs->L; + TValue *idx = luaH_set(L, fs->h, k); + Proto *f = fs->f; + int oldsize = f->sizek; + if (ttisnumber(idx)) { + lua_assert(luaO_rawequalObj(&fs->f->k[cast_int(nvalue(idx))], v)); + return cast_int(nvalue(idx)); + } + else { /* constant not found; create a new entry */ + setnvalue(idx, cast_num(fs->nk)); + luaM_growvector(L, f->k, fs->nk, f->sizek, TValue, + MAXARG_Bx, "constant table overflow"); + while (oldsize < f->sizek) setnilvalue(&f->k[oldsize++]); + setobj(L, &f->k[fs->nk], v); + luaC_barrier(L, f, v); + return fs->nk++; + } +} + + +int luaK_stringK (FuncState *fs, TString *s) { + TValue o; + setsvalue(fs->L, &o, s); + return addk(fs, &o, &o); +} + + +int luaK_numberK (FuncState *fs, lua_Number r) { + TValue o; + setnvalue(&o, r); + return addk(fs, &o, &o); +} + + +static int boolK (FuncState *fs, int b) { + TValue o; + setbvalue(&o, b); + return addk(fs, &o, &o); +} + + +static int nilK (FuncState *fs) { + TValue k, v; + setnilvalue(&v); + /* cannot use nil as key; instead use table itself to represent nil */ + sethvalue(fs->L, &k, fs->h); + return addk(fs, &k, &v); +} + + +void luaK_setreturns (FuncState *fs, expdesc *e, int nresults) { + if (e->k == VCALL) { /* expression is an open function call? */ + SETARG_C(getcode(fs, e), nresults+1); + } + else if (e->k == VVARARG) { + SETARG_B(getcode(fs, e), nresults+1); + SETARG_A(getcode(fs, e), fs->freereg); + luaK_reserveregs(fs, 1); + } +} + + +void luaK_setoneret (FuncState *fs, expdesc *e) { + if (e->k == VCALL) { /* expression is an open function call? */ + e->k = VNONRELOC; + e->u.s.info = GETARG_A(getcode(fs, e)); + } + else if (e->k == VVARARG) { + SETARG_B(getcode(fs, e), 2); + e->k = VRELOCABLE; /* can relocate its simple result */ + } +} + + +void luaK_dischargevars (FuncState *fs, expdesc *e) { + switch (e->k) { + case VLOCAL: { + e->k = VNONRELOC; + break; + } + case VUPVAL: { + e->u.s.info = luaK_codeABC(fs, OP_GETUPVAL, 0, e->u.s.info, 0); + e->k = VRELOCABLE; + break; + } + case VGLOBAL: { + e->u.s.info = luaK_codeABx(fs, OP_GETGLOBAL, 0, e->u.s.info); + e->k = VRELOCABLE; + break; + } + case VINDEXED: { + freereg(fs, e->u.s.aux); + freereg(fs, e->u.s.info); + e->u.s.info = luaK_codeABC(fs, OP_GETTABLE, 0, e->u.s.info, e->u.s.aux); + e->k = VRELOCABLE; + break; + } + case VVARARG: + case VCALL: { + luaK_setoneret(fs, e); + break; + } + default: break; /* there is one value available (somewhere) */ + } +} + + +static int code_label (FuncState *fs, int A, int b, int jump) { + luaK_getlabel(fs); /* those instructions may be jump targets */ + return luaK_codeABC(fs, OP_LOADBOOL, A, b, jump); +} + + +static void discharge2reg (FuncState *fs, expdesc *e, int reg) { + luaK_dischargevars(fs, e); + switch (e->k) { + case VNIL: { + luaK_nil(fs, reg, 1); + break; + } + case VFALSE: case VTRUE: { + luaK_codeABC(fs, OP_LOADBOOL, reg, e->k == VTRUE, 0); + break; + } + case VK: { + luaK_codeABx(fs, OP_LOADK, reg, e->u.s.info); + break; + } + case VKNUM: { + luaK_codeABx(fs, OP_LOADK, reg, luaK_numberK(fs, e->u.nval)); + break; + } + case VRELOCABLE: { + Instruction *pc = &getcode(fs, e); + SETARG_A(*pc, reg); + break; + } + case VNONRELOC: { + if (reg != e->u.s.info) + luaK_codeABC(fs, OP_MOVE, reg, e->u.s.info, 0); + break; + } + default: { + lua_assert(e->k == VVOID || e->k == VJMP); + return; /* nothing to do... */ + } + } + e->u.s.info = reg; + e->k = VNONRELOC; +} + + +static void discharge2anyreg (FuncState *fs, expdesc *e) { + if (e->k != VNONRELOC) { + luaK_reserveregs(fs, 1); + discharge2reg(fs, e, fs->freereg-1); + } +} + + +static void exp2reg (FuncState *fs, expdesc *e, int reg) { + discharge2reg(fs, e, reg); + if (e->k == VJMP) + luaK_concat(fs, &e->t, e->u.s.info); /* put this jump in `t' list */ + if (hasjumps(e)) { + int final; /* position after whole expression */ + int p_f = NO_JUMP; /* position of an eventual LOAD false */ + int p_t = NO_JUMP; /* position of an eventual LOAD true */ + if (need_value(fs, e->t) || need_value(fs, e->f)) { + int fj = (e->k == VJMP) ? NO_JUMP : luaK_jump(fs); + p_f = code_label(fs, reg, 0, 1); + p_t = code_label(fs, reg, 1, 0); + luaK_patchtohere(fs, fj); + } + final = luaK_getlabel(fs); + patchlistaux(fs, e->f, final, reg, p_f); + patchlistaux(fs, e->t, final, reg, p_t); + } + e->f = e->t = NO_JUMP; + e->u.s.info = reg; + e->k = VNONRELOC; +} + + +void luaK_exp2nextreg (FuncState *fs, expdesc *e) { + luaK_dischargevars(fs, e); + freeexp(fs, e); + luaK_reserveregs(fs, 1); + exp2reg(fs, e, fs->freereg - 1); +} + + +int luaK_exp2anyreg (FuncState *fs, expdesc *e) { + luaK_dischargevars(fs, e); + if (e->k == VNONRELOC) { + if (!hasjumps(e)) return e->u.s.info; /* exp is already in a register */ + if (e->u.s.info >= fs->nactvar) { /* reg. is not a local? */ + exp2reg(fs, e, e->u.s.info); /* put value on it */ + return e->u.s.info; + } + } + luaK_exp2nextreg(fs, e); /* default */ + return e->u.s.info; +} + + +void luaK_exp2val (FuncState *fs, expdesc *e) { + if (hasjumps(e)) + luaK_exp2anyreg(fs, e); + else + luaK_dischargevars(fs, e); +} + + +int luaK_exp2RK (FuncState *fs, expdesc *e) { + luaK_exp2val(fs, e); + switch (e->k) { + case VKNUM: + case VTRUE: + case VFALSE: + case VNIL: { + if (fs->nk <= MAXINDEXRK) { /* constant fit in RK operand? */ + e->u.s.info = (e->k == VNIL) ? nilK(fs) : + (e->k == VKNUM) ? luaK_numberK(fs, e->u.nval) : + boolK(fs, (e->k == VTRUE)); + e->k = VK; + return RKASK(e->u.s.info); + } + else break; + } + case VK: { + if (e->u.s.info <= MAXINDEXRK) /* constant fit in argC? */ + return RKASK(e->u.s.info); + else break; + } + default: break; + } + /* not a constant in the right range: put it in a register */ + return luaK_exp2anyreg(fs, e); +} + + +void luaK_storevar (FuncState *fs, expdesc *var, expdesc *ex) { + switch (var->k) { + case VLOCAL: { + freeexp(fs, ex); + exp2reg(fs, ex, var->u.s.info); + return; + } + case VUPVAL: { + int e = luaK_exp2anyreg(fs, ex); + luaK_codeABC(fs, OP_SETUPVAL, e, var->u.s.info, 0); + break; + } + case VGLOBAL: { + int e = luaK_exp2anyreg(fs, ex); + luaK_codeABx(fs, OP_SETGLOBAL, e, var->u.s.info); + break; + } + case VINDEXED: { + int e = luaK_exp2RK(fs, ex); + luaK_codeABC(fs, OP_SETTABLE, var->u.s.info, var->u.s.aux, e); + break; + } + default: { + lua_assert(0); /* invalid var kind to store */ + break; + } + } + freeexp(fs, ex); +} + + +void luaK_self (FuncState *fs, expdesc *e, expdesc *key) { + int func; + luaK_exp2anyreg(fs, e); + freeexp(fs, e); + func = fs->freereg; + luaK_reserveregs(fs, 2); + luaK_codeABC(fs, OP_SELF, func, e->u.s.info, luaK_exp2RK(fs, key)); + freeexp(fs, key); + e->u.s.info = func; + e->k = VNONRELOC; +} + + +static void invertjump (FuncState *fs, expdesc *e) { + Instruction *pc = getjumpcontrol(fs, e->u.s.info); + lua_assert(testTMode(GET_OPCODE(*pc)) && GET_OPCODE(*pc) != OP_TESTSET && + GET_OPCODE(*pc) != OP_TEST); + SETARG_A(*pc, !(GETARG_A(*pc))); +} + + +static int jumponcond (FuncState *fs, expdesc *e, int cond) { + if (e->k == VRELOCABLE) { + Instruction ie = getcode(fs, e); + if (GET_OPCODE(ie) == OP_NOT) { + fs->pc--; /* remove previous OP_NOT */ + return condjump(fs, OP_TEST, GETARG_B(ie), 0, !cond); + } + /* else go through */ + } + discharge2anyreg(fs, e); + freeexp(fs, e); + return condjump(fs, OP_TESTSET, NO_REG, e->u.s.info, cond); +} + + +void luaK_goiftrue (FuncState *fs, expdesc *e) { + int pc; /* pc of last jump */ + luaK_dischargevars(fs, e); + switch (e->k) { + case VK: case VKNUM: case VTRUE: { + pc = NO_JUMP; /* always true; do nothing */ + break; + } + case VFALSE: { + pc = luaK_jump(fs); /* always jump */ + break; + } + case VJMP: { + invertjump(fs, e); + pc = e->u.s.info; + break; + } + default: { + pc = jumponcond(fs, e, 0); + break; + } + } + luaK_concat(fs, &e->f, pc); /* insert last jump in `f' list */ + luaK_patchtohere(fs, e->t); + e->t = NO_JUMP; +} + + +static void luaK_goiffalse (FuncState *fs, expdesc *e) { + int pc; /* pc of last jump */ + luaK_dischargevars(fs, e); + switch (e->k) { + case VNIL: case VFALSE: { + pc = NO_JUMP; /* always false; do nothing */ + break; + } + case VTRUE: { + pc = luaK_jump(fs); /* always jump */ + break; + } + case VJMP: { + pc = e->u.s.info; + break; + } + default: { + pc = jumponcond(fs, e, 1); + break; + } + } + luaK_concat(fs, &e->t, pc); /* insert last jump in `t' list */ + luaK_patchtohere(fs, e->f); + e->f = NO_JUMP; +} + + +static void codenot (FuncState *fs, expdesc *e) { + luaK_dischargevars(fs, e); + switch (e->k) { + case VNIL: case VFALSE: { + e->k = VTRUE; + break; + } + case VK: case VKNUM: case VTRUE: { + e->k = VFALSE; + break; + } + case VJMP: { + invertjump(fs, e); + break; + } + case VRELOCABLE: + case VNONRELOC: { + discharge2anyreg(fs, e); + freeexp(fs, e); + e->u.s.info = luaK_codeABC(fs, OP_NOT, 0, e->u.s.info, 0); + e->k = VRELOCABLE; + break; + } + default: { + lua_assert(0); /* cannot happen */ + break; + } + } + /* interchange true and false lists */ + { int temp = e->f; e->f = e->t; e->t = temp; } + removevalues(fs, e->f); + removevalues(fs, e->t); +} + + +void luaK_indexed (FuncState *fs, expdesc *t, expdesc *k) { + t->u.s.aux = luaK_exp2RK(fs, k); + t->k = VINDEXED; +} + + +static int constfolding (OpCode op, expdesc *e1, expdesc *e2) { + lua_Number v1, v2, r; + if (!isnumeral(e1) || !isnumeral(e2)) return 0; + v1 = e1->u.nval; + v2 = e2->u.nval; + switch (op) { + case OP_ADD: r = luai_numadd(v1, v2); break; + case OP_SUB: r = luai_numsub(v1, v2); break; + case OP_MUL: r = luai_nummul(v1, v2); break; + case OP_DIV: + if (v2 == 0) return 0; /* do not attempt to divide by 0 */ + r = luai_numdiv(v1, v2); break; + case OP_MOD: + if (v2 == 0) return 0; /* do not attempt to divide by 0 */ + r = luai_nummod(v1, v2); break; + case OP_POW: r = luai_numpow(v1, v2); break; + case OP_UNM: r = luai_numunm(v1); break; + case OP_LEN: return 0; /* no constant folding for 'len' */ + default: lua_assert(0); r = 0; break; + } + if (luai_numisnan(r)) return 0; /* do not attempt to produce NaN */ + e1->u.nval = r; + return 1; +} + + +static void codearith (FuncState *fs, OpCode op, expdesc *e1, expdesc *e2) { + if (constfolding(op, e1, e2)) + return; + else { + int o2 = (op != OP_UNM && op != OP_LEN) ? luaK_exp2RK(fs, e2) : 0; + int o1 = luaK_exp2RK(fs, e1); + if (o1 > o2) { + freeexp(fs, e1); + freeexp(fs, e2); + } + else { + freeexp(fs, e2); + freeexp(fs, e1); + } + e1->u.s.info = luaK_codeABC(fs, op, 0, o1, o2); + e1->k = VRELOCABLE; + } +} + + +static void codecomp (FuncState *fs, OpCode op, int cond, expdesc *e1, + expdesc *e2) { + int o1 = luaK_exp2RK(fs, e1); + int o2 = luaK_exp2RK(fs, e2); + freeexp(fs, e2); + freeexp(fs, e1); + if (cond == 0 && op != OP_EQ) { + int temp; /* exchange args to replace by `<' or `<=' */ + temp = o1; o1 = o2; o2 = temp; /* o1 <==> o2 */ + cond = 1; + } + e1->u.s.info = condjump(fs, op, cond, o1, o2); + e1->k = VJMP; +} + + +void luaK_prefix (FuncState *fs, UnOpr op, expdesc *e) { + expdesc e2; + e2.t = e2.f = NO_JUMP; e2.k = VKNUM; e2.u.nval = 0; + switch (op) { + case OPR_MINUS: { + if (!isnumeral(e)) + luaK_exp2anyreg(fs, e); /* cannot operate on non-numeric constants */ + codearith(fs, OP_UNM, e, &e2); + break; + } + case OPR_NOT: codenot(fs, e); break; + case OPR_LEN: { + luaK_exp2anyreg(fs, e); /* cannot operate on constants */ + codearith(fs, OP_LEN, e, &e2); + break; + } + default: lua_assert(0); + } +} + + +void luaK_infix (FuncState *fs, BinOpr op, expdesc *v) { + switch (op) { + case OPR_AND: { + luaK_goiftrue(fs, v); + break; + } + case OPR_OR: { + luaK_goiffalse(fs, v); + break; + } + case OPR_CONCAT: { + luaK_exp2nextreg(fs, v); /* operand must be on the `stack' */ + break; + } + case OPR_ADD: case OPR_SUB: case OPR_MUL: case OPR_DIV: + case OPR_MOD: case OPR_POW: { + if (!isnumeral(v)) luaK_exp2RK(fs, v); + break; + } + default: { + luaK_exp2RK(fs, v); + break; + } + } +} + + +void luaK_posfix (FuncState *fs, BinOpr op, expdesc *e1, expdesc *e2) { + switch (op) { + case OPR_AND: { + lua_assert(e1->t == NO_JUMP); /* list must be closed */ + luaK_dischargevars(fs, e2); + luaK_concat(fs, &e2->f, e1->f); + *e1 = *e2; + break; + } + case OPR_OR: { + lua_assert(e1->f == NO_JUMP); /* list must be closed */ + luaK_dischargevars(fs, e2); + luaK_concat(fs, &e2->t, e1->t); + *e1 = *e2; + break; + } + case OPR_CONCAT: { + luaK_exp2val(fs, e2); + if (e2->k == VRELOCABLE && GET_OPCODE(getcode(fs, e2)) == OP_CONCAT) { + lua_assert(e1->u.s.info == GETARG_B(getcode(fs, e2))-1); + freeexp(fs, e1); + SETARG_B(getcode(fs, e2), e1->u.s.info); + e1->k = VRELOCABLE; e1->u.s.info = e2->u.s.info; + } + else { + luaK_exp2nextreg(fs, e2); /* operand must be on the 'stack' */ + codearith(fs, OP_CONCAT, e1, e2); + } + break; + } + case OPR_ADD: codearith(fs, OP_ADD, e1, e2); break; + case OPR_SUB: codearith(fs, OP_SUB, e1, e2); break; + case OPR_MUL: codearith(fs, OP_MUL, e1, e2); break; + case OPR_DIV: codearith(fs, OP_DIV, e1, e2); break; + case OPR_MOD: codearith(fs, OP_MOD, e1, e2); break; + case OPR_POW: codearith(fs, OP_POW, e1, e2); break; + case OPR_EQ: codecomp(fs, OP_EQ, 1, e1, e2); break; + case OPR_NE: codecomp(fs, OP_EQ, 0, e1, e2); break; + case OPR_LT: codecomp(fs, OP_LT, 1, e1, e2); break; + case OPR_LE: codecomp(fs, OP_LE, 1, e1, e2); break; + case OPR_GT: codecomp(fs, OP_LT, 0, e1, e2); break; + case OPR_GE: codecomp(fs, OP_LE, 0, e1, e2); break; + default: lua_assert(0); + } +} + + +void luaK_fixline (FuncState *fs, int line) { + fs->f->lineinfo[fs->pc - 1] = line; +} + + +static int luaK_code (FuncState *fs, Instruction i, int line) { + Proto *f = fs->f; + dischargejpc(fs); /* `pc' will change */ + /* put new instruction in code array */ + luaM_growvector(fs->L, f->code, fs->pc, f->sizecode, Instruction, + MAX_INT, "code size overflow"); + f->code[fs->pc] = i; + /* save corresponding line information */ + luaM_growvector(fs->L, f->lineinfo, fs->pc, f->sizelineinfo, int, + MAX_INT, "code size overflow"); + f->lineinfo[fs->pc] = line; + return fs->pc++; +} + + +int luaK_codeABC (FuncState *fs, OpCode o, int a, int b, int c) { + lua_assert(getOpMode(o) == iABC); + lua_assert(getBMode(o) != OpArgN || b == 0); + lua_assert(getCMode(o) != OpArgN || c == 0); + return luaK_code(fs, CREATE_ABC(o, a, b, c), fs->ls->lastline); +} + + +int luaK_codeABx (FuncState *fs, OpCode o, int a, unsigned int bc) { + lua_assert(getOpMode(o) == iABx || getOpMode(o) == iAsBx); + lua_assert(getCMode(o) == OpArgN); + return luaK_code(fs, CREATE_ABx(o, a, bc), fs->ls->lastline); +} + + +void luaK_setlist (FuncState *fs, int base, int nelems, int tostore) { + int c = (nelems - 1)/LFIELDS_PER_FLUSH + 1; + int b = (tostore == LUA_MULTRET) ? 0 : tostore; + lua_assert(tostore != 0); + if (c <= MAXARG_C) + luaK_codeABC(fs, OP_SETLIST, base, b, c); + else { + luaK_codeABC(fs, OP_SETLIST, base, b, 0); + luaK_code(fs, cast(Instruction, c), fs->ls->lastline); + } + fs->freereg = base + 1; /* free registers with list values */ +} + diff --git a/mk/linux/mojosetup/lua/src/lcode.h b/mk/linux/mojosetup/lua/src/lcode.h new file mode 100644 index 00000000..b941c607 --- /dev/null +++ b/mk/linux/mojosetup/lua/src/lcode.h @@ -0,0 +1,76 @@ +/* +** $Id: lcode.h,v 1.48.1.1 2007/12/27 13:02:25 roberto Exp $ +** Code generator for Lua +** See Copyright Notice in lua.h +*/ + +#ifndef lcode_h +#define lcode_h + +#include "llex.h" +#include "lobject.h" +#include "lopcodes.h" +#include "lparser.h" + + +/* +** Marks the end of a patch list. It is an invalid value both as an absolute +** address, and as a list link (would link an element to itself). +*/ +#define NO_JUMP (-1) + + +/* +** grep "ORDER OPR" if you change these enums +*/ +typedef enum BinOpr { + OPR_ADD, OPR_SUB, OPR_MUL, OPR_DIV, OPR_MOD, OPR_POW, + OPR_CONCAT, + OPR_NE, OPR_EQ, + OPR_LT, OPR_LE, OPR_GT, OPR_GE, + OPR_AND, OPR_OR, + OPR_NOBINOPR +} BinOpr; + + +typedef enum UnOpr { OPR_MINUS, OPR_NOT, OPR_LEN, OPR_NOUNOPR } UnOpr; + + +#define getcode(fs,e) ((fs)->f->code[(e)->u.s.info]) + +#define luaK_codeAsBx(fs,o,A,sBx) luaK_codeABx(fs,o,A,(sBx)+MAXARG_sBx) + +#define luaK_setmultret(fs,e) luaK_setreturns(fs, e, LUA_MULTRET) + +LUAI_FUNC int luaK_codeABx (FuncState *fs, OpCode o, int A, unsigned int Bx); +LUAI_FUNC int luaK_codeABC (FuncState *fs, OpCode o, int A, int B, int C); +LUAI_FUNC void luaK_fixline (FuncState *fs, int line); +LUAI_FUNC void luaK_nil (FuncState *fs, int from, int n); +LUAI_FUNC void luaK_reserveregs (FuncState *fs, int n); +LUAI_FUNC void luaK_checkstack (FuncState *fs, int n); +LUAI_FUNC int luaK_stringK (FuncState *fs, TString *s); +LUAI_FUNC int luaK_numberK (FuncState *fs, lua_Number r); +LUAI_FUNC void luaK_dischargevars (FuncState *fs, expdesc *e); +LUAI_FUNC int luaK_exp2anyreg (FuncState *fs, expdesc *e); +LUAI_FUNC void luaK_exp2nextreg (FuncState *fs, expdesc *e); +LUAI_FUNC void luaK_exp2val (FuncState *fs, expdesc *e); +LUAI_FUNC int luaK_exp2RK (FuncState *fs, expdesc *e); +LUAI_FUNC void luaK_self (FuncState *fs, expdesc *e, expdesc *key); +LUAI_FUNC void luaK_indexed (FuncState *fs, expdesc *t, expdesc *k); +LUAI_FUNC void luaK_goiftrue (FuncState *fs, expdesc *e); +LUAI_FUNC void luaK_storevar (FuncState *fs, expdesc *var, expdesc *e); +LUAI_FUNC void luaK_setreturns (FuncState *fs, expdesc *e, int nresults); +LUAI_FUNC void luaK_setoneret (FuncState *fs, expdesc *e); +LUAI_FUNC int luaK_jump (FuncState *fs); +LUAI_FUNC void luaK_ret (FuncState *fs, int first, int nret); +LUAI_FUNC void luaK_patchlist (FuncState *fs, int list, int target); +LUAI_FUNC void luaK_patchtohere (FuncState *fs, int list); +LUAI_FUNC void luaK_concat (FuncState *fs, int *l1, int l2); +LUAI_FUNC int luaK_getlabel (FuncState *fs); +LUAI_FUNC void luaK_prefix (FuncState *fs, UnOpr op, expdesc *v); +LUAI_FUNC void luaK_infix (FuncState *fs, BinOpr op, expdesc *v); +LUAI_FUNC void luaK_posfix (FuncState *fs, BinOpr op, expdesc *v1, expdesc *v2); +LUAI_FUNC void luaK_setlist (FuncState *fs, int base, int nelems, int tostore); + + +#endif diff --git a/mk/linux/mojosetup/lua/src/ldblib.c b/mk/linux/mojosetup/lua/src/ldblib.c new file mode 100644 index 00000000..67de1222 --- /dev/null +++ b/mk/linux/mojosetup/lua/src/ldblib.c @@ -0,0 +1,397 @@ +/* +** $Id: ldblib.c,v 1.104.1.3 2008/01/21 13:11:21 roberto Exp $ +** Interface from Lua to its debug API +** See Copyright Notice in lua.h +*/ + + +#include +#include +#include + +#define ldblib_c +#define LUA_LIB + +#include "lua.h" + +#include "lauxlib.h" +#include "lualib.h" + + + +static int db_getregistry (lua_State *L) { + lua_pushvalue(L, LUA_REGISTRYINDEX); + return 1; +} + + +static int db_getmetatable (lua_State *L) { + luaL_checkany(L, 1); + if (!lua_getmetatable(L, 1)) { + lua_pushnil(L); /* no metatable */ + } + return 1; +} + + +static int db_setmetatable (lua_State *L) { + int t = lua_type(L, 2); + luaL_argcheck(L, t == LUA_TNIL || t == LUA_TTABLE, 2, + "nil or table expected"); + lua_settop(L, 2); + lua_pushboolean(L, lua_setmetatable(L, 1)); + return 1; +} + + +static int db_getfenv (lua_State *L) { + lua_getfenv(L, 1); + return 1; +} + + +static int db_setfenv (lua_State *L) { + luaL_checktype(L, 2, LUA_TTABLE); + lua_settop(L, 2); + if (lua_setfenv(L, 1) == 0) + luaL_error(L, LUA_QL("setfenv") + " cannot change environment of given object"); + return 1; +} + + +static void settabss (lua_State *L, const char *i, const char *v) { + lua_pushstring(L, v); + lua_setfield(L, -2, i); +} + + +static void settabsi (lua_State *L, const char *i, int v) { + lua_pushinteger(L, v); + lua_setfield(L, -2, i); +} + + +static lua_State *getthread (lua_State *L, int *arg) { + if (lua_isthread(L, 1)) { + *arg = 1; + return lua_tothread(L, 1); + } + else { + *arg = 0; + return L; + } +} + + +static void treatstackoption (lua_State *L, lua_State *L1, const char *fname) { + if (L == L1) { + lua_pushvalue(L, -2); + lua_remove(L, -3); + } + else + lua_xmove(L1, L, 1); + lua_setfield(L, -2, fname); +} + + +static int db_getinfo (lua_State *L) { + lua_Debug ar; + int arg; + lua_State *L1 = getthread(L, &arg); + const char *options = luaL_optstring(L, arg+2, "flnSu"); + if (lua_isnumber(L, arg+1)) { + if (!lua_getstack(L1, (int)lua_tointeger(L, arg+1), &ar)) { + lua_pushnil(L); /* level out of range */ + return 1; + } + } + else if (lua_isfunction(L, arg+1)) { + lua_pushfstring(L, ">%s", options); + options = lua_tostring(L, -1); + lua_pushvalue(L, arg+1); + lua_xmove(L, L1, 1); + } + else + return luaL_argerror(L, arg+1, "function or level expected"); + if (!lua_getinfo(L1, options, &ar)) + return luaL_argerror(L, arg+2, "invalid option"); + lua_createtable(L, 0, 2); + if (strchr(options, 'S')) { + settabss(L, "source", ar.source); + settabss(L, "short_src", ar.short_src); + settabsi(L, "linedefined", ar.linedefined); + settabsi(L, "lastlinedefined", ar.lastlinedefined); + settabss(L, "what", ar.what); + } + if (strchr(options, 'l')) + settabsi(L, "currentline", ar.currentline); + if (strchr(options, 'u')) + settabsi(L, "nups", ar.nups); + if (strchr(options, 'n')) { + settabss(L, "name", ar.name); + settabss(L, "namewhat", ar.namewhat); + } + if (strchr(options, 'L')) + treatstackoption(L, L1, "activelines"); + if (strchr(options, 'f')) + treatstackoption(L, L1, "func"); + return 1; /* return table */ +} + + +static int db_getlocal (lua_State *L) { + int arg; + lua_State *L1 = getthread(L, &arg); + lua_Debug ar; + const char *name; + if (!lua_getstack(L1, luaL_checkint(L, arg+1), &ar)) /* out of range? */ + return luaL_argerror(L, arg+1, "level out of range"); + name = lua_getlocal(L1, &ar, luaL_checkint(L, arg+2)); + if (name) { + lua_xmove(L1, L, 1); + lua_pushstring(L, name); + lua_pushvalue(L, -2); + return 2; + } + else { + lua_pushnil(L); + return 1; + } +} + + +static int db_setlocal (lua_State *L) { + int arg; + lua_State *L1 = getthread(L, &arg); + lua_Debug ar; + if (!lua_getstack(L1, luaL_checkint(L, arg+1), &ar)) /* out of range? */ + return luaL_argerror(L, arg+1, "level out of range"); + luaL_checkany(L, arg+3); + lua_settop(L, arg+3); + lua_xmove(L, L1, 1); + lua_pushstring(L, lua_setlocal(L1, &ar, luaL_checkint(L, arg+2))); + return 1; +} + + +static int auxupvalue (lua_State *L, int get) { + const char *name; + int n = luaL_checkint(L, 2); + luaL_checktype(L, 1, LUA_TFUNCTION); + if (lua_iscfunction(L, 1)) return 0; /* cannot touch C upvalues from Lua */ + name = get ? lua_getupvalue(L, 1, n) : lua_setupvalue(L, 1, n); + if (name == NULL) return 0; + lua_pushstring(L, name); + lua_insert(L, -(get+1)); + return get + 1; +} + + +static int db_getupvalue (lua_State *L) { + return auxupvalue(L, 1); +} + + +static int db_setupvalue (lua_State *L) { + luaL_checkany(L, 3); + return auxupvalue(L, 0); +} + + + +static const char KEY_HOOK = 'h'; + + +static void hookf (lua_State *L, lua_Debug *ar) { + static const char *const hooknames[] = + {"call", "return", "line", "count", "tail return"}; + lua_pushlightuserdata(L, (void *)&KEY_HOOK); + lua_rawget(L, LUA_REGISTRYINDEX); + lua_pushlightuserdata(L, L); + lua_rawget(L, -2); + if (lua_isfunction(L, -1)) { + lua_pushstring(L, hooknames[(int)ar->event]); + if (ar->currentline >= 0) + lua_pushinteger(L, ar->currentline); + else lua_pushnil(L); + lua_assert(lua_getinfo(L, "lS", ar)); + lua_call(L, 2, 0); + } +} + + +static int makemask (const char *smask, int count) { + int mask = 0; + if (strchr(smask, 'c')) mask |= LUA_MASKCALL; + if (strchr(smask, 'r')) mask |= LUA_MASKRET; + if (strchr(smask, 'l')) mask |= LUA_MASKLINE; + if (count > 0) mask |= LUA_MASKCOUNT; + return mask; +} + + +static char *unmakemask (int mask, char *smask) { + int i = 0; + if (mask & LUA_MASKCALL) smask[i++] = 'c'; + if (mask & LUA_MASKRET) smask[i++] = 'r'; + if (mask & LUA_MASKLINE) smask[i++] = 'l'; + smask[i] = '\0'; + return smask; +} + + +static void gethooktable (lua_State *L) { + lua_pushlightuserdata(L, (void *)&KEY_HOOK); + lua_rawget(L, LUA_REGISTRYINDEX); + if (!lua_istable(L, -1)) { + lua_pop(L, 1); + lua_createtable(L, 0, 1); + lua_pushlightuserdata(L, (void *)&KEY_HOOK); + lua_pushvalue(L, -2); + lua_rawset(L, LUA_REGISTRYINDEX); + } +} + + +static int db_sethook (lua_State *L) { + int arg, mask, count; + lua_Hook func; + lua_State *L1 = getthread(L, &arg); + if (lua_isnoneornil(L, arg+1)) { + lua_settop(L, arg+1); + func = NULL; mask = 0; count = 0; /* turn off hooks */ + } + else { + const char *smask = luaL_checkstring(L, arg+2); + luaL_checktype(L, arg+1, LUA_TFUNCTION); + count = luaL_optint(L, arg+3, 0); + func = hookf; mask = makemask(smask, count); + } + gethooktable(L); + lua_pushlightuserdata(L, L1); + lua_pushvalue(L, arg+1); + lua_rawset(L, -3); /* set new hook */ + lua_pop(L, 1); /* remove hook table */ + lua_sethook(L1, func, mask, count); /* set hooks */ + return 0; +} + + +static int db_gethook (lua_State *L) { + int arg; + lua_State *L1 = getthread(L, &arg); + char buff[5]; + int mask = lua_gethookmask(L1); + lua_Hook hook = lua_gethook(L1); + if (hook != NULL && hook != hookf) /* external hook? */ + lua_pushliteral(L, "external hook"); + else { + gethooktable(L); + lua_pushlightuserdata(L, L1); + lua_rawget(L, -2); /* get hook */ + lua_remove(L, -2); /* remove hook table */ + } + lua_pushstring(L, unmakemask(mask, buff)); + lua_pushinteger(L, lua_gethookcount(L1)); + return 3; +} + + +static int db_debug (lua_State *L) { + for (;;) { + char buffer[250]; + fputs("lua_debug> ", stderr); + if (fgets(buffer, sizeof(buffer), stdin) == 0 || + strcmp(buffer, "cont\n") == 0) + return 0; + if (luaL_loadbuffer(L, buffer, strlen(buffer), "=(debug command)") || + lua_pcall(L, 0, 0, 0)) { + fputs(lua_tostring(L, -1), stderr); + fputs("\n", stderr); + } + lua_settop(L, 0); /* remove eventual returns */ + } +} + + +#define LEVELS1 12 /* size of the first part of the stack */ +#define LEVELS2 10 /* size of the second part of the stack */ + +static int db_errorfb (lua_State *L) { + int level; + int firstpart = 1; /* still before eventual `...' */ + int arg; + lua_State *L1 = getthread(L, &arg); + lua_Debug ar; + if (lua_isnumber(L, arg+2)) { + level = (int)lua_tointeger(L, arg+2); + lua_pop(L, 1); + } + else + level = (L == L1) ? 1 : 0; /* level 0 may be this own function */ + if (lua_gettop(L) == arg) + lua_pushliteral(L, ""); + else if (!lua_isstring(L, arg+1)) return 1; /* message is not a string */ + else lua_pushliteral(L, "\n"); + lua_pushliteral(L, "stack traceback:"); + while (lua_getstack(L1, level++, &ar)) { + if (level > LEVELS1 && firstpart) { + /* no more than `LEVELS2' more levels? */ + if (!lua_getstack(L1, level+LEVELS2, &ar)) + level--; /* keep going */ + else { + lua_pushliteral(L, "\n\t..."); /* too many levels */ + while (lua_getstack(L1, level+LEVELS2, &ar)) /* find last levels */ + level++; + } + firstpart = 0; + continue; + } + lua_pushliteral(L, "\n\t"); + lua_getinfo(L1, "Snl", &ar); + lua_pushfstring(L, "%s:", ar.short_src); + if (ar.currentline > 0) + lua_pushfstring(L, "%d:", ar.currentline); + if (*ar.namewhat != '\0') /* is there a name? */ + lua_pushfstring(L, " in function " LUA_QS, ar.name); + else { + if (*ar.what == 'm') /* main? */ + lua_pushfstring(L, " in main chunk"); + else if (*ar.what == 'C' || *ar.what == 't') + lua_pushliteral(L, " ?"); /* C function or tail call */ + else + lua_pushfstring(L, " in function <%s:%d>", + ar.short_src, ar.linedefined); + } + lua_concat(L, lua_gettop(L) - arg); + } + lua_concat(L, lua_gettop(L) - arg); + return 1; +} + + +static const luaL_Reg dblib[] = { + {"debug", db_debug}, + {"getfenv", db_getfenv}, + {"gethook", db_gethook}, + {"getinfo", db_getinfo}, + {"getlocal", db_getlocal}, + {"getregistry", db_getregistry}, + {"getmetatable", db_getmetatable}, + {"getupvalue", db_getupvalue}, + {"setfenv", db_setfenv}, + {"sethook", db_sethook}, + {"setlocal", db_setlocal}, + {"setmetatable", db_setmetatable}, + {"setupvalue", db_setupvalue}, + {"traceback", db_errorfb}, + {NULL, NULL} +}; + + +LUALIB_API int luaopen_debug (lua_State *L) { + luaL_register(L, LUA_DBLIBNAME, dblib); + return 1; +} + diff --git a/mk/linux/mojosetup/lua/src/ldebug.c b/mk/linux/mojosetup/lua/src/ldebug.c new file mode 100644 index 00000000..50ad3d38 --- /dev/null +++ b/mk/linux/mojosetup/lua/src/ldebug.c @@ -0,0 +1,638 @@ +/* +** $Id: ldebug.c,v 2.29.1.6 2008/05/08 16:56:26 roberto Exp $ +** Debug Interface +** See Copyright Notice in lua.h +*/ + + +#include +#include +#include + + +#define ldebug_c +#define LUA_CORE + +#include "lua.h" + +#include "lapi.h" +#include "lcode.h" +#include "ldebug.h" +#include "ldo.h" +#include "lfunc.h" +#include "lobject.h" +#include "lopcodes.h" +#include "lstate.h" +#include "lstring.h" +#include "ltable.h" +#include "ltm.h" +#include "lvm.h" + + + +static const char *getfuncname (lua_State *L, CallInfo *ci, const char **name); + + +static int currentpc (lua_State *L, CallInfo *ci) { + if (!isLua(ci)) return -1; /* function is not a Lua function? */ + if (ci == L->ci) + ci->savedpc = L->savedpc; + return pcRel(ci->savedpc, ci_func(ci)->l.p); +} + + +static int currentline (lua_State *L, CallInfo *ci) { + int pc = currentpc(L, ci); + if (pc < 0) + return -1; /* only active lua functions have current-line information */ + else + return getline(ci_func(ci)->l.p, pc); +} + + +/* +** this function can be called asynchronous (e.g. during a signal) +*/ +LUA_API int lua_sethook (lua_State *L, lua_Hook func, int mask, int count) { + if (func == NULL || mask == 0) { /* turn off hooks? */ + mask = 0; + func = NULL; + } + L->hook = func; + L->basehookcount = count; + resethookcount(L); + L->hookmask = cast_byte(mask); + return 1; +} + + +LUA_API lua_Hook lua_gethook (lua_State *L) { + return L->hook; +} + + +LUA_API int lua_gethookmask (lua_State *L) { + return L->hookmask; +} + + +LUA_API int lua_gethookcount (lua_State *L) { + return L->basehookcount; +} + + +LUA_API int lua_getstack (lua_State *L, int level, lua_Debug *ar) { + int status; + CallInfo *ci; + lua_lock(L); + for (ci = L->ci; level > 0 && ci > L->base_ci; ci--) { + level--; + if (f_isLua(ci)) /* Lua function? */ + level -= ci->tailcalls; /* skip lost tail calls */ + } + if (level == 0 && ci > L->base_ci) { /* level found? */ + status = 1; + ar->i_ci = cast_int(ci - L->base_ci); + } + else if (level < 0) { /* level is of a lost tail call? */ + status = 1; + ar->i_ci = 0; + } + else status = 0; /* no such level */ + lua_unlock(L); + return status; +} + + +static Proto *getluaproto (CallInfo *ci) { + return (isLua(ci) ? ci_func(ci)->l.p : NULL); +} + + +static const char *findlocal (lua_State *L, CallInfo *ci, int n) { + const char *name; + Proto *fp = getluaproto(ci); + if (fp && (name = luaF_getlocalname(fp, n, currentpc(L, ci))) != NULL) + return name; /* is a local variable in a Lua function */ + else { + StkId limit = (ci == L->ci) ? L->top : (ci+1)->func; + if (limit - ci->base >= n && n > 0) /* is 'n' inside 'ci' stack? */ + return "(*temporary)"; + else + return NULL; + } +} + + +LUA_API const char *lua_getlocal (lua_State *L, const lua_Debug *ar, int n) { + CallInfo *ci = L->base_ci + ar->i_ci; + const char *name = findlocal(L, ci, n); + lua_lock(L); + if (name) + luaA_pushobject(L, ci->base + (n - 1)); + lua_unlock(L); + return name; +} + + +LUA_API const char *lua_setlocal (lua_State *L, const lua_Debug *ar, int n) { + CallInfo *ci = L->base_ci + ar->i_ci; + const char *name = findlocal(L, ci, n); + lua_lock(L); + if (name) + setobjs2s(L, ci->base + (n - 1), L->top - 1); + L->top--; /* pop value */ + lua_unlock(L); + return name; +} + + +static void funcinfo (lua_Debug *ar, Closure *cl) { + if (cl->c.isC) { + ar->source = "=[C]"; + ar->linedefined = -1; + ar->lastlinedefined = -1; + ar->what = "C"; + } + else { + ar->source = getstr(cl->l.p->source); + ar->linedefined = cl->l.p->linedefined; + ar->lastlinedefined = cl->l.p->lastlinedefined; + ar->what = (ar->linedefined == 0) ? "main" : "Lua"; + } + luaO_chunkid(ar->short_src, ar->source, LUA_IDSIZE); +} + + +static void info_tailcall (lua_Debug *ar) { + ar->name = ar->namewhat = ""; + ar->what = "tail"; + ar->lastlinedefined = ar->linedefined = ar->currentline = -1; + ar->source = "=(tail call)"; + luaO_chunkid(ar->short_src, ar->source, LUA_IDSIZE); + ar->nups = 0; +} + + +static void collectvalidlines (lua_State *L, Closure *f) { + if (f == NULL || f->c.isC) { + setnilvalue(L->top); + } + else { + Table *t = luaH_new(L, 0, 0); + int *lineinfo = f->l.p->lineinfo; + int i; + for (i=0; il.p->sizelineinfo; i++) + setbvalue(luaH_setnum(L, t, lineinfo[i]), 1); + sethvalue(L, L->top, t); + } + incr_top(L); +} + + +static int auxgetinfo (lua_State *L, const char *what, lua_Debug *ar, + Closure *f, CallInfo *ci) { + int status = 1; + if (f == NULL) { + info_tailcall(ar); + return status; + } + for (; *what; what++) { + switch (*what) { + case 'S': { + funcinfo(ar, f); + break; + } + case 'l': { + ar->currentline = (ci) ? currentline(L, ci) : -1; + break; + } + case 'u': { + ar->nups = f->c.nupvalues; + break; + } + case 'n': { + ar->namewhat = (ci) ? getfuncname(L, ci, &ar->name) : NULL; + if (ar->namewhat == NULL) { + ar->namewhat = ""; /* not found */ + ar->name = NULL; + } + break; + } + case 'L': + case 'f': /* handled by lua_getinfo */ + break; + default: status = 0; /* invalid option */ + } + } + return status; +} + + +LUA_API int lua_getinfo (lua_State *L, const char *what, lua_Debug *ar) { + int status; + Closure *f = NULL; + CallInfo *ci = NULL; + lua_lock(L); + if (*what == '>') { + StkId func = L->top - 1; + luai_apicheck(L, ttisfunction(func)); + what++; /* skip the '>' */ + f = clvalue(func); + L->top--; /* pop function */ + } + else if (ar->i_ci != 0) { /* no tail call? */ + ci = L->base_ci + ar->i_ci; + lua_assert(ttisfunction(ci->func)); + f = clvalue(ci->func); + } + status = auxgetinfo(L, what, ar, f, ci); + if (strchr(what, 'f')) { + if (f == NULL) setnilvalue(L->top); + else setclvalue(L, L->top, f); + incr_top(L); + } + if (strchr(what, 'L')) + collectvalidlines(L, f); + lua_unlock(L); + return status; +} + + +/* +** {====================================================== +** Symbolic Execution and code checker +** ======================================================= +*/ + +#define check(x) if (!(x)) return 0; + +#define checkjump(pt,pc) check(0 <= pc && pc < pt->sizecode) + +#define checkreg(pt,reg) check((reg) < (pt)->maxstacksize) + + + +static int precheck (const Proto *pt) { + check(pt->maxstacksize <= MAXSTACK); + check(pt->numparams+(pt->is_vararg & VARARG_HASARG) <= pt->maxstacksize); + check(!(pt->is_vararg & VARARG_NEEDSARG) || + (pt->is_vararg & VARARG_HASARG)); + check(pt->sizeupvalues <= pt->nups); + check(pt->sizelineinfo == pt->sizecode || pt->sizelineinfo == 0); + check(pt->sizecode > 0 && GET_OPCODE(pt->code[pt->sizecode-1]) == OP_RETURN); + return 1; +} + + +#define checkopenop(pt,pc) luaG_checkopenop((pt)->code[(pc)+1]) + +int luaG_checkopenop (Instruction i) { + switch (GET_OPCODE(i)) { + case OP_CALL: + case OP_TAILCALL: + case OP_RETURN: + case OP_SETLIST: { + check(GETARG_B(i) == 0); + return 1; + } + default: return 0; /* invalid instruction after an open call */ + } +} + + +static int checkArgMode (const Proto *pt, int r, enum OpArgMask mode) { + switch (mode) { + case OpArgN: check(r == 0); break; + case OpArgU: break; + case OpArgR: checkreg(pt, r); break; + case OpArgK: + check(ISK(r) ? INDEXK(r) < pt->sizek : r < pt->maxstacksize); + break; + } + return 1; +} + + +static Instruction symbexec (const Proto *pt, int lastpc, int reg) { + int pc; + int last; /* stores position of last instruction that changed `reg' */ + last = pt->sizecode-1; /* points to final return (a `neutral' instruction) */ + check(precheck(pt)); + for (pc = 0; pc < lastpc; pc++) { + Instruction i = pt->code[pc]; + OpCode op = GET_OPCODE(i); + int a = GETARG_A(i); + int b = 0; + int c = 0; + check(op < NUM_OPCODES); + checkreg(pt, a); + switch (getOpMode(op)) { + case iABC: { + b = GETARG_B(i); + c = GETARG_C(i); + check(checkArgMode(pt, b, getBMode(op))); + check(checkArgMode(pt, c, getCMode(op))); + break; + } + case iABx: { + b = GETARG_Bx(i); + if (getBMode(op) == OpArgK) check(b < pt->sizek); + break; + } + case iAsBx: { + b = GETARG_sBx(i); + if (getBMode(op) == OpArgR) { + int dest = pc+1+b; + check(0 <= dest && dest < pt->sizecode); + if (dest > 0) { + int j; + /* check that it does not jump to a setlist count; this + is tricky, because the count from a previous setlist may + have the same value of an invalid setlist; so, we must + go all the way back to the first of them (if any) */ + for (j = 0; j < dest; j++) { + Instruction d = pt->code[dest-1-j]; + if (!(GET_OPCODE(d) == OP_SETLIST && GETARG_C(d) == 0)) break; + } + /* if 'j' is even, previous value is not a setlist (even if + it looks like one) */ + check((j&1) == 0); + } + } + break; + } + } + if (testAMode(op)) { + if (a == reg) last = pc; /* change register `a' */ + } + if (testTMode(op)) { + check(pc+2 < pt->sizecode); /* check skip */ + check(GET_OPCODE(pt->code[pc+1]) == OP_JMP); + } + switch (op) { + case OP_LOADBOOL: { + if (c == 1) { /* does it jump? */ + check(pc+2 < pt->sizecode); /* check its jump */ + check(GET_OPCODE(pt->code[pc+1]) != OP_SETLIST || + GETARG_C(pt->code[pc+1]) != 0); + } + break; + } + case OP_LOADNIL: { + if (a <= reg && reg <= b) + last = pc; /* set registers from `a' to `b' */ + break; + } + case OP_GETUPVAL: + case OP_SETUPVAL: { + check(b < pt->nups); + break; + } + case OP_GETGLOBAL: + case OP_SETGLOBAL: { + check(ttisstring(&pt->k[b])); + break; + } + case OP_SELF: { + checkreg(pt, a+1); + if (reg == a+1) last = pc; + break; + } + case OP_CONCAT: { + check(b < c); /* at least two operands */ + break; + } + case OP_TFORLOOP: { + check(c >= 1); /* at least one result (control variable) */ + checkreg(pt, a+2+c); /* space for results */ + if (reg >= a+2) last = pc; /* affect all regs above its base */ + break; + } + case OP_FORLOOP: + case OP_FORPREP: + checkreg(pt, a+3); + /* go through */ + case OP_JMP: { + int dest = pc+1+b; + /* not full check and jump is forward and do not skip `lastpc'? */ + if (reg != NO_REG && pc < dest && dest <= lastpc) + pc += b; /* do the jump */ + break; + } + case OP_CALL: + case OP_TAILCALL: { + if (b != 0) { + checkreg(pt, a+b-1); + } + c--; /* c = num. returns */ + if (c == LUA_MULTRET) { + check(checkopenop(pt, pc)); + } + else if (c != 0) + checkreg(pt, a+c-1); + if (reg >= a) last = pc; /* affect all registers above base */ + break; + } + case OP_RETURN: { + b--; /* b = num. returns */ + if (b > 0) checkreg(pt, a+b-1); + break; + } + case OP_SETLIST: { + if (b > 0) checkreg(pt, a + b); + if (c == 0) { + pc++; + check(pc < pt->sizecode - 1); + } + break; + } + case OP_CLOSURE: { + int nup, j; + check(b < pt->sizep); + nup = pt->p[b]->nups; + check(pc + nup < pt->sizecode); + for (j = 1; j <= nup; j++) { + OpCode op1 = GET_OPCODE(pt->code[pc + j]); + check(op1 == OP_GETUPVAL || op1 == OP_MOVE); + } + if (reg != NO_REG) /* tracing? */ + pc += nup; /* do not 'execute' these pseudo-instructions */ + break; + } + case OP_VARARG: { + check((pt->is_vararg & VARARG_ISVARARG) && + !(pt->is_vararg & VARARG_NEEDSARG)); + b--; + if (b == LUA_MULTRET) check(checkopenop(pt, pc)); + checkreg(pt, a+b-1); + break; + } + default: break; + } + } + return pt->code[last]; +} + +#undef check +#undef checkjump +#undef checkreg + +/* }====================================================== */ + + +int luaG_checkcode (const Proto *pt) { + return (symbexec(pt, pt->sizecode, NO_REG) != 0); +} + + +static const char *kname (Proto *p, int c) { + if (ISK(c) && ttisstring(&p->k[INDEXK(c)])) + return svalue(&p->k[INDEXK(c)]); + else + return "?"; +} + + +static const char *getobjname (lua_State *L, CallInfo *ci, int stackpos, + const char **name) { + if (isLua(ci)) { /* a Lua function? */ + Proto *p = ci_func(ci)->l.p; + int pc = currentpc(L, ci); + Instruction i; + *name = luaF_getlocalname(p, stackpos+1, pc); + if (*name) /* is a local? */ + return "local"; + i = symbexec(p, pc, stackpos); /* try symbolic execution */ + lua_assert(pc != -1); + switch (GET_OPCODE(i)) { + case OP_GETGLOBAL: { + int g = GETARG_Bx(i); /* global index */ + lua_assert(ttisstring(&p->k[g])); + *name = svalue(&p->k[g]); + return "global"; + } + case OP_MOVE: { + int a = GETARG_A(i); + int b = GETARG_B(i); /* move from `b' to `a' */ + if (b < a) + return getobjname(L, ci, b, name); /* get name for `b' */ + break; + } + case OP_GETTABLE: { + int k = GETARG_C(i); /* key index */ + *name = kname(p, k); + return "field"; + } + case OP_GETUPVAL: { + int u = GETARG_B(i); /* upvalue index */ + *name = p->upvalues ? getstr(p->upvalues[u]) : "?"; + return "upvalue"; + } + case OP_SELF: { + int k = GETARG_C(i); /* key index */ + *name = kname(p, k); + return "method"; + } + default: break; + } + } + return NULL; /* no useful name found */ +} + + +static const char *getfuncname (lua_State *L, CallInfo *ci, const char **name) { + Instruction i; + if ((isLua(ci) && ci->tailcalls > 0) || !isLua(ci - 1)) + return NULL; /* calling function is not Lua (or is unknown) */ + ci--; /* calling function */ + i = ci_func(ci)->l.p->code[currentpc(L, ci)]; + if (GET_OPCODE(i) == OP_CALL || GET_OPCODE(i) == OP_TAILCALL || + GET_OPCODE(i) == OP_TFORLOOP) + return getobjname(L, ci, GETARG_A(i), name); + else + return NULL; /* no useful name can be found */ +} + + +/* only ANSI way to check whether a pointer points to an array */ +static int isinstack (CallInfo *ci, const TValue *o) { + StkId p; + for (p = ci->base; p < ci->top; p++) + if (o == p) return 1; + return 0; +} + + +void luaG_typeerror (lua_State *L, const TValue *o, const char *op) { + const char *name = NULL; + const char *t = luaT_typenames[ttype(o)]; + const char *kind = (isinstack(L->ci, o)) ? + getobjname(L, L->ci, cast_int(o - L->base), &name) : + NULL; + if (kind) + luaG_runerror(L, "attempt to %s %s " LUA_QS " (a %s value)", + op, kind, name, t); + else + luaG_runerror(L, "attempt to %s a %s value", op, t); +} + + +void luaG_concaterror (lua_State *L, StkId p1, StkId p2) { + if (ttisstring(p1) || ttisnumber(p1)) p1 = p2; + lua_assert(!ttisstring(p1) && !ttisnumber(p1)); + luaG_typeerror(L, p1, "concatenate"); +} + + +void luaG_aritherror (lua_State *L, const TValue *p1, const TValue *p2) { + TValue temp; + if (luaV_tonumber(p1, &temp) == NULL) + p2 = p1; /* first operand is wrong */ + luaG_typeerror(L, p2, "perform arithmetic on"); +} + + +int luaG_ordererror (lua_State *L, const TValue *p1, const TValue *p2) { + const char *t1 = luaT_typenames[ttype(p1)]; + const char *t2 = luaT_typenames[ttype(p2)]; + if (t1[2] == t2[2]) + luaG_runerror(L, "attempt to compare two %s values", t1); + else + luaG_runerror(L, "attempt to compare %s with %s", t1, t2); + return 0; +} + + +static void addinfo (lua_State *L, const char *msg) { + CallInfo *ci = L->ci; + if (isLua(ci)) { /* is Lua code? */ + char buff[LUA_IDSIZE]; /* add file:line information */ + int line = currentline(L, ci); + luaO_chunkid(buff, getstr(getluaproto(ci)->source), LUA_IDSIZE); + luaO_pushfstring(L, "%s:%d: %s", buff, line, msg); + } +} + + +void luaG_errormsg (lua_State *L) { + if (L->errfunc != 0) { /* is there an error handling function? */ + StkId errfunc = restorestack(L, L->errfunc); + if (!ttisfunction(errfunc)) luaD_throw(L, LUA_ERRERR); + setobjs2s(L, L->top, L->top - 1); /* move argument */ + setobjs2s(L, L->top - 1, errfunc); /* push function */ + incr_top(L); + luaD_call(L, L->top - 2, 1); /* call it */ + } + luaD_throw(L, LUA_ERRRUN); +} + + +void luaG_runerror (lua_State *L, const char *fmt, ...) { + va_list argp; + va_start(argp, fmt); + addinfo(L, luaO_pushvfstring(L, fmt, argp)); + va_end(argp); + luaG_errormsg(L); +} + diff --git a/mk/linux/mojosetup/lua/src/ldebug.h b/mk/linux/mojosetup/lua/src/ldebug.h new file mode 100644 index 00000000..ba28a972 --- /dev/null +++ b/mk/linux/mojosetup/lua/src/ldebug.h @@ -0,0 +1,33 @@ +/* +** $Id: ldebug.h,v 2.3.1.1 2007/12/27 13:02:25 roberto Exp $ +** Auxiliary functions from Debug Interface module +** See Copyright Notice in lua.h +*/ + +#ifndef ldebug_h +#define ldebug_h + + +#include "lstate.h" + + +#define pcRel(pc, p) (cast(int, (pc) - (p)->code) - 1) + +#define getline(f,pc) (((f)->lineinfo) ? (f)->lineinfo[pc] : 0) + +#define resethookcount(L) (L->hookcount = L->basehookcount) + + +LUAI_FUNC void luaG_typeerror (lua_State *L, const TValue *o, + const char *opname); +LUAI_FUNC void luaG_concaterror (lua_State *L, StkId p1, StkId p2); +LUAI_FUNC void luaG_aritherror (lua_State *L, const TValue *p1, + const TValue *p2); +LUAI_FUNC int luaG_ordererror (lua_State *L, const TValue *p1, + const TValue *p2); +LUAI_FUNC void luaG_runerror (lua_State *L, const char *fmt, ...); +LUAI_FUNC void luaG_errormsg (lua_State *L); +LUAI_FUNC int luaG_checkcode (const Proto *pt); +LUAI_FUNC int luaG_checkopenop (Instruction i); + +#endif diff --git a/mk/linux/mojosetup/lua/src/ldo.c b/mk/linux/mojosetup/lua/src/ldo.c new file mode 100644 index 00000000..8de05f72 --- /dev/null +++ b/mk/linux/mojosetup/lua/src/ldo.c @@ -0,0 +1,518 @@ +/* +** $Id: ldo.c,v 2.38.1.3 2008/01/18 22:31:22 roberto Exp $ +** Stack and Call structure of Lua +** See Copyright Notice in lua.h +*/ + + +#include +#include +#include + +#define ldo_c +#define LUA_CORE + +#include "lua.h" + +#include "ldebug.h" +#include "ldo.h" +#include "lfunc.h" +#include "lgc.h" +#include "lmem.h" +#include "lobject.h" +#include "lopcodes.h" +#include "lparser.h" +#include "lstate.h" +#include "lstring.h" +#include "ltable.h" +#include "ltm.h" +#include "lundump.h" +#include "lvm.h" +#include "lzio.h" + + + + +/* +** {====================================================== +** Error-recovery functions +** ======================================================= +*/ + + +/* chain list of long jump buffers */ +struct lua_longjmp { + struct lua_longjmp *previous; + luai_jmpbuf b; + volatile int status; /* error code */ +}; + + +void luaD_seterrorobj (lua_State *L, int errcode, StkId oldtop) { + switch (errcode) { + case LUA_ERRMEM: { + setsvalue2s(L, oldtop, luaS_newliteral(L, MEMERRMSG)); + break; + } + case LUA_ERRERR: { + setsvalue2s(L, oldtop, luaS_newliteral(L, "error in error handling")); + break; + } + case LUA_ERRSYNTAX: + case LUA_ERRRUN: { + setobjs2s(L, oldtop, L->top - 1); /* error message on current top */ + break; + } + } + L->top = oldtop + 1; +} + + +static void restore_stack_limit (lua_State *L) { + lua_assert(L->stack_last - L->stack == L->stacksize - EXTRA_STACK - 1); + if (L->size_ci > LUAI_MAXCALLS) { /* there was an overflow? */ + int inuse = cast_int(L->ci - L->base_ci); + if (inuse + 1 < LUAI_MAXCALLS) /* can `undo' overflow? */ + luaD_reallocCI(L, LUAI_MAXCALLS); + } +} + + +static void resetstack (lua_State *L, int status) { + L->ci = L->base_ci; + L->base = L->ci->base; + luaF_close(L, L->base); /* close eventual pending closures */ + luaD_seterrorobj(L, status, L->base); + L->nCcalls = L->baseCcalls; + L->allowhook = 1; + restore_stack_limit(L); + L->errfunc = 0; + L->errorJmp = NULL; +} + + +void luaD_throw (lua_State *L, int errcode) { + if (L->errorJmp) { + L->errorJmp->status = errcode; + LUAI_THROW(L, L->errorJmp); + } + else { + L->status = cast_byte(errcode); + if (G(L)->panic) { + resetstack(L, errcode); + lua_unlock(L); + G(L)->panic(L); + } + exit(EXIT_FAILURE); + } +} + + +int luaD_rawrunprotected (lua_State *L, Pfunc f, void *ud) { + struct lua_longjmp lj; + lj.status = 0; + lj.previous = L->errorJmp; /* chain new error handler */ + L->errorJmp = &lj; + LUAI_TRY(L, &lj, + (*f)(L, ud); + ); + L->errorJmp = lj.previous; /* restore old error handler */ + return lj.status; +} + +/* }====================================================== */ + + +static void correctstack (lua_State *L, TValue *oldstack) { + CallInfo *ci; + GCObject *up; + L->top = (L->top - oldstack) + L->stack; + for (up = L->openupval; up != NULL; up = up->gch.next) + gco2uv(up)->v = (gco2uv(up)->v - oldstack) + L->stack; + for (ci = L->base_ci; ci <= L->ci; ci++) { + ci->top = (ci->top - oldstack) + L->stack; + ci->base = (ci->base - oldstack) + L->stack; + ci->func = (ci->func - oldstack) + L->stack; + } + L->base = (L->base - oldstack) + L->stack; +} + + +void luaD_reallocstack (lua_State *L, int newsize) { + TValue *oldstack = L->stack; + int realsize = newsize + 1 + EXTRA_STACK; + lua_assert(L->stack_last - L->stack == L->stacksize - EXTRA_STACK - 1); + luaM_reallocvector(L, L->stack, L->stacksize, realsize, TValue); + L->stacksize = realsize; + L->stack_last = L->stack+newsize; + correctstack(L, oldstack); +} + + +void luaD_reallocCI (lua_State *L, int newsize) { + CallInfo *oldci = L->base_ci; + luaM_reallocvector(L, L->base_ci, L->size_ci, newsize, CallInfo); + L->size_ci = newsize; + L->ci = (L->ci - oldci) + L->base_ci; + L->end_ci = L->base_ci + L->size_ci - 1; +} + + +void luaD_growstack (lua_State *L, int n) { + if (n <= L->stacksize) /* double size is enough? */ + luaD_reallocstack(L, 2*L->stacksize); + else + luaD_reallocstack(L, L->stacksize + n); +} + + +static CallInfo *growCI (lua_State *L) { + if (L->size_ci > LUAI_MAXCALLS) /* overflow while handling overflow? */ + luaD_throw(L, LUA_ERRERR); + else { + luaD_reallocCI(L, 2*L->size_ci); + if (L->size_ci > LUAI_MAXCALLS) + luaG_runerror(L, "stack overflow"); + } + return ++L->ci; +} + + +void luaD_callhook (lua_State *L, int event, int line) { + lua_Hook hook = L->hook; + if (hook && L->allowhook) { + ptrdiff_t top = savestack(L, L->top); + ptrdiff_t ci_top = savestack(L, L->ci->top); + lua_Debug ar; + ar.event = event; + ar.currentline = line; + if (event == LUA_HOOKTAILRET) + ar.i_ci = 0; /* tail call; no debug information about it */ + else + ar.i_ci = cast_int(L->ci - L->base_ci); + luaD_checkstack(L, LUA_MINSTACK); /* ensure minimum stack size */ + L->ci->top = L->top + LUA_MINSTACK; + lua_assert(L->ci->top <= L->stack_last); + L->allowhook = 0; /* cannot call hooks inside a hook */ + lua_unlock(L); + (*hook)(L, &ar); + lua_lock(L); + lua_assert(!L->allowhook); + L->allowhook = 1; + L->ci->top = restorestack(L, ci_top); + L->top = restorestack(L, top); + } +} + + +static StkId adjust_varargs (lua_State *L, Proto *p, int actual) { + int i; + int nfixargs = p->numparams; + Table *htab = NULL; + StkId base, fixed; + for (; actual < nfixargs; ++actual) + setnilvalue(L->top++); +#if defined(LUA_COMPAT_VARARG) + if (p->is_vararg & VARARG_NEEDSARG) { /* compat. with old-style vararg? */ + int nvar = actual - nfixargs; /* number of extra arguments */ + lua_assert(p->is_vararg & VARARG_HASARG); + luaC_checkGC(L); + htab = luaH_new(L, nvar, 1); /* create `arg' table */ + for (i=0; itop - nvar + i); + /* store counter in field `n' */ + setnvalue(luaH_setstr(L, htab, luaS_newliteral(L, "n")), cast_num(nvar)); + } +#endif + /* move fixed parameters to final position */ + fixed = L->top - actual; /* first fixed argument */ + base = L->top; /* final position of first argument */ + for (i=0; itop++, fixed+i); + setnilvalue(fixed+i); + } + /* add `arg' parameter */ + if (htab) { + sethvalue(L, L->top++, htab); + lua_assert(iswhite(obj2gco(htab))); + } + return base; +} + + +static StkId tryfuncTM (lua_State *L, StkId func) { + const TValue *tm = luaT_gettmbyobj(L, func, TM_CALL); + StkId p; + ptrdiff_t funcr = savestack(L, func); + if (!ttisfunction(tm)) + luaG_typeerror(L, func, "call"); + /* Open a hole inside the stack at `func' */ + for (p = L->top; p > func; p--) setobjs2s(L, p, p-1); + incr_top(L); + func = restorestack(L, funcr); /* previous call may change stack */ + setobj2s(L, func, tm); /* tag method is the new function to be called */ + return func; +} + + + +#define inc_ci(L) \ + ((L->ci == L->end_ci) ? growCI(L) : \ + (condhardstacktests(luaD_reallocCI(L, L->size_ci)), ++L->ci)) + + +int luaD_precall (lua_State *L, StkId func, int nresults) { + LClosure *cl; + ptrdiff_t funcr; + if (!ttisfunction(func)) /* `func' is not a function? */ + func = tryfuncTM(L, func); /* check the `function' tag method */ + funcr = savestack(L, func); + cl = &clvalue(func)->l; + L->ci->savedpc = L->savedpc; + if (!cl->isC) { /* Lua function? prepare its call */ + CallInfo *ci; + StkId st, base; + Proto *p = cl->p; + luaD_checkstack(L, p->maxstacksize); + func = restorestack(L, funcr); + if (!p->is_vararg) { /* no varargs? */ + base = func + 1; + if (L->top > base + p->numparams) + L->top = base + p->numparams; + } + else { /* vararg function */ + int nargs = cast_int(L->top - func) - 1; + base = adjust_varargs(L, p, nargs); + func = restorestack(L, funcr); /* previous call may change the stack */ + } + ci = inc_ci(L); /* now `enter' new function */ + ci->func = func; + L->base = ci->base = base; + ci->top = L->base + p->maxstacksize; + lua_assert(ci->top <= L->stack_last); + L->savedpc = p->code; /* starting point */ + ci->tailcalls = 0; + ci->nresults = nresults; + for (st = L->top; st < ci->top; st++) + setnilvalue(st); + L->top = ci->top; + if (L->hookmask & LUA_MASKCALL) { + L->savedpc++; /* hooks assume 'pc' is already incremented */ + luaD_callhook(L, LUA_HOOKCALL, -1); + L->savedpc--; /* correct 'pc' */ + } + return PCRLUA; + } + else { /* if is a C function, call it */ + CallInfo *ci; + int n; + luaD_checkstack(L, LUA_MINSTACK); /* ensure minimum stack size */ + ci = inc_ci(L); /* now `enter' new function */ + ci->func = restorestack(L, funcr); + L->base = ci->base = ci->func + 1; + ci->top = L->top + LUA_MINSTACK; + lua_assert(ci->top <= L->stack_last); + ci->nresults = nresults; + if (L->hookmask & LUA_MASKCALL) + luaD_callhook(L, LUA_HOOKCALL, -1); + lua_unlock(L); + n = (*curr_func(L)->c.f)(L); /* do the actual call */ + lua_lock(L); + if (n < 0) /* yielding? */ + return PCRYIELD; + else { + luaD_poscall(L, L->top - n); + return PCRC; + } + } +} + + +static StkId callrethooks (lua_State *L, StkId firstResult) { + ptrdiff_t fr = savestack(L, firstResult); /* next call may change stack */ + luaD_callhook(L, LUA_HOOKRET, -1); + if (f_isLua(L->ci)) { /* Lua function? */ + while ((L->hookmask & LUA_MASKRET) && L->ci->tailcalls--) /* tail calls */ + luaD_callhook(L, LUA_HOOKTAILRET, -1); + } + return restorestack(L, fr); +} + + +int luaD_poscall (lua_State *L, StkId firstResult) { + StkId res; + int wanted, i; + CallInfo *ci; + if (L->hookmask & LUA_MASKRET) + firstResult = callrethooks(L, firstResult); + ci = L->ci--; + res = ci->func; /* res == final position of 1st result */ + wanted = ci->nresults; + L->base = (ci - 1)->base; /* restore base */ + L->savedpc = (ci - 1)->savedpc; /* restore savedpc */ + /* move results to correct place */ + for (i = wanted; i != 0 && firstResult < L->top; i--) + setobjs2s(L, res++, firstResult++); + while (i-- > 0) + setnilvalue(res++); + L->top = res; + return (wanted - LUA_MULTRET); /* 0 iff wanted == LUA_MULTRET */ +} + + +/* +** Call a function (C or Lua). The function to be called is at *func. +** The arguments are on the stack, right after the function. +** When returns, all the results are on the stack, starting at the original +** function position. +*/ +void luaD_call (lua_State *L, StkId func, int nResults) { + if (++L->nCcalls >= LUAI_MAXCCALLS) { + if (L->nCcalls == LUAI_MAXCCALLS) + luaG_runerror(L, "C stack overflow"); + else if (L->nCcalls >= (LUAI_MAXCCALLS + (LUAI_MAXCCALLS>>3))) + luaD_throw(L, LUA_ERRERR); /* error while handing stack error */ + } + if (luaD_precall(L, func, nResults) == PCRLUA) /* is a Lua function? */ + luaV_execute(L, 1); /* call it */ + L->nCcalls--; + luaC_checkGC(L); +} + + +static void resume (lua_State *L, void *ud) { + StkId firstArg = cast(StkId, ud); + CallInfo *ci = L->ci; + if (L->status == 0) { /* start coroutine? */ + lua_assert(ci == L->base_ci && firstArg > L->base); + if (luaD_precall(L, firstArg - 1, LUA_MULTRET) != PCRLUA) + return; + } + else { /* resuming from previous yield */ + lua_assert(L->status == LUA_YIELD); + L->status = 0; + if (!f_isLua(ci)) { /* `common' yield? */ + /* finish interrupted execution of `OP_CALL' */ + lua_assert(GET_OPCODE(*((ci-1)->savedpc - 1)) == OP_CALL || + GET_OPCODE(*((ci-1)->savedpc - 1)) == OP_TAILCALL); + if (luaD_poscall(L, firstArg)) /* complete it... */ + L->top = L->ci->top; /* and correct top if not multiple results */ + } + else /* yielded inside a hook: just continue its execution */ + L->base = L->ci->base; + } + luaV_execute(L, cast_int(L->ci - L->base_ci)); +} + + +static int resume_error (lua_State *L, const char *msg) { + L->top = L->ci->base; + setsvalue2s(L, L->top, luaS_new(L, msg)); + incr_top(L); + lua_unlock(L); + return LUA_ERRRUN; +} + + +LUA_API int lua_resume (lua_State *L, int nargs) { + int status; + lua_lock(L); + if (L->status != LUA_YIELD && (L->status != 0 || L->ci != L->base_ci)) + return resume_error(L, "cannot resume non-suspended coroutine"); + if (L->nCcalls >= LUAI_MAXCCALLS) + return resume_error(L, "C stack overflow"); + luai_userstateresume(L, nargs); + lua_assert(L->errfunc == 0); + L->baseCcalls = ++L->nCcalls; + status = luaD_rawrunprotected(L, resume, L->top - nargs); + if (status != 0) { /* error? */ + L->status = cast_byte(status); /* mark thread as `dead' */ + luaD_seterrorobj(L, status, L->top); + L->ci->top = L->top; + } + else { + lua_assert(L->nCcalls == L->baseCcalls); + status = L->status; + } + --L->nCcalls; + lua_unlock(L); + return status; +} + + +LUA_API int lua_yield (lua_State *L, int nresults) { + luai_userstateyield(L, nresults); + lua_lock(L); + if (L->nCcalls > L->baseCcalls) + luaG_runerror(L, "attempt to yield across metamethod/C-call boundary"); + L->base = L->top - nresults; /* protect stack slots below */ + L->status = LUA_YIELD; + lua_unlock(L); + return -1; +} + + +int luaD_pcall (lua_State *L, Pfunc func, void *u, + ptrdiff_t old_top, ptrdiff_t ef) { + int status; + unsigned short oldnCcalls = L->nCcalls; + ptrdiff_t old_ci = saveci(L, L->ci); + lu_byte old_allowhooks = L->allowhook; + ptrdiff_t old_errfunc = L->errfunc; + L->errfunc = ef; + status = luaD_rawrunprotected(L, func, u); + if (status != 0) { /* an error occurred? */ + StkId oldtop = restorestack(L, old_top); + luaF_close(L, oldtop); /* close eventual pending closures */ + luaD_seterrorobj(L, status, oldtop); + L->nCcalls = oldnCcalls; + L->ci = restoreci(L, old_ci); + L->base = L->ci->base; + L->savedpc = L->ci->savedpc; + L->allowhook = old_allowhooks; + restore_stack_limit(L); + } + L->errfunc = old_errfunc; + return status; +} + + + +/* +** Execute a protected parser. +*/ +struct SParser { /* data to `f_parser' */ + ZIO *z; + Mbuffer buff; /* buffer to be used by the scanner */ + const char *name; +}; + +static void f_parser (lua_State *L, void *ud) { + int i; + Proto *tf; + Closure *cl; + struct SParser *p = cast(struct SParser *, ud); + int c = luaZ_lookahead(p->z); + luaC_checkGC(L); + tf = ((c == LUA_SIGNATURE[0]) ? luaU_undump : luaY_parser)(L, p->z, + &p->buff, p->name); + cl = luaF_newLclosure(L, tf->nups, hvalue(gt(L))); + cl->l.p = tf; + for (i = 0; i < tf->nups; i++) /* initialize eventual upvalues */ + cl->l.upvals[i] = luaF_newupval(L); + setclvalue(L, L->top, cl); + incr_top(L); +} + + +int luaD_protectedparser (lua_State *L, ZIO *z, const char *name) { + struct SParser p; + int status; + p.z = z; p.name = name; + luaZ_initbuffer(L, &p.buff); + status = luaD_pcall(L, f_parser, &p, savestack(L, L->top), L->errfunc); + luaZ_freebuffer(L, &p.buff); + return status; +} + + diff --git a/mk/linux/mojosetup/lua/src/ldo.h b/mk/linux/mojosetup/lua/src/ldo.h new file mode 100644 index 00000000..98fddac5 --- /dev/null +++ b/mk/linux/mojosetup/lua/src/ldo.h @@ -0,0 +1,57 @@ +/* +** $Id: ldo.h,v 2.7.1.1 2007/12/27 13:02:25 roberto Exp $ +** Stack and Call structure of Lua +** See Copyright Notice in lua.h +*/ + +#ifndef ldo_h +#define ldo_h + + +#include "lobject.h" +#include "lstate.h" +#include "lzio.h" + + +#define luaD_checkstack(L,n) \ + if ((char *)L->stack_last - (char *)L->top <= (n)*(int)sizeof(TValue)) \ + luaD_growstack(L, n); \ + else condhardstacktests(luaD_reallocstack(L, L->stacksize - EXTRA_STACK - 1)); + + +#define incr_top(L) {luaD_checkstack(L,1); L->top++;} + +#define savestack(L,p) ((char *)(p) - (char *)L->stack) +#define restorestack(L,n) ((TValue *)((char *)L->stack + (n))) + +#define saveci(L,p) ((char *)(p) - (char *)L->base_ci) +#define restoreci(L,n) ((CallInfo *)((char *)L->base_ci + (n))) + + +/* results from luaD_precall */ +#define PCRLUA 0 /* initiated a call to a Lua function */ +#define PCRC 1 /* did a call to a C function */ +#define PCRYIELD 2 /* C funtion yielded */ + + +/* type of protected functions, to be ran by `runprotected' */ +typedef void (*Pfunc) (lua_State *L, void *ud); + +LUAI_FUNC int luaD_protectedparser (lua_State *L, ZIO *z, const char *name); +LUAI_FUNC void luaD_callhook (lua_State *L, int event, int line); +LUAI_FUNC int luaD_precall (lua_State *L, StkId func, int nresults); +LUAI_FUNC void luaD_call (lua_State *L, StkId func, int nResults); +LUAI_FUNC int luaD_pcall (lua_State *L, Pfunc func, void *u, + ptrdiff_t oldtop, ptrdiff_t ef); +LUAI_FUNC int luaD_poscall (lua_State *L, StkId firstResult); +LUAI_FUNC void luaD_reallocCI (lua_State *L, int newsize); +LUAI_FUNC void luaD_reallocstack (lua_State *L, int newsize); +LUAI_FUNC void luaD_growstack (lua_State *L, int n); + +LUAI_FUNC void luaD_throw (lua_State *L, int errcode); +LUAI_FUNC int luaD_rawrunprotected (lua_State *L, Pfunc f, void *ud); + +LUAI_FUNC void luaD_seterrorobj (lua_State *L, int errcode, StkId oldtop); + +#endif + diff --git a/mk/linux/mojosetup/lua/src/ldump.c b/mk/linux/mojosetup/lua/src/ldump.c new file mode 100644 index 00000000..c9d3d487 --- /dev/null +++ b/mk/linux/mojosetup/lua/src/ldump.c @@ -0,0 +1,164 @@ +/* +** $Id: ldump.c,v 2.8.1.1 2007/12/27 13:02:25 roberto Exp $ +** save precompiled Lua chunks +** See Copyright Notice in lua.h +*/ + +#include + +#define ldump_c +#define LUA_CORE + +#include "lua.h" + +#include "lobject.h" +#include "lstate.h" +#include "lundump.h" + +typedef struct { + lua_State* L; + lua_Writer writer; + void* data; + int strip; + int status; +} DumpState; + +#define DumpMem(b,n,size,D) DumpBlock(b,(n)*(size),D) +#define DumpVar(x,D) DumpMem(&x,1,sizeof(x),D) + +static void DumpBlock(const void* b, size_t size, DumpState* D) +{ + if (D->status==0) + { + lua_unlock(D->L); + D->status=(*D->writer)(D->L,b,size,D->data); + lua_lock(D->L); + } +} + +static void DumpChar(int y, DumpState* D) +{ + char x=(char)y; + DumpVar(x,D); +} + +static void DumpInt(int x, DumpState* D) +{ + DumpVar(x,D); +} + +static void DumpNumber(lua_Number x, DumpState* D) +{ + DumpVar(x,D); +} + +static void DumpVector(const void* b, int n, size_t size, DumpState* D) +{ + DumpInt(n,D); + DumpMem(b,n,size,D); +} + +static void DumpString(const TString* s, DumpState* D) +{ + if (s==NULL || getstr(s)==NULL) + { + size_t size=0; + DumpVar(size,D); + } + else + { + size_t size=s->tsv.len+1; /* include trailing '\0' */ + DumpVar(size,D); + DumpBlock(getstr(s),size,D); + } +} + +#define DumpCode(f,D) DumpVector(f->code,f->sizecode,sizeof(Instruction),D) + +static void DumpFunction(const Proto* f, const TString* p, DumpState* D); + +static void DumpConstants(const Proto* f, DumpState* D) +{ + int i,n=f->sizek; + DumpInt(n,D); + for (i=0; ik[i]; + DumpChar(ttype(o),D); + switch (ttype(o)) + { + case LUA_TNIL: + break; + case LUA_TBOOLEAN: + DumpChar(bvalue(o),D); + break; + case LUA_TNUMBER: + DumpNumber(nvalue(o),D); + break; + case LUA_TSTRING: + DumpString(rawtsvalue(o),D); + break; + default: + lua_assert(0); /* cannot happen */ + break; + } + } + n=f->sizep; + DumpInt(n,D); + for (i=0; ip[i],f->source,D); +} + +static void DumpDebug(const Proto* f, DumpState* D) +{ + int i,n; + n= (D->strip) ? 0 : f->sizelineinfo; + DumpVector(f->lineinfo,n,sizeof(int),D); + n= (D->strip) ? 0 : f->sizelocvars; + DumpInt(n,D); + for (i=0; ilocvars[i].varname,D); + DumpInt(f->locvars[i].startpc,D); + DumpInt(f->locvars[i].endpc,D); + } + n= (D->strip) ? 0 : f->sizeupvalues; + DumpInt(n,D); + for (i=0; iupvalues[i],D); +} + +static void DumpFunction(const Proto* f, const TString* p, DumpState* D) +{ + DumpString((f->source==p || D->strip) ? NULL : f->source,D); + DumpInt(f->linedefined,D); + DumpInt(f->lastlinedefined,D); + DumpChar(f->nups,D); + DumpChar(f->numparams,D); + DumpChar(f->is_vararg,D); + DumpChar(f->maxstacksize,D); + DumpCode(f,D); + DumpConstants(f,D); + DumpDebug(f,D); +} + +static void DumpHeader(DumpState* D) +{ + char h[LUAC_HEADERSIZE]; + luaU_header(h); + DumpBlock(h,LUAC_HEADERSIZE,D); +} + +/* +** dump Lua function as precompiled chunk +*/ +int luaU_dump (lua_State* L, const Proto* f, lua_Writer w, void* data, int strip) +{ + DumpState D; + D.L=L; + D.writer=w; + D.data=data; + D.strip=strip; + D.status=0; + DumpHeader(&D); + DumpFunction(f,NULL,&D); + return D.status; +} diff --git a/mk/linux/mojosetup/lua/src/lfunc.c b/mk/linux/mojosetup/lua/src/lfunc.c new file mode 100644 index 00000000..813e88f5 --- /dev/null +++ b/mk/linux/mojosetup/lua/src/lfunc.c @@ -0,0 +1,174 @@ +/* +** $Id: lfunc.c,v 2.12.1.2 2007/12/28 14:58:43 roberto Exp $ +** Auxiliary functions to manipulate prototypes and closures +** See Copyright Notice in lua.h +*/ + + +#include + +#define lfunc_c +#define LUA_CORE + +#include "lua.h" + +#include "lfunc.h" +#include "lgc.h" +#include "lmem.h" +#include "lobject.h" +#include "lstate.h" + + + +Closure *luaF_newCclosure (lua_State *L, int nelems, Table *e) { + Closure *c = cast(Closure *, luaM_malloc(L, sizeCclosure(nelems))); + luaC_link(L, obj2gco(c), LUA_TFUNCTION); + c->c.isC = 1; + c->c.env = e; + c->c.nupvalues = cast_byte(nelems); + return c; +} + + +Closure *luaF_newLclosure (lua_State *L, int nelems, Table *e) { + Closure *c = cast(Closure *, luaM_malloc(L, sizeLclosure(nelems))); + luaC_link(L, obj2gco(c), LUA_TFUNCTION); + c->l.isC = 0; + c->l.env = e; + c->l.nupvalues = cast_byte(nelems); + while (nelems--) c->l.upvals[nelems] = NULL; + return c; +} + + +UpVal *luaF_newupval (lua_State *L) { + UpVal *uv = luaM_new(L, UpVal); + luaC_link(L, obj2gco(uv), LUA_TUPVAL); + uv->v = &uv->u.value; + setnilvalue(uv->v); + return uv; +} + + +UpVal *luaF_findupval (lua_State *L, StkId level) { + global_State *g = G(L); + GCObject **pp = &L->openupval; + UpVal *p; + UpVal *uv; + while (*pp != NULL && (p = ngcotouv(*pp))->v >= level) { + lua_assert(p->v != &p->u.value); + if (p->v == level) { /* found a corresponding upvalue? */ + if (isdead(g, obj2gco(p))) /* is it dead? */ + changewhite(obj2gco(p)); /* ressurect it */ + return p; + } + pp = &p->next; + } + uv = luaM_new(L, UpVal); /* not found: create a new one */ + uv->tt = LUA_TUPVAL; + uv->marked = luaC_white(g); + uv->v = level; /* current value lives in the stack */ + uv->next = *pp; /* chain it in the proper position */ + *pp = obj2gco(uv); + uv->u.l.prev = &g->uvhead; /* double link it in `uvhead' list */ + uv->u.l.next = g->uvhead.u.l.next; + uv->u.l.next->u.l.prev = uv; + g->uvhead.u.l.next = uv; + lua_assert(uv->u.l.next->u.l.prev == uv && uv->u.l.prev->u.l.next == uv); + return uv; +} + + +static void unlinkupval (UpVal *uv) { + lua_assert(uv->u.l.next->u.l.prev == uv && uv->u.l.prev->u.l.next == uv); + uv->u.l.next->u.l.prev = uv->u.l.prev; /* remove from `uvhead' list */ + uv->u.l.prev->u.l.next = uv->u.l.next; +} + + +void luaF_freeupval (lua_State *L, UpVal *uv) { + if (uv->v != &uv->u.value) /* is it open? */ + unlinkupval(uv); /* remove from open list */ + luaM_free(L, uv); /* free upvalue */ +} + + +void luaF_close (lua_State *L, StkId level) { + UpVal *uv; + global_State *g = G(L); + while (L->openupval != NULL && (uv = ngcotouv(L->openupval))->v >= level) { + GCObject *o = obj2gco(uv); + lua_assert(!isblack(o) && uv->v != &uv->u.value); + L->openupval = uv->next; /* remove from `open' list */ + if (isdead(g, o)) + luaF_freeupval(L, uv); /* free upvalue */ + else { + unlinkupval(uv); + setobj(L, &uv->u.value, uv->v); + uv->v = &uv->u.value; /* now current value lives here */ + luaC_linkupval(L, uv); /* link upvalue into `gcroot' list */ + } + } +} + + +Proto *luaF_newproto (lua_State *L) { + Proto *f = luaM_new(L, Proto); + luaC_link(L, obj2gco(f), LUA_TPROTO); + f->k = NULL; + f->sizek = 0; + f->p = NULL; + f->sizep = 0; + f->code = NULL; + f->sizecode = 0; + f->sizelineinfo = 0; + f->sizeupvalues = 0; + f->nups = 0; + f->upvalues = NULL; + f->numparams = 0; + f->is_vararg = 0; + f->maxstacksize = 0; + f->lineinfo = NULL; + f->sizelocvars = 0; + f->locvars = NULL; + f->linedefined = 0; + f->lastlinedefined = 0; + f->source = NULL; + return f; +} + + +void luaF_freeproto (lua_State *L, Proto *f) { + luaM_freearray(L, f->code, f->sizecode, Instruction); + luaM_freearray(L, f->p, f->sizep, Proto *); + luaM_freearray(L, f->k, f->sizek, TValue); + luaM_freearray(L, f->lineinfo, f->sizelineinfo, int); + luaM_freearray(L, f->locvars, f->sizelocvars, struct LocVar); + luaM_freearray(L, f->upvalues, f->sizeupvalues, TString *); + luaM_free(L, f); +} + + +void luaF_freeclosure (lua_State *L, Closure *c) { + int size = (c->c.isC) ? sizeCclosure(c->c.nupvalues) : + sizeLclosure(c->l.nupvalues); + luaM_freemem(L, c, size); +} + + +/* +** Look for n-th local variable at line `line' in function `func'. +** Returns NULL if not found. +*/ +const char *luaF_getlocalname (const Proto *f, int local_number, int pc) { + int i; + for (i = 0; isizelocvars && f->locvars[i].startpc <= pc; i++) { + if (pc < f->locvars[i].endpc) { /* is variable active? */ + local_number--; + if (local_number == 0) + return getstr(f->locvars[i].varname); + } + } + return NULL; /* not found */ +} + diff --git a/mk/linux/mojosetup/lua/src/lfunc.h b/mk/linux/mojosetup/lua/src/lfunc.h new file mode 100644 index 00000000..a68cf515 --- /dev/null +++ b/mk/linux/mojosetup/lua/src/lfunc.h @@ -0,0 +1,34 @@ +/* +** $Id: lfunc.h,v 2.4.1.1 2007/12/27 13:02:25 roberto Exp $ +** Auxiliary functions to manipulate prototypes and closures +** See Copyright Notice in lua.h +*/ + +#ifndef lfunc_h +#define lfunc_h + + +#include "lobject.h" + + +#define sizeCclosure(n) (cast(int, sizeof(CClosure)) + \ + cast(int, sizeof(TValue)*((n)-1))) + +#define sizeLclosure(n) (cast(int, sizeof(LClosure)) + \ + cast(int, sizeof(TValue *)*((n)-1))) + + +LUAI_FUNC Proto *luaF_newproto (lua_State *L); +LUAI_FUNC Closure *luaF_newCclosure (lua_State *L, int nelems, Table *e); +LUAI_FUNC Closure *luaF_newLclosure (lua_State *L, int nelems, Table *e); +LUAI_FUNC UpVal *luaF_newupval (lua_State *L); +LUAI_FUNC UpVal *luaF_findupval (lua_State *L, StkId level); +LUAI_FUNC void luaF_close (lua_State *L, StkId level); +LUAI_FUNC void luaF_freeproto (lua_State *L, Proto *f); +LUAI_FUNC void luaF_freeclosure (lua_State *L, Closure *c); +LUAI_FUNC void luaF_freeupval (lua_State *L, UpVal *uv); +LUAI_FUNC const char *luaF_getlocalname (const Proto *func, int local_number, + int pc); + + +#endif diff --git a/mk/linux/mojosetup/lua/src/lgc.c b/mk/linux/mojosetup/lua/src/lgc.c new file mode 100644 index 00000000..d9e0b782 --- /dev/null +++ b/mk/linux/mojosetup/lua/src/lgc.c @@ -0,0 +1,711 @@ +/* +** $Id: lgc.c,v 2.38.1.1 2007/12/27 13:02:25 roberto Exp $ +** Garbage Collector +** See Copyright Notice in lua.h +*/ + +#include + +#define lgc_c +#define LUA_CORE + +#include "lua.h" + +#include "ldebug.h" +#include "ldo.h" +#include "lfunc.h" +#include "lgc.h" +#include "lmem.h" +#include "lobject.h" +#include "lstate.h" +#include "lstring.h" +#include "ltable.h" +#include "ltm.h" + + +#define GCSTEPSIZE 1024u +#define GCSWEEPMAX 40 +#define GCSWEEPCOST 10 +#define GCFINALIZECOST 100 + + +#define maskmarks cast_byte(~(bitmask(BLACKBIT)|WHITEBITS)) + +#define makewhite(g,x) \ + ((x)->gch.marked = cast_byte(((x)->gch.marked & maskmarks) | luaC_white(g))) + +#define white2gray(x) reset2bits((x)->gch.marked, WHITE0BIT, WHITE1BIT) +#define black2gray(x) resetbit((x)->gch.marked, BLACKBIT) + +#define stringmark(s) reset2bits((s)->tsv.marked, WHITE0BIT, WHITE1BIT) + + +#define isfinalized(u) testbit((u)->marked, FINALIZEDBIT) +#define markfinalized(u) l_setbit((u)->marked, FINALIZEDBIT) + + +#define KEYWEAK bitmask(KEYWEAKBIT) +#define VALUEWEAK bitmask(VALUEWEAKBIT) + + + +#define markvalue(g,o) { checkconsistency(o); \ + if (iscollectable(o) && iswhite(gcvalue(o))) reallymarkobject(g,gcvalue(o)); } + +#define markobject(g,t) { if (iswhite(obj2gco(t))) \ + reallymarkobject(g, obj2gco(t)); } + + +#define setthreshold(g) (g->GCthreshold = (g->estimate/100) * g->gcpause) + + +static void removeentry (Node *n) { + lua_assert(ttisnil(gval(n))); + if (iscollectable(gkey(n))) + setttype(gkey(n), LUA_TDEADKEY); /* dead key; remove it */ +} + + +static void reallymarkobject (global_State *g, GCObject *o) { + lua_assert(iswhite(o) && !isdead(g, o)); + white2gray(o); + switch (o->gch.tt) { + case LUA_TSTRING: { + return; + } + case LUA_TUSERDATA: { + Table *mt = gco2u(o)->metatable; + gray2black(o); /* udata are never gray */ + if (mt) markobject(g, mt); + markobject(g, gco2u(o)->env); + return; + } + case LUA_TUPVAL: { + UpVal *uv = gco2uv(o); + markvalue(g, uv->v); + if (uv->v == &uv->u.value) /* closed? */ + gray2black(o); /* open upvalues are never black */ + return; + } + case LUA_TFUNCTION: { + gco2cl(o)->c.gclist = g->gray; + g->gray = o; + break; + } + case LUA_TTABLE: { + gco2h(o)->gclist = g->gray; + g->gray = o; + break; + } + case LUA_TTHREAD: { + gco2th(o)->gclist = g->gray; + g->gray = o; + break; + } + case LUA_TPROTO: { + gco2p(o)->gclist = g->gray; + g->gray = o; + break; + } + default: lua_assert(0); + } +} + + +static void marktmu (global_State *g) { + GCObject *u = g->tmudata; + if (u) { + do { + u = u->gch.next; + makewhite(g, u); /* may be marked, if left from previous GC */ + reallymarkobject(g, u); + } while (u != g->tmudata); + } +} + + +/* move `dead' udata that need finalization to list `tmudata' */ +size_t luaC_separateudata (lua_State *L, int all) { + global_State *g = G(L); + size_t deadmem = 0; + GCObject **p = &g->mainthread->next; + GCObject *curr; + while ((curr = *p) != NULL) { + if (!(iswhite(curr) || all) || isfinalized(gco2u(curr))) + p = &curr->gch.next; /* don't bother with them */ + else if (fasttm(L, gco2u(curr)->metatable, TM_GC) == NULL) { + markfinalized(gco2u(curr)); /* don't need finalization */ + p = &curr->gch.next; + } + else { /* must call its gc method */ + deadmem += sizeudata(gco2u(curr)); + markfinalized(gco2u(curr)); + *p = curr->gch.next; + /* link `curr' at the end of `tmudata' list */ + if (g->tmudata == NULL) /* list is empty? */ + g->tmudata = curr->gch.next = curr; /* creates a circular list */ + else { + curr->gch.next = g->tmudata->gch.next; + g->tmudata->gch.next = curr; + g->tmudata = curr; + } + } + } + return deadmem; +} + + +static int traversetable (global_State *g, Table *h) { + int i; + int weakkey = 0; + int weakvalue = 0; + const TValue *mode; + if (h->metatable) + markobject(g, h->metatable); + mode = gfasttm(g, h->metatable, TM_MODE); + if (mode && ttisstring(mode)) { /* is there a weak mode? */ + weakkey = (strchr(svalue(mode), 'k') != NULL); + weakvalue = (strchr(svalue(mode), 'v') != NULL); + if (weakkey || weakvalue) { /* is really weak? */ + h->marked &= ~(KEYWEAK | VALUEWEAK); /* clear bits */ + h->marked |= cast_byte((weakkey << KEYWEAKBIT) | + (weakvalue << VALUEWEAKBIT)); + h->gclist = g->weak; /* must be cleared after GC, ... */ + g->weak = obj2gco(h); /* ... so put in the appropriate list */ + } + } + if (weakkey && weakvalue) return 1; + if (!weakvalue) { + i = h->sizearray; + while (i--) + markvalue(g, &h->array[i]); + } + i = sizenode(h); + while (i--) { + Node *n = gnode(h, i); + lua_assert(ttype(gkey(n)) != LUA_TDEADKEY || ttisnil(gval(n))); + if (ttisnil(gval(n))) + removeentry(n); /* remove empty entries */ + else { + lua_assert(!ttisnil(gkey(n))); + if (!weakkey) markvalue(g, gkey(n)); + if (!weakvalue) markvalue(g, gval(n)); + } + } + return weakkey || weakvalue; +} + + +/* +** All marks are conditional because a GC may happen while the +** prototype is still being created +*/ +static void traverseproto (global_State *g, Proto *f) { + int i; + if (f->source) stringmark(f->source); + for (i=0; isizek; i++) /* mark literals */ + markvalue(g, &f->k[i]); + for (i=0; isizeupvalues; i++) { /* mark upvalue names */ + if (f->upvalues[i]) + stringmark(f->upvalues[i]); + } + for (i=0; isizep; i++) { /* mark nested protos */ + if (f->p[i]) + markobject(g, f->p[i]); + } + for (i=0; isizelocvars; i++) { /* mark local-variable names */ + if (f->locvars[i].varname) + stringmark(f->locvars[i].varname); + } +} + + + +static void traverseclosure (global_State *g, Closure *cl) { + markobject(g, cl->c.env); + if (cl->c.isC) { + int i; + for (i=0; ic.nupvalues; i++) /* mark its upvalues */ + markvalue(g, &cl->c.upvalue[i]); + } + else { + int i; + lua_assert(cl->l.nupvalues == cl->l.p->nups); + markobject(g, cl->l.p); + for (i=0; il.nupvalues; i++) /* mark its upvalues */ + markobject(g, cl->l.upvals[i]); + } +} + + +static void checkstacksizes (lua_State *L, StkId max) { + int ci_used = cast_int(L->ci - L->base_ci); /* number of `ci' in use */ + int s_used = cast_int(max - L->stack); /* part of stack in use */ + if (L->size_ci > LUAI_MAXCALLS) /* handling overflow? */ + return; /* do not touch the stacks */ + if (4*ci_used < L->size_ci && 2*BASIC_CI_SIZE < L->size_ci) + luaD_reallocCI(L, L->size_ci/2); /* still big enough... */ + condhardstacktests(luaD_reallocCI(L, ci_used + 1)); + if (4*s_used < L->stacksize && + 2*(BASIC_STACK_SIZE+EXTRA_STACK) < L->stacksize) + luaD_reallocstack(L, L->stacksize/2); /* still big enough... */ + condhardstacktests(luaD_reallocstack(L, s_used)); +} + + +static void traversestack (global_State *g, lua_State *l) { + StkId o, lim; + CallInfo *ci; + markvalue(g, gt(l)); + lim = l->top; + for (ci = l->base_ci; ci <= l->ci; ci++) { + lua_assert(ci->top <= l->stack_last); + if (lim < ci->top) lim = ci->top; + } + for (o = l->stack; o < l->top; o++) + markvalue(g, o); + for (; o <= lim; o++) + setnilvalue(o); + checkstacksizes(l, lim); +} + + +/* +** traverse one gray object, turning it to black. +** Returns `quantity' traversed. +*/ +static l_mem propagatemark (global_State *g) { + GCObject *o = g->gray; + lua_assert(isgray(o)); + gray2black(o); + switch (o->gch.tt) { + case LUA_TTABLE: { + Table *h = gco2h(o); + g->gray = h->gclist; + if (traversetable(g, h)) /* table is weak? */ + black2gray(o); /* keep it gray */ + return sizeof(Table) + sizeof(TValue) * h->sizearray + + sizeof(Node) * sizenode(h); + } + case LUA_TFUNCTION: { + Closure *cl = gco2cl(o); + g->gray = cl->c.gclist; + traverseclosure(g, cl); + return (cl->c.isC) ? sizeCclosure(cl->c.nupvalues) : + sizeLclosure(cl->l.nupvalues); + } + case LUA_TTHREAD: { + lua_State *th = gco2th(o); + g->gray = th->gclist; + th->gclist = g->grayagain; + g->grayagain = o; + black2gray(o); + traversestack(g, th); + return sizeof(lua_State) + sizeof(TValue) * th->stacksize + + sizeof(CallInfo) * th->size_ci; + } + case LUA_TPROTO: { + Proto *p = gco2p(o); + g->gray = p->gclist; + traverseproto(g, p); + return sizeof(Proto) + sizeof(Instruction) * p->sizecode + + sizeof(Proto *) * p->sizep + + sizeof(TValue) * p->sizek + + sizeof(int) * p->sizelineinfo + + sizeof(LocVar) * p->sizelocvars + + sizeof(TString *) * p->sizeupvalues; + } + default: lua_assert(0); return 0; + } +} + + +static size_t propagateall (global_State *g) { + size_t m = 0; + while (g->gray) m += propagatemark(g); + return m; +} + + +/* +** The next function tells whether a key or value can be cleared from +** a weak table. Non-collectable objects are never removed from weak +** tables. Strings behave as `values', so are never removed too. for +** other objects: if really collected, cannot keep them; for userdata +** being finalized, keep them in keys, but not in values +*/ +static int iscleared (const TValue *o, int iskey) { + if (!iscollectable(o)) return 0; + if (ttisstring(o)) { + stringmark(rawtsvalue(o)); /* strings are `values', so are never weak */ + return 0; + } + return iswhite(gcvalue(o)) || + (ttisuserdata(o) && (!iskey && isfinalized(uvalue(o)))); +} + + +/* +** clear collected entries from weaktables +*/ +static void cleartable (GCObject *l) { + while (l) { + Table *h = gco2h(l); + int i = h->sizearray; + lua_assert(testbit(h->marked, VALUEWEAKBIT) || + testbit(h->marked, KEYWEAKBIT)); + if (testbit(h->marked, VALUEWEAKBIT)) { + while (i--) { + TValue *o = &h->array[i]; + if (iscleared(o, 0)) /* value was collected? */ + setnilvalue(o); /* remove value */ + } + } + i = sizenode(h); + while (i--) { + Node *n = gnode(h, i); + if (!ttisnil(gval(n)) && /* non-empty entry? */ + (iscleared(key2tval(n), 1) || iscleared(gval(n), 0))) { + setnilvalue(gval(n)); /* remove value ... */ + removeentry(n); /* remove entry from table */ + } + } + l = h->gclist; + } +} + + +static void freeobj (lua_State *L, GCObject *o) { + switch (o->gch.tt) { + case LUA_TPROTO: luaF_freeproto(L, gco2p(o)); break; + case LUA_TFUNCTION: luaF_freeclosure(L, gco2cl(o)); break; + case LUA_TUPVAL: luaF_freeupval(L, gco2uv(o)); break; + case LUA_TTABLE: luaH_free(L, gco2h(o)); break; + case LUA_TTHREAD: { + lua_assert(gco2th(o) != L && gco2th(o) != G(L)->mainthread); + luaE_freethread(L, gco2th(o)); + break; + } + case LUA_TSTRING: { + G(L)->strt.nuse--; + luaM_freemem(L, o, sizestring(gco2ts(o))); + break; + } + case LUA_TUSERDATA: { + luaM_freemem(L, o, sizeudata(gco2u(o))); + break; + } + default: lua_assert(0); + } +} + + + +#define sweepwholelist(L,p) sweeplist(L,p,MAX_LUMEM) + + +static GCObject **sweeplist (lua_State *L, GCObject **p, lu_mem count) { + GCObject *curr; + global_State *g = G(L); + int deadmask = otherwhite(g); + while ((curr = *p) != NULL && count-- > 0) { + if (curr->gch.tt == LUA_TTHREAD) /* sweep open upvalues of each thread */ + sweepwholelist(L, &gco2th(curr)->openupval); + if ((curr->gch.marked ^ WHITEBITS) & deadmask) { /* not dead? */ + lua_assert(!isdead(g, curr) || testbit(curr->gch.marked, FIXEDBIT)); + makewhite(g, curr); /* make it white (for next cycle) */ + p = &curr->gch.next; + } + else { /* must erase `curr' */ + lua_assert(isdead(g, curr) || deadmask == bitmask(SFIXEDBIT)); + *p = curr->gch.next; + if (curr == g->rootgc) /* is the first element of the list? */ + g->rootgc = curr->gch.next; /* adjust first */ + freeobj(L, curr); + } + } + return p; +} + + +static void checkSizes (lua_State *L) { + global_State *g = G(L); + /* check size of string hash */ + if (g->strt.nuse < cast(lu_int32, g->strt.size/4) && + g->strt.size > MINSTRTABSIZE*2) + luaS_resize(L, g->strt.size/2); /* table is too big */ + /* check size of buffer */ + if (luaZ_sizebuffer(&g->buff) > LUA_MINBUFFER*2) { /* buffer too big? */ + size_t newsize = luaZ_sizebuffer(&g->buff) / 2; + luaZ_resizebuffer(L, &g->buff, newsize); + } +} + + +static void GCTM (lua_State *L) { + global_State *g = G(L); + GCObject *o = g->tmudata->gch.next; /* get first element */ + Udata *udata = rawgco2u(o); + const TValue *tm; + /* remove udata from `tmudata' */ + if (o == g->tmudata) /* last element? */ + g->tmudata = NULL; + else + g->tmudata->gch.next = udata->uv.next; + udata->uv.next = g->mainthread->next; /* return it to `root' list */ + g->mainthread->next = o; + makewhite(g, o); + tm = fasttm(L, udata->uv.metatable, TM_GC); + if (tm != NULL) { + lu_byte oldah = L->allowhook; + lu_mem oldt = g->GCthreshold; + L->allowhook = 0; /* stop debug hooks during GC tag method */ + g->GCthreshold = 2*g->totalbytes; /* avoid GC steps */ + setobj2s(L, L->top, tm); + setuvalue(L, L->top+1, udata); + L->top += 2; + luaD_call(L, L->top - 2, 0); + L->allowhook = oldah; /* restore hooks */ + g->GCthreshold = oldt; /* restore threshold */ + } +} + + +/* +** Call all GC tag methods +*/ +void luaC_callGCTM (lua_State *L) { + while (G(L)->tmudata) + GCTM(L); +} + + +void luaC_freeall (lua_State *L) { + global_State *g = G(L); + int i; + g->currentwhite = WHITEBITS | bitmask(SFIXEDBIT); /* mask to collect all elements */ + sweepwholelist(L, &g->rootgc); + for (i = 0; i < g->strt.size; i++) /* free all string lists */ + sweepwholelist(L, &g->strt.hash[i]); +} + + +static void markmt (global_State *g) { + int i; + for (i=0; imt[i]) markobject(g, g->mt[i]); +} + + +/* mark root set */ +static void markroot (lua_State *L) { + global_State *g = G(L); + g->gray = NULL; + g->grayagain = NULL; + g->weak = NULL; + markobject(g, g->mainthread); + /* make global table be traversed before main stack */ + markvalue(g, gt(g->mainthread)); + markvalue(g, registry(L)); + markmt(g); + g->gcstate = GCSpropagate; +} + + +static void remarkupvals (global_State *g) { + UpVal *uv; + for (uv = g->uvhead.u.l.next; uv != &g->uvhead; uv = uv->u.l.next) { + lua_assert(uv->u.l.next->u.l.prev == uv && uv->u.l.prev->u.l.next == uv); + if (isgray(obj2gco(uv))) + markvalue(g, uv->v); + } +} + + +static void atomic (lua_State *L) { + global_State *g = G(L); + size_t udsize; /* total size of userdata to be finalized */ + /* remark occasional upvalues of (maybe) dead threads */ + remarkupvals(g); + /* traverse objects cautch by write barrier and by 'remarkupvals' */ + propagateall(g); + /* remark weak tables */ + g->gray = g->weak; + g->weak = NULL; + lua_assert(!iswhite(obj2gco(g->mainthread))); + markobject(g, L); /* mark running thread */ + markmt(g); /* mark basic metatables (again) */ + propagateall(g); + /* remark gray again */ + g->gray = g->grayagain; + g->grayagain = NULL; + propagateall(g); + udsize = luaC_separateudata(L, 0); /* separate userdata to be finalized */ + marktmu(g); /* mark `preserved' userdata */ + udsize += propagateall(g); /* remark, to propagate `preserveness' */ + cleartable(g->weak); /* remove collected objects from weak tables */ + /* flip current white */ + g->currentwhite = cast_byte(otherwhite(g)); + g->sweepstrgc = 0; + g->sweepgc = &g->rootgc; + g->gcstate = GCSsweepstring; + g->estimate = g->totalbytes - udsize; /* first estimate */ +} + + +static l_mem singlestep (lua_State *L) { + global_State *g = G(L); + /*lua_checkmemory(L);*/ + switch (g->gcstate) { + case GCSpause: { + markroot(L); /* start a new collection */ + return 0; + } + case GCSpropagate: { + if (g->gray) + return propagatemark(g); + else { /* no more `gray' objects */ + atomic(L); /* finish mark phase */ + return 0; + } + } + case GCSsweepstring: { + lu_mem old = g->totalbytes; + sweepwholelist(L, &g->strt.hash[g->sweepstrgc++]); + if (g->sweepstrgc >= g->strt.size) /* nothing more to sweep? */ + g->gcstate = GCSsweep; /* end sweep-string phase */ + lua_assert(old >= g->totalbytes); + g->estimate -= old - g->totalbytes; + return GCSWEEPCOST; + } + case GCSsweep: { + lu_mem old = g->totalbytes; + g->sweepgc = sweeplist(L, g->sweepgc, GCSWEEPMAX); + if (*g->sweepgc == NULL) { /* nothing more to sweep? */ + checkSizes(L); + g->gcstate = GCSfinalize; /* end sweep phase */ + } + lua_assert(old >= g->totalbytes); + g->estimate -= old - g->totalbytes; + return GCSWEEPMAX*GCSWEEPCOST; + } + case GCSfinalize: { + if (g->tmudata) { + GCTM(L); + if (g->estimate > GCFINALIZECOST) + g->estimate -= GCFINALIZECOST; + return GCFINALIZECOST; + } + else { + g->gcstate = GCSpause; /* end collection */ + g->gcdept = 0; + return 0; + } + } + default: lua_assert(0); return 0; + } +} + + +void luaC_step (lua_State *L) { + global_State *g = G(L); + l_mem lim = (GCSTEPSIZE/100) * g->gcstepmul; + if (lim == 0) + lim = (MAX_LUMEM-1)/2; /* no limit */ + g->gcdept += g->totalbytes - g->GCthreshold; + do { + lim -= singlestep(L); + if (g->gcstate == GCSpause) + break; + } while (lim > 0); + if (g->gcstate != GCSpause) { + if (g->gcdept < GCSTEPSIZE) + g->GCthreshold = g->totalbytes + GCSTEPSIZE; /* - lim/g->gcstepmul;*/ + else { + g->gcdept -= GCSTEPSIZE; + g->GCthreshold = g->totalbytes; + } + } + else { + lua_assert(g->totalbytes >= g->estimate); + setthreshold(g); + } +} + + +void luaC_fullgc (lua_State *L) { + global_State *g = G(L); + if (g->gcstate <= GCSpropagate) { + /* reset sweep marks to sweep all elements (returning them to white) */ + g->sweepstrgc = 0; + g->sweepgc = &g->rootgc; + /* reset other collector lists */ + g->gray = NULL; + g->grayagain = NULL; + g->weak = NULL; + g->gcstate = GCSsweepstring; + } + lua_assert(g->gcstate != GCSpause && g->gcstate != GCSpropagate); + /* finish any pending sweep phase */ + while (g->gcstate != GCSfinalize) { + lua_assert(g->gcstate == GCSsweepstring || g->gcstate == GCSsweep); + singlestep(L); + } + markroot(L); + while (g->gcstate != GCSpause) { + singlestep(L); + } + setthreshold(g); +} + + +void luaC_barrierf (lua_State *L, GCObject *o, GCObject *v) { + global_State *g = G(L); + lua_assert(isblack(o) && iswhite(v) && !isdead(g, v) && !isdead(g, o)); + lua_assert(g->gcstate != GCSfinalize && g->gcstate != GCSpause); + lua_assert(ttype(&o->gch) != LUA_TTABLE); + /* must keep invariant? */ + if (g->gcstate == GCSpropagate) + reallymarkobject(g, v); /* restore invariant */ + else /* don't mind */ + makewhite(g, o); /* mark as white just to avoid other barriers */ +} + + +void luaC_barrierback (lua_State *L, Table *t) { + global_State *g = G(L); + GCObject *o = obj2gco(t); + lua_assert(isblack(o) && !isdead(g, o)); + lua_assert(g->gcstate != GCSfinalize && g->gcstate != GCSpause); + black2gray(o); /* make table gray (again) */ + t->gclist = g->grayagain; + g->grayagain = o; +} + + +void luaC_link (lua_State *L, GCObject *o, lu_byte tt) { + global_State *g = G(L); + o->gch.next = g->rootgc; + g->rootgc = o; + o->gch.marked = luaC_white(g); + o->gch.tt = tt; +} + + +void luaC_linkupval (lua_State *L, UpVal *uv) { + global_State *g = G(L); + GCObject *o = obj2gco(uv); + o->gch.next = g->rootgc; /* link upvalue into `rootgc' list */ + g->rootgc = o; + if (isgray(o)) { + if (g->gcstate == GCSpropagate) { + gray2black(o); /* closed upvalues need barrier */ + luaC_barrier(L, uv, uv->v); + } + else { /* sweep phase: sweep it (turning it into white) */ + makewhite(g, o); + lua_assert(g->gcstate != GCSfinalize && g->gcstate != GCSpause); + } + } +} + diff --git a/mk/linux/mojosetup/lua/src/lgc.h b/mk/linux/mojosetup/lua/src/lgc.h new file mode 100644 index 00000000..5a8dc605 --- /dev/null +++ b/mk/linux/mojosetup/lua/src/lgc.h @@ -0,0 +1,110 @@ +/* +** $Id: lgc.h,v 2.15.1.1 2007/12/27 13:02:25 roberto Exp $ +** Garbage Collector +** See Copyright Notice in lua.h +*/ + +#ifndef lgc_h +#define lgc_h + + +#include "lobject.h" + + +/* +** Possible states of the Garbage Collector +*/ +#define GCSpause 0 +#define GCSpropagate 1 +#define GCSsweepstring 2 +#define GCSsweep 3 +#define GCSfinalize 4 + + +/* +** some userful bit tricks +*/ +#define resetbits(x,m) ((x) &= cast(lu_byte, ~(m))) +#define setbits(x,m) ((x) |= (m)) +#define testbits(x,m) ((x) & (m)) +#define bitmask(b) (1<<(b)) +#define bit2mask(b1,b2) (bitmask(b1) | bitmask(b2)) +#define l_setbit(x,b) setbits(x, bitmask(b)) +#define resetbit(x,b) resetbits(x, bitmask(b)) +#define testbit(x,b) testbits(x, bitmask(b)) +#define set2bits(x,b1,b2) setbits(x, (bit2mask(b1, b2))) +#define reset2bits(x,b1,b2) resetbits(x, (bit2mask(b1, b2))) +#define test2bits(x,b1,b2) testbits(x, (bit2mask(b1, b2))) + + + +/* +** Layout for bit use in `marked' field: +** bit 0 - object is white (type 0) +** bit 1 - object is white (type 1) +** bit 2 - object is black +** bit 3 - for userdata: has been finalized +** bit 3 - for tables: has weak keys +** bit 4 - for tables: has weak values +** bit 5 - object is fixed (should not be collected) +** bit 6 - object is "super" fixed (only the main thread) +*/ + + +#define WHITE0BIT 0 +#define WHITE1BIT 1 +#define BLACKBIT 2 +#define FINALIZEDBIT 3 +#define KEYWEAKBIT 3 +#define VALUEWEAKBIT 4 +#define FIXEDBIT 5 +#define SFIXEDBIT 6 +#define WHITEBITS bit2mask(WHITE0BIT, WHITE1BIT) + + +#define iswhite(x) test2bits((x)->gch.marked, WHITE0BIT, WHITE1BIT) +#define isblack(x) testbit((x)->gch.marked, BLACKBIT) +#define isgray(x) (!isblack(x) && !iswhite(x)) + +#define otherwhite(g) (g->currentwhite ^ WHITEBITS) +#define isdead(g,v) ((v)->gch.marked & otherwhite(g) & WHITEBITS) + +#define changewhite(x) ((x)->gch.marked ^= WHITEBITS) +#define gray2black(x) l_setbit((x)->gch.marked, BLACKBIT) + +#define valiswhite(x) (iscollectable(x) && iswhite(gcvalue(x))) + +#define luaC_white(g) cast(lu_byte, (g)->currentwhite & WHITEBITS) + + +#define luaC_checkGC(L) { \ + condhardstacktests(luaD_reallocstack(L, L->stacksize - EXTRA_STACK - 1)); \ + if (G(L)->totalbytes >= G(L)->GCthreshold) \ + luaC_step(L); } + + +#define luaC_barrier(L,p,v) { if (valiswhite(v) && isblack(obj2gco(p))) \ + luaC_barrierf(L,obj2gco(p),gcvalue(v)); } + +#define luaC_barriert(L,t,v) { if (valiswhite(v) && isblack(obj2gco(t))) \ + luaC_barrierback(L,t); } + +#define luaC_objbarrier(L,p,o) \ + { if (iswhite(obj2gco(o)) && isblack(obj2gco(p))) \ + luaC_barrierf(L,obj2gco(p),obj2gco(o)); } + +#define luaC_objbarriert(L,t,o) \ + { if (iswhite(obj2gco(o)) && isblack(obj2gco(t))) luaC_barrierback(L,t); } + +LUAI_FUNC size_t luaC_separateudata (lua_State *L, int all); +LUAI_FUNC void luaC_callGCTM (lua_State *L); +LUAI_FUNC void luaC_freeall (lua_State *L); +LUAI_FUNC void luaC_step (lua_State *L); +LUAI_FUNC void luaC_fullgc (lua_State *L); +LUAI_FUNC void luaC_link (lua_State *L, GCObject *o, lu_byte tt); +LUAI_FUNC void luaC_linkupval (lua_State *L, UpVal *uv); +LUAI_FUNC void luaC_barrierf (lua_State *L, GCObject *o, GCObject *v); +LUAI_FUNC void luaC_barrierback (lua_State *L, Table *t); + + +#endif diff --git a/mk/linux/mojosetup/lua/src/linit.c b/mk/linux/mojosetup/lua/src/linit.c new file mode 100644 index 00000000..c1f90dfa --- /dev/null +++ b/mk/linux/mojosetup/lua/src/linit.c @@ -0,0 +1,38 @@ +/* +** $Id: linit.c,v 1.14.1.1 2007/12/27 13:02:25 roberto Exp $ +** Initialization of libraries for lua.c +** See Copyright Notice in lua.h +*/ + + +#define linit_c +#define LUA_LIB + +#include "lua.h" + +#include "lualib.h" +#include "lauxlib.h" + + +static const luaL_Reg lualibs[] = { + {"", luaopen_base}, + {LUA_LOADLIBNAME, luaopen_package}, + {LUA_TABLIBNAME, luaopen_table}, + {LUA_IOLIBNAME, luaopen_io}, + {LUA_OSLIBNAME, luaopen_os}, + {LUA_STRLIBNAME, luaopen_string}, + {LUA_MATHLIBNAME, luaopen_math}, + {LUA_DBLIBNAME, luaopen_debug}, + {NULL, NULL} +}; + + +LUALIB_API void luaL_openlibs (lua_State *L) { + const luaL_Reg *lib = lualibs; + for (; lib->func; lib++) { + lua_pushcfunction(L, lib->func); + lua_pushstring(L, lib->name); + lua_call(L, 1, 0); + } +} + diff --git a/mk/linux/mojosetup/lua/src/liolib.c b/mk/linux/mojosetup/lua/src/liolib.c new file mode 100644 index 00000000..e79ed1cb --- /dev/null +++ b/mk/linux/mojosetup/lua/src/liolib.c @@ -0,0 +1,553 @@ +/* +** $Id: liolib.c,v 2.73.1.3 2008/01/18 17:47:43 roberto Exp $ +** Standard I/O (and system) library +** See Copyright Notice in lua.h +*/ + + +#include +#include +#include +#include + +#define liolib_c +#define LUA_LIB + +#include "lua.h" + +#include "lauxlib.h" +#include "lualib.h" + + + +#define IO_INPUT 1 +#define IO_OUTPUT 2 + + +static const char *const fnames[] = {"input", "output"}; + + +static int pushresult (lua_State *L, int i, const char *filename) { + int en = errno; /* calls to Lua API may change this value */ + if (i) { + lua_pushboolean(L, 1); + return 1; + } + else { + lua_pushnil(L); + if (filename) + lua_pushfstring(L, "%s: %s", filename, strerror(en)); + else + lua_pushfstring(L, "%s", strerror(en)); + lua_pushinteger(L, en); + return 3; + } +} + + +static void fileerror (lua_State *L, int arg, const char *filename) { + lua_pushfstring(L, "%s: %s", filename, strerror(errno)); + luaL_argerror(L, arg, lua_tostring(L, -1)); +} + + +#define tofilep(L) ((FILE **)luaL_checkudata(L, 1, LUA_FILEHANDLE)) + + +static int io_type (lua_State *L) { + void *ud; + luaL_checkany(L, 1); + ud = lua_touserdata(L, 1); + lua_getfield(L, LUA_REGISTRYINDEX, LUA_FILEHANDLE); + if (ud == NULL || !lua_getmetatable(L, 1) || !lua_rawequal(L, -2, -1)) + lua_pushnil(L); /* not a file */ + else if (*((FILE **)ud) == NULL) + lua_pushliteral(L, "closed file"); + else + lua_pushliteral(L, "file"); + return 1; +} + + +static FILE *tofile (lua_State *L) { + FILE **f = tofilep(L); + if (*f == NULL) + luaL_error(L, "attempt to use a closed file"); + return *f; +} + + + +/* +** When creating file handles, always creates a `closed' file handle +** before opening the actual file; so, if there is a memory error, the +** file is not left opened. +*/ +static FILE **newfile (lua_State *L) { + FILE **pf = (FILE **)lua_newuserdata(L, sizeof(FILE *)); + *pf = NULL; /* file handle is currently `closed' */ + luaL_getmetatable(L, LUA_FILEHANDLE); + lua_setmetatable(L, -2); + return pf; +} + + +/* +** function to (not) close the standard files stdin, stdout, and stderr +*/ +static int io_noclose (lua_State *L) { + lua_pushnil(L); + lua_pushliteral(L, "cannot close standard file"); + return 2; +} + + +/* +** function to close 'popen' files +*/ +static int io_pclose (lua_State *L) { + FILE **p = tofilep(L); + int ok = lua_pclose(L, *p); + *p = NULL; + return pushresult(L, ok, NULL); +} + + +/* +** function to close regular files +*/ +static int io_fclose (lua_State *L) { + FILE **p = tofilep(L); + int ok = (fclose(*p) == 0); + *p = NULL; + return pushresult(L, ok, NULL); +} + + +static int aux_close (lua_State *L) { + lua_getfenv(L, 1); + lua_getfield(L, -1, "__close"); + return (lua_tocfunction(L, -1))(L); +} + + +static int io_close (lua_State *L) { + if (lua_isnone(L, 1)) + lua_rawgeti(L, LUA_ENVIRONINDEX, IO_OUTPUT); + tofile(L); /* make sure argument is a file */ + return aux_close(L); +} + + +static int io_gc (lua_State *L) { + FILE *f = *tofilep(L); + /* ignore closed files */ + if (f != NULL) + aux_close(L); + return 0; +} + + +static int io_tostring (lua_State *L) { + FILE *f = *tofilep(L); + if (f == NULL) + lua_pushliteral(L, "file (closed)"); + else + lua_pushfstring(L, "file (%p)", f); + return 1; +} + + +static int io_open (lua_State *L) { + const char *filename = luaL_checkstring(L, 1); + const char *mode = luaL_optstring(L, 2, "r"); + FILE **pf = newfile(L); + *pf = fopen(filename, mode); + return (*pf == NULL) ? pushresult(L, 0, filename) : 1; +} + + +/* +** this function has a separated environment, which defines the +** correct __close for 'popen' files +*/ +static int io_popen (lua_State *L) { + const char *filename = luaL_checkstring(L, 1); + const char *mode = luaL_optstring(L, 2, "r"); + FILE **pf = newfile(L); + *pf = lua_popen(L, filename, mode); + return (*pf == NULL) ? pushresult(L, 0, filename) : 1; +} + + +static int io_tmpfile (lua_State *L) { + FILE **pf = newfile(L); + *pf = tmpfile(); + return (*pf == NULL) ? pushresult(L, 0, NULL) : 1; +} + + +static FILE *getiofile (lua_State *L, int findex) { + FILE *f; + lua_rawgeti(L, LUA_ENVIRONINDEX, findex); + f = *(FILE **)lua_touserdata(L, -1); + if (f == NULL) + luaL_error(L, "standard %s file is closed", fnames[findex - 1]); + return f; +} + + +static int g_iofile (lua_State *L, int f, const char *mode) { + if (!lua_isnoneornil(L, 1)) { + const char *filename = lua_tostring(L, 1); + if (filename) { + FILE **pf = newfile(L); + *pf = fopen(filename, mode); + if (*pf == NULL) + fileerror(L, 1, filename); + } + else { + tofile(L); /* check that it's a valid file handle */ + lua_pushvalue(L, 1); + } + lua_rawseti(L, LUA_ENVIRONINDEX, f); + } + /* return current value */ + lua_rawgeti(L, LUA_ENVIRONINDEX, f); + return 1; +} + + +static int io_input (lua_State *L) { + return g_iofile(L, IO_INPUT, "r"); +} + + +static int io_output (lua_State *L) { + return g_iofile(L, IO_OUTPUT, "w"); +} + + +static int io_readline (lua_State *L); + + +static void aux_lines (lua_State *L, int idx, int toclose) { + lua_pushvalue(L, idx); + lua_pushboolean(L, toclose); /* close/not close file when finished */ + lua_pushcclosure(L, io_readline, 2); +} + + +static int f_lines (lua_State *L) { + tofile(L); /* check that it's a valid file handle */ + aux_lines(L, 1, 0); + return 1; +} + + +static int io_lines (lua_State *L) { + if (lua_isnoneornil(L, 1)) { /* no arguments? */ + /* will iterate over default input */ + lua_rawgeti(L, LUA_ENVIRONINDEX, IO_INPUT); + return f_lines(L); + } + else { + const char *filename = luaL_checkstring(L, 1); + FILE **pf = newfile(L); + *pf = fopen(filename, "r"); + if (*pf == NULL) + fileerror(L, 1, filename); + aux_lines(L, lua_gettop(L), 1); + return 1; + } +} + + +/* +** {====================================================== +** READ +** ======================================================= +*/ + + +static int read_number (lua_State *L, FILE *f) { + lua_Number d; + if (fscanf(f, LUA_NUMBER_SCAN, &d) == 1) { + lua_pushnumber(L, d); + return 1; + } + else return 0; /* read fails */ +} + + +static int test_eof (lua_State *L, FILE *f) { + int c = getc(f); + ungetc(c, f); + lua_pushlstring(L, NULL, 0); + return (c != EOF); +} + + +static int read_line (lua_State *L, FILE *f) { + luaL_Buffer b; + luaL_buffinit(L, &b); + for (;;) { + size_t l; + char *p = luaL_prepbuffer(&b); + if (fgets(p, LUAL_BUFFERSIZE, f) == NULL) { /* eof? */ + luaL_pushresult(&b); /* close buffer */ + return (lua_objlen(L, -1) > 0); /* check whether read something */ + } + l = strlen(p); + if (l == 0 || p[l-1] != '\n') + luaL_addsize(&b, l); + else { + luaL_addsize(&b, l - 1); /* do not include `eol' */ + luaL_pushresult(&b); /* close buffer */ + return 1; /* read at least an `eol' */ + } + } +} + + +static int read_chars (lua_State *L, FILE *f, size_t n) { + size_t rlen; /* how much to read */ + size_t nr; /* number of chars actually read */ + luaL_Buffer b; + luaL_buffinit(L, &b); + rlen = LUAL_BUFFERSIZE; /* try to read that much each time */ + do { + char *p = luaL_prepbuffer(&b); + if (rlen > n) rlen = n; /* cannot read more than asked */ + nr = fread(p, sizeof(char), rlen, f); + luaL_addsize(&b, nr); + n -= nr; /* still have to read `n' chars */ + } while (n > 0 && nr == rlen); /* until end of count or eof */ + luaL_pushresult(&b); /* close buffer */ + return (n == 0 || lua_objlen(L, -1) > 0); +} + + +static int g_read (lua_State *L, FILE *f, int first) { + int nargs = lua_gettop(L) - 1; + int success; + int n; + clearerr(f); + if (nargs == 0) { /* no arguments? */ + success = read_line(L, f); + n = first+1; /* to return 1 result */ + } + else { /* ensure stack space for all results and for auxlib's buffer */ + luaL_checkstack(L, nargs+LUA_MINSTACK, "too many arguments"); + success = 1; + for (n = first; nargs-- && success; n++) { + if (lua_type(L, n) == LUA_TNUMBER) { + size_t l = (size_t)lua_tointeger(L, n); + success = (l == 0) ? test_eof(L, f) : read_chars(L, f, l); + } + else { + const char *p = lua_tostring(L, n); + luaL_argcheck(L, p && p[0] == '*', n, "invalid option"); + switch (p[1]) { + case 'n': /* number */ + success = read_number(L, f); + break; + case 'l': /* line */ + success = read_line(L, f); + break; + case 'a': /* file */ + read_chars(L, f, ~((size_t)0)); /* read MAX_SIZE_T chars */ + success = 1; /* always success */ + break; + default: + return luaL_argerror(L, n, "invalid format"); + } + } + } + } + if (ferror(f)) + return pushresult(L, 0, NULL); + if (!success) { + lua_pop(L, 1); /* remove last result */ + lua_pushnil(L); /* push nil instead */ + } + return n - first; +} + + +static int io_read (lua_State *L) { + return g_read(L, getiofile(L, IO_INPUT), 1); +} + + +static int f_read (lua_State *L) { + return g_read(L, tofile(L), 2); +} + + +static int io_readline (lua_State *L) { + FILE *f = *(FILE **)lua_touserdata(L, lua_upvalueindex(1)); + int sucess; + if (f == NULL) /* file is already closed? */ + luaL_error(L, "file is already closed"); + sucess = read_line(L, f); + if (ferror(f)) + return luaL_error(L, "%s", strerror(errno)); + if (sucess) return 1; + else { /* EOF */ + if (lua_toboolean(L, lua_upvalueindex(2))) { /* generator created file? */ + lua_settop(L, 0); + lua_pushvalue(L, lua_upvalueindex(1)); + aux_close(L); /* close it */ + } + return 0; + } +} + +/* }====================================================== */ + + +static int g_write (lua_State *L, FILE *f, int arg) { + int nargs = lua_gettop(L) - 1; + int status = 1; + for (; nargs--; arg++) { + if (lua_type(L, arg) == LUA_TNUMBER) { + /* optimization: could be done exactly as for strings */ + status = status && + fprintf(f, LUA_NUMBER_FMT, lua_tonumber(L, arg)) > 0; + } + else { + size_t l; + const char *s = luaL_checklstring(L, arg, &l); + status = status && (fwrite(s, sizeof(char), l, f) == l); + } + } + return pushresult(L, status, NULL); +} + + +static int io_write (lua_State *L) { + return g_write(L, getiofile(L, IO_OUTPUT), 1); +} + + +static int f_write (lua_State *L) { + return g_write(L, tofile(L), 2); +} + + +static int f_seek (lua_State *L) { + static const int mode[] = {SEEK_SET, SEEK_CUR, SEEK_END}; + static const char *const modenames[] = {"set", "cur", "end", NULL}; + FILE *f = tofile(L); + int op = luaL_checkoption(L, 2, "cur", modenames); + long offset = luaL_optlong(L, 3, 0); + op = fseek(f, offset, mode[op]); + if (op) + return pushresult(L, 0, NULL); /* error */ + else { + lua_pushinteger(L, ftell(f)); + return 1; + } +} + + +static int f_setvbuf (lua_State *L) { + static const int mode[] = {_IONBF, _IOFBF, _IOLBF}; + static const char *const modenames[] = {"no", "full", "line", NULL}; + FILE *f = tofile(L); + int op = luaL_checkoption(L, 2, NULL, modenames); + lua_Integer sz = luaL_optinteger(L, 3, LUAL_BUFFERSIZE); + int res = setvbuf(f, NULL, mode[op], sz); + return pushresult(L, res == 0, NULL); +} + + + +static int io_flush (lua_State *L) { + return pushresult(L, fflush(getiofile(L, IO_OUTPUT)) == 0, NULL); +} + + +static int f_flush (lua_State *L) { + return pushresult(L, fflush(tofile(L)) == 0, NULL); +} + + +static const luaL_Reg iolib[] = { + {"close", io_close}, + {"flush", io_flush}, + {"input", io_input}, + {"lines", io_lines}, + {"open", io_open}, + {"output", io_output}, + {"popen", io_popen}, + {"read", io_read}, + {"tmpfile", io_tmpfile}, + {"type", io_type}, + {"write", io_write}, + {NULL, NULL} +}; + + +static const luaL_Reg flib[] = { + {"close", io_close}, + {"flush", f_flush}, + {"lines", f_lines}, + {"read", f_read}, + {"seek", f_seek}, + {"setvbuf", f_setvbuf}, + {"write", f_write}, + {"__gc", io_gc}, + {"__tostring", io_tostring}, + {NULL, NULL} +}; + + +static void createmeta (lua_State *L) { + luaL_newmetatable(L, LUA_FILEHANDLE); /* create metatable for file handles */ + lua_pushvalue(L, -1); /* push metatable */ + lua_setfield(L, -2, "__index"); /* metatable.__index = metatable */ + luaL_register(L, NULL, flib); /* file methods */ +} + + +static void createstdfile (lua_State *L, FILE *f, int k, const char *fname) { + *newfile(L) = f; + if (k > 0) { + lua_pushvalue(L, -1); + lua_rawseti(L, LUA_ENVIRONINDEX, k); + } + lua_pushvalue(L, -2); /* copy environment */ + lua_setfenv(L, -2); /* set it */ + lua_setfield(L, -3, fname); +} + + +static void newfenv (lua_State *L, lua_CFunction cls) { + lua_createtable(L, 0, 1); + lua_pushcfunction(L, cls); + lua_setfield(L, -2, "__close"); +} + + +LUALIB_API int luaopen_io (lua_State *L) { + createmeta(L); + /* create (private) environment (with fields IO_INPUT, IO_OUTPUT, __close) */ + newfenv(L, io_fclose); + lua_replace(L, LUA_ENVIRONINDEX); + /* open library */ + luaL_register(L, LUA_IOLIBNAME, iolib); + /* create (and set) default files */ + newfenv(L, io_noclose); /* close function for default files */ + createstdfile(L, stdin, IO_INPUT, "stdin"); + createstdfile(L, stdout, IO_OUTPUT, "stdout"); + createstdfile(L, stderr, 0, "stderr"); + lua_pop(L, 1); /* pop environment for default files */ + lua_getfield(L, -1, "popen"); + newfenv(L, io_pclose); /* create environment for 'popen' */ + lua_setfenv(L, -2); /* set fenv for 'popen' */ + lua_pop(L, 1); /* pop 'popen' */ + return 1; +} + diff --git a/mk/linux/mojosetup/lua/src/llex.c b/mk/linux/mojosetup/lua/src/llex.c new file mode 100644 index 00000000..6dc31935 --- /dev/null +++ b/mk/linux/mojosetup/lua/src/llex.c @@ -0,0 +1,461 @@ +/* +** $Id: llex.c,v 2.20.1.1 2007/12/27 13:02:25 roberto Exp $ +** Lexical Analyzer +** See Copyright Notice in lua.h +*/ + + +#include +#include +#include + +#define llex_c +#define LUA_CORE + +#include "lua.h" + +#include "ldo.h" +#include "llex.h" +#include "lobject.h" +#include "lparser.h" +#include "lstate.h" +#include "lstring.h" +#include "ltable.h" +#include "lzio.h" + + + +#define next(ls) (ls->current = zgetc(ls->z)) + + + + +#define currIsNewline(ls) (ls->current == '\n' || ls->current == '\r') + + +/* ORDER RESERVED */ +const char *const luaX_tokens [] = { + "and", "break", "do", "else", "elseif", + "end", "false", "for", "function", "if", + "in", "local", "nil", "not", "or", "repeat", + "return", "then", "true", "until", "while", + "..", "...", "==", ">=", "<=", "~=", + "", "", "", "", + NULL +}; + + +#define save_and_next(ls) (save(ls, ls->current), next(ls)) + + +static void save (LexState *ls, int c) { + Mbuffer *b = ls->buff; + if (b->n + 1 > b->buffsize) { + size_t newsize; + if (b->buffsize >= MAX_SIZET/2) + luaX_lexerror(ls, "lexical element too long", 0); + newsize = b->buffsize * 2; + luaZ_resizebuffer(ls->L, b, newsize); + } + b->buffer[b->n++] = cast(char, c); +} + + +void luaX_init (lua_State *L) { + int i; + for (i=0; itsv.reserved = cast_byte(i+1); /* reserved word */ + } +} + + +#define MAXSRC 80 + + +const char *luaX_token2str (LexState *ls, int token) { + if (token < FIRST_RESERVED) { + lua_assert(token == cast(unsigned char, token)); + return (iscntrl(token)) ? luaO_pushfstring(ls->L, "char(%d)", token) : + luaO_pushfstring(ls->L, "%c", token); + } + else + return luaX_tokens[token-FIRST_RESERVED]; +} + + +static const char *txtToken (LexState *ls, int token) { + switch (token) { + case TK_NAME: + case TK_STRING: + case TK_NUMBER: + save(ls, '\0'); + return luaZ_buffer(ls->buff); + default: + return luaX_token2str(ls, token); + } +} + + +void luaX_lexerror (LexState *ls, const char *msg, int token) { + char buff[MAXSRC]; + luaO_chunkid(buff, getstr(ls->source), MAXSRC); + msg = luaO_pushfstring(ls->L, "%s:%d: %s", buff, ls->linenumber, msg); + if (token) + luaO_pushfstring(ls->L, "%s near " LUA_QS, msg, txtToken(ls, token)); + luaD_throw(ls->L, LUA_ERRSYNTAX); +} + + +void luaX_syntaxerror (LexState *ls, const char *msg) { + luaX_lexerror(ls, msg, ls->t.token); +} + + +TString *luaX_newstring (LexState *ls, const char *str, size_t l) { + lua_State *L = ls->L; + TString *ts = luaS_newlstr(L, str, l); + TValue *o = luaH_setstr(L, ls->fs->h, ts); /* entry for `str' */ + if (ttisnil(o)) + setbvalue(o, 1); /* make sure `str' will not be collected */ + return ts; +} + + +static void inclinenumber (LexState *ls) { + int old = ls->current; + lua_assert(currIsNewline(ls)); + next(ls); /* skip `\n' or `\r' */ + if (currIsNewline(ls) && ls->current != old) + next(ls); /* skip `\n\r' or `\r\n' */ + if (++ls->linenumber >= MAX_INT) + luaX_syntaxerror(ls, "chunk has too many lines"); +} + + +void luaX_setinput (lua_State *L, LexState *ls, ZIO *z, TString *source) { + ls->decpoint = '.'; + ls->L = L; + ls->lookahead.token = TK_EOS; /* no look-ahead token */ + ls->z = z; + ls->fs = NULL; + ls->linenumber = 1; + ls->lastline = 1; + ls->source = source; + luaZ_resizebuffer(ls->L, ls->buff, LUA_MINBUFFER); /* initialize buffer */ + next(ls); /* read first char */ +} + + + +/* +** ======================================================= +** LEXICAL ANALYZER +** ======================================================= +*/ + + + +static int check_next (LexState *ls, const char *set) { + if (!strchr(set, ls->current)) + return 0; + save_and_next(ls); + return 1; +} + + +static void buffreplace (LexState *ls, char from, char to) { + size_t n = luaZ_bufflen(ls->buff); + char *p = luaZ_buffer(ls->buff); + while (n--) + if (p[n] == from) p[n] = to; +} + + +static void trydecpoint (LexState *ls, SemInfo *seminfo) { + /* format error: try to update decimal point separator */ + struct lconv *cv = localeconv(); + char old = ls->decpoint; + ls->decpoint = (cv ? cv->decimal_point[0] : '.'); + buffreplace(ls, old, ls->decpoint); /* try updated decimal separator */ + if (!luaO_str2d(luaZ_buffer(ls->buff), &seminfo->r)) { + /* format error with correct decimal point: no more options */ + buffreplace(ls, ls->decpoint, '.'); /* undo change (for error message) */ + luaX_lexerror(ls, "malformed number", TK_NUMBER); + } +} + + +/* LUA_NUMBER */ +static void read_numeral (LexState *ls, SemInfo *seminfo) { + lua_assert(isdigit(ls->current)); + do { + save_and_next(ls); + } while (isdigit(ls->current) || ls->current == '.'); + if (check_next(ls, "Ee")) /* `E'? */ + check_next(ls, "+-"); /* optional exponent sign */ + while (isalnum(ls->current) || ls->current == '_') + save_and_next(ls); + save(ls, '\0'); + buffreplace(ls, '.', ls->decpoint); /* follow locale for decimal point */ + if (!luaO_str2d(luaZ_buffer(ls->buff), &seminfo->r)) /* format error? */ + trydecpoint(ls, seminfo); /* try to update decimal point separator */ +} + + +static int skip_sep (LexState *ls) { + int count = 0; + int s = ls->current; + lua_assert(s == '[' || s == ']'); + save_and_next(ls); + while (ls->current == '=') { + save_and_next(ls); + count++; + } + return (ls->current == s) ? count : (-count) - 1; +} + + +static void read_long_string (LexState *ls, SemInfo *seminfo, int sep) { + int cont = 0; + (void)(cont); /* avoid warnings when `cont' is not used */ + save_and_next(ls); /* skip 2nd `[' */ + if (currIsNewline(ls)) /* string starts with a newline? */ + inclinenumber(ls); /* skip it */ + for (;;) { + switch (ls->current) { + case EOZ: + luaX_lexerror(ls, (seminfo) ? "unfinished long string" : + "unfinished long comment", TK_EOS); + break; /* to avoid warnings */ +#if defined(LUA_COMPAT_LSTR) + case '[': { + if (skip_sep(ls) == sep) { + save_and_next(ls); /* skip 2nd `[' */ + cont++; +#if LUA_COMPAT_LSTR == 1 + if (sep == 0) + luaX_lexerror(ls, "nesting of [[...]] is deprecated", '['); +#endif + } + break; + } +#endif + case ']': { + if (skip_sep(ls) == sep) { + save_and_next(ls); /* skip 2nd `]' */ +#if defined(LUA_COMPAT_LSTR) && LUA_COMPAT_LSTR == 2 + cont--; + if (sep == 0 && cont >= 0) break; +#endif + goto endloop; + } + break; + } + case '\n': + case '\r': { + save(ls, '\n'); + inclinenumber(ls); + if (!seminfo) luaZ_resetbuffer(ls->buff); /* avoid wasting space */ + break; + } + default: { + if (seminfo) save_and_next(ls); + else next(ls); + } + } + } endloop: + if (seminfo) + seminfo->ts = luaX_newstring(ls, luaZ_buffer(ls->buff) + (2 + sep), + luaZ_bufflen(ls->buff) - 2*(2 + sep)); +} + + +static void read_string (LexState *ls, int del, SemInfo *seminfo) { + save_and_next(ls); + while (ls->current != del) { + switch (ls->current) { + case EOZ: + luaX_lexerror(ls, "unfinished string", TK_EOS); + continue; /* to avoid warnings */ + case '\n': + case '\r': + luaX_lexerror(ls, "unfinished string", TK_STRING); + continue; /* to avoid warnings */ + case '\\': { + int c; + next(ls); /* do not save the `\' */ + switch (ls->current) { + case 'a': c = '\a'; break; + case 'b': c = '\b'; break; + case 'f': c = '\f'; break; + case 'n': c = '\n'; break; + case 'r': c = '\r'; break; + case 't': c = '\t'; break; + case 'v': c = '\v'; break; + case '\n': /* go through */ + case '\r': save(ls, '\n'); inclinenumber(ls); continue; + case EOZ: continue; /* will raise an error next loop */ + default: { + if (!isdigit(ls->current)) + save_and_next(ls); /* handles \\, \", \', and \? */ + else { /* \xxx */ + int i = 0; + c = 0; + do { + c = 10*c + (ls->current-'0'); + next(ls); + } while (++i<3 && isdigit(ls->current)); + if (c > UCHAR_MAX) + luaX_lexerror(ls, "escape sequence too large", TK_STRING); + save(ls, c); + } + continue; + } + } + save(ls, c); + next(ls); + continue; + } + default: + save_and_next(ls); + } + } + save_and_next(ls); /* skip delimiter */ + seminfo->ts = luaX_newstring(ls, luaZ_buffer(ls->buff) + 1, + luaZ_bufflen(ls->buff) - 2); +} + + +static int llex (LexState *ls, SemInfo *seminfo) { + luaZ_resetbuffer(ls->buff); + for (;;) { + switch (ls->current) { + case '\n': + case '\r': { + inclinenumber(ls); + continue; + } + case '-': { + next(ls); + if (ls->current != '-') return '-'; + /* else is a comment */ + next(ls); + if (ls->current == '[') { + int sep = skip_sep(ls); + luaZ_resetbuffer(ls->buff); /* `skip_sep' may dirty the buffer */ + if (sep >= 0) { + read_long_string(ls, NULL, sep); /* long comment */ + luaZ_resetbuffer(ls->buff); + continue; + } + } + /* else short comment */ + while (!currIsNewline(ls) && ls->current != EOZ) + next(ls); + continue; + } + case '[': { + int sep = skip_sep(ls); + if (sep >= 0) { + read_long_string(ls, seminfo, sep); + return TK_STRING; + } + else if (sep == -1) return '['; + else luaX_lexerror(ls, "invalid long string delimiter", TK_STRING); + } + case '=': { + next(ls); + if (ls->current != '=') return '='; + else { next(ls); return TK_EQ; } + } + case '<': { + next(ls); + if (ls->current != '=') return '<'; + else { next(ls); return TK_LE; } + } + case '>': { + next(ls); + if (ls->current != '=') return '>'; + else { next(ls); return TK_GE; } + } + case '~': { + next(ls); + if (ls->current != '=') return '~'; + else { next(ls); return TK_NE; } + } + case '"': + case '\'': { + read_string(ls, ls->current, seminfo); + return TK_STRING; + } + case '.': { + save_and_next(ls); + if (check_next(ls, ".")) { + if (check_next(ls, ".")) + return TK_DOTS; /* ... */ + else return TK_CONCAT; /* .. */ + } + else if (!isdigit(ls->current)) return '.'; + else { + read_numeral(ls, seminfo); + return TK_NUMBER; + } + } + case EOZ: { + return TK_EOS; + } + default: { + if (isspace(ls->current)) { + lua_assert(!currIsNewline(ls)); + next(ls); + continue; + } + else if (isdigit(ls->current)) { + read_numeral(ls, seminfo); + return TK_NUMBER; + } + else if (isalpha(ls->current) || ls->current == '_') { + /* identifier or reserved word */ + TString *ts; + do { + save_and_next(ls); + } while (isalnum(ls->current) || ls->current == '_'); + ts = luaX_newstring(ls, luaZ_buffer(ls->buff), + luaZ_bufflen(ls->buff)); + if (ts->tsv.reserved > 0) /* reserved word? */ + return ts->tsv.reserved - 1 + FIRST_RESERVED; + else { + seminfo->ts = ts; + return TK_NAME; + } + } + else { + int c = ls->current; + next(ls); + return c; /* single-char tokens (+ - / ...) */ + } + } + } + } +} + + +void luaX_next (LexState *ls) { + ls->lastline = ls->linenumber; + if (ls->lookahead.token != TK_EOS) { /* is there a look-ahead token? */ + ls->t = ls->lookahead; /* use this one */ + ls->lookahead.token = TK_EOS; /* and discharge it */ + } + else + ls->t.token = llex(ls, &ls->t.seminfo); /* read next token */ +} + + +void luaX_lookahead (LexState *ls) { + lua_assert(ls->lookahead.token == TK_EOS); + ls->lookahead.token = llex(ls, &ls->lookahead.seminfo); +} + diff --git a/mk/linux/mojosetup/lua/src/llex.h b/mk/linux/mojosetup/lua/src/llex.h new file mode 100644 index 00000000..a9201cee --- /dev/null +++ b/mk/linux/mojosetup/lua/src/llex.h @@ -0,0 +1,81 @@ +/* +** $Id: llex.h,v 1.58.1.1 2007/12/27 13:02:25 roberto Exp $ +** Lexical Analyzer +** See Copyright Notice in lua.h +*/ + +#ifndef llex_h +#define llex_h + +#include "lobject.h" +#include "lzio.h" + + +#define FIRST_RESERVED 257 + +/* maximum length of a reserved word */ +#define TOKEN_LEN (sizeof("function")/sizeof(char)) + + +/* +* WARNING: if you change the order of this enumeration, +* grep "ORDER RESERVED" +*/ +enum RESERVED { + /* terminal symbols denoted by reserved words */ + TK_AND = FIRST_RESERVED, TK_BREAK, + TK_DO, TK_ELSE, TK_ELSEIF, TK_END, TK_FALSE, TK_FOR, TK_FUNCTION, + TK_IF, TK_IN, TK_LOCAL, TK_NIL, TK_NOT, TK_OR, TK_REPEAT, + TK_RETURN, TK_THEN, TK_TRUE, TK_UNTIL, TK_WHILE, + /* other terminal symbols */ + TK_CONCAT, TK_DOTS, TK_EQ, TK_GE, TK_LE, TK_NE, TK_NUMBER, + TK_NAME, TK_STRING, TK_EOS +}; + +/* number of reserved words */ +#define NUM_RESERVED (cast(int, TK_WHILE-FIRST_RESERVED+1)) + + +/* array with token `names' */ +LUAI_DATA const char *const luaX_tokens []; + + +typedef union { + lua_Number r; + TString *ts; +} SemInfo; /* semantics information */ + + +typedef struct Token { + int token; + SemInfo seminfo; +} Token; + + +typedef struct LexState { + int current; /* current character (charint) */ + int linenumber; /* input line counter */ + int lastline; /* line of last token `consumed' */ + Token t; /* current token */ + Token lookahead; /* look ahead token */ + struct FuncState *fs; /* `FuncState' is private to the parser */ + struct lua_State *L; + ZIO *z; /* input stream */ + Mbuffer *buff; /* buffer for tokens */ + TString *source; /* current source name */ + char decpoint; /* locale decimal point */ +} LexState; + + +LUAI_FUNC void luaX_init (lua_State *L); +LUAI_FUNC void luaX_setinput (lua_State *L, LexState *ls, ZIO *z, + TString *source); +LUAI_FUNC TString *luaX_newstring (LexState *ls, const char *str, size_t l); +LUAI_FUNC void luaX_next (LexState *ls); +LUAI_FUNC void luaX_lookahead (LexState *ls); +LUAI_FUNC void luaX_lexerror (LexState *ls, const char *msg, int token); +LUAI_FUNC void luaX_syntaxerror (LexState *ls, const char *s); +LUAI_FUNC const char *luaX_token2str (LexState *ls, int token); + + +#endif diff --git a/mk/linux/mojosetup/lua/src/llimits.h b/mk/linux/mojosetup/lua/src/llimits.h new file mode 100644 index 00000000..ca8dcb72 --- /dev/null +++ b/mk/linux/mojosetup/lua/src/llimits.h @@ -0,0 +1,128 @@ +/* +** $Id: llimits.h,v 1.69.1.1 2007/12/27 13:02:25 roberto Exp $ +** Limits, basic types, and some other `installation-dependent' definitions +** See Copyright Notice in lua.h +*/ + +#ifndef llimits_h +#define llimits_h + + +#include +#include + + +#include "lua.h" + + +typedef LUAI_UINT32 lu_int32; + +typedef LUAI_UMEM lu_mem; + +typedef LUAI_MEM l_mem; + + + +/* chars used as small naturals (so that `char' is reserved for characters) */ +typedef unsigned char lu_byte; + + +#define MAX_SIZET ((size_t)(~(size_t)0)-2) + +#define MAX_LUMEM ((lu_mem)(~(lu_mem)0)-2) + + +#define MAX_INT (INT_MAX-2) /* maximum value of an int (-2 for safety) */ + +/* +** conversion of pointer to integer +** this is for hashing only; there is no problem if the integer +** cannot hold the whole pointer value +*/ +#define IntPoint(p) ((unsigned int)(lu_mem)(p)) + + + +/* type to ensure maximum alignment */ +typedef LUAI_USER_ALIGNMENT_T L_Umaxalign; + + +/* result of a `usual argument conversion' over lua_Number */ +typedef LUAI_UACNUMBER l_uacNumber; + + +/* internal assertions for in-house debugging */ +#ifdef lua_assert + +#define check_exp(c,e) (lua_assert(c), (e)) +#define api_check(l,e) lua_assert(e) + +#else + +#define lua_assert(c) ((void)0) +#define check_exp(c,e) (e) +#define api_check luai_apicheck + +#endif + + +#ifndef UNUSED +#define UNUSED(x) ((void)(x)) /* to avoid warnings */ +#endif + + +#ifndef cast +#define cast(t, exp) ((t)(exp)) +#endif + +#define cast_byte(i) cast(lu_byte, (i)) +#define cast_num(i) cast(lua_Number, (i)) +#define cast_int(i) cast(int, (i)) + + + +/* +** type for virtual-machine instructions +** must be an unsigned with (at least) 4 bytes (see details in lopcodes.h) +*/ +typedef lu_int32 Instruction; + + + +/* maximum stack for a Lua function */ +#define MAXSTACK 250 + + + +/* minimum size for the string table (must be power of 2) */ +#ifndef MINSTRTABSIZE +#define MINSTRTABSIZE 32 +#endif + + +/* minimum size for string buffer */ +#ifndef LUA_MINBUFFER +#define LUA_MINBUFFER 32 +#endif + + +#ifndef lua_lock +#define lua_lock(L) ((void) 0) +#define lua_unlock(L) ((void) 0) +#endif + +#ifndef luai_threadyield +#define luai_threadyield(L) {lua_unlock(L); lua_lock(L);} +#endif + + +/* +** macro to control inclusion of some hard tests on stack reallocation +*/ +#ifndef HARDSTACKTESTS +#define condhardstacktests(x) ((void)0) +#else +#define condhardstacktests(x) x +#endif + +#endif diff --git a/mk/linux/mojosetup/lua/src/lmathlib.c b/mk/linux/mojosetup/lua/src/lmathlib.c new file mode 100644 index 00000000..441fbf73 --- /dev/null +++ b/mk/linux/mojosetup/lua/src/lmathlib.c @@ -0,0 +1,263 @@ +/* +** $Id: lmathlib.c,v 1.67.1.1 2007/12/27 13:02:25 roberto Exp $ +** Standard mathematical library +** See Copyright Notice in lua.h +*/ + + +#include +#include + +#define lmathlib_c +#define LUA_LIB + +#include "lua.h" + +#include "lauxlib.h" +#include "lualib.h" + + +#undef PI +#define PI (3.14159265358979323846) +#define RADIANS_PER_DEGREE (PI/180.0) + + + +static int math_abs (lua_State *L) { + lua_pushnumber(L, fabs(luaL_checknumber(L, 1))); + return 1; +} + +static int math_sin (lua_State *L) { + lua_pushnumber(L, sin(luaL_checknumber(L, 1))); + return 1; +} + +static int math_sinh (lua_State *L) { + lua_pushnumber(L, sinh(luaL_checknumber(L, 1))); + return 1; +} + +static int math_cos (lua_State *L) { + lua_pushnumber(L, cos(luaL_checknumber(L, 1))); + return 1; +} + +static int math_cosh (lua_State *L) { + lua_pushnumber(L, cosh(luaL_checknumber(L, 1))); + return 1; +} + +static int math_tan (lua_State *L) { + lua_pushnumber(L, tan(luaL_checknumber(L, 1))); + return 1; +} + +static int math_tanh (lua_State *L) { + lua_pushnumber(L, tanh(luaL_checknumber(L, 1))); + return 1; +} + +static int math_asin (lua_State *L) { + lua_pushnumber(L, asin(luaL_checknumber(L, 1))); + return 1; +} + +static int math_acos (lua_State *L) { + lua_pushnumber(L, acos(luaL_checknumber(L, 1))); + return 1; +} + +static int math_atan (lua_State *L) { + lua_pushnumber(L, atan(luaL_checknumber(L, 1))); + return 1; +} + +static int math_atan2 (lua_State *L) { + lua_pushnumber(L, atan2(luaL_checknumber(L, 1), luaL_checknumber(L, 2))); + return 1; +} + +static int math_ceil (lua_State *L) { + lua_pushnumber(L, ceil(luaL_checknumber(L, 1))); + return 1; +} + +static int math_floor (lua_State *L) { + lua_pushnumber(L, floor(luaL_checknumber(L, 1))); + return 1; +} + +static int math_fmod (lua_State *L) { + lua_pushnumber(L, fmod(luaL_checknumber(L, 1), luaL_checknumber(L, 2))); + return 1; +} + +static int math_modf (lua_State *L) { + double ip; + double fp = modf(luaL_checknumber(L, 1), &ip); + lua_pushnumber(L, ip); + lua_pushnumber(L, fp); + return 2; +} + +static int math_sqrt (lua_State *L) { + lua_pushnumber(L, sqrt(luaL_checknumber(L, 1))); + return 1; +} + +static int math_pow (lua_State *L) { + lua_pushnumber(L, pow(luaL_checknumber(L, 1), luaL_checknumber(L, 2))); + return 1; +} + +static int math_log (lua_State *L) { + lua_pushnumber(L, log(luaL_checknumber(L, 1))); + return 1; +} + +static int math_log10 (lua_State *L) { + lua_pushnumber(L, log10(luaL_checknumber(L, 1))); + return 1; +} + +static int math_exp (lua_State *L) { + lua_pushnumber(L, exp(luaL_checknumber(L, 1))); + return 1; +} + +static int math_deg (lua_State *L) { + lua_pushnumber(L, luaL_checknumber(L, 1)/RADIANS_PER_DEGREE); + return 1; +} + +static int math_rad (lua_State *L) { + lua_pushnumber(L, luaL_checknumber(L, 1)*RADIANS_PER_DEGREE); + return 1; +} + +static int math_frexp (lua_State *L) { + int e; + lua_pushnumber(L, frexp(luaL_checknumber(L, 1), &e)); + lua_pushinteger(L, e); + return 2; +} + +static int math_ldexp (lua_State *L) { + lua_pushnumber(L, ldexp(luaL_checknumber(L, 1), luaL_checkint(L, 2))); + return 1; +} + + + +static int math_min (lua_State *L) { + int n = lua_gettop(L); /* number of arguments */ + lua_Number dmin = luaL_checknumber(L, 1); + int i; + for (i=2; i<=n; i++) { + lua_Number d = luaL_checknumber(L, i); + if (d < dmin) + dmin = d; + } + lua_pushnumber(L, dmin); + return 1; +} + + +static int math_max (lua_State *L) { + int n = lua_gettop(L); /* number of arguments */ + lua_Number dmax = luaL_checknumber(L, 1); + int i; + for (i=2; i<=n; i++) { + lua_Number d = luaL_checknumber(L, i); + if (d > dmax) + dmax = d; + } + lua_pushnumber(L, dmax); + return 1; +} + + +static int math_random (lua_State *L) { + /* the `%' avoids the (rare) case of r==1, and is needed also because on + some systems (SunOS!) `rand()' may return a value larger than RAND_MAX */ + lua_Number r = (lua_Number)(rand()%RAND_MAX) / (lua_Number)RAND_MAX; + switch (lua_gettop(L)) { /* check number of arguments */ + case 0: { /* no arguments */ + lua_pushnumber(L, r); /* Number between 0 and 1 */ + break; + } + case 1: { /* only upper limit */ + int u = luaL_checkint(L, 1); + luaL_argcheck(L, 1<=u, 1, "interval is empty"); + lua_pushnumber(L, floor(r*u)+1); /* int between 1 and `u' */ + break; + } + case 2: { /* lower and upper limits */ + int l = luaL_checkint(L, 1); + int u = luaL_checkint(L, 2); + luaL_argcheck(L, l<=u, 2, "interval is empty"); + lua_pushnumber(L, floor(r*(u-l+1))+l); /* int between `l' and `u' */ + break; + } + default: return luaL_error(L, "wrong number of arguments"); + } + return 1; +} + + +static int math_randomseed (lua_State *L) { + srand(luaL_checkint(L, 1)); + return 0; +} + + +static const luaL_Reg mathlib[] = { + {"abs", math_abs}, + {"acos", math_acos}, + {"asin", math_asin}, + {"atan2", math_atan2}, + {"atan", math_atan}, + {"ceil", math_ceil}, + {"cosh", math_cosh}, + {"cos", math_cos}, + {"deg", math_deg}, + {"exp", math_exp}, + {"floor", math_floor}, + {"fmod", math_fmod}, + {"frexp", math_frexp}, + {"ldexp", math_ldexp}, + {"log10", math_log10}, + {"log", math_log}, + {"max", math_max}, + {"min", math_min}, + {"modf", math_modf}, + {"pow", math_pow}, + {"rad", math_rad}, + {"random", math_random}, + {"randomseed", math_randomseed}, + {"sinh", math_sinh}, + {"sin", math_sin}, + {"sqrt", math_sqrt}, + {"tanh", math_tanh}, + {"tan", math_tan}, + {NULL, NULL} +}; + + +/* +** Open math library +*/ +LUALIB_API int luaopen_math (lua_State *L) { + luaL_register(L, LUA_MATHLIBNAME, mathlib); + lua_pushnumber(L, PI); + lua_setfield(L, -2, "pi"); + lua_pushnumber(L, HUGE_VAL); + lua_setfield(L, -2, "huge"); +#if defined(LUA_COMPAT_MOD) + lua_getfield(L, -1, "fmod"); + lua_setfield(L, -2, "mod"); +#endif + return 1; +} + diff --git a/mk/linux/mojosetup/lua/src/lmem.c b/mk/linux/mojosetup/lua/src/lmem.c new file mode 100644 index 00000000..ae7d8c96 --- /dev/null +++ b/mk/linux/mojosetup/lua/src/lmem.c @@ -0,0 +1,86 @@ +/* +** $Id: lmem.c,v 1.70.1.1 2007/12/27 13:02:25 roberto Exp $ +** Interface to Memory Manager +** See Copyright Notice in lua.h +*/ + + +#include + +#define lmem_c +#define LUA_CORE + +#include "lua.h" + +#include "ldebug.h" +#include "ldo.h" +#include "lmem.h" +#include "lobject.h" +#include "lstate.h" + + + +/* +** About the realloc function: +** void * frealloc (void *ud, void *ptr, size_t osize, size_t nsize); +** (`osize' is the old size, `nsize' is the new size) +** +** Lua ensures that (ptr == NULL) iff (osize == 0). +** +** * frealloc(ud, NULL, 0, x) creates a new block of size `x' +** +** * frealloc(ud, p, x, 0) frees the block `p' +** (in this specific case, frealloc must return NULL). +** particularly, frealloc(ud, NULL, 0, 0) does nothing +** (which is equivalent to free(NULL) in ANSI C) +** +** frealloc returns NULL if it cannot create or reallocate the area +** (any reallocation to an equal or smaller size cannot fail!) +*/ + + + +#define MINSIZEARRAY 4 + + +void *luaM_growaux_ (lua_State *L, void *block, int *size, size_t size_elems, + int limit, const char *errormsg) { + void *newblock; + int newsize; + if (*size >= limit/2) { /* cannot double it? */ + if (*size >= limit) /* cannot grow even a little? */ + luaG_runerror(L, errormsg); + newsize = limit; /* still have at least one free place */ + } + else { + newsize = (*size)*2; + if (newsize < MINSIZEARRAY) + newsize = MINSIZEARRAY; /* minimum size */ + } + newblock = luaM_reallocv(L, block, *size, newsize, size_elems); + *size = newsize; /* update only when everything else is OK */ + return newblock; +} + + +void *luaM_toobig (lua_State *L) { + luaG_runerror(L, "memory allocation error: block too big"); + return NULL; /* to avoid warnings */ +} + + + +/* +** generic allocation routine. +*/ +void *luaM_realloc_ (lua_State *L, void *block, size_t osize, size_t nsize) { + global_State *g = G(L); + lua_assert((osize == 0) == (block == NULL)); + block = (*g->frealloc)(g->ud, block, osize, nsize); + if (block == NULL && nsize > 0) + luaD_throw(L, LUA_ERRMEM); + lua_assert((nsize == 0) == (block == NULL)); + g->totalbytes = (g->totalbytes - osize) + nsize; + return block; +} + diff --git a/mk/linux/mojosetup/lua/src/lmem.h b/mk/linux/mojosetup/lua/src/lmem.h new file mode 100644 index 00000000..7c2dcb32 --- /dev/null +++ b/mk/linux/mojosetup/lua/src/lmem.h @@ -0,0 +1,49 @@ +/* +** $Id: lmem.h,v 1.31.1.1 2007/12/27 13:02:25 roberto Exp $ +** Interface to Memory Manager +** See Copyright Notice in lua.h +*/ + +#ifndef lmem_h +#define lmem_h + + +#include + +#include "llimits.h" +#include "lua.h" + +#define MEMERRMSG "not enough memory" + + +#define luaM_reallocv(L,b,on,n,e) \ + ((cast(size_t, (n)+1) <= MAX_SIZET/(e)) ? /* +1 to avoid warnings */ \ + luaM_realloc_(L, (b), (on)*(e), (n)*(e)) : \ + luaM_toobig(L)) + +#define luaM_freemem(L, b, s) luaM_realloc_(L, (b), (s), 0) +#define luaM_free(L, b) luaM_realloc_(L, (b), sizeof(*(b)), 0) +#define luaM_freearray(L, b, n, t) luaM_reallocv(L, (b), n, 0, sizeof(t)) + +#define luaM_malloc(L,t) luaM_realloc_(L, NULL, 0, (t)) +#define luaM_new(L,t) cast(t *, luaM_malloc(L, sizeof(t))) +#define luaM_newvector(L,n,t) \ + cast(t *, luaM_reallocv(L, NULL, 0, n, sizeof(t))) + +#define luaM_growvector(L,v,nelems,size,t,limit,e) \ + if ((nelems)+1 > (size)) \ + ((v)=cast(t *, luaM_growaux_(L,v,&(size),sizeof(t),limit,e))) + +#define luaM_reallocvector(L, v,oldn,n,t) \ + ((v)=cast(t *, luaM_reallocv(L, v, oldn, n, sizeof(t)))) + + +LUAI_FUNC void *luaM_realloc_ (lua_State *L, void *block, size_t oldsize, + size_t size); +LUAI_FUNC void *luaM_toobig (lua_State *L); +LUAI_FUNC void *luaM_growaux_ (lua_State *L, void *block, int *size, + size_t size_elem, int limit, + const char *errormsg); + +#endif + diff --git a/mk/linux/mojosetup/lua/src/loadlib.c b/mk/linux/mojosetup/lua/src/loadlib.c new file mode 100644 index 00000000..0d401eba --- /dev/null +++ b/mk/linux/mojosetup/lua/src/loadlib.c @@ -0,0 +1,666 @@ +/* +** $Id: loadlib.c,v 1.52.1.3 2008/08/06 13:29:28 roberto Exp $ +** Dynamic library loader for Lua +** See Copyright Notice in lua.h +** +** This module contains an implementation of loadlib for Unix systems +** that have dlfcn, an implementation for Darwin (Mac OS X), an +** implementation for Windows, and a stub for other systems. +*/ + + +#include +#include + + +#define loadlib_c +#define LUA_LIB + +#include "lua.h" + +#include "lauxlib.h" +#include "lualib.h" + + +/* prefix for open functions in C libraries */ +#define LUA_POF "luaopen_" + +/* separator for open functions in C libraries */ +#define LUA_OFSEP "_" + + +#define LIBPREFIX "LOADLIB: " + +#define POF LUA_POF +#define LIB_FAIL "open" + + +/* error codes for ll_loadfunc */ +#define ERRLIB 1 +#define ERRFUNC 2 + +#define setprogdir(L) ((void)0) + + +static void ll_unloadlib (void *lib); +static void *ll_load (lua_State *L, const char *path); +static lua_CFunction ll_sym (lua_State *L, void *lib, const char *sym); + + + +#if defined(LUA_DL_DLOPEN) +/* +** {======================================================================== +** This is an implementation of loadlib based on the dlfcn interface. +** The dlfcn interface is available in Linux, SunOS, Solaris, IRIX, FreeBSD, +** NetBSD, AIX 4.2, HPUX 11, and probably most other Unix flavors, at least +** as an emulation layer on top of native functions. +** ========================================================================= +*/ + +#include + +static void ll_unloadlib (void *lib) { + dlclose(lib); +} + + +static void *ll_load (lua_State *L, const char *path) { + void *lib = dlopen(path, RTLD_NOW); + if (lib == NULL) lua_pushstring(L, dlerror()); + return lib; +} + + +static lua_CFunction ll_sym (lua_State *L, void *lib, const char *sym) { + lua_CFunction f = (lua_CFunction)dlsym(lib, sym); + if (f == NULL) lua_pushstring(L, dlerror()); + return f; +} + +/* }====================================================== */ + + + +#elif defined(LUA_DL_DLL) +/* +** {====================================================================== +** This is an implementation of loadlib for Windows using native functions. +** ======================================================================= +*/ + +#include + + +#undef setprogdir + +static void setprogdir (lua_State *L) { + char buff[MAX_PATH + 1]; + char *lb; + DWORD nsize = sizeof(buff)/sizeof(char); + DWORD n = GetModuleFileNameA(NULL, buff, nsize); + if (n == 0 || n == nsize || (lb = strrchr(buff, '\\')) == NULL) + luaL_error(L, "unable to get ModuleFileName"); + else { + *lb = '\0'; + luaL_gsub(L, lua_tostring(L, -1), LUA_EXECDIR, buff); + lua_remove(L, -2); /* remove original string */ + } +} + + +static void pusherror (lua_State *L) { + int error = GetLastError(); + char buffer[128]; + if (FormatMessageA(FORMAT_MESSAGE_IGNORE_INSERTS | FORMAT_MESSAGE_FROM_SYSTEM, + NULL, error, 0, buffer, sizeof(buffer), NULL)) + lua_pushstring(L, buffer); + else + lua_pushfstring(L, "system error %d\n", error); +} + +static void ll_unloadlib (void *lib) { + FreeLibrary((HINSTANCE)lib); +} + + +static void *ll_load (lua_State *L, const char *path) { + HINSTANCE lib = LoadLibraryA(path); + if (lib == NULL) pusherror(L); + return lib; +} + + +static lua_CFunction ll_sym (lua_State *L, void *lib, const char *sym) { + lua_CFunction f = (lua_CFunction)GetProcAddress((HINSTANCE)lib, sym); + if (f == NULL) pusherror(L); + return f; +} + +/* }====================================================== */ + + + +#elif defined(LUA_DL_DYLD) +/* +** {====================================================================== +** Native Mac OS X / Darwin Implementation +** ======================================================================= +*/ + +#include + + +/* Mac appends a `_' before C function names */ +#undef POF +#define POF "_" LUA_POF + + +static void pusherror (lua_State *L) { + const char *err_str; + const char *err_file; + NSLinkEditErrors err; + int err_num; + NSLinkEditError(&err, &err_num, &err_file, &err_str); + lua_pushstring(L, err_str); +} + + +static const char *errorfromcode (NSObjectFileImageReturnCode ret) { + switch (ret) { + case NSObjectFileImageInappropriateFile: + return "file is not a bundle"; + case NSObjectFileImageArch: + return "library is for wrong CPU type"; + case NSObjectFileImageFormat: + return "bad format"; + case NSObjectFileImageAccess: + return "cannot access file"; + case NSObjectFileImageFailure: + default: + return "unable to load library"; + } +} + + +static void ll_unloadlib (void *lib) { + NSUnLinkModule((NSModule)lib, NSUNLINKMODULE_OPTION_RESET_LAZY_REFERENCES); +} + + +static void *ll_load (lua_State *L, const char *path) { + NSObjectFileImage img; + NSObjectFileImageReturnCode ret; + /* this would be a rare case, but prevents crashing if it happens */ + if(!_dyld_present()) { + lua_pushliteral(L, "dyld not present"); + return NULL; + } + ret = NSCreateObjectFileImageFromFile(path, &img); + if (ret == NSObjectFileImageSuccess) { + NSModule mod = NSLinkModule(img, path, NSLINKMODULE_OPTION_PRIVATE | + NSLINKMODULE_OPTION_RETURN_ON_ERROR); + NSDestroyObjectFileImage(img); + if (mod == NULL) pusherror(L); + return mod; + } + lua_pushstring(L, errorfromcode(ret)); + return NULL; +} + + +static lua_CFunction ll_sym (lua_State *L, void *lib, const char *sym) { + NSSymbol nss = NSLookupSymbolInModule((NSModule)lib, sym); + if (nss == NULL) { + lua_pushfstring(L, "symbol " LUA_QS " not found", sym); + return NULL; + } + return (lua_CFunction)NSAddressOfSymbol(nss); +} + +/* }====================================================== */ + + + +#else +/* +** {====================================================== +** Fallback for other systems +** ======================================================= +*/ + +#undef LIB_FAIL +#define LIB_FAIL "absent" + + +#define DLMSG "dynamic libraries not enabled; check your Lua installation" + + +static void ll_unloadlib (void *lib) { + (void)lib; /* to avoid warnings */ +} + + +static void *ll_load (lua_State *L, const char *path) { + (void)path; /* to avoid warnings */ + lua_pushliteral(L, DLMSG); + return NULL; +} + + +static lua_CFunction ll_sym (lua_State *L, void *lib, const char *sym) { + (void)lib; (void)sym; /* to avoid warnings */ + lua_pushliteral(L, DLMSG); + return NULL; +} + +/* }====================================================== */ +#endif + + + +static void **ll_register (lua_State *L, const char *path) { + void **plib; + lua_pushfstring(L, "%s%s", LIBPREFIX, path); + lua_gettable(L, LUA_REGISTRYINDEX); /* check library in registry? */ + if (!lua_isnil(L, -1)) /* is there an entry? */ + plib = (void **)lua_touserdata(L, -1); + else { /* no entry yet; create one */ + lua_pop(L, 1); + plib = (void **)lua_newuserdata(L, sizeof(const void *)); + *plib = NULL; + luaL_getmetatable(L, "_LOADLIB"); + lua_setmetatable(L, -2); + lua_pushfstring(L, "%s%s", LIBPREFIX, path); + lua_pushvalue(L, -2); + lua_settable(L, LUA_REGISTRYINDEX); + } + return plib; +} + + +/* +** __gc tag method: calls library's `ll_unloadlib' function with the lib +** handle +*/ +static int gctm (lua_State *L) { + void **lib = (void **)luaL_checkudata(L, 1, "_LOADLIB"); + if (*lib) ll_unloadlib(*lib); + *lib = NULL; /* mark library as closed */ + return 0; +} + + +static int ll_loadfunc (lua_State *L, const char *path, const char *sym) { + void **reg = ll_register(L, path); + if (*reg == NULL) *reg = ll_load(L, path); + if (*reg == NULL) + return ERRLIB; /* unable to load library */ + else { + lua_CFunction f = ll_sym(L, *reg, sym); + if (f == NULL) + return ERRFUNC; /* unable to find function */ + lua_pushcfunction(L, f); + return 0; /* return function */ + } +} + + +static int ll_loadlib (lua_State *L) { + const char *path = luaL_checkstring(L, 1); + const char *init = luaL_checkstring(L, 2); + int stat = ll_loadfunc(L, path, init); + if (stat == 0) /* no errors? */ + return 1; /* return the loaded function */ + else { /* error; error message is on stack top */ + lua_pushnil(L); + lua_insert(L, -2); + lua_pushstring(L, (stat == ERRLIB) ? LIB_FAIL : "init"); + return 3; /* return nil, error message, and where */ + } +} + + + +/* +** {====================================================== +** 'require' function +** ======================================================= +*/ + + +static int readable (const char *filename) { + FILE *f = fopen(filename, "r"); /* try to open file */ + if (f == NULL) return 0; /* open failed */ + fclose(f); + return 1; +} + + +static const char *pushnexttemplate (lua_State *L, const char *path) { + const char *l; + while (*path == *LUA_PATHSEP) path++; /* skip separators */ + if (*path == '\0') return NULL; /* no more templates */ + l = strchr(path, *LUA_PATHSEP); /* find next separator */ + if (l == NULL) l = path + strlen(path); + lua_pushlstring(L, path, l - path); /* template */ + return l; +} + + +static const char *findfile (lua_State *L, const char *name, + const char *pname) { + const char *path; + name = luaL_gsub(L, name, ".", LUA_DIRSEP); + lua_getfield(L, LUA_ENVIRONINDEX, pname); + path = lua_tostring(L, -1); + if (path == NULL) + luaL_error(L, LUA_QL("package.%s") " must be a string", pname); + lua_pushliteral(L, ""); /* error accumulator */ + while ((path = pushnexttemplate(L, path)) != NULL) { + const char *filename; + filename = luaL_gsub(L, lua_tostring(L, -1), LUA_PATH_MARK, name); + lua_remove(L, -2); /* remove path template */ + if (readable(filename)) /* does file exist and is readable? */ + return filename; /* return that file name */ + lua_pushfstring(L, "\n\tno file " LUA_QS, filename); + lua_remove(L, -2); /* remove file name */ + lua_concat(L, 2); /* add entry to possible error message */ + } + return NULL; /* not found */ +} + + +static void loaderror (lua_State *L, const char *filename) { + luaL_error(L, "error loading module " LUA_QS " from file " LUA_QS ":\n\t%s", + lua_tostring(L, 1), filename, lua_tostring(L, -1)); +} + + +static int loader_Lua (lua_State *L) { + const char *filename; + const char *name = luaL_checkstring(L, 1); + filename = findfile(L, name, "path"); + if (filename == NULL) return 1; /* library not found in this path */ + if (luaL_loadfile(L, filename) != 0) + loaderror(L, filename); + return 1; /* library loaded successfully */ +} + + +static const char *mkfuncname (lua_State *L, const char *modname) { + const char *funcname; + const char *mark = strchr(modname, *LUA_IGMARK); + if (mark) modname = mark + 1; + funcname = luaL_gsub(L, modname, ".", LUA_OFSEP); + funcname = lua_pushfstring(L, POF"%s", funcname); + lua_remove(L, -2); /* remove 'gsub' result */ + return funcname; +} + + +static int loader_C (lua_State *L) { + const char *funcname; + const char *name = luaL_checkstring(L, 1); + const char *filename = findfile(L, name, "cpath"); + if (filename == NULL) return 1; /* library not found in this path */ + funcname = mkfuncname(L, name); + if (ll_loadfunc(L, filename, funcname) != 0) + loaderror(L, filename); + return 1; /* library loaded successfully */ +} + + +static int loader_Croot (lua_State *L) { + const char *funcname; + const char *filename; + const char *name = luaL_checkstring(L, 1); + const char *p = strchr(name, '.'); + int stat; + if (p == NULL) return 0; /* is root */ + lua_pushlstring(L, name, p - name); + filename = findfile(L, lua_tostring(L, -1), "cpath"); + if (filename == NULL) return 1; /* root not found */ + funcname = mkfuncname(L, name); + if ((stat = ll_loadfunc(L, filename, funcname)) != 0) { + if (stat != ERRFUNC) loaderror(L, filename); /* real error */ + lua_pushfstring(L, "\n\tno module " LUA_QS " in file " LUA_QS, + name, filename); + return 1; /* function not found */ + } + return 1; +} + + +static int loader_preload (lua_State *L) { + const char *name = luaL_checkstring(L, 1); + lua_getfield(L, LUA_ENVIRONINDEX, "preload"); + if (!lua_istable(L, -1)) + luaL_error(L, LUA_QL("package.preload") " must be a table"); + lua_getfield(L, -1, name); + if (lua_isnil(L, -1)) /* not found? */ + lua_pushfstring(L, "\n\tno field package.preload['%s']", name); + return 1; +} + + +static const int sentinel_ = 0; +#define sentinel ((void *)&sentinel_) + + +static int ll_require (lua_State *L) { + const char *name = luaL_checkstring(L, 1); + int i; + lua_settop(L, 1); /* _LOADED table will be at index 2 */ + lua_getfield(L, LUA_REGISTRYINDEX, "_LOADED"); + lua_getfield(L, 2, name); + if (lua_toboolean(L, -1)) { /* is it there? */ + if (lua_touserdata(L, -1) == sentinel) /* check loops */ + luaL_error(L, "loop or previous error loading module " LUA_QS, name); + return 1; /* package is already loaded */ + } + /* else must load it; iterate over available loaders */ + lua_getfield(L, LUA_ENVIRONINDEX, "loaders"); + if (!lua_istable(L, -1)) + luaL_error(L, LUA_QL("package.loaders") " must be a table"); + lua_pushliteral(L, ""); /* error message accumulator */ + for (i=1; ; i++) { + lua_rawgeti(L, -2, i); /* get a loader */ + if (lua_isnil(L, -1)) + luaL_error(L, "module " LUA_QS " not found:%s", + name, lua_tostring(L, -2)); + lua_pushstring(L, name); + lua_call(L, 1, 1); /* call it */ + if (lua_isfunction(L, -1)) /* did it find module? */ + break; /* module loaded successfully */ + else if (lua_isstring(L, -1)) /* loader returned error message? */ + lua_concat(L, 2); /* accumulate it */ + else + lua_pop(L, 1); + } + lua_pushlightuserdata(L, sentinel); + lua_setfield(L, 2, name); /* _LOADED[name] = sentinel */ + lua_pushstring(L, name); /* pass name as argument to module */ + lua_call(L, 1, 1); /* run loaded module */ + if (!lua_isnil(L, -1)) /* non-nil return? */ + lua_setfield(L, 2, name); /* _LOADED[name] = returned value */ + lua_getfield(L, 2, name); + if (lua_touserdata(L, -1) == sentinel) { /* module did not set a value? */ + lua_pushboolean(L, 1); /* use true as result */ + lua_pushvalue(L, -1); /* extra copy to be returned */ + lua_setfield(L, 2, name); /* _LOADED[name] = true */ + } + return 1; +} + +/* }====================================================== */ + + + +/* +** {====================================================== +** 'module' function +** ======================================================= +*/ + + +static void setfenv (lua_State *L) { + lua_Debug ar; + if (lua_getstack(L, 1, &ar) == 0 || + lua_getinfo(L, "f", &ar) == 0 || /* get calling function */ + lua_iscfunction(L, -1)) + luaL_error(L, LUA_QL("module") " not called from a Lua function"); + lua_pushvalue(L, -2); + lua_setfenv(L, -2); + lua_pop(L, 1); +} + + +static void dooptions (lua_State *L, int n) { + int i; + for (i = 2; i <= n; i++) { + lua_pushvalue(L, i); /* get option (a function) */ + lua_pushvalue(L, -2); /* module */ + lua_call(L, 1, 0); + } +} + + +static void modinit (lua_State *L, const char *modname) { + const char *dot; + lua_pushvalue(L, -1); + lua_setfield(L, -2, "_M"); /* module._M = module */ + lua_pushstring(L, modname); + lua_setfield(L, -2, "_NAME"); + dot = strrchr(modname, '.'); /* look for last dot in module name */ + if (dot == NULL) dot = modname; + else dot++; + /* set _PACKAGE as package name (full module name minus last part) */ + lua_pushlstring(L, modname, dot - modname); + lua_setfield(L, -2, "_PACKAGE"); +} + + +static int ll_module (lua_State *L) { + const char *modname = luaL_checkstring(L, 1); + int loaded = lua_gettop(L) + 1; /* index of _LOADED table */ + lua_getfield(L, LUA_REGISTRYINDEX, "_LOADED"); + lua_getfield(L, loaded, modname); /* get _LOADED[modname] */ + if (!lua_istable(L, -1)) { /* not found? */ + lua_pop(L, 1); /* remove previous result */ + /* try global variable (and create one if it does not exist) */ + if (luaL_findtable(L, LUA_GLOBALSINDEX, modname, 1) != NULL) + return luaL_error(L, "name conflict for module " LUA_QS, modname); + lua_pushvalue(L, -1); + lua_setfield(L, loaded, modname); /* _LOADED[modname] = new table */ + } + /* check whether table already has a _NAME field */ + lua_getfield(L, -1, "_NAME"); + if (!lua_isnil(L, -1)) /* is table an initialized module? */ + lua_pop(L, 1); + else { /* no; initialize it */ + lua_pop(L, 1); + modinit(L, modname); + } + lua_pushvalue(L, -1); + setfenv(L); + dooptions(L, loaded - 1); + return 0; +} + + +static int ll_seeall (lua_State *L) { + luaL_checktype(L, 1, LUA_TTABLE); + if (!lua_getmetatable(L, 1)) { + lua_createtable(L, 0, 1); /* create new metatable */ + lua_pushvalue(L, -1); + lua_setmetatable(L, 1); + } + lua_pushvalue(L, LUA_GLOBALSINDEX); + lua_setfield(L, -2, "__index"); /* mt.__index = _G */ + return 0; +} + + +/* }====================================================== */ + + + +/* auxiliary mark (for internal use) */ +#define AUXMARK "\1" + +static void setpath (lua_State *L, const char *fieldname, const char *envname, + const char *def) { + const char *path = getenv(envname); + if (path == NULL) /* no environment variable? */ + lua_pushstring(L, def); /* use default */ + else { + /* replace ";;" by ";AUXMARK;" and then AUXMARK by default path */ + path = luaL_gsub(L, path, LUA_PATHSEP LUA_PATHSEP, + LUA_PATHSEP AUXMARK LUA_PATHSEP); + luaL_gsub(L, path, AUXMARK, def); + lua_remove(L, -2); + } + setprogdir(L); + lua_setfield(L, -2, fieldname); +} + + +static const luaL_Reg pk_funcs[] = { + {"loadlib", ll_loadlib}, + {"seeall", ll_seeall}, + {NULL, NULL} +}; + + +static const luaL_Reg ll_funcs[] = { + {"module", ll_module}, + {"require", ll_require}, + {NULL, NULL} +}; + + +static const lua_CFunction loaders[] = + {loader_preload, loader_Lua, loader_C, loader_Croot, NULL}; + + +LUALIB_API int luaopen_package (lua_State *L) { + int i; + /* create new type _LOADLIB */ + luaL_newmetatable(L, "_LOADLIB"); + lua_pushcfunction(L, gctm); + lua_setfield(L, -2, "__gc"); + /* create `package' table */ + luaL_register(L, LUA_LOADLIBNAME, pk_funcs); +#if defined(LUA_COMPAT_LOADLIB) + lua_getfield(L, -1, "loadlib"); + lua_setfield(L, LUA_GLOBALSINDEX, "loadlib"); +#endif + lua_pushvalue(L, -1); + lua_replace(L, LUA_ENVIRONINDEX); + /* create `loaders' table */ + lua_createtable(L, 0, sizeof(loaders)/sizeof(loaders[0]) - 1); + /* fill it with pre-defined loaders */ + for (i=0; loaders[i] != NULL; i++) { + lua_pushcfunction(L, loaders[i]); + lua_rawseti(L, -2, i+1); + } + lua_setfield(L, -2, "loaders"); /* put it in field `loaders' */ + setpath(L, "path", LUA_PATH, LUA_PATH_DEFAULT); /* set field `path' */ + setpath(L, "cpath", LUA_CPATH, LUA_CPATH_DEFAULT); /* set field `cpath' */ + /* store config information */ + lua_pushliteral(L, LUA_DIRSEP "\n" LUA_PATHSEP "\n" LUA_PATH_MARK "\n" + LUA_EXECDIR "\n" LUA_IGMARK); + lua_setfield(L, -2, "config"); + /* set field `loaded' */ + luaL_findtable(L, LUA_REGISTRYINDEX, "_LOADED", 2); + lua_setfield(L, -2, "loaded"); + /* set field `preload' */ + lua_newtable(L); + lua_setfield(L, -2, "preload"); + lua_pushvalue(L, LUA_GLOBALSINDEX); + luaL_register(L, NULL, ll_funcs); /* open lib into global table */ + lua_pop(L, 1); + return 1; /* return 'package' table */ +} + diff --git a/mk/linux/mojosetup/lua/src/lobject.c b/mk/linux/mojosetup/lua/src/lobject.c new file mode 100644 index 00000000..4ff50732 --- /dev/null +++ b/mk/linux/mojosetup/lua/src/lobject.c @@ -0,0 +1,214 @@ +/* +** $Id: lobject.c,v 2.22.1.1 2007/12/27 13:02:25 roberto Exp $ +** Some generic functions over Lua objects +** See Copyright Notice in lua.h +*/ + +#include +#include +#include +#include +#include + +#define lobject_c +#define LUA_CORE + +#include "lua.h" + +#include "ldo.h" +#include "lmem.h" +#include "lobject.h" +#include "lstate.h" +#include "lstring.h" +#include "lvm.h" + + + +const TValue luaO_nilobject_ = {{NULL}, LUA_TNIL}; + + +/* +** converts an integer to a "floating point byte", represented as +** (eeeeexxx), where the real value is (1xxx) * 2^(eeeee - 1) if +** eeeee != 0 and (xxx) otherwise. +*/ +int luaO_int2fb (unsigned int x) { + int e = 0; /* expoent */ + while (x >= 16) { + x = (x+1) >> 1; + e++; + } + if (x < 8) return x; + else return ((e+1) << 3) | (cast_int(x) - 8); +} + + +/* converts back */ +int luaO_fb2int (int x) { + int e = (x >> 3) & 31; + if (e == 0) return x; + else return ((x & 7)+8) << (e - 1); +} + + +int luaO_log2 (unsigned int x) { + static const lu_byte log_2[256] = { + 0,1,2,2,3,3,3,3,4,4,4,4,4,4,4,4,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5, + 6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6, + 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7, + 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7, + 8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8, + 8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8, + 8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8, + 8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8 + }; + int l = -1; + while (x >= 256) { l += 8; x >>= 8; } + return l + log_2[x]; + +} + + +int luaO_rawequalObj (const TValue *t1, const TValue *t2) { + if (ttype(t1) != ttype(t2)) return 0; + else switch (ttype(t1)) { + case LUA_TNIL: + return 1; + case LUA_TNUMBER: + return luai_numeq(nvalue(t1), nvalue(t2)); + case LUA_TBOOLEAN: + return bvalue(t1) == bvalue(t2); /* boolean true must be 1 !! */ + case LUA_TLIGHTUSERDATA: + return pvalue(t1) == pvalue(t2); + default: + lua_assert(iscollectable(t1)); + return gcvalue(t1) == gcvalue(t2); + } +} + + +int luaO_str2d (const char *s, lua_Number *result) { + char *endptr; + *result = lua_str2number(s, &endptr); + if (endptr == s) return 0; /* conversion failed */ + if (*endptr == 'x' || *endptr == 'X') /* maybe an hexadecimal constant? */ + *result = cast_num(strtoul(s, &endptr, 16)); + if (*endptr == '\0') return 1; /* most common case */ + while (isspace(cast(unsigned char, *endptr))) endptr++; + if (*endptr != '\0') return 0; /* invalid trailing characters? */ + return 1; +} + + + +static void pushstr (lua_State *L, const char *str) { + setsvalue2s(L, L->top, luaS_new(L, str)); + incr_top(L); +} + + +/* this function handles only `%d', `%c', %f, %p, and `%s' formats */ +const char *luaO_pushvfstring (lua_State *L, const char *fmt, va_list argp) { + int n = 1; + pushstr(L, ""); + for (;;) { + const char *e = strchr(fmt, '%'); + if (e == NULL) break; + setsvalue2s(L, L->top, luaS_newlstr(L, fmt, e-fmt)); + incr_top(L); + switch (*(e+1)) { + case 's': { + const char *s = va_arg(argp, char *); + if (s == NULL) s = "(null)"; + pushstr(L, s); + break; + } + case 'c': { + char buff[2]; + buff[0] = cast(char, va_arg(argp, int)); + buff[1] = '\0'; + pushstr(L, buff); + break; + } + case 'd': { + setnvalue(L->top, cast_num(va_arg(argp, int))); + incr_top(L); + break; + } + case 'f': { + setnvalue(L->top, cast_num(va_arg(argp, l_uacNumber))); + incr_top(L); + break; + } + case 'p': { + char buff[4*sizeof(void *) + 8]; /* should be enough space for a `%p' */ + sprintf(buff, "%p", va_arg(argp, void *)); + pushstr(L, buff); + break; + } + case '%': { + pushstr(L, "%"); + break; + } + default: { + char buff[3]; + buff[0] = '%'; + buff[1] = *(e+1); + buff[2] = '\0'; + pushstr(L, buff); + break; + } + } + n += 2; + fmt = e+2; + } + pushstr(L, fmt); + luaV_concat(L, n+1, cast_int(L->top - L->base) - 1); + L->top -= n; + return svalue(L->top - 1); +} + + +const char *luaO_pushfstring (lua_State *L, const char *fmt, ...) { + const char *msg; + va_list argp; + va_start(argp, fmt); + msg = luaO_pushvfstring(L, fmt, argp); + va_end(argp); + return msg; +} + + +void luaO_chunkid (char *out, const char *source, size_t bufflen) { + if (*source == '=') { + strncpy(out, source+1, bufflen); /* remove first char */ + out[bufflen-1] = '\0'; /* ensures null termination */ + } + else { /* out = "source", or "...source" */ + if (*source == '@') { + size_t l; + source++; /* skip the `@' */ + bufflen -= sizeof(" '...' "); + l = strlen(source); + strcpy(out, ""); + if (l > bufflen) { + source += (l-bufflen); /* get last part of file name */ + strcat(out, "..."); + } + strcat(out, source); + } + else { /* out = [string "string"] */ + size_t len = strcspn(source, "\n\r"); /* stop at first newline */ + bufflen -= sizeof(" [string \"...\"] "); + if (len > bufflen) len = bufflen; + strcpy(out, "[string \""); + if (source[len] != '\0') { /* must truncate? */ + strncat(out, source, len); + strcat(out, "..."); + } + else + strcat(out, source); + strcat(out, "\"]"); + } + } +} diff --git a/mk/linux/mojosetup/lua/src/lobject.h b/mk/linux/mojosetup/lua/src/lobject.h new file mode 100644 index 00000000..f1e447ef --- /dev/null +++ b/mk/linux/mojosetup/lua/src/lobject.h @@ -0,0 +1,381 @@ +/* +** $Id: lobject.h,v 2.20.1.2 2008/08/06 13:29:48 roberto Exp $ +** Type definitions for Lua objects +** See Copyright Notice in lua.h +*/ + + +#ifndef lobject_h +#define lobject_h + + +#include + + +#include "llimits.h" +#include "lua.h" + + +/* tags for values visible from Lua */ +#define LAST_TAG LUA_TTHREAD + +#define NUM_TAGS (LAST_TAG+1) + + +/* +** Extra tags for non-values +*/ +#define LUA_TPROTO (LAST_TAG+1) +#define LUA_TUPVAL (LAST_TAG+2) +#define LUA_TDEADKEY (LAST_TAG+3) + + +/* +** Union of all collectable objects +*/ +typedef union GCObject GCObject; + + +/* +** Common Header for all collectable objects (in macro form, to be +** included in other objects) +*/ +#define CommonHeader GCObject *next; lu_byte tt; lu_byte marked + + +/* +** Common header in struct form +*/ +typedef struct GCheader { + CommonHeader; +} GCheader; + + + + +/* +** Union of all Lua values +*/ +typedef union { + GCObject *gc; + void *p; + lua_Number n; + int b; +} Value; + + +/* +** Tagged Values +*/ + +#define TValuefields Value value; int tt + +typedef struct lua_TValue { + TValuefields; +} TValue; + + +/* Macros to test type */ +#define ttisnil(o) (ttype(o) == LUA_TNIL) +#define ttisnumber(o) (ttype(o) == LUA_TNUMBER) +#define ttisstring(o) (ttype(o) == LUA_TSTRING) +#define ttistable(o) (ttype(o) == LUA_TTABLE) +#define ttisfunction(o) (ttype(o) == LUA_TFUNCTION) +#define ttisboolean(o) (ttype(o) == LUA_TBOOLEAN) +#define ttisuserdata(o) (ttype(o) == LUA_TUSERDATA) +#define ttisthread(o) (ttype(o) == LUA_TTHREAD) +#define ttislightuserdata(o) (ttype(o) == LUA_TLIGHTUSERDATA) + +/* Macros to access values */ +#define ttype(o) ((o)->tt) +#define gcvalue(o) check_exp(iscollectable(o), (o)->value.gc) +#define pvalue(o) check_exp(ttislightuserdata(o), (o)->value.p) +#define nvalue(o) check_exp(ttisnumber(o), (o)->value.n) +#define rawtsvalue(o) check_exp(ttisstring(o), &(o)->value.gc->ts) +#define tsvalue(o) (&rawtsvalue(o)->tsv) +#define rawuvalue(o) check_exp(ttisuserdata(o), &(o)->value.gc->u) +#define uvalue(o) (&rawuvalue(o)->uv) +#define clvalue(o) check_exp(ttisfunction(o), &(o)->value.gc->cl) +#define hvalue(o) check_exp(ttistable(o), &(o)->value.gc->h) +#define bvalue(o) check_exp(ttisboolean(o), (o)->value.b) +#define thvalue(o) check_exp(ttisthread(o), &(o)->value.gc->th) + +#define l_isfalse(o) (ttisnil(o) || (ttisboolean(o) && bvalue(o) == 0)) + +/* +** for internal debug only +*/ +#define checkconsistency(obj) \ + lua_assert(!iscollectable(obj) || (ttype(obj) == (obj)->value.gc->gch.tt)) + +#define checkliveness(g,obj) \ + lua_assert(!iscollectable(obj) || \ + ((ttype(obj) == (obj)->value.gc->gch.tt) && !isdead(g, (obj)->value.gc))) + + +/* Macros to set values */ +#define setnilvalue(obj) ((obj)->tt=LUA_TNIL) + +#define setnvalue(obj,x) \ + { TValue *i_o=(obj); i_o->value.n=(x); i_o->tt=LUA_TNUMBER; } + +#define setpvalue(obj,x) \ + { TValue *i_o=(obj); i_o->value.p=(x); i_o->tt=LUA_TLIGHTUSERDATA; } + +#define setbvalue(obj,x) \ + { TValue *i_o=(obj); i_o->value.b=(x); i_o->tt=LUA_TBOOLEAN; } + +#define setsvalue(L,obj,x) \ + { TValue *i_o=(obj); \ + i_o->value.gc=cast(GCObject *, (x)); i_o->tt=LUA_TSTRING; \ + checkliveness(G(L),i_o); } + +#define setuvalue(L,obj,x) \ + { TValue *i_o=(obj); \ + i_o->value.gc=cast(GCObject *, (x)); i_o->tt=LUA_TUSERDATA; \ + checkliveness(G(L),i_o); } + +#define setthvalue(L,obj,x) \ + { TValue *i_o=(obj); \ + i_o->value.gc=cast(GCObject *, (x)); i_o->tt=LUA_TTHREAD; \ + checkliveness(G(L),i_o); } + +#define setclvalue(L,obj,x) \ + { TValue *i_o=(obj); \ + i_o->value.gc=cast(GCObject *, (x)); i_o->tt=LUA_TFUNCTION; \ + checkliveness(G(L),i_o); } + +#define sethvalue(L,obj,x) \ + { TValue *i_o=(obj); \ + i_o->value.gc=cast(GCObject *, (x)); i_o->tt=LUA_TTABLE; \ + checkliveness(G(L),i_o); } + +#define setptvalue(L,obj,x) \ + { TValue *i_o=(obj); \ + i_o->value.gc=cast(GCObject *, (x)); i_o->tt=LUA_TPROTO; \ + checkliveness(G(L),i_o); } + + + + +#define setobj(L,obj1,obj2) \ + { const TValue *o2=(obj2); TValue *o1=(obj1); \ + o1->value = o2->value; o1->tt=o2->tt; \ + checkliveness(G(L),o1); } + + +/* +** different types of sets, according to destination +*/ + +/* from stack to (same) stack */ +#define setobjs2s setobj +/* to stack (not from same stack) */ +#define setobj2s setobj +#define setsvalue2s setsvalue +#define sethvalue2s sethvalue +#define setptvalue2s setptvalue +/* from table to same table */ +#define setobjt2t setobj +/* to table */ +#define setobj2t setobj +/* to new object */ +#define setobj2n setobj +#define setsvalue2n setsvalue + +#define setttype(obj, tt) (ttype(obj) = (tt)) + + +#define iscollectable(o) (ttype(o) >= LUA_TSTRING) + + + +typedef TValue *StkId; /* index to stack elements */ + + +/* +** String headers for string table +*/ +typedef union TString { + L_Umaxalign dummy; /* ensures maximum alignment for strings */ + struct { + CommonHeader; + lu_byte reserved; + unsigned int hash; + size_t len; + } tsv; +} TString; + + +#define getstr(ts) cast(const char *, (ts) + 1) +#define svalue(o) getstr(rawtsvalue(o)) + + + +typedef union Udata { + L_Umaxalign dummy; /* ensures maximum alignment for `local' udata */ + struct { + CommonHeader; + struct Table *metatable; + struct Table *env; + size_t len; + } uv; +} Udata; + + + + +/* +** Function Prototypes +*/ +typedef struct Proto { + CommonHeader; + TValue *k; /* constants used by the function */ + Instruction *code; + struct Proto **p; /* functions defined inside the function */ + int *lineinfo; /* map from opcodes to source lines */ + struct LocVar *locvars; /* information about local variables */ + TString **upvalues; /* upvalue names */ + TString *source; + int sizeupvalues; + int sizek; /* size of `k' */ + int sizecode; + int sizelineinfo; + int sizep; /* size of `p' */ + int sizelocvars; + int linedefined; + int lastlinedefined; + GCObject *gclist; + lu_byte nups; /* number of upvalues */ + lu_byte numparams; + lu_byte is_vararg; + lu_byte maxstacksize; +} Proto; + + +/* masks for new-style vararg */ +#define VARARG_HASARG 1 +#define VARARG_ISVARARG 2 +#define VARARG_NEEDSARG 4 + + +typedef struct LocVar { + TString *varname; + int startpc; /* first point where variable is active */ + int endpc; /* first point where variable is dead */ +} LocVar; + + + +/* +** Upvalues +*/ + +typedef struct UpVal { + CommonHeader; + TValue *v; /* points to stack or to its own value */ + union { + TValue value; /* the value (when closed) */ + struct { /* double linked list (when open) */ + struct UpVal *prev; + struct UpVal *next; + } l; + } u; +} UpVal; + + +/* +** Closures +*/ + +#define ClosureHeader \ + CommonHeader; lu_byte isC; lu_byte nupvalues; GCObject *gclist; \ + struct Table *env + +typedef struct CClosure { + ClosureHeader; + lua_CFunction f; + TValue upvalue[1]; +} CClosure; + + +typedef struct LClosure { + ClosureHeader; + struct Proto *p; + UpVal *upvals[1]; +} LClosure; + + +typedef union Closure { + CClosure c; + LClosure l; +} Closure; + + +#define iscfunction(o) (ttype(o) == LUA_TFUNCTION && clvalue(o)->c.isC) +#define isLfunction(o) (ttype(o) == LUA_TFUNCTION && !clvalue(o)->c.isC) + + +/* +** Tables +*/ + +typedef union TKey { + struct { + TValuefields; + struct Node *next; /* for chaining */ + } nk; + TValue tvk; +} TKey; + + +typedef struct Node { + TValue i_val; + TKey i_key; +} Node; + + +typedef struct Table { + CommonHeader; + lu_byte flags; /* 1<

lsizenode)) + + +#define luaO_nilobject (&luaO_nilobject_) + +LUAI_DATA const TValue luaO_nilobject_; + +#define ceillog2(x) (luaO_log2((x)-1) + 1) + +LUAI_FUNC int luaO_log2 (unsigned int x); +LUAI_FUNC int luaO_int2fb (unsigned int x); +LUAI_FUNC int luaO_fb2int (int x); +LUAI_FUNC int luaO_rawequalObj (const TValue *t1, const TValue *t2); +LUAI_FUNC int luaO_str2d (const char *s, lua_Number *result); +LUAI_FUNC const char *luaO_pushvfstring (lua_State *L, const char *fmt, + va_list argp); +LUAI_FUNC const char *luaO_pushfstring (lua_State *L, const char *fmt, ...); +LUAI_FUNC void luaO_chunkid (char *out, const char *source, size_t len); + + +#endif + diff --git a/mk/linux/mojosetup/lua/src/lopcodes.c b/mk/linux/mojosetup/lua/src/lopcodes.c new file mode 100644 index 00000000..4cc74523 --- /dev/null +++ b/mk/linux/mojosetup/lua/src/lopcodes.c @@ -0,0 +1,102 @@ +/* +** $Id: lopcodes.c,v 1.37.1.1 2007/12/27 13:02:25 roberto Exp $ +** See Copyright Notice in lua.h +*/ + + +#define lopcodes_c +#define LUA_CORE + + +#include "lopcodes.h" + + +/* ORDER OP */ + +const char *const luaP_opnames[NUM_OPCODES+1] = { + "MOVE", + "LOADK", + "LOADBOOL", + "LOADNIL", + "GETUPVAL", + "GETGLOBAL", + "GETTABLE", + "SETGLOBAL", + "SETUPVAL", + "SETTABLE", + "NEWTABLE", + "SELF", + "ADD", + "SUB", + "MUL", + "DIV", + "MOD", + "POW", + "UNM", + "NOT", + "LEN", + "CONCAT", + "JMP", + "EQ", + "LT", + "LE", + "TEST", + "TESTSET", + "CALL", + "TAILCALL", + "RETURN", + "FORLOOP", + "FORPREP", + "TFORLOOP", + "SETLIST", + "CLOSE", + "CLOSURE", + "VARARG", + NULL +}; + + +#define opmode(t,a,b,c,m) (((t)<<7) | ((a)<<6) | ((b)<<4) | ((c)<<2) | (m)) + +const lu_byte luaP_opmodes[NUM_OPCODES] = { +/* T A B C mode opcode */ + opmode(0, 1, OpArgR, OpArgN, iABC) /* OP_MOVE */ + ,opmode(0, 1, OpArgK, OpArgN, iABx) /* OP_LOADK */ + ,opmode(0, 1, OpArgU, OpArgU, iABC) /* OP_LOADBOOL */ + ,opmode(0, 1, OpArgR, OpArgN, iABC) /* OP_LOADNIL */ + ,opmode(0, 1, OpArgU, OpArgN, iABC) /* OP_GETUPVAL */ + ,opmode(0, 1, OpArgK, OpArgN, iABx) /* OP_GETGLOBAL */ + ,opmode(0, 1, OpArgR, OpArgK, iABC) /* OP_GETTABLE */ + ,opmode(0, 0, OpArgK, OpArgN, iABx) /* OP_SETGLOBAL */ + ,opmode(0, 0, OpArgU, OpArgN, iABC) /* OP_SETUPVAL */ + ,opmode(0, 0, OpArgK, OpArgK, iABC) /* OP_SETTABLE */ + ,opmode(0, 1, OpArgU, OpArgU, iABC) /* OP_NEWTABLE */ + ,opmode(0, 1, OpArgR, OpArgK, iABC) /* OP_SELF */ + ,opmode(0, 1, OpArgK, OpArgK, iABC) /* OP_ADD */ + ,opmode(0, 1, OpArgK, OpArgK, iABC) /* OP_SUB */ + ,opmode(0, 1, OpArgK, OpArgK, iABC) /* OP_MUL */ + ,opmode(0, 1, OpArgK, OpArgK, iABC) /* OP_DIV */ + ,opmode(0, 1, OpArgK, OpArgK, iABC) /* OP_MOD */ + ,opmode(0, 1, OpArgK, OpArgK, iABC) /* OP_POW */ + ,opmode(0, 1, OpArgR, OpArgN, iABC) /* OP_UNM */ + ,opmode(0, 1, OpArgR, OpArgN, iABC) /* OP_NOT */ + ,opmode(0, 1, OpArgR, OpArgN, iABC) /* OP_LEN */ + ,opmode(0, 1, OpArgR, OpArgR, iABC) /* OP_CONCAT */ + ,opmode(0, 0, OpArgR, OpArgN, iAsBx) /* OP_JMP */ + ,opmode(1, 0, OpArgK, OpArgK, iABC) /* OP_EQ */ + ,opmode(1, 0, OpArgK, OpArgK, iABC) /* OP_LT */ + ,opmode(1, 0, OpArgK, OpArgK, iABC) /* OP_LE */ + ,opmode(1, 1, OpArgR, OpArgU, iABC) /* OP_TEST */ + ,opmode(1, 1, OpArgR, OpArgU, iABC) /* OP_TESTSET */ + ,opmode(0, 1, OpArgU, OpArgU, iABC) /* OP_CALL */ + ,opmode(0, 1, OpArgU, OpArgU, iABC) /* OP_TAILCALL */ + ,opmode(0, 0, OpArgU, OpArgN, iABC) /* OP_RETURN */ + ,opmode(0, 1, OpArgR, OpArgN, iAsBx) /* OP_FORLOOP */ + ,opmode(0, 1, OpArgR, OpArgN, iAsBx) /* OP_FORPREP */ + ,opmode(1, 0, OpArgN, OpArgU, iABC) /* OP_TFORLOOP */ + ,opmode(0, 0, OpArgU, OpArgU, iABC) /* OP_SETLIST */ + ,opmode(0, 0, OpArgN, OpArgN, iABC) /* OP_CLOSE */ + ,opmode(0, 1, OpArgU, OpArgN, iABx) /* OP_CLOSURE */ + ,opmode(0, 1, OpArgU, OpArgN, iABC) /* OP_VARARG */ +}; + diff --git a/mk/linux/mojosetup/lua/src/lopcodes.h b/mk/linux/mojosetup/lua/src/lopcodes.h new file mode 100644 index 00000000..41224d6e --- /dev/null +++ b/mk/linux/mojosetup/lua/src/lopcodes.h @@ -0,0 +1,268 @@ +/* +** $Id: lopcodes.h,v 1.125.1.1 2007/12/27 13:02:25 roberto Exp $ +** Opcodes for Lua virtual machine +** See Copyright Notice in lua.h +*/ + +#ifndef lopcodes_h +#define lopcodes_h + +#include "llimits.h" + + +/*=========================================================================== + We assume that instructions are unsigned numbers. + All instructions have an opcode in the first 6 bits. + Instructions can have the following fields: + `A' : 8 bits + `B' : 9 bits + `C' : 9 bits + `Bx' : 18 bits (`B' and `C' together) + `sBx' : signed Bx + + A signed argument is represented in excess K; that is, the number + value is the unsigned value minus K. K is exactly the maximum value + for that argument (so that -max is represented by 0, and +max is + represented by 2*max), which is half the maximum for the corresponding + unsigned argument. +===========================================================================*/ + + +enum OpMode {iABC, iABx, iAsBx}; /* basic instruction format */ + + +/* +** size and position of opcode arguments. +*/ +#define SIZE_C 9 +#define SIZE_B 9 +#define SIZE_Bx (SIZE_C + SIZE_B) +#define SIZE_A 8 + +#define SIZE_OP 6 + +#define POS_OP 0 +#define POS_A (POS_OP + SIZE_OP) +#define POS_C (POS_A + SIZE_A) +#define POS_B (POS_C + SIZE_C) +#define POS_Bx POS_C + + +/* +** limits for opcode arguments. +** we use (signed) int to manipulate most arguments, +** so they must fit in LUAI_BITSINT-1 bits (-1 for sign) +*/ +#if SIZE_Bx < LUAI_BITSINT-1 +#define MAXARG_Bx ((1<>1) /* `sBx' is signed */ +#else +#define MAXARG_Bx MAX_INT +#define MAXARG_sBx MAX_INT +#endif + + +#define MAXARG_A ((1<>POS_OP) & MASK1(SIZE_OP,0))) +#define SET_OPCODE(i,o) ((i) = (((i)&MASK0(SIZE_OP,POS_OP)) | \ + ((cast(Instruction, o)<>POS_A) & MASK1(SIZE_A,0))) +#define SETARG_A(i,u) ((i) = (((i)&MASK0(SIZE_A,POS_A)) | \ + ((cast(Instruction, u)<>POS_B) & MASK1(SIZE_B,0))) +#define SETARG_B(i,b) ((i) = (((i)&MASK0(SIZE_B,POS_B)) | \ + ((cast(Instruction, b)<>POS_C) & MASK1(SIZE_C,0))) +#define SETARG_C(i,b) ((i) = (((i)&MASK0(SIZE_C,POS_C)) | \ + ((cast(Instruction, b)<>POS_Bx) & MASK1(SIZE_Bx,0))) +#define SETARG_Bx(i,b) ((i) = (((i)&MASK0(SIZE_Bx,POS_Bx)) | \ + ((cast(Instruction, b)< C) then pc++ */ +OP_TESTSET,/* A B C if (R(B) <=> C) then R(A) := R(B) else pc++ */ + +OP_CALL,/* A B C R(A), ... ,R(A+C-2) := R(A)(R(A+1), ... ,R(A+B-1)) */ +OP_TAILCALL,/* A B C return R(A)(R(A+1), ... ,R(A+B-1)) */ +OP_RETURN,/* A B return R(A), ... ,R(A+B-2) (see note) */ + +OP_FORLOOP,/* A sBx R(A)+=R(A+2); + if R(A) =) R(A)*/ +OP_CLOSURE,/* A Bx R(A) := closure(KPROTO[Bx], R(A), ... ,R(A+n)) */ + +OP_VARARG/* A B R(A), R(A+1), ..., R(A+B-1) = vararg */ +} OpCode; + + +#define NUM_OPCODES (cast(int, OP_VARARG) + 1) + + + +/*=========================================================================== + Notes: + (*) In OP_CALL, if (B == 0) then B = top. C is the number of returns - 1, + and can be 0: OP_CALL then sets `top' to last_result+1, so + next open instruction (OP_CALL, OP_RETURN, OP_SETLIST) may use `top'. + + (*) In OP_VARARG, if (B == 0) then use actual number of varargs and + set top (like in OP_CALL with C == 0). + + (*) In OP_RETURN, if (B == 0) then return up to `top' + + (*) In OP_SETLIST, if (B == 0) then B = `top'; + if (C == 0) then next `instruction' is real C + + (*) For comparisons, A specifies what condition the test should accept + (true or false). + + (*) All `skips' (pc++) assume that next instruction is a jump +===========================================================================*/ + + +/* +** masks for instruction properties. The format is: +** bits 0-1: op mode +** bits 2-3: C arg mode +** bits 4-5: B arg mode +** bit 6: instruction set register A +** bit 7: operator is a test +*/ + +enum OpArgMask { + OpArgN, /* argument is not used */ + OpArgU, /* argument is used */ + OpArgR, /* argument is a register or a jump offset */ + OpArgK /* argument is a constant or register/constant */ +}; + +LUAI_DATA const lu_byte luaP_opmodes[NUM_OPCODES]; + +#define getOpMode(m) (cast(enum OpMode, luaP_opmodes[m] & 3)) +#define getBMode(m) (cast(enum OpArgMask, (luaP_opmodes[m] >> 4) & 3)) +#define getCMode(m) (cast(enum OpArgMask, (luaP_opmodes[m] >> 2) & 3)) +#define testAMode(m) (luaP_opmodes[m] & (1 << 6)) +#define testTMode(m) (luaP_opmodes[m] & (1 << 7)) + + +LUAI_DATA const char *const luaP_opnames[NUM_OPCODES+1]; /* opcode names */ + + +/* number of list items to accumulate before a SETLIST instruction */ +#define LFIELDS_PER_FLUSH 50 + + +#endif diff --git a/mk/linux/mojosetup/lua/src/loslib.c b/mk/linux/mojosetup/lua/src/loslib.c new file mode 100644 index 00000000..da06a572 --- /dev/null +++ b/mk/linux/mojosetup/lua/src/loslib.c @@ -0,0 +1,243 @@ +/* +** $Id: loslib.c,v 1.19.1.3 2008/01/18 16:38:18 roberto Exp $ +** Standard Operating System library +** See Copyright Notice in lua.h +*/ + + +#include +#include +#include +#include +#include + +#define loslib_c +#define LUA_LIB + +#include "lua.h" + +#include "lauxlib.h" +#include "lualib.h" + + +static int os_pushresult (lua_State *L, int i, const char *filename) { + int en = errno; /* calls to Lua API may change this value */ + if (i) { + lua_pushboolean(L, 1); + return 1; + } + else { + lua_pushnil(L); + lua_pushfstring(L, "%s: %s", filename, strerror(en)); + lua_pushinteger(L, en); + return 3; + } +} + + +static int os_execute (lua_State *L) { + lua_pushinteger(L, system(luaL_optstring(L, 1, NULL))); + return 1; +} + + +static int os_remove (lua_State *L) { + const char *filename = luaL_checkstring(L, 1); + return os_pushresult(L, remove(filename) == 0, filename); +} + + +static int os_rename (lua_State *L) { + const char *fromname = luaL_checkstring(L, 1); + const char *toname = luaL_checkstring(L, 2); + return os_pushresult(L, rename(fromname, toname) == 0, fromname); +} + + +static int os_tmpname (lua_State *L) { + char buff[LUA_TMPNAMBUFSIZE]; + int err; + lua_tmpnam(buff, err); + if (err) + return luaL_error(L, "unable to generate a unique filename"); + lua_pushstring(L, buff); + return 1; +} + + +static int os_getenv (lua_State *L) { + lua_pushstring(L, getenv(luaL_checkstring(L, 1))); /* if NULL push nil */ + return 1; +} + + +static int os_clock (lua_State *L) { + lua_pushnumber(L, ((lua_Number)clock())/(lua_Number)CLOCKS_PER_SEC); + return 1; +} + + +/* +** {====================================================== +** Time/Date operations +** { year=%Y, month=%m, day=%d, hour=%H, min=%M, sec=%S, +** wday=%w+1, yday=%j, isdst=? } +** ======================================================= +*/ + +static void setfield (lua_State *L, const char *key, int value) { + lua_pushinteger(L, value); + lua_setfield(L, -2, key); +} + +static void setboolfield (lua_State *L, const char *key, int value) { + if (value < 0) /* undefined? */ + return; /* does not set field */ + lua_pushboolean(L, value); + lua_setfield(L, -2, key); +} + +static int getboolfield (lua_State *L, const char *key) { + int res; + lua_getfield(L, -1, key); + res = lua_isnil(L, -1) ? -1 : lua_toboolean(L, -1); + lua_pop(L, 1); + return res; +} + + +static int getfield (lua_State *L, const char *key, int d) { + int res; + lua_getfield(L, -1, key); + if (lua_isnumber(L, -1)) + res = (int)lua_tointeger(L, -1); + else { + if (d < 0) + return luaL_error(L, "field " LUA_QS " missing in date table", key); + res = d; + } + lua_pop(L, 1); + return res; +} + + +static int os_date (lua_State *L) { + const char *s = luaL_optstring(L, 1, "%c"); + time_t t = luaL_opt(L, (time_t)luaL_checknumber, 2, time(NULL)); + struct tm *stm; + if (*s == '!') { /* UTC? */ + stm = gmtime(&t); + s++; /* skip `!' */ + } + else + stm = localtime(&t); + if (stm == NULL) /* invalid date? */ + lua_pushnil(L); + else if (strcmp(s, "*t") == 0) { + lua_createtable(L, 0, 9); /* 9 = number of fields */ + setfield(L, "sec", stm->tm_sec); + setfield(L, "min", stm->tm_min); + setfield(L, "hour", stm->tm_hour); + setfield(L, "day", stm->tm_mday); + setfield(L, "month", stm->tm_mon+1); + setfield(L, "year", stm->tm_year+1900); + setfield(L, "wday", stm->tm_wday+1); + setfield(L, "yday", stm->tm_yday+1); + setboolfield(L, "isdst", stm->tm_isdst); + } + else { + char cc[3]; + luaL_Buffer b; + cc[0] = '%'; cc[2] = '\0'; + luaL_buffinit(L, &b); + for (; *s; s++) { + if (*s != '%' || *(s + 1) == '\0') /* no conversion specifier? */ + luaL_addchar(&b, *s); + else { + size_t reslen; + char buff[200]; /* should be big enough for any conversion result */ + cc[1] = *(++s); + reslen = strftime(buff, sizeof(buff), cc, stm); + luaL_addlstring(&b, buff, reslen); + } + } + luaL_pushresult(&b); + } + return 1; +} + + +static int os_time (lua_State *L) { + time_t t; + if (lua_isnoneornil(L, 1)) /* called without args? */ + t = time(NULL); /* get current time */ + else { + struct tm ts; + luaL_checktype(L, 1, LUA_TTABLE); + lua_settop(L, 1); /* make sure table is at the top */ + ts.tm_sec = getfield(L, "sec", 0); + ts.tm_min = getfield(L, "min", 0); + ts.tm_hour = getfield(L, "hour", 12); + ts.tm_mday = getfield(L, "day", -1); + ts.tm_mon = getfield(L, "month", -1) - 1; + ts.tm_year = getfield(L, "year", -1) - 1900; + ts.tm_isdst = getboolfield(L, "isdst"); + t = mktime(&ts); + } + if (t == (time_t)(-1)) + lua_pushnil(L); + else + lua_pushnumber(L, (lua_Number)t); + return 1; +} + + +static int os_difftime (lua_State *L) { + lua_pushnumber(L, difftime((time_t)(luaL_checknumber(L, 1)), + (time_t)(luaL_optnumber(L, 2, 0)))); + return 1; +} + +/* }====================================================== */ + + +static int os_setlocale (lua_State *L) { + static const int cat[] = {LC_ALL, LC_COLLATE, LC_CTYPE, LC_MONETARY, + LC_NUMERIC, LC_TIME}; + static const char *const catnames[] = {"all", "collate", "ctype", "monetary", + "numeric", "time", NULL}; + const char *l = luaL_optstring(L, 1, NULL); + int op = luaL_checkoption(L, 2, "all", catnames); + lua_pushstring(L, setlocale(cat[op], l)); + return 1; +} + + +static int os_exit (lua_State *L) { + exit(luaL_optint(L, 1, EXIT_SUCCESS)); +} + +static const luaL_Reg syslib[] = { + {"clock", os_clock}, + {"date", os_date}, + {"difftime", os_difftime}, + {"execute", os_execute}, + {"exit", os_exit}, + {"getenv", os_getenv}, + {"remove", os_remove}, + {"rename", os_rename}, + {"setlocale", os_setlocale}, + {"time", os_time}, + {"tmpname", os_tmpname}, + {NULL, NULL} +}; + +/* }====================================================== */ + + + +LUALIB_API int luaopen_os (lua_State *L) { + luaL_register(L, LUA_OSLIBNAME, syslib); + return 1; +} + diff --git a/mk/linux/mojosetup/lua/src/lparser.c b/mk/linux/mojosetup/lua/src/lparser.c new file mode 100644 index 00000000..1e2a9a88 --- /dev/null +++ b/mk/linux/mojosetup/lua/src/lparser.c @@ -0,0 +1,1339 @@ +/* +** $Id: lparser.c,v 2.42.1.3 2007/12/28 15:32:23 roberto Exp $ +** Lua Parser +** See Copyright Notice in lua.h +*/ + + +#include + +#define lparser_c +#define LUA_CORE + +#include "lua.h" + +#include "lcode.h" +#include "ldebug.h" +#include "ldo.h" +#include "lfunc.h" +#include "llex.h" +#include "lmem.h" +#include "lobject.h" +#include "lopcodes.h" +#include "lparser.h" +#include "lstate.h" +#include "lstring.h" +#include "ltable.h" + + + +#define hasmultret(k) ((k) == VCALL || (k) == VVARARG) + +#define getlocvar(fs, i) ((fs)->f->locvars[(fs)->actvar[i]]) + +#define luaY_checklimit(fs,v,l,m) if ((v)>(l)) errorlimit(fs,l,m) + + +/* +** nodes for block list (list of active blocks) +*/ +typedef struct BlockCnt { + struct BlockCnt *previous; /* chain */ + int breaklist; /* list of jumps out of this loop */ + lu_byte nactvar; /* # active locals outside the breakable structure */ + lu_byte upval; /* true if some variable in the block is an upvalue */ + lu_byte isbreakable; /* true if `block' is a loop */ +} BlockCnt; + + + +/* +** prototypes for recursive non-terminal functions +*/ +static void chunk (LexState *ls); +static void expr (LexState *ls, expdesc *v); + + +static void anchor_token (LexState *ls) { + if (ls->t.token == TK_NAME || ls->t.token == TK_STRING) { + TString *ts = ls->t.seminfo.ts; + luaX_newstring(ls, getstr(ts), ts->tsv.len); + } +} + + +static void error_expected (LexState *ls, int token) { + luaX_syntaxerror(ls, + luaO_pushfstring(ls->L, LUA_QS " expected", luaX_token2str(ls, token))); +} + + +static void errorlimit (FuncState *fs, int limit, const char *what) { + const char *msg = (fs->f->linedefined == 0) ? + luaO_pushfstring(fs->L, "main function has more than %d %s", limit, what) : + luaO_pushfstring(fs->L, "function at line %d has more than %d %s", + fs->f->linedefined, limit, what); + luaX_lexerror(fs->ls, msg, 0); +} + + +static int testnext (LexState *ls, int c) { + if (ls->t.token == c) { + luaX_next(ls); + return 1; + } + else return 0; +} + + +static void check (LexState *ls, int c) { + if (ls->t.token != c) + error_expected(ls, c); +} + +static void checknext (LexState *ls, int c) { + check(ls, c); + luaX_next(ls); +} + + +#define check_condition(ls,c,msg) { if (!(c)) luaX_syntaxerror(ls, msg); } + + + +static void check_match (LexState *ls, int what, int who, int where) { + if (!testnext(ls, what)) { + if (where == ls->linenumber) + error_expected(ls, what); + else { + luaX_syntaxerror(ls, luaO_pushfstring(ls->L, + LUA_QS " expected (to close " LUA_QS " at line %d)", + luaX_token2str(ls, what), luaX_token2str(ls, who), where)); + } + } +} + + +static TString *str_checkname (LexState *ls) { + TString *ts; + check(ls, TK_NAME); + ts = ls->t.seminfo.ts; + luaX_next(ls); + return ts; +} + + +static void init_exp (expdesc *e, expkind k, int i) { + e->f = e->t = NO_JUMP; + e->k = k; + e->u.s.info = i; +} + + +static void codestring (LexState *ls, expdesc *e, TString *s) { + init_exp(e, VK, luaK_stringK(ls->fs, s)); +} + + +static void checkname(LexState *ls, expdesc *e) { + codestring(ls, e, str_checkname(ls)); +} + + +static int registerlocalvar (LexState *ls, TString *varname) { + FuncState *fs = ls->fs; + Proto *f = fs->f; + int oldsize = f->sizelocvars; + luaM_growvector(ls->L, f->locvars, fs->nlocvars, f->sizelocvars, + LocVar, SHRT_MAX, "too many local variables"); + while (oldsize < f->sizelocvars) f->locvars[oldsize++].varname = NULL; + f->locvars[fs->nlocvars].varname = varname; + luaC_objbarrier(ls->L, f, varname); + return fs->nlocvars++; +} + + +#define new_localvarliteral(ls,v,n) \ + new_localvar(ls, luaX_newstring(ls, "" v, (sizeof(v)/sizeof(char))-1), n) + + +static void new_localvar (LexState *ls, TString *name, int n) { + FuncState *fs = ls->fs; + luaY_checklimit(fs, fs->nactvar+n+1, LUAI_MAXVARS, "local variables"); + fs->actvar[fs->nactvar+n] = cast(unsigned short, registerlocalvar(ls, name)); +} + + +static void adjustlocalvars (LexState *ls, int nvars) { + FuncState *fs = ls->fs; + fs->nactvar = cast_byte(fs->nactvar + nvars); + for (; nvars; nvars--) { + getlocvar(fs, fs->nactvar - nvars).startpc = fs->pc; + } +} + + +static void removevars (LexState *ls, int tolevel) { + FuncState *fs = ls->fs; + while (fs->nactvar > tolevel) + getlocvar(fs, --fs->nactvar).endpc = fs->pc; +} + + +static int indexupvalue (FuncState *fs, TString *name, expdesc *v) { + int i; + Proto *f = fs->f; + int oldsize = f->sizeupvalues; + for (i=0; inups; i++) { + if (fs->upvalues[i].k == v->k && fs->upvalues[i].info == v->u.s.info) { + lua_assert(f->upvalues[i] == name); + return i; + } + } + /* new one */ + luaY_checklimit(fs, f->nups + 1, LUAI_MAXUPVALUES, "upvalues"); + luaM_growvector(fs->L, f->upvalues, f->nups, f->sizeupvalues, + TString *, MAX_INT, ""); + while (oldsize < f->sizeupvalues) f->upvalues[oldsize++] = NULL; + f->upvalues[f->nups] = name; + luaC_objbarrier(fs->L, f, name); + lua_assert(v->k == VLOCAL || v->k == VUPVAL); + fs->upvalues[f->nups].k = cast_byte(v->k); + fs->upvalues[f->nups].info = cast_byte(v->u.s.info); + return f->nups++; +} + + +static int searchvar (FuncState *fs, TString *n) { + int i; + for (i=fs->nactvar-1; i >= 0; i--) { + if (n == getlocvar(fs, i).varname) + return i; + } + return -1; /* not found */ +} + + +static void markupval (FuncState *fs, int level) { + BlockCnt *bl = fs->bl; + while (bl && bl->nactvar > level) bl = bl->previous; + if (bl) bl->upval = 1; +} + + +static int singlevaraux (FuncState *fs, TString *n, expdesc *var, int base) { + if (fs == NULL) { /* no more levels? */ + init_exp(var, VGLOBAL, NO_REG); /* default is global variable */ + return VGLOBAL; + } + else { + int v = searchvar(fs, n); /* look up at current level */ + if (v >= 0) { + init_exp(var, VLOCAL, v); + if (!base) + markupval(fs, v); /* local will be used as an upval */ + return VLOCAL; + } + else { /* not found at current level; try upper one */ + if (singlevaraux(fs->prev, n, var, 0) == VGLOBAL) + return VGLOBAL; + var->u.s.info = indexupvalue(fs, n, var); /* else was LOCAL or UPVAL */ + var->k = VUPVAL; /* upvalue in this level */ + return VUPVAL; + } + } +} + + +static void singlevar (LexState *ls, expdesc *var) { + TString *varname = str_checkname(ls); + FuncState *fs = ls->fs; + if (singlevaraux(fs, varname, var, 1) == VGLOBAL) + var->u.s.info = luaK_stringK(fs, varname); /* info points to global name */ +} + + +static void adjust_assign (LexState *ls, int nvars, int nexps, expdesc *e) { + FuncState *fs = ls->fs; + int extra = nvars - nexps; + if (hasmultret(e->k)) { + extra++; /* includes call itself */ + if (extra < 0) extra = 0; + luaK_setreturns(fs, e, extra); /* last exp. provides the difference */ + if (extra > 1) luaK_reserveregs(fs, extra-1); + } + else { + if (e->k != VVOID) luaK_exp2nextreg(fs, e); /* close last expression */ + if (extra > 0) { + int reg = fs->freereg; + luaK_reserveregs(fs, extra); + luaK_nil(fs, reg, extra); + } + } +} + + +static void enterlevel (LexState *ls) { + if (++ls->L->nCcalls > LUAI_MAXCCALLS) + luaX_lexerror(ls, "chunk has too many syntax levels", 0); +} + + +#define leavelevel(ls) ((ls)->L->nCcalls--) + + +static void enterblock (FuncState *fs, BlockCnt *bl, lu_byte isbreakable) { + bl->breaklist = NO_JUMP; + bl->isbreakable = isbreakable; + bl->nactvar = fs->nactvar; + bl->upval = 0; + bl->previous = fs->bl; + fs->bl = bl; + lua_assert(fs->freereg == fs->nactvar); +} + + +static void leaveblock (FuncState *fs) { + BlockCnt *bl = fs->bl; + fs->bl = bl->previous; + removevars(fs->ls, bl->nactvar); + if (bl->upval) + luaK_codeABC(fs, OP_CLOSE, bl->nactvar, 0, 0); + /* a block either controls scope or breaks (never both) */ + lua_assert(!bl->isbreakable || !bl->upval); + lua_assert(bl->nactvar == fs->nactvar); + fs->freereg = fs->nactvar; /* free registers */ + luaK_patchtohere(fs, bl->breaklist); +} + + +static void pushclosure (LexState *ls, FuncState *func, expdesc *v) { + FuncState *fs = ls->fs; + Proto *f = fs->f; + int oldsize = f->sizep; + int i; + luaM_growvector(ls->L, f->p, fs->np, f->sizep, Proto *, + MAXARG_Bx, "constant table overflow"); + while (oldsize < f->sizep) f->p[oldsize++] = NULL; + f->p[fs->np++] = func->f; + luaC_objbarrier(ls->L, f, func->f); + init_exp(v, VRELOCABLE, luaK_codeABx(fs, OP_CLOSURE, 0, fs->np-1)); + for (i=0; if->nups; i++) { + OpCode o = (func->upvalues[i].k == VLOCAL) ? OP_MOVE : OP_GETUPVAL; + luaK_codeABC(fs, o, 0, func->upvalues[i].info, 0); + } +} + + +static void open_func (LexState *ls, FuncState *fs) { + lua_State *L = ls->L; + Proto *f = luaF_newproto(L); + fs->f = f; + fs->prev = ls->fs; /* linked list of funcstates */ + fs->ls = ls; + fs->L = L; + ls->fs = fs; + fs->pc = 0; + fs->lasttarget = -1; + fs->jpc = NO_JUMP; + fs->freereg = 0; + fs->nk = 0; + fs->np = 0; + fs->nlocvars = 0; + fs->nactvar = 0; + fs->bl = NULL; + f->source = ls->source; + f->maxstacksize = 2; /* registers 0/1 are always valid */ + fs->h = luaH_new(L, 0, 0); + /* anchor table of constants and prototype (to avoid being collected) */ + sethvalue2s(L, L->top, fs->h); + incr_top(L); + setptvalue2s(L, L->top, f); + incr_top(L); +} + + +static void close_func (LexState *ls) { + lua_State *L = ls->L; + FuncState *fs = ls->fs; + Proto *f = fs->f; + removevars(ls, 0); + luaK_ret(fs, 0, 0); /* final return */ + luaM_reallocvector(L, f->code, f->sizecode, fs->pc, Instruction); + f->sizecode = fs->pc; + luaM_reallocvector(L, f->lineinfo, f->sizelineinfo, fs->pc, int); + f->sizelineinfo = fs->pc; + luaM_reallocvector(L, f->k, f->sizek, fs->nk, TValue); + f->sizek = fs->nk; + luaM_reallocvector(L, f->p, f->sizep, fs->np, Proto *); + f->sizep = fs->np; + luaM_reallocvector(L, f->locvars, f->sizelocvars, fs->nlocvars, LocVar); + f->sizelocvars = fs->nlocvars; + luaM_reallocvector(L, f->upvalues, f->sizeupvalues, f->nups, TString *); + f->sizeupvalues = f->nups; + lua_assert(luaG_checkcode(f)); + lua_assert(fs->bl == NULL); + ls->fs = fs->prev; + L->top -= 2; /* remove table and prototype from the stack */ + /* last token read was anchored in defunct function; must reanchor it */ + if (fs) anchor_token(ls); +} + + +Proto *luaY_parser (lua_State *L, ZIO *z, Mbuffer *buff, const char *name) { + struct LexState lexstate; + struct FuncState funcstate; + lexstate.buff = buff; + luaX_setinput(L, &lexstate, z, luaS_new(L, name)); + open_func(&lexstate, &funcstate); + funcstate.f->is_vararg = VARARG_ISVARARG; /* main func. is always vararg */ + luaX_next(&lexstate); /* read first token */ + chunk(&lexstate); + check(&lexstate, TK_EOS); + close_func(&lexstate); + lua_assert(funcstate.prev == NULL); + lua_assert(funcstate.f->nups == 0); + lua_assert(lexstate.fs == NULL); + return funcstate.f; +} + + + +/*============================================================*/ +/* GRAMMAR RULES */ +/*============================================================*/ + + +static void field (LexState *ls, expdesc *v) { + /* field -> ['.' | ':'] NAME */ + FuncState *fs = ls->fs; + expdesc key; + luaK_exp2anyreg(fs, v); + luaX_next(ls); /* skip the dot or colon */ + checkname(ls, &key); + luaK_indexed(fs, v, &key); +} + + +static void yindex (LexState *ls, expdesc *v) { + /* index -> '[' expr ']' */ + luaX_next(ls); /* skip the '[' */ + expr(ls, v); + luaK_exp2val(ls->fs, v); + checknext(ls, ']'); +} + + +/* +** {====================================================================== +** Rules for Constructors +** ======================================================================= +*/ + + +struct ConsControl { + expdesc v; /* last list item read */ + expdesc *t; /* table descriptor */ + int nh; /* total number of `record' elements */ + int na; /* total number of array elements */ + int tostore; /* number of array elements pending to be stored */ +}; + + +static void recfield (LexState *ls, struct ConsControl *cc) { + /* recfield -> (NAME | `['exp1`]') = exp1 */ + FuncState *fs = ls->fs; + int reg = ls->fs->freereg; + expdesc key, val; + int rkkey; + if (ls->t.token == TK_NAME) { + luaY_checklimit(fs, cc->nh, MAX_INT, "items in a constructor"); + checkname(ls, &key); + } + else /* ls->t.token == '[' */ + yindex(ls, &key); + cc->nh++; + checknext(ls, '='); + rkkey = luaK_exp2RK(fs, &key); + expr(ls, &val); + luaK_codeABC(fs, OP_SETTABLE, cc->t->u.s.info, rkkey, luaK_exp2RK(fs, &val)); + fs->freereg = reg; /* free registers */ +} + + +static void closelistfield (FuncState *fs, struct ConsControl *cc) { + if (cc->v.k == VVOID) return; /* there is no list item */ + luaK_exp2nextreg(fs, &cc->v); + cc->v.k = VVOID; + if (cc->tostore == LFIELDS_PER_FLUSH) { + luaK_setlist(fs, cc->t->u.s.info, cc->na, cc->tostore); /* flush */ + cc->tostore = 0; /* no more items pending */ + } +} + + +static void lastlistfield (FuncState *fs, struct ConsControl *cc) { + if (cc->tostore == 0) return; + if (hasmultret(cc->v.k)) { + luaK_setmultret(fs, &cc->v); + luaK_setlist(fs, cc->t->u.s.info, cc->na, LUA_MULTRET); + cc->na--; /* do not count last expression (unknown number of elements) */ + } + else { + if (cc->v.k != VVOID) + luaK_exp2nextreg(fs, &cc->v); + luaK_setlist(fs, cc->t->u.s.info, cc->na, cc->tostore); + } +} + + +static void listfield (LexState *ls, struct ConsControl *cc) { + expr(ls, &cc->v); + luaY_checklimit(ls->fs, cc->na, MAX_INT, "items in a constructor"); + cc->na++; + cc->tostore++; +} + + +static void constructor (LexState *ls, expdesc *t) { + /* constructor -> ?? */ + FuncState *fs = ls->fs; + int line = ls->linenumber; + int pc = luaK_codeABC(fs, OP_NEWTABLE, 0, 0, 0); + struct ConsControl cc; + cc.na = cc.nh = cc.tostore = 0; + cc.t = t; + init_exp(t, VRELOCABLE, pc); + init_exp(&cc.v, VVOID, 0); /* no value (yet) */ + luaK_exp2nextreg(ls->fs, t); /* fix it at stack top (for gc) */ + checknext(ls, '{'); + do { + lua_assert(cc.v.k == VVOID || cc.tostore > 0); + if (ls->t.token == '}') break; + closelistfield(fs, &cc); + switch(ls->t.token) { + case TK_NAME: { /* may be listfields or recfields */ + luaX_lookahead(ls); + if (ls->lookahead.token != '=') /* expression? */ + listfield(ls, &cc); + else + recfield(ls, &cc); + break; + } + case '[': { /* constructor_item -> recfield */ + recfield(ls, &cc); + break; + } + default: { /* constructor_part -> listfield */ + listfield(ls, &cc); + break; + } + } + } while (testnext(ls, ',') || testnext(ls, ';')); + check_match(ls, '}', '{', line); + lastlistfield(fs, &cc); + SETARG_B(fs->f->code[pc], luaO_int2fb(cc.na)); /* set initial array size */ + SETARG_C(fs->f->code[pc], luaO_int2fb(cc.nh)); /* set initial table size */ +} + +/* }====================================================================== */ + + + +static void parlist (LexState *ls) { + /* parlist -> [ param { `,' param } ] */ + FuncState *fs = ls->fs; + Proto *f = fs->f; + int nparams = 0; + f->is_vararg = 0; + if (ls->t.token != ')') { /* is `parlist' not empty? */ + do { + switch (ls->t.token) { + case TK_NAME: { /* param -> NAME */ + new_localvar(ls, str_checkname(ls), nparams++); + break; + } + case TK_DOTS: { /* param -> `...' */ + luaX_next(ls); +#if defined(LUA_COMPAT_VARARG) + /* use `arg' as default name */ + new_localvarliteral(ls, "arg", nparams++); + f->is_vararg = VARARG_HASARG | VARARG_NEEDSARG; +#endif + f->is_vararg |= VARARG_ISVARARG; + break; + } + default: luaX_syntaxerror(ls, " or " LUA_QL("...") " expected"); + } + } while (!f->is_vararg && testnext(ls, ',')); + } + adjustlocalvars(ls, nparams); + f->numparams = cast_byte(fs->nactvar - (f->is_vararg & VARARG_HASARG)); + luaK_reserveregs(fs, fs->nactvar); /* reserve register for parameters */ +} + + +static void body (LexState *ls, expdesc *e, int needself, int line) { + /* body -> `(' parlist `)' chunk END */ + FuncState new_fs; + open_func(ls, &new_fs); + new_fs.f->linedefined = line; + checknext(ls, '('); + if (needself) { + new_localvarliteral(ls, "self", 0); + adjustlocalvars(ls, 1); + } + parlist(ls); + checknext(ls, ')'); + chunk(ls); + new_fs.f->lastlinedefined = ls->linenumber; + check_match(ls, TK_END, TK_FUNCTION, line); + close_func(ls); + pushclosure(ls, &new_fs, e); +} + + +static int explist1 (LexState *ls, expdesc *v) { + /* explist1 -> expr { `,' expr } */ + int n = 1; /* at least one expression */ + expr(ls, v); + while (testnext(ls, ',')) { + luaK_exp2nextreg(ls->fs, v); + expr(ls, v); + n++; + } + return n; +} + + +static void funcargs (LexState *ls, expdesc *f) { + FuncState *fs = ls->fs; + expdesc args; + int base, nparams; + int line = ls->linenumber; + switch (ls->t.token) { + case '(': { /* funcargs -> `(' [ explist1 ] `)' */ + if (line != ls->lastline) + luaX_syntaxerror(ls,"ambiguous syntax (function call x new statement)"); + luaX_next(ls); + if (ls->t.token == ')') /* arg list is empty? */ + args.k = VVOID; + else { + explist1(ls, &args); + luaK_setmultret(fs, &args); + } + check_match(ls, ')', '(', line); + break; + } + case '{': { /* funcargs -> constructor */ + constructor(ls, &args); + break; + } + case TK_STRING: { /* funcargs -> STRING */ + codestring(ls, &args, ls->t.seminfo.ts); + luaX_next(ls); /* must use `seminfo' before `next' */ + break; + } + default: { + luaX_syntaxerror(ls, "function arguments expected"); + return; + } + } + lua_assert(f->k == VNONRELOC); + base = f->u.s.info; /* base register for call */ + if (hasmultret(args.k)) + nparams = LUA_MULTRET; /* open call */ + else { + if (args.k != VVOID) + luaK_exp2nextreg(fs, &args); /* close last argument */ + nparams = fs->freereg - (base+1); + } + init_exp(f, VCALL, luaK_codeABC(fs, OP_CALL, base, nparams+1, 2)); + luaK_fixline(fs, line); + fs->freereg = base+1; /* call remove function and arguments and leaves + (unless changed) one result */ +} + + + + +/* +** {====================================================================== +** Expression parsing +** ======================================================================= +*/ + + +static void prefixexp (LexState *ls, expdesc *v) { + /* prefixexp -> NAME | '(' expr ')' */ + switch (ls->t.token) { + case '(': { + int line = ls->linenumber; + luaX_next(ls); + expr(ls, v); + check_match(ls, ')', '(', line); + luaK_dischargevars(ls->fs, v); + return; + } + case TK_NAME: { + singlevar(ls, v); + return; + } + default: { + luaX_syntaxerror(ls, "unexpected symbol"); + return; + } + } +} + + +static void primaryexp (LexState *ls, expdesc *v) { + /* primaryexp -> + prefixexp { `.' NAME | `[' exp `]' | `:' NAME funcargs | funcargs } */ + FuncState *fs = ls->fs; + prefixexp(ls, v); + for (;;) { + switch (ls->t.token) { + case '.': { /* field */ + field(ls, v); + break; + } + case '[': { /* `[' exp1 `]' */ + expdesc key; + luaK_exp2anyreg(fs, v); + yindex(ls, &key); + luaK_indexed(fs, v, &key); + break; + } + case ':': { /* `:' NAME funcargs */ + expdesc key; + luaX_next(ls); + checkname(ls, &key); + luaK_self(fs, v, &key); + funcargs(ls, v); + break; + } + case '(': case TK_STRING: case '{': { /* funcargs */ + luaK_exp2nextreg(fs, v); + funcargs(ls, v); + break; + } + default: return; + } + } +} + + +static void simpleexp (LexState *ls, expdesc *v) { + /* simpleexp -> NUMBER | STRING | NIL | true | false | ... | + constructor | FUNCTION body | primaryexp */ + switch (ls->t.token) { + case TK_NUMBER: { + init_exp(v, VKNUM, 0); + v->u.nval = ls->t.seminfo.r; + break; + } + case TK_STRING: { + codestring(ls, v, ls->t.seminfo.ts); + break; + } + case TK_NIL: { + init_exp(v, VNIL, 0); + break; + } + case TK_TRUE: { + init_exp(v, VTRUE, 0); + break; + } + case TK_FALSE: { + init_exp(v, VFALSE, 0); + break; + } + case TK_DOTS: { /* vararg */ + FuncState *fs = ls->fs; + check_condition(ls, fs->f->is_vararg, + "cannot use " LUA_QL("...") " outside a vararg function"); + fs->f->is_vararg &= ~VARARG_NEEDSARG; /* don't need 'arg' */ + init_exp(v, VVARARG, luaK_codeABC(fs, OP_VARARG, 0, 1, 0)); + break; + } + case '{': { /* constructor */ + constructor(ls, v); + return; + } + case TK_FUNCTION: { + luaX_next(ls); + body(ls, v, 0, ls->linenumber); + return; + } + default: { + primaryexp(ls, v); + return; + } + } + luaX_next(ls); +} + + +static UnOpr getunopr (int op) { + switch (op) { + case TK_NOT: return OPR_NOT; + case '-': return OPR_MINUS; + case '#': return OPR_LEN; + default: return OPR_NOUNOPR; + } +} + + +static BinOpr getbinopr (int op) { + switch (op) { + case '+': return OPR_ADD; + case '-': return OPR_SUB; + case '*': return OPR_MUL; + case '/': return OPR_DIV; + case '%': return OPR_MOD; + case '^': return OPR_POW; + case TK_CONCAT: return OPR_CONCAT; + case TK_NE: return OPR_NE; + case TK_EQ: return OPR_EQ; + case '<': return OPR_LT; + case TK_LE: return OPR_LE; + case '>': return OPR_GT; + case TK_GE: return OPR_GE; + case TK_AND: return OPR_AND; + case TK_OR: return OPR_OR; + default: return OPR_NOBINOPR; + } +} + + +static const struct { + lu_byte left; /* left priority for each binary operator */ + lu_byte right; /* right priority */ +} priority[] = { /* ORDER OPR */ + {6, 6}, {6, 6}, {7, 7}, {7, 7}, {7, 7}, /* `+' `-' `/' `%' */ + {10, 9}, {5, 4}, /* power and concat (right associative) */ + {3, 3}, {3, 3}, /* equality and inequality */ + {3, 3}, {3, 3}, {3, 3}, {3, 3}, /* order */ + {2, 2}, {1, 1} /* logical (and/or) */ +}; + +#define UNARY_PRIORITY 8 /* priority for unary operators */ + + +/* +** subexpr -> (simpleexp | unop subexpr) { binop subexpr } +** where `binop' is any binary operator with a priority higher than `limit' +*/ +static BinOpr subexpr (LexState *ls, expdesc *v, unsigned int limit) { + BinOpr op; + UnOpr uop; + enterlevel(ls); + uop = getunopr(ls->t.token); + if (uop != OPR_NOUNOPR) { + luaX_next(ls); + subexpr(ls, v, UNARY_PRIORITY); + luaK_prefix(ls->fs, uop, v); + } + else simpleexp(ls, v); + /* expand while operators have priorities higher than `limit' */ + op = getbinopr(ls->t.token); + while (op != OPR_NOBINOPR && priority[op].left > limit) { + expdesc v2; + BinOpr nextop; + luaX_next(ls); + luaK_infix(ls->fs, op, v); + /* read sub-expression with higher priority */ + nextop = subexpr(ls, &v2, priority[op].right); + luaK_posfix(ls->fs, op, v, &v2); + op = nextop; + } + leavelevel(ls); + return op; /* return first untreated operator */ +} + + +static void expr (LexState *ls, expdesc *v) { + subexpr(ls, v, 0); +} + +/* }==================================================================== */ + + + +/* +** {====================================================================== +** Rules for Statements +** ======================================================================= +*/ + + +static int block_follow (int token) { + switch (token) { + case TK_ELSE: case TK_ELSEIF: case TK_END: + case TK_UNTIL: case TK_EOS: + return 1; + default: return 0; + } +} + + +static void block (LexState *ls) { + /* block -> chunk */ + FuncState *fs = ls->fs; + BlockCnt bl; + enterblock(fs, &bl, 0); + chunk(ls); + lua_assert(bl.breaklist == NO_JUMP); + leaveblock(fs); +} + + +/* +** structure to chain all variables in the left-hand side of an +** assignment +*/ +struct LHS_assign { + struct LHS_assign *prev; + expdesc v; /* variable (global, local, upvalue, or indexed) */ +}; + + +/* +** check whether, in an assignment to a local variable, the local variable +** is needed in a previous assignment (to a table). If so, save original +** local value in a safe place and use this safe copy in the previous +** assignment. +*/ +static void check_conflict (LexState *ls, struct LHS_assign *lh, expdesc *v) { + FuncState *fs = ls->fs; + int extra = fs->freereg; /* eventual position to save local variable */ + int conflict = 0; + for (; lh; lh = lh->prev) { + if (lh->v.k == VINDEXED) { + if (lh->v.u.s.info == v->u.s.info) { /* conflict? */ + conflict = 1; + lh->v.u.s.info = extra; /* previous assignment will use safe copy */ + } + if (lh->v.u.s.aux == v->u.s.info) { /* conflict? */ + conflict = 1; + lh->v.u.s.aux = extra; /* previous assignment will use safe copy */ + } + } + } + if (conflict) { + luaK_codeABC(fs, OP_MOVE, fs->freereg, v->u.s.info, 0); /* make copy */ + luaK_reserveregs(fs, 1); + } +} + + +static void assignment (LexState *ls, struct LHS_assign *lh, int nvars) { + expdesc e; + check_condition(ls, VLOCAL <= lh->v.k && lh->v.k <= VINDEXED, + "syntax error"); + if (testnext(ls, ',')) { /* assignment -> `,' primaryexp assignment */ + struct LHS_assign nv; + nv.prev = lh; + primaryexp(ls, &nv.v); + if (nv.v.k == VLOCAL) + check_conflict(ls, lh, &nv.v); + luaY_checklimit(ls->fs, nvars, LUAI_MAXCCALLS - ls->L->nCcalls, + "variables in assignment"); + assignment(ls, &nv, nvars+1); + } + else { /* assignment -> `=' explist1 */ + int nexps; + checknext(ls, '='); + nexps = explist1(ls, &e); + if (nexps != nvars) { + adjust_assign(ls, nvars, nexps, &e); + if (nexps > nvars) + ls->fs->freereg -= nexps - nvars; /* remove extra values */ + } + else { + luaK_setoneret(ls->fs, &e); /* close last expression */ + luaK_storevar(ls->fs, &lh->v, &e); + return; /* avoid default */ + } + } + init_exp(&e, VNONRELOC, ls->fs->freereg-1); /* default assignment */ + luaK_storevar(ls->fs, &lh->v, &e); +} + + +static int cond (LexState *ls) { + /* cond -> exp */ + expdesc v; + expr(ls, &v); /* read condition */ + if (v.k == VNIL) v.k = VFALSE; /* `falses' are all equal here */ + luaK_goiftrue(ls->fs, &v); + return v.f; +} + + +static void breakstat (LexState *ls) { + FuncState *fs = ls->fs; + BlockCnt *bl = fs->bl; + int upval = 0; + while (bl && !bl->isbreakable) { + upval |= bl->upval; + bl = bl->previous; + } + if (!bl) + luaX_syntaxerror(ls, "no loop to break"); + if (upval) + luaK_codeABC(fs, OP_CLOSE, bl->nactvar, 0, 0); + luaK_concat(fs, &bl->breaklist, luaK_jump(fs)); +} + + +static void whilestat (LexState *ls, int line) { + /* whilestat -> WHILE cond DO block END */ + FuncState *fs = ls->fs; + int whileinit; + int condexit; + BlockCnt bl; + luaX_next(ls); /* skip WHILE */ + whileinit = luaK_getlabel(fs); + condexit = cond(ls); + enterblock(fs, &bl, 1); + checknext(ls, TK_DO); + block(ls); + luaK_patchlist(fs, luaK_jump(fs), whileinit); + check_match(ls, TK_END, TK_WHILE, line); + leaveblock(fs); + luaK_patchtohere(fs, condexit); /* false conditions finish the loop */ +} + + +static void repeatstat (LexState *ls, int line) { + /* repeatstat -> REPEAT block UNTIL cond */ + int condexit; + FuncState *fs = ls->fs; + int repeat_init = luaK_getlabel(fs); + BlockCnt bl1, bl2; + enterblock(fs, &bl1, 1); /* loop block */ + enterblock(fs, &bl2, 0); /* scope block */ + luaX_next(ls); /* skip REPEAT */ + chunk(ls); + check_match(ls, TK_UNTIL, TK_REPEAT, line); + condexit = cond(ls); /* read condition (inside scope block) */ + if (!bl2.upval) { /* no upvalues? */ + leaveblock(fs); /* finish scope */ + luaK_patchlist(ls->fs, condexit, repeat_init); /* close the loop */ + } + else { /* complete semantics when there are upvalues */ + breakstat(ls); /* if condition then break */ + luaK_patchtohere(ls->fs, condexit); /* else... */ + leaveblock(fs); /* finish scope... */ + luaK_patchlist(ls->fs, luaK_jump(fs), repeat_init); /* and repeat */ + } + leaveblock(fs); /* finish loop */ +} + + +static int exp1 (LexState *ls) { + expdesc e; + int k; + expr(ls, &e); + k = e.k; + luaK_exp2nextreg(ls->fs, &e); + return k; +} + + +static void forbody (LexState *ls, int base, int line, int nvars, int isnum) { + /* forbody -> DO block */ + BlockCnt bl; + FuncState *fs = ls->fs; + int prep, endfor; + adjustlocalvars(ls, 3); /* control variables */ + checknext(ls, TK_DO); + prep = isnum ? luaK_codeAsBx(fs, OP_FORPREP, base, NO_JUMP) : luaK_jump(fs); + enterblock(fs, &bl, 0); /* scope for declared variables */ + adjustlocalvars(ls, nvars); + luaK_reserveregs(fs, nvars); + block(ls); + leaveblock(fs); /* end of scope for declared variables */ + luaK_patchtohere(fs, prep); + endfor = (isnum) ? luaK_codeAsBx(fs, OP_FORLOOP, base, NO_JUMP) : + luaK_codeABC(fs, OP_TFORLOOP, base, 0, nvars); + luaK_fixline(fs, line); /* pretend that `OP_FOR' starts the loop */ + luaK_patchlist(fs, (isnum ? endfor : luaK_jump(fs)), prep + 1); +} + + +static void fornum (LexState *ls, TString *varname, int line) { + /* fornum -> NAME = exp1,exp1[,exp1] forbody */ + FuncState *fs = ls->fs; + int base = fs->freereg; + new_localvarliteral(ls, "(for index)", 0); + new_localvarliteral(ls, "(for limit)", 1); + new_localvarliteral(ls, "(for step)", 2); + new_localvar(ls, varname, 3); + checknext(ls, '='); + exp1(ls); /* initial value */ + checknext(ls, ','); + exp1(ls); /* limit */ + if (testnext(ls, ',')) + exp1(ls); /* optional step */ + else { /* default step = 1 */ + luaK_codeABx(fs, OP_LOADK, fs->freereg, luaK_numberK(fs, 1)); + luaK_reserveregs(fs, 1); + } + forbody(ls, base, line, 1, 1); +} + + +static void forlist (LexState *ls, TString *indexname) { + /* forlist -> NAME {,NAME} IN explist1 forbody */ + FuncState *fs = ls->fs; + expdesc e; + int nvars = 0; + int line; + int base = fs->freereg; + /* create control variables */ + new_localvarliteral(ls, "(for generator)", nvars++); + new_localvarliteral(ls, "(for state)", nvars++); + new_localvarliteral(ls, "(for control)", nvars++); + /* create declared variables */ + new_localvar(ls, indexname, nvars++); + while (testnext(ls, ',')) + new_localvar(ls, str_checkname(ls), nvars++); + checknext(ls, TK_IN); + line = ls->linenumber; + adjust_assign(ls, 3, explist1(ls, &e), &e); + luaK_checkstack(fs, 3); /* extra space to call generator */ + forbody(ls, base, line, nvars - 3, 0); +} + + +static void forstat (LexState *ls, int line) { + /* forstat -> FOR (fornum | forlist) END */ + FuncState *fs = ls->fs; + TString *varname; + BlockCnt bl; + enterblock(fs, &bl, 1); /* scope for loop and control variables */ + luaX_next(ls); /* skip `for' */ + varname = str_checkname(ls); /* first variable name */ + switch (ls->t.token) { + case '=': fornum(ls, varname, line); break; + case ',': case TK_IN: forlist(ls, varname); break; + default: luaX_syntaxerror(ls, LUA_QL("=") " or " LUA_QL("in") " expected"); + } + check_match(ls, TK_END, TK_FOR, line); + leaveblock(fs); /* loop scope (`break' jumps to this point) */ +} + + +static int test_then_block (LexState *ls) { + /* test_then_block -> [IF | ELSEIF] cond THEN block */ + int condexit; + luaX_next(ls); /* skip IF or ELSEIF */ + condexit = cond(ls); + checknext(ls, TK_THEN); + block(ls); /* `then' part */ + return condexit; +} + + +static void ifstat (LexState *ls, int line) { + /* ifstat -> IF cond THEN block {ELSEIF cond THEN block} [ELSE block] END */ + FuncState *fs = ls->fs; + int flist; + int escapelist = NO_JUMP; + flist = test_then_block(ls); /* IF cond THEN block */ + while (ls->t.token == TK_ELSEIF) { + luaK_concat(fs, &escapelist, luaK_jump(fs)); + luaK_patchtohere(fs, flist); + flist = test_then_block(ls); /* ELSEIF cond THEN block */ + } + if (ls->t.token == TK_ELSE) { + luaK_concat(fs, &escapelist, luaK_jump(fs)); + luaK_patchtohere(fs, flist); + luaX_next(ls); /* skip ELSE (after patch, for correct line info) */ + block(ls); /* `else' part */ + } + else + luaK_concat(fs, &escapelist, flist); + luaK_patchtohere(fs, escapelist); + check_match(ls, TK_END, TK_IF, line); +} + + +static void localfunc (LexState *ls) { + expdesc v, b; + FuncState *fs = ls->fs; + new_localvar(ls, str_checkname(ls), 0); + init_exp(&v, VLOCAL, fs->freereg); + luaK_reserveregs(fs, 1); + adjustlocalvars(ls, 1); + body(ls, &b, 0, ls->linenumber); + luaK_storevar(fs, &v, &b); + /* debug information will only see the variable after this point! */ + getlocvar(fs, fs->nactvar - 1).startpc = fs->pc; +} + + +static void localstat (LexState *ls) { + /* stat -> LOCAL NAME {`,' NAME} [`=' explist1] */ + int nvars = 0; + int nexps; + expdesc e; + do { + new_localvar(ls, str_checkname(ls), nvars++); + } while (testnext(ls, ',')); + if (testnext(ls, '=')) + nexps = explist1(ls, &e); + else { + e.k = VVOID; + nexps = 0; + } + adjust_assign(ls, nvars, nexps, &e); + adjustlocalvars(ls, nvars); +} + + +static int funcname (LexState *ls, expdesc *v) { + /* funcname -> NAME {field} [`:' NAME] */ + int needself = 0; + singlevar(ls, v); + while (ls->t.token == '.') + field(ls, v); + if (ls->t.token == ':') { + needself = 1; + field(ls, v); + } + return needself; +} + + +static void funcstat (LexState *ls, int line) { + /* funcstat -> FUNCTION funcname body */ + int needself; + expdesc v, b; + luaX_next(ls); /* skip FUNCTION */ + needself = funcname(ls, &v); + body(ls, &b, needself, line); + luaK_storevar(ls->fs, &v, &b); + luaK_fixline(ls->fs, line); /* definition `happens' in the first line */ +} + + +static void exprstat (LexState *ls) { + /* stat -> func | assignment */ + FuncState *fs = ls->fs; + struct LHS_assign v; + primaryexp(ls, &v.v); + if (v.v.k == VCALL) /* stat -> func */ + SETARG_C(getcode(fs, &v.v), 1); /* call statement uses no results */ + else { /* stat -> assignment */ + v.prev = NULL; + assignment(ls, &v, 1); + } +} + + +static void retstat (LexState *ls) { + /* stat -> RETURN explist */ + FuncState *fs = ls->fs; + expdesc e; + int first, nret; /* registers with returned values */ + luaX_next(ls); /* skip RETURN */ + if (block_follow(ls->t.token) || ls->t.token == ';') + first = nret = 0; /* return no values */ + else { + nret = explist1(ls, &e); /* optional return values */ + if (hasmultret(e.k)) { + luaK_setmultret(fs, &e); + if (e.k == VCALL && nret == 1) { /* tail call? */ + SET_OPCODE(getcode(fs,&e), OP_TAILCALL); + lua_assert(GETARG_A(getcode(fs,&e)) == fs->nactvar); + } + first = fs->nactvar; + nret = LUA_MULTRET; /* return all values */ + } + else { + if (nret == 1) /* only one single value? */ + first = luaK_exp2anyreg(fs, &e); + else { + luaK_exp2nextreg(fs, &e); /* values must go to the `stack' */ + first = fs->nactvar; /* return all `active' values */ + lua_assert(nret == fs->freereg - first); + } + } + } + luaK_ret(fs, first, nret); +} + + +static int statement (LexState *ls) { + int line = ls->linenumber; /* may be needed for error messages */ + switch (ls->t.token) { + case TK_IF: { /* stat -> ifstat */ + ifstat(ls, line); + return 0; + } + case TK_WHILE: { /* stat -> whilestat */ + whilestat(ls, line); + return 0; + } + case TK_DO: { /* stat -> DO block END */ + luaX_next(ls); /* skip DO */ + block(ls); + check_match(ls, TK_END, TK_DO, line); + return 0; + } + case TK_FOR: { /* stat -> forstat */ + forstat(ls, line); + return 0; + } + case TK_REPEAT: { /* stat -> repeatstat */ + repeatstat(ls, line); + return 0; + } + case TK_FUNCTION: { + funcstat(ls, line); /* stat -> funcstat */ + return 0; + } + case TK_LOCAL: { /* stat -> localstat */ + luaX_next(ls); /* skip LOCAL */ + if (testnext(ls, TK_FUNCTION)) /* local function? */ + localfunc(ls); + else + localstat(ls); + return 0; + } + case TK_RETURN: { /* stat -> retstat */ + retstat(ls); + return 1; /* must be last statement */ + } + case TK_BREAK: { /* stat -> breakstat */ + luaX_next(ls); /* skip BREAK */ + breakstat(ls); + return 1; /* must be last statement */ + } + default: { + exprstat(ls); + return 0; /* to avoid warnings */ + } + } +} + + +static void chunk (LexState *ls) { + /* chunk -> { stat [`;'] } */ + int islast = 0; + enterlevel(ls); + while (!islast && !block_follow(ls->t.token)) { + islast = statement(ls); + testnext(ls, ';'); + lua_assert(ls->fs->f->maxstacksize >= ls->fs->freereg && + ls->fs->freereg >= ls->fs->nactvar); + ls->fs->freereg = ls->fs->nactvar; /* free registers */ + } + leavelevel(ls); +} + +/* }====================================================================== */ diff --git a/mk/linux/mojosetup/lua/src/lparser.h b/mk/linux/mojosetup/lua/src/lparser.h new file mode 100644 index 00000000..18836afd --- /dev/null +++ b/mk/linux/mojosetup/lua/src/lparser.h @@ -0,0 +1,82 @@ +/* +** $Id: lparser.h,v 1.57.1.1 2007/12/27 13:02:25 roberto Exp $ +** Lua Parser +** See Copyright Notice in lua.h +*/ + +#ifndef lparser_h +#define lparser_h + +#include "llimits.h" +#include "lobject.h" +#include "lzio.h" + + +/* +** Expression descriptor +*/ + +typedef enum { + VVOID, /* no value */ + VNIL, + VTRUE, + VFALSE, + VK, /* info = index of constant in `k' */ + VKNUM, /* nval = numerical value */ + VLOCAL, /* info = local register */ + VUPVAL, /* info = index of upvalue in `upvalues' */ + VGLOBAL, /* info = index of table; aux = index of global name in `k' */ + VINDEXED, /* info = table register; aux = index register (or `k') */ + VJMP, /* info = instruction pc */ + VRELOCABLE, /* info = instruction pc */ + VNONRELOC, /* info = result register */ + VCALL, /* info = instruction pc */ + VVARARG /* info = instruction pc */ +} expkind; + +typedef struct expdesc { + expkind k; + union { + struct { int info, aux; } s; + lua_Number nval; + } u; + int t; /* patch list of `exit when true' */ + int f; /* patch list of `exit when false' */ +} expdesc; + + +typedef struct upvaldesc { + lu_byte k; + lu_byte info; +} upvaldesc; + + +struct BlockCnt; /* defined in lparser.c */ + + +/* state needed to generate code for a given function */ +typedef struct FuncState { + Proto *f; /* current function header */ + Table *h; /* table to find (and reuse) elements in `k' */ + struct FuncState *prev; /* enclosing function */ + struct LexState *ls; /* lexical state */ + struct lua_State *L; /* copy of the Lua state */ + struct BlockCnt *bl; /* chain of current blocks */ + int pc; /* next position to code (equivalent to `ncode') */ + int lasttarget; /* `pc' of last `jump target' */ + int jpc; /* list of pending jumps to `pc' */ + int freereg; /* first free register */ + int nk; /* number of elements in `k' */ + int np; /* number of elements in `p' */ + short nlocvars; /* number of elements in `locvars' */ + lu_byte nactvar; /* number of active local variables */ + upvaldesc upvalues[LUAI_MAXUPVALUES]; /* upvalues */ + unsigned short actvar[LUAI_MAXVARS]; /* declared-variable stack */ +} FuncState; + + +LUAI_FUNC Proto *luaY_parser (lua_State *L, ZIO *z, Mbuffer *buff, + const char *name); + + +#endif diff --git a/mk/linux/mojosetup/lua/src/lstate.c b/mk/linux/mojosetup/lua/src/lstate.c new file mode 100644 index 00000000..4313b83a --- /dev/null +++ b/mk/linux/mojosetup/lua/src/lstate.c @@ -0,0 +1,214 @@ +/* +** $Id: lstate.c,v 2.36.1.2 2008/01/03 15:20:39 roberto Exp $ +** Global State +** See Copyright Notice in lua.h +*/ + + +#include + +#define lstate_c +#define LUA_CORE + +#include "lua.h" + +#include "ldebug.h" +#include "ldo.h" +#include "lfunc.h" +#include "lgc.h" +#include "llex.h" +#include "lmem.h" +#include "lstate.h" +#include "lstring.h" +#include "ltable.h" +#include "ltm.h" + + +#define state_size(x) (sizeof(x) + LUAI_EXTRASPACE) +#define fromstate(l) (cast(lu_byte *, (l)) - LUAI_EXTRASPACE) +#define tostate(l) (cast(lua_State *, cast(lu_byte *, l) + LUAI_EXTRASPACE)) + + +/* +** Main thread combines a thread state and the global state +*/ +typedef struct LG { + lua_State l; + global_State g; +} LG; + + + +static void stack_init (lua_State *L1, lua_State *L) { + /* initialize CallInfo array */ + L1->base_ci = luaM_newvector(L, BASIC_CI_SIZE, CallInfo); + L1->ci = L1->base_ci; + L1->size_ci = BASIC_CI_SIZE; + L1->end_ci = L1->base_ci + L1->size_ci - 1; + /* initialize stack array */ + L1->stack = luaM_newvector(L, BASIC_STACK_SIZE + EXTRA_STACK, TValue); + L1->stacksize = BASIC_STACK_SIZE + EXTRA_STACK; + L1->top = L1->stack; + L1->stack_last = L1->stack+(L1->stacksize - EXTRA_STACK)-1; + /* initialize first ci */ + L1->ci->func = L1->top; + setnilvalue(L1->top++); /* `function' entry for this `ci' */ + L1->base = L1->ci->base = L1->top; + L1->ci->top = L1->top + LUA_MINSTACK; +} + + +static void freestack (lua_State *L, lua_State *L1) { + luaM_freearray(L, L1->base_ci, L1->size_ci, CallInfo); + luaM_freearray(L, L1->stack, L1->stacksize, TValue); +} + + +/* +** open parts that may cause memory-allocation errors +*/ +static void f_luaopen (lua_State *L, void *ud) { + global_State *g = G(L); + UNUSED(ud); + stack_init(L, L); /* init stack */ + sethvalue(L, gt(L), luaH_new(L, 0, 2)); /* table of globals */ + sethvalue(L, registry(L), luaH_new(L, 0, 2)); /* registry */ + luaS_resize(L, MINSTRTABSIZE); /* initial size of string table */ + luaT_init(L); + luaX_init(L); + luaS_fix(luaS_newliteral(L, MEMERRMSG)); + g->GCthreshold = 4*g->totalbytes; +} + + +static void preinit_state (lua_State *L, global_State *g) { + G(L) = g; + L->stack = NULL; + L->stacksize = 0; + L->errorJmp = NULL; + L->hook = NULL; + L->hookmask = 0; + L->basehookcount = 0; + L->allowhook = 1; + resethookcount(L); + L->openupval = NULL; + L->size_ci = 0; + L->nCcalls = L->baseCcalls = 0; + L->status = 0; + L->base_ci = L->ci = NULL; + L->savedpc = NULL; + L->errfunc = 0; + setnilvalue(gt(L)); +} + + +static void close_state (lua_State *L) { + global_State *g = G(L); + luaF_close(L, L->stack); /* close all upvalues for this thread */ + luaC_freeall(L); /* collect all objects */ + lua_assert(g->rootgc == obj2gco(L)); + lua_assert(g->strt.nuse == 0); + luaM_freearray(L, G(L)->strt.hash, G(L)->strt.size, TString *); + luaZ_freebuffer(L, &g->buff); + freestack(L, L); + lua_assert(g->totalbytes == sizeof(LG)); + (*g->frealloc)(g->ud, fromstate(L), state_size(LG), 0); +} + + +lua_State *luaE_newthread (lua_State *L) { + lua_State *L1 = tostate(luaM_malloc(L, state_size(lua_State))); + luaC_link(L, obj2gco(L1), LUA_TTHREAD); + preinit_state(L1, G(L)); + stack_init(L1, L); /* init stack */ + setobj2n(L, gt(L1), gt(L)); /* share table of globals */ + L1->hookmask = L->hookmask; + L1->basehookcount = L->basehookcount; + L1->hook = L->hook; + resethookcount(L1); + lua_assert(iswhite(obj2gco(L1))); + return L1; +} + + +void luaE_freethread (lua_State *L, lua_State *L1) { + luaF_close(L1, L1->stack); /* close all upvalues for this thread */ + lua_assert(L1->openupval == NULL); + luai_userstatefree(L1); + freestack(L, L1); + luaM_freemem(L, fromstate(L1), state_size(lua_State)); +} + + +LUA_API lua_State *lua_newstate (lua_Alloc f, void *ud) { + int i; + lua_State *L; + global_State *g; + void *l = (*f)(ud, NULL, 0, state_size(LG)); + if (l == NULL) return NULL; + L = tostate(l); + g = &((LG *)L)->g; + L->next = NULL; + L->tt = LUA_TTHREAD; + g->currentwhite = bit2mask(WHITE0BIT, FIXEDBIT); + L->marked = luaC_white(g); + set2bits(L->marked, FIXEDBIT, SFIXEDBIT); + preinit_state(L, g); + g->frealloc = f; + g->ud = ud; + g->mainthread = L; + g->uvhead.u.l.prev = &g->uvhead; + g->uvhead.u.l.next = &g->uvhead; + g->GCthreshold = 0; /* mark it as unfinished state */ + g->strt.size = 0; + g->strt.nuse = 0; + g->strt.hash = NULL; + setnilvalue(registry(L)); + luaZ_initbuffer(L, &g->buff); + g->panic = NULL; + g->gcstate = GCSpause; + g->rootgc = obj2gco(L); + g->sweepstrgc = 0; + g->sweepgc = &g->rootgc; + g->gray = NULL; + g->grayagain = NULL; + g->weak = NULL; + g->tmudata = NULL; + g->totalbytes = sizeof(LG); + g->gcpause = LUAI_GCPAUSE; + g->gcstepmul = LUAI_GCMUL; + g->gcdept = 0; + for (i=0; imt[i] = NULL; + if (luaD_rawrunprotected(L, f_luaopen, NULL) != 0) { + /* memory allocation error: free partial state */ + close_state(L); + L = NULL; + } + else + luai_userstateopen(L); + return L; +} + + +static void callallgcTM (lua_State *L, void *ud) { + UNUSED(ud); + luaC_callGCTM(L); /* call GC metamethods for all udata */ +} + + +LUA_API void lua_close (lua_State *L) { + L = G(L)->mainthread; /* only the main thread can be closed */ + lua_lock(L); + luaF_close(L, L->stack); /* close all upvalues for this thread */ + luaC_separateudata(L, 1); /* separate udata that have GC metamethods */ + L->errfunc = 0; /* no error function during GC metamethods */ + do { /* repeat until no more errors */ + L->ci = L->base_ci; + L->base = L->top = L->ci->base; + L->nCcalls = L->baseCcalls = 0; + } while (luaD_rawrunprotected(L, callallgcTM, NULL) != 0); + lua_assert(G(L)->tmudata == NULL); + luai_userstateclose(L); + close_state(L); +} + diff --git a/mk/linux/mojosetup/lua/src/lstate.h b/mk/linux/mojosetup/lua/src/lstate.h new file mode 100644 index 00000000..3bc575b6 --- /dev/null +++ b/mk/linux/mojosetup/lua/src/lstate.h @@ -0,0 +1,169 @@ +/* +** $Id: lstate.h,v 2.24.1.2 2008/01/03 15:20:39 roberto Exp $ +** Global State +** See Copyright Notice in lua.h +*/ + +#ifndef lstate_h +#define lstate_h + +#include "lua.h" + +#include "lobject.h" +#include "ltm.h" +#include "lzio.h" + + + +struct lua_longjmp; /* defined in ldo.c */ + + +/* table of globals */ +#define gt(L) (&L->l_gt) + +/* registry */ +#define registry(L) (&G(L)->l_registry) + + +/* extra stack space to handle TM calls and some other extras */ +#define EXTRA_STACK 5 + + +#define BASIC_CI_SIZE 8 + +#define BASIC_STACK_SIZE (2*LUA_MINSTACK) + + + +typedef struct stringtable { + GCObject **hash; + lu_int32 nuse; /* number of elements */ + int size; +} stringtable; + + +/* +** informations about a call +*/ +typedef struct CallInfo { + StkId base; /* base for this function */ + StkId func; /* function index in the stack */ + StkId top; /* top for this function */ + const Instruction *savedpc; + int nresults; /* expected number of results from this function */ + int tailcalls; /* number of tail calls lost under this entry */ +} CallInfo; + + + +#define curr_func(L) (clvalue(L->ci->func)) +#define ci_func(ci) (clvalue((ci)->func)) +#define f_isLua(ci) (!ci_func(ci)->c.isC) +#define isLua(ci) (ttisfunction((ci)->func) && f_isLua(ci)) + + +/* +** `global state', shared by all threads of this state +*/ +typedef struct global_State { + stringtable strt; /* hash table for strings */ + lua_Alloc frealloc; /* function to reallocate memory */ + void *ud; /* auxiliary data to `frealloc' */ + lu_byte currentwhite; + lu_byte gcstate; /* state of garbage collector */ + int sweepstrgc; /* position of sweep in `strt' */ + GCObject *rootgc; /* list of all collectable objects */ + GCObject **sweepgc; /* position of sweep in `rootgc' */ + GCObject *gray; /* list of gray objects */ + GCObject *grayagain; /* list of objects to be traversed atomically */ + GCObject *weak; /* list of weak tables (to be cleared) */ + GCObject *tmudata; /* last element of list of userdata to be GC */ + Mbuffer buff; /* temporary buffer for string concatentation */ + lu_mem GCthreshold; + lu_mem totalbytes; /* number of bytes currently allocated */ + lu_mem estimate; /* an estimate of number of bytes actually in use */ + lu_mem gcdept; /* how much GC is `behind schedule' */ + int gcpause; /* size of pause between successive GCs */ + int gcstepmul; /* GC `granularity' */ + lua_CFunction panic; /* to be called in unprotected errors */ + TValue l_registry; + struct lua_State *mainthread; + UpVal uvhead; /* head of double-linked list of all open upvalues */ + struct Table *mt[NUM_TAGS]; /* metatables for basic types */ + TString *tmname[TM_N]; /* array with tag-method names */ +} global_State; + + +/* +** `per thread' state +*/ +struct lua_State { + CommonHeader; + lu_byte status; + StkId top; /* first free slot in the stack */ + StkId base; /* base of current function */ + global_State *l_G; + CallInfo *ci; /* call info for current function */ + const Instruction *savedpc; /* `savedpc' of current function */ + StkId stack_last; /* last free slot in the stack */ + StkId stack; /* stack base */ + CallInfo *end_ci; /* points after end of ci array*/ + CallInfo *base_ci; /* array of CallInfo's */ + int stacksize; + int size_ci; /* size of array `base_ci' */ + unsigned short nCcalls; /* number of nested C calls */ + unsigned short baseCcalls; /* nested C calls when resuming coroutine */ + lu_byte hookmask; + lu_byte allowhook; + int basehookcount; + int hookcount; + lua_Hook hook; + TValue l_gt; /* table of globals */ + TValue env; /* temporary place for environments */ + GCObject *openupval; /* list of open upvalues in this stack */ + GCObject *gclist; + struct lua_longjmp *errorJmp; /* current error recover point */ + ptrdiff_t errfunc; /* current error handling function (stack index) */ +}; + + +#define G(L) (L->l_G) + + +/* +** Union of all collectable objects +*/ +union GCObject { + GCheader gch; + union TString ts; + union Udata u; + union Closure cl; + struct Table h; + struct Proto p; + struct UpVal uv; + struct lua_State th; /* thread */ +}; + + +/* macros to convert a GCObject into a specific value */ +#define rawgco2ts(o) check_exp((o)->gch.tt == LUA_TSTRING, &((o)->ts)) +#define gco2ts(o) (&rawgco2ts(o)->tsv) +#define rawgco2u(o) check_exp((o)->gch.tt == LUA_TUSERDATA, &((o)->u)) +#define gco2u(o) (&rawgco2u(o)->uv) +#define gco2cl(o) check_exp((o)->gch.tt == LUA_TFUNCTION, &((o)->cl)) +#define gco2h(o) check_exp((o)->gch.tt == LUA_TTABLE, &((o)->h)) +#define gco2p(o) check_exp((o)->gch.tt == LUA_TPROTO, &((o)->p)) +#define gco2uv(o) check_exp((o)->gch.tt == LUA_TUPVAL, &((o)->uv)) +#define ngcotouv(o) \ + check_exp((o) == NULL || (o)->gch.tt == LUA_TUPVAL, &((o)->uv)) +#define gco2th(o) check_exp((o)->gch.tt == LUA_TTHREAD, &((o)->th)) + +/* macro to convert any Lua object into a GCObject */ +#define obj2gco(v) (cast(GCObject *, (v))) + + +LUAI_FUNC lua_State *luaE_newthread (lua_State *L); +LUAI_FUNC void luaE_freethread (lua_State *L, lua_State *L1); + +#endif + diff --git a/mk/linux/mojosetup/lua/src/lstring.c b/mk/linux/mojosetup/lua/src/lstring.c new file mode 100644 index 00000000..49113151 --- /dev/null +++ b/mk/linux/mojosetup/lua/src/lstring.c @@ -0,0 +1,111 @@ +/* +** $Id: lstring.c,v 2.8.1.1 2007/12/27 13:02:25 roberto Exp $ +** String table (keeps all strings handled by Lua) +** See Copyright Notice in lua.h +*/ + + +#include + +#define lstring_c +#define LUA_CORE + +#include "lua.h" + +#include "lmem.h" +#include "lobject.h" +#include "lstate.h" +#include "lstring.h" + + + +void luaS_resize (lua_State *L, int newsize) { + GCObject **newhash; + stringtable *tb; + int i; + if (G(L)->gcstate == GCSsweepstring) + return; /* cannot resize during GC traverse */ + newhash = luaM_newvector(L, newsize, GCObject *); + tb = &G(L)->strt; + for (i=0; isize; i++) { + GCObject *p = tb->hash[i]; + while (p) { /* for each node in the list */ + GCObject *next = p->gch.next; /* save next */ + unsigned int h = gco2ts(p)->hash; + int h1 = lmod(h, newsize); /* new position */ + lua_assert(cast_int(h%newsize) == lmod(h, newsize)); + p->gch.next = newhash[h1]; /* chain it */ + newhash[h1] = p; + p = next; + } + } + luaM_freearray(L, tb->hash, tb->size, TString *); + tb->size = newsize; + tb->hash = newhash; +} + + +static TString *newlstr (lua_State *L, const char *str, size_t l, + unsigned int h) { + TString *ts; + stringtable *tb; + if (l+1 > (MAX_SIZET - sizeof(TString))/sizeof(char)) + luaM_toobig(L); + ts = cast(TString *, luaM_malloc(L, (l+1)*sizeof(char)+sizeof(TString))); + ts->tsv.len = l; + ts->tsv.hash = h; + ts->tsv.marked = luaC_white(G(L)); + ts->tsv.tt = LUA_TSTRING; + ts->tsv.reserved = 0; + memcpy(ts+1, str, l*sizeof(char)); + ((char *)(ts+1))[l] = '\0'; /* ending 0 */ + tb = &G(L)->strt; + h = lmod(h, tb->size); + ts->tsv.next = tb->hash[h]; /* chain new entry */ + tb->hash[h] = obj2gco(ts); + tb->nuse++; + if (tb->nuse > cast(lu_int32, tb->size) && tb->size <= MAX_INT/2) + luaS_resize(L, tb->size*2); /* too crowded */ + return ts; +} + + +TString *luaS_newlstr (lua_State *L, const char *str, size_t l) { + GCObject *o; + unsigned int h = cast(unsigned int, l); /* seed */ + size_t step = (l>>5)+1; /* if string is too long, don't hash all its chars */ + size_t l1; + for (l1=l; l1>=step; l1-=step) /* compute hash */ + h = h ^ ((h<<5)+(h>>2)+cast(unsigned char, str[l1-1])); + for (o = G(L)->strt.hash[lmod(h, G(L)->strt.size)]; + o != NULL; + o = o->gch.next) { + TString *ts = rawgco2ts(o); + if (ts->tsv.len == l && (memcmp(str, getstr(ts), l) == 0)) { + /* string may be dead */ + if (isdead(G(L), o)) changewhite(o); + return ts; + } + } + return newlstr(L, str, l, h); /* not found */ +} + + +Udata *luaS_newudata (lua_State *L, size_t s, Table *e) { + Udata *u; + if (s > MAX_SIZET - sizeof(Udata)) + luaM_toobig(L); + u = cast(Udata *, luaM_malloc(L, s + sizeof(Udata))); + u->uv.marked = luaC_white(G(L)); /* is not finalized */ + u->uv.tt = LUA_TUSERDATA; + u->uv.len = s; + u->uv.metatable = NULL; + u->uv.env = e; + /* chain it on udata list (after main thread) */ + u->uv.next = G(L)->mainthread->next; + G(L)->mainthread->next = obj2gco(u); + return u; +} + diff --git a/mk/linux/mojosetup/lua/src/lstring.h b/mk/linux/mojosetup/lua/src/lstring.h new file mode 100644 index 00000000..73a2ff8b --- /dev/null +++ b/mk/linux/mojosetup/lua/src/lstring.h @@ -0,0 +1,31 @@ +/* +** $Id: lstring.h,v 1.43.1.1 2007/12/27 13:02:25 roberto Exp $ +** String table (keep all strings handled by Lua) +** See Copyright Notice in lua.h +*/ + +#ifndef lstring_h +#define lstring_h + + +#include "lgc.h" +#include "lobject.h" +#include "lstate.h" + + +#define sizestring(s) (sizeof(union TString)+((s)->len+1)*sizeof(char)) + +#define sizeudata(u) (sizeof(union Udata)+(u)->len) + +#define luaS_new(L, s) (luaS_newlstr(L, s, strlen(s))) +#define luaS_newliteral(L, s) (luaS_newlstr(L, "" s, \ + (sizeof(s)/sizeof(char))-1)) + +#define luaS_fix(s) l_setbit((s)->tsv.marked, FIXEDBIT) + +LUAI_FUNC void luaS_resize (lua_State *L, int newsize); +LUAI_FUNC Udata *luaS_newudata (lua_State *L, size_t s, Table *e); +LUAI_FUNC TString *luaS_newlstr (lua_State *L, const char *str, size_t l); + + +#endif diff --git a/mk/linux/mojosetup/lua/src/lstrlib.c b/mk/linux/mojosetup/lua/src/lstrlib.c new file mode 100644 index 00000000..1b4763d4 --- /dev/null +++ b/mk/linux/mojosetup/lua/src/lstrlib.c @@ -0,0 +1,869 @@ +/* +** $Id: lstrlib.c,v 1.132.1.4 2008/07/11 17:27:21 roberto Exp $ +** Standard library for string operations and pattern-matching +** See Copyright Notice in lua.h +*/ + + +#include +#include +#include +#include +#include + +#define lstrlib_c +#define LUA_LIB + +#include "lua.h" + +#include "lauxlib.h" +#include "lualib.h" + + +/* macro to `unsign' a character */ +#define uchar(c) ((unsigned char)(c)) + + + +static int str_len (lua_State *L) { + size_t l; + luaL_checklstring(L, 1, &l); + lua_pushinteger(L, l); + return 1; +} + + +static ptrdiff_t posrelat (ptrdiff_t pos, size_t len) { + /* relative string position: negative means back from end */ + if (pos < 0) pos += (ptrdiff_t)len + 1; + return (pos >= 0) ? pos : 0; +} + + +static int str_sub (lua_State *L) { + size_t l; + const char *s = luaL_checklstring(L, 1, &l); + ptrdiff_t start = posrelat(luaL_checkinteger(L, 2), l); + ptrdiff_t end = posrelat(luaL_optinteger(L, 3, -1), l); + if (start < 1) start = 1; + if (end > (ptrdiff_t)l) end = (ptrdiff_t)l; + if (start <= end) + lua_pushlstring(L, s+start-1, end-start+1); + else lua_pushliteral(L, ""); + return 1; +} + + +static int str_reverse (lua_State *L) { + size_t l; + luaL_Buffer b; + const char *s = luaL_checklstring(L, 1, &l); + luaL_buffinit(L, &b); + while (l--) luaL_addchar(&b, s[l]); + luaL_pushresult(&b); + return 1; +} + + +static int str_lower (lua_State *L) { + size_t l; + size_t i; + luaL_Buffer b; + const char *s = luaL_checklstring(L, 1, &l); + luaL_buffinit(L, &b); + for (i=0; i 0) + luaL_addlstring(&b, s, l); + luaL_pushresult(&b); + return 1; +} + + +static int str_byte (lua_State *L) { + size_t l; + const char *s = luaL_checklstring(L, 1, &l); + ptrdiff_t posi = posrelat(luaL_optinteger(L, 2, 1), l); + ptrdiff_t pose = posrelat(luaL_optinteger(L, 3, posi), l); + int n, i; + if (posi <= 0) posi = 1; + if ((size_t)pose > l) pose = l; + if (posi > pose) return 0; /* empty interval; return no values */ + n = (int)(pose - posi + 1); + if (posi + n <= pose) /* overflow? */ + luaL_error(L, "string slice too long"); + luaL_checkstack(L, n, "string slice too long"); + for (i=0; i= ms->level || ms->capture[l].len == CAP_UNFINISHED) + return luaL_error(ms->L, "invalid capture index"); + return l; +} + + +static int capture_to_close (MatchState *ms) { + int level = ms->level; + for (level--; level>=0; level--) + if (ms->capture[level].len == CAP_UNFINISHED) return level; + return luaL_error(ms->L, "invalid pattern capture"); +} + + +static const char *classend (MatchState *ms, const char *p) { + switch (*p++) { + case L_ESC: { + if (*p == '\0') + luaL_error(ms->L, "malformed pattern (ends with " LUA_QL("%%") ")"); + return p+1; + } + case '[': { + if (*p == '^') p++; + do { /* look for a `]' */ + if (*p == '\0') + luaL_error(ms->L, "malformed pattern (missing " LUA_QL("]") ")"); + if (*(p++) == L_ESC && *p != '\0') + p++; /* skip escapes (e.g. `%]') */ + } while (*p != ']'); + return p+1; + } + default: { + return p; + } + } +} + + +static int match_class (int c, int cl) { + int res; + switch (tolower(cl)) { + case 'a' : res = isalpha(c); break; + case 'c' : res = iscntrl(c); break; + case 'd' : res = isdigit(c); break; + case 'l' : res = islower(c); break; + case 'p' : res = ispunct(c); break; + case 's' : res = isspace(c); break; + case 'u' : res = isupper(c); break; + case 'w' : res = isalnum(c); break; + case 'x' : res = isxdigit(c); break; + case 'z' : res = (c == 0); break; + default: return (cl == c); + } + return (islower(cl) ? res : !res); +} + + +static int matchbracketclass (int c, const char *p, const char *ec) { + int sig = 1; + if (*(p+1) == '^') { + sig = 0; + p++; /* skip the `^' */ + } + while (++p < ec) { + if (*p == L_ESC) { + p++; + if (match_class(c, uchar(*p))) + return sig; + } + else if ((*(p+1) == '-') && (p+2 < ec)) { + p+=2; + if (uchar(*(p-2)) <= c && c <= uchar(*p)) + return sig; + } + else if (uchar(*p) == c) return sig; + } + return !sig; +} + + +static int singlematch (int c, const char *p, const char *ep) { + switch (*p) { + case '.': return 1; /* matches any char */ + case L_ESC: return match_class(c, uchar(*(p+1))); + case '[': return matchbracketclass(c, p, ep-1); + default: return (uchar(*p) == c); + } +} + + +static const char *match (MatchState *ms, const char *s, const char *p); + + +static const char *matchbalance (MatchState *ms, const char *s, + const char *p) { + if (*p == 0 || *(p+1) == 0) + luaL_error(ms->L, "unbalanced pattern"); + if (*s != *p) return NULL; + else { + int b = *p; + int e = *(p+1); + int cont = 1; + while (++s < ms->src_end) { + if (*s == e) { + if (--cont == 0) return s+1; + } + else if (*s == b) cont++; + } + } + return NULL; /* string ends out of balance */ +} + + +static const char *max_expand (MatchState *ms, const char *s, + const char *p, const char *ep) { + ptrdiff_t i = 0; /* counts maximum expand for item */ + while ((s+i)src_end && singlematch(uchar(*(s+i)), p, ep)) + i++; + /* keeps trying to match with the maximum repetitions */ + while (i>=0) { + const char *res = match(ms, (s+i), ep+1); + if (res) return res; + i--; /* else didn't match; reduce 1 repetition to try again */ + } + return NULL; +} + + +static const char *min_expand (MatchState *ms, const char *s, + const char *p, const char *ep) { + for (;;) { + const char *res = match(ms, s, ep+1); + if (res != NULL) + return res; + else if (ssrc_end && singlematch(uchar(*s), p, ep)) + s++; /* try with one more repetition */ + else return NULL; + } +} + + +static const char *start_capture (MatchState *ms, const char *s, + const char *p, int what) { + const char *res; + int level = ms->level; + if (level >= LUA_MAXCAPTURES) luaL_error(ms->L, "too many captures"); + ms->capture[level].init = s; + ms->capture[level].len = what; + ms->level = level+1; + if ((res=match(ms, s, p)) == NULL) /* match failed? */ + ms->level--; /* undo capture */ + return res; +} + + +static const char *end_capture (MatchState *ms, const char *s, + const char *p) { + int l = capture_to_close(ms); + const char *res; + ms->capture[l].len = s - ms->capture[l].init; /* close capture */ + if ((res = match(ms, s, p)) == NULL) /* match failed? */ + ms->capture[l].len = CAP_UNFINISHED; /* undo capture */ + return res; +} + + +static const char *match_capture (MatchState *ms, const char *s, int l) { + size_t len; + l = check_capture(ms, l); + len = ms->capture[l].len; + if ((size_t)(ms->src_end-s) >= len && + memcmp(ms->capture[l].init, s, len) == 0) + return s+len; + else return NULL; +} + + +static const char *match (MatchState *ms, const char *s, const char *p) { + init: /* using goto's to optimize tail recursion */ + switch (*p) { + case '(': { /* start capture */ + if (*(p+1) == ')') /* position capture? */ + return start_capture(ms, s, p+2, CAP_POSITION); + else + return start_capture(ms, s, p+1, CAP_UNFINISHED); + } + case ')': { /* end capture */ + return end_capture(ms, s, p+1); + } + case L_ESC: { + switch (*(p+1)) { + case 'b': { /* balanced string? */ + s = matchbalance(ms, s, p+2); + if (s == NULL) return NULL; + p+=4; goto init; /* else return match(ms, s, p+4); */ + } + case 'f': { /* frontier? */ + const char *ep; char previous; + p += 2; + if (*p != '[') + luaL_error(ms->L, "missing " LUA_QL("[") " after " + LUA_QL("%%f") " in pattern"); + ep = classend(ms, p); /* points to what is next */ + previous = (s == ms->src_init) ? '\0' : *(s-1); + if (matchbracketclass(uchar(previous), p, ep-1) || + !matchbracketclass(uchar(*s), p, ep-1)) return NULL; + p=ep; goto init; /* else return match(ms, s, ep); */ + } + default: { + if (isdigit(uchar(*(p+1)))) { /* capture results (%0-%9)? */ + s = match_capture(ms, s, uchar(*(p+1))); + if (s == NULL) return NULL; + p+=2; goto init; /* else return match(ms, s, p+2) */ + } + goto dflt; /* case default */ + } + } + } + case '\0': { /* end of pattern */ + return s; /* match succeeded */ + } + case '$': { + if (*(p+1) == '\0') /* is the `$' the last char in pattern? */ + return (s == ms->src_end) ? s : NULL; /* check end of string */ + else goto dflt; + } + default: dflt: { /* it is a pattern item */ + const char *ep = classend(ms, p); /* points to what is next */ + int m = ssrc_end && singlematch(uchar(*s), p, ep); + switch (*ep) { + case '?': { /* optional */ + const char *res; + if (m && ((res=match(ms, s+1, ep+1)) != NULL)) + return res; + p=ep+1; goto init; /* else return match(ms, s, ep+1); */ + } + case '*': { /* 0 or more repetitions */ + return max_expand(ms, s, p, ep); + } + case '+': { /* 1 or more repetitions */ + return (m ? max_expand(ms, s+1, p, ep) : NULL); + } + case '-': { /* 0 or more repetitions (minimum) */ + return min_expand(ms, s, p, ep); + } + default: { + if (!m) return NULL; + s++; p=ep; goto init; /* else return match(ms, s+1, ep); */ + } + } + } + } +} + + + +static const char *lmemfind (const char *s1, size_t l1, + const char *s2, size_t l2) { + if (l2 == 0) return s1; /* empty strings are everywhere */ + else if (l2 > l1) return NULL; /* avoids a negative `l1' */ + else { + const char *init; /* to search for a `*s2' inside `s1' */ + l2--; /* 1st char will be checked by `memchr' */ + l1 = l1-l2; /* `s2' cannot be found after that */ + while (l1 > 0 && (init = (const char *)memchr(s1, *s2, l1)) != NULL) { + init++; /* 1st char is already checked */ + if (memcmp(init, s2+1, l2) == 0) + return init-1; + else { /* correct `l1' and `s1' to try again */ + l1 -= init-s1; + s1 = init; + } + } + return NULL; /* not found */ + } +} + + +static void push_onecapture (MatchState *ms, int i, const char *s, + const char *e) { + if (i >= ms->level) { + if (i == 0) /* ms->level == 0, too */ + lua_pushlstring(ms->L, s, e - s); /* add whole match */ + else + luaL_error(ms->L, "invalid capture index"); + } + else { + ptrdiff_t l = ms->capture[i].len; + if (l == CAP_UNFINISHED) luaL_error(ms->L, "unfinished capture"); + if (l == CAP_POSITION) + lua_pushinteger(ms->L, ms->capture[i].init - ms->src_init + 1); + else + lua_pushlstring(ms->L, ms->capture[i].init, l); + } +} + + +static int push_captures (MatchState *ms, const char *s, const char *e) { + int i; + int nlevels = (ms->level == 0 && s) ? 1 : ms->level; + luaL_checkstack(ms->L, nlevels, "too many captures"); + for (i = 0; i < nlevels; i++) + push_onecapture(ms, i, s, e); + return nlevels; /* number of strings pushed */ +} + + +static int str_find_aux (lua_State *L, int find) { + size_t l1, l2; + const char *s = luaL_checklstring(L, 1, &l1); + const char *p = luaL_checklstring(L, 2, &l2); + ptrdiff_t init = posrelat(luaL_optinteger(L, 3, 1), l1) - 1; + if (init < 0) init = 0; + else if ((size_t)(init) > l1) init = (ptrdiff_t)l1; + if (find && (lua_toboolean(L, 4) || /* explicit request? */ + strpbrk(p, SPECIALS) == NULL)) { /* or no special characters? */ + /* do a plain search */ + const char *s2 = lmemfind(s+init, l1-init, p, l2); + if (s2) { + lua_pushinteger(L, s2-s+1); + lua_pushinteger(L, s2-s+l2); + return 2; + } + } + else { + MatchState ms; + int anchor = (*p == '^') ? (p++, 1) : 0; + const char *s1=s+init; + ms.L = L; + ms.src_init = s; + ms.src_end = s+l1; + do { + const char *res; + ms.level = 0; + if ((res=match(&ms, s1, p)) != NULL) { + if (find) { + lua_pushinteger(L, s1-s+1); /* start */ + lua_pushinteger(L, res-s); /* end */ + return push_captures(&ms, NULL, 0) + 2; + } + else + return push_captures(&ms, s1, res); + } + } while (s1++ < ms.src_end && !anchor); + } + lua_pushnil(L); /* not found */ + return 1; +} + + +static int str_find (lua_State *L) { + return str_find_aux(L, 1); +} + + +static int str_match (lua_State *L) { + return str_find_aux(L, 0); +} + + +static int gmatch_aux (lua_State *L) { + MatchState ms; + size_t ls; + const char *s = lua_tolstring(L, lua_upvalueindex(1), &ls); + const char *p = lua_tostring(L, lua_upvalueindex(2)); + const char *src; + ms.L = L; + ms.src_init = s; + ms.src_end = s+ls; + for (src = s + (size_t)lua_tointeger(L, lua_upvalueindex(3)); + src <= ms.src_end; + src++) { + const char *e; + ms.level = 0; + if ((e = match(&ms, src, p)) != NULL) { + lua_Integer newstart = e-s; + if (e == src) newstart++; /* empty match? go at least one position */ + lua_pushinteger(L, newstart); + lua_replace(L, lua_upvalueindex(3)); + return push_captures(&ms, src, e); + } + } + return 0; /* not found */ +} + + +static int gmatch (lua_State *L) { + luaL_checkstring(L, 1); + luaL_checkstring(L, 2); + lua_settop(L, 2); + lua_pushinteger(L, 0); + lua_pushcclosure(L, gmatch_aux, 3); + return 1; +} + + +static int gfind_nodef (lua_State *L) { + return luaL_error(L, LUA_QL("string.gfind") " was renamed to " + LUA_QL("string.gmatch")); +} + + +static void add_s (MatchState *ms, luaL_Buffer *b, const char *s, + const char *e) { + size_t l, i; + const char *news = lua_tolstring(ms->L, 3, &l); + for (i = 0; i < l; i++) { + if (news[i] != L_ESC) + luaL_addchar(b, news[i]); + else { + i++; /* skip ESC */ + if (!isdigit(uchar(news[i]))) + luaL_addchar(b, news[i]); + else if (news[i] == '0') + luaL_addlstring(b, s, e - s); + else { + push_onecapture(ms, news[i] - '1', s, e); + luaL_addvalue(b); /* add capture to accumulated result */ + } + } + } +} + + +static void add_value (MatchState *ms, luaL_Buffer *b, const char *s, + const char *e) { + lua_State *L = ms->L; + switch (lua_type(L, 3)) { + case LUA_TNUMBER: + case LUA_TSTRING: { + add_s(ms, b, s, e); + return; + } + case LUA_TFUNCTION: { + int n; + lua_pushvalue(L, 3); + n = push_captures(ms, s, e); + lua_call(L, n, 1); + break; + } + case LUA_TTABLE: { + push_onecapture(ms, 0, s, e); + lua_gettable(L, 3); + break; + } + } + if (!lua_toboolean(L, -1)) { /* nil or false? */ + lua_pop(L, 1); + lua_pushlstring(L, s, e - s); /* keep original text */ + } + else if (!lua_isstring(L, -1)) + luaL_error(L, "invalid replacement value (a %s)", luaL_typename(L, -1)); + luaL_addvalue(b); /* add result to accumulator */ +} + + +static int str_gsub (lua_State *L) { + size_t srcl; + const char *src = luaL_checklstring(L, 1, &srcl); + const char *p = luaL_checkstring(L, 2); + int tr = lua_type(L, 3); + int max_s = luaL_optint(L, 4, srcl+1); + int anchor = (*p == '^') ? (p++, 1) : 0; + int n = 0; + MatchState ms; + luaL_Buffer b; + luaL_argcheck(L, tr == LUA_TNUMBER || tr == LUA_TSTRING || + tr == LUA_TFUNCTION || tr == LUA_TTABLE, 3, + "string/function/table expected"); + luaL_buffinit(L, &b); + ms.L = L; + ms.src_init = src; + ms.src_end = src+srcl; + while (n < max_s) { + const char *e; + ms.level = 0; + e = match(&ms, src, p); + if (e) { + n++; + add_value(&ms, &b, src, e); + } + if (e && e>src) /* non empty match? */ + src = e; /* skip it */ + else if (src < ms.src_end) + luaL_addchar(&b, *src++); + else break; + if (anchor) break; + } + luaL_addlstring(&b, src, ms.src_end-src); + luaL_pushresult(&b); + lua_pushinteger(L, n); /* number of substitutions */ + return 2; +} + +/* }====================================================== */ + + +/* maximum size of each formatted item (> len(format('%99.99f', -1e308))) */ +#define MAX_ITEM 512 +/* valid flags in a format specification */ +#define FLAGS "-+ #0" +/* +** maximum size of each format specification (such as '%-099.99d') +** (+10 accounts for %99.99x plus margin of error) +*/ +#define MAX_FORMAT (sizeof(FLAGS) + sizeof(LUA_INTFRMLEN) + 10) + + +static void addquoted (lua_State *L, luaL_Buffer *b, int arg) { + size_t l; + const char *s = luaL_checklstring(L, arg, &l); + luaL_addchar(b, '"'); + while (l--) { + switch (*s) { + case '"': case '\\': case '\n': { + luaL_addchar(b, '\\'); + luaL_addchar(b, *s); + break; + } + case '\r': { + luaL_addlstring(b, "\\r", 2); + break; + } + case '\0': { + luaL_addlstring(b, "\\000", 4); + break; + } + default: { + luaL_addchar(b, *s); + break; + } + } + s++; + } + luaL_addchar(b, '"'); +} + +static const char *scanformat (lua_State *L, const char *strfrmt, char *form) { + const char *p = strfrmt; + while (*p != '\0' && strchr(FLAGS, *p) != NULL) p++; /* skip flags */ + if ((size_t)(p - strfrmt) >= sizeof(FLAGS)) + luaL_error(L, "invalid format (repeated flags)"); + if (isdigit(uchar(*p))) p++; /* skip width */ + if (isdigit(uchar(*p))) p++; /* (2 digits at most) */ + if (*p == '.') { + p++; + if (isdigit(uchar(*p))) p++; /* skip precision */ + if (isdigit(uchar(*p))) p++; /* (2 digits at most) */ + } + if (isdigit(uchar(*p))) + luaL_error(L, "invalid format (width or precision too long)"); + *(form++) = '%'; + strncpy(form, strfrmt, p - strfrmt + 1); + form += p - strfrmt + 1; + *form = '\0'; + return p; +} + + +static void addintlen (char *form) { + size_t l = strlen(form); + char spec = form[l - 1]; + strcpy(form + l - 1, LUA_INTFRMLEN); + form[l + sizeof(LUA_INTFRMLEN) - 2] = spec; + form[l + sizeof(LUA_INTFRMLEN) - 1] = '\0'; +} + + +static int str_format (lua_State *L) { + int arg = 1; + size_t sfl; + const char *strfrmt = luaL_checklstring(L, arg, &sfl); + const char *strfrmt_end = strfrmt+sfl; + luaL_Buffer b; + luaL_buffinit(L, &b); + while (strfrmt < strfrmt_end) { + if (*strfrmt != L_ESC) + luaL_addchar(&b, *strfrmt++); + else if (*++strfrmt == L_ESC) + luaL_addchar(&b, *strfrmt++); /* %% */ + else { /* format item */ + char form[MAX_FORMAT]; /* to store the format (`%...') */ + char buff[MAX_ITEM]; /* to store the formatted item */ + arg++; + strfrmt = scanformat(L, strfrmt, form); + switch (*strfrmt++) { + case 'c': { + sprintf(buff, form, (int)luaL_checknumber(L, arg)); + break; + } + case 'd': case 'i': { + addintlen(form); + sprintf(buff, form, (LUA_INTFRM_T)luaL_checknumber(L, arg)); + break; + } + case 'o': case 'u': case 'x': case 'X': { + addintlen(form); + sprintf(buff, form, (unsigned LUA_INTFRM_T)luaL_checknumber(L, arg)); + break; + } + case 'e': case 'E': case 'f': + case 'g': case 'G': { + sprintf(buff, form, (double)luaL_checknumber(L, arg)); + break; + } + case 'q': { + addquoted(L, &b, arg); + continue; /* skip the 'addsize' at the end */ + } + case 's': { + size_t l; + const char *s = luaL_checklstring(L, arg, &l); + if (!strchr(form, '.') && l >= 100) { + /* no precision and string is too long to be formatted; + keep original string */ + lua_pushvalue(L, arg); + luaL_addvalue(&b); + continue; /* skip the `addsize' at the end */ + } + else { + sprintf(buff, form, s); + break; + } + } + default: { /* also treat cases `pnLlh' */ + return luaL_error(L, "invalid option " LUA_QL("%%%c") " to " + LUA_QL("format"), *(strfrmt - 1)); + } + } + luaL_addlstring(&b, buff, strlen(buff)); + } + } + luaL_pushresult(&b); + return 1; +} + + +static const luaL_Reg strlib[] = { + {"byte", str_byte}, + {"char", str_char}, + {"dump", str_dump}, + {"find", str_find}, + {"format", str_format}, + {"gfind", gfind_nodef}, + {"gmatch", gmatch}, + {"gsub", str_gsub}, + {"len", str_len}, + {"lower", str_lower}, + {"match", str_match}, + {"rep", str_rep}, + {"reverse", str_reverse}, + {"sub", str_sub}, + {"upper", str_upper}, + {NULL, NULL} +}; + + +static void createmetatable (lua_State *L) { + lua_createtable(L, 0, 1); /* create metatable for strings */ + lua_pushliteral(L, ""); /* dummy string */ + lua_pushvalue(L, -2); + lua_setmetatable(L, -2); /* set string metatable */ + lua_pop(L, 1); /* pop dummy string */ + lua_pushvalue(L, -2); /* string library... */ + lua_setfield(L, -2, "__index"); /* ...is the __index metamethod */ + lua_pop(L, 1); /* pop metatable */ +} + + +/* +** Open string library +*/ +LUALIB_API int luaopen_string (lua_State *L) { + luaL_register(L, LUA_STRLIBNAME, strlib); +#if defined(LUA_COMPAT_GFIND) + lua_getfield(L, -1, "gmatch"); + lua_setfield(L, -2, "gfind"); +#endif + createmetatable(L); + return 1; +} + diff --git a/mk/linux/mojosetup/lua/src/ltable.c b/mk/linux/mojosetup/lua/src/ltable.c new file mode 100644 index 00000000..ec84f4fa --- /dev/null +++ b/mk/linux/mojosetup/lua/src/ltable.c @@ -0,0 +1,588 @@ +/* +** $Id: ltable.c,v 2.32.1.2 2007/12/28 15:32:23 roberto Exp $ +** Lua tables (hash) +** See Copyright Notice in lua.h +*/ + + +/* +** Implementation of tables (aka arrays, objects, or hash tables). +** Tables keep its elements in two parts: an array part and a hash part. +** Non-negative integer keys are all candidates to be kept in the array +** part. The actual size of the array is the largest `n' such that at +** least half the slots between 0 and n are in use. +** Hash uses a mix of chained scatter table with Brent's variation. +** A main invariant of these tables is that, if an element is not +** in its main position (i.e. the `original' position that its hash gives +** to it), then the colliding element is in its own main position. +** Hence even when the load factor reaches 100%, performance remains good. +*/ + +#include +#include + +#define ltable_c +#define LUA_CORE + +#include "lua.h" + +#include "ldebug.h" +#include "ldo.h" +#include "lgc.h" +#include "lmem.h" +#include "lobject.h" +#include "lstate.h" +#include "ltable.h" + + +/* +** max size of array part is 2^MAXBITS +*/ +#if LUAI_BITSINT > 26 +#define MAXBITS 26 +#else +#define MAXBITS (LUAI_BITSINT-2) +#endif + +#define MAXASIZE (1 << MAXBITS) + + +#define hashpow2(t,n) (gnode(t, lmod((n), sizenode(t)))) + +#define hashstr(t,str) hashpow2(t, (str)->tsv.hash) +#define hashboolean(t,p) hashpow2(t, p) + + +/* +** for some types, it is better to avoid modulus by power of 2, as +** they tend to have many 2 factors. +*/ +#define hashmod(t,n) (gnode(t, ((n) % ((sizenode(t)-1)|1)))) + + +#define hashpointer(t,p) hashmod(t, IntPoint(p)) + + +/* +** number of ints inside a lua_Number +*/ +#define numints cast_int(sizeof(lua_Number)/sizeof(int)) + + + +#define dummynode (&dummynode_) + +static const Node dummynode_ = { + {{NULL}, LUA_TNIL}, /* value */ + {{{NULL}, LUA_TNIL, NULL}} /* key */ +}; + + +/* +** hash for lua_Numbers +*/ +static Node *hashnum (const Table *t, lua_Number n) { + unsigned int a[numints]; + int i; + if (luai_numeq(n, 0)) /* avoid problems with -0 */ + return gnode(t, 0); + memcpy(a, &n, sizeof(a)); + for (i = 1; i < numints; i++) a[0] += a[i]; + return hashmod(t, a[0]); +} + + + +/* +** returns the `main' position of an element in a table (that is, the index +** of its hash value) +*/ +static Node *mainposition (const Table *t, const TValue *key) { + switch (ttype(key)) { + case LUA_TNUMBER: + return hashnum(t, nvalue(key)); + case LUA_TSTRING: + return hashstr(t, rawtsvalue(key)); + case LUA_TBOOLEAN: + return hashboolean(t, bvalue(key)); + case LUA_TLIGHTUSERDATA: + return hashpointer(t, pvalue(key)); + default: + return hashpointer(t, gcvalue(key)); + } +} + + +/* +** returns the index for `key' if `key' is an appropriate key to live in +** the array part of the table, -1 otherwise. +*/ +static int arrayindex (const TValue *key) { + if (ttisnumber(key)) { + lua_Number n = nvalue(key); + int k; + lua_number2int(k, n); + if (luai_numeq(cast_num(k), n)) + return k; + } + return -1; /* `key' did not match some condition */ +} + + +/* +** returns the index of a `key' for table traversals. First goes all +** elements in the array part, then elements in the hash part. The +** beginning of a traversal is signalled by -1. +*/ +static int findindex (lua_State *L, Table *t, StkId key) { + int i; + if (ttisnil(key)) return -1; /* first iteration */ + i = arrayindex(key); + if (0 < i && i <= t->sizearray) /* is `key' inside array part? */ + return i-1; /* yes; that's the index (corrected to C) */ + else { + Node *n = mainposition(t, key); + do { /* check whether `key' is somewhere in the chain */ + /* key may be dead already, but it is ok to use it in `next' */ + if (luaO_rawequalObj(key2tval(n), key) || + (ttype(gkey(n)) == LUA_TDEADKEY && iscollectable(key) && + gcvalue(gkey(n)) == gcvalue(key))) { + i = cast_int(n - gnode(t, 0)); /* key index in hash table */ + /* hash elements are numbered after array ones */ + return i + t->sizearray; + } + else n = gnext(n); + } while (n); + luaG_runerror(L, "invalid key to " LUA_QL("next")); /* key not found */ + return 0; /* to avoid warnings */ + } +} + + +int luaH_next (lua_State *L, Table *t, StkId key) { + int i = findindex(L, t, key); /* find original element */ + for (i++; i < t->sizearray; i++) { /* try first array part */ + if (!ttisnil(&t->array[i])) { /* a non-nil value? */ + setnvalue(key, cast_num(i+1)); + setobj2s(L, key+1, &t->array[i]); + return 1; + } + } + for (i -= t->sizearray; i < sizenode(t); i++) { /* then hash part */ + if (!ttisnil(gval(gnode(t, i)))) { /* a non-nil value? */ + setobj2s(L, key, key2tval(gnode(t, i))); + setobj2s(L, key+1, gval(gnode(t, i))); + return 1; + } + } + return 0; /* no more elements */ +} + + +/* +** {============================================================= +** Rehash +** ============================================================== +*/ + + +static int computesizes (int nums[], int *narray) { + int i; + int twotoi; /* 2^i */ + int a = 0; /* number of elements smaller than 2^i */ + int na = 0; /* number of elements to go to array part */ + int n = 0; /* optimal size for array part */ + for (i = 0, twotoi = 1; twotoi/2 < *narray; i++, twotoi *= 2) { + if (nums[i] > 0) { + a += nums[i]; + if (a > twotoi/2) { /* more than half elements present? */ + n = twotoi; /* optimal size (till now) */ + na = a; /* all elements smaller than n will go to array part */ + } + } + if (a == *narray) break; /* all elements already counted */ + } + *narray = n; + lua_assert(*narray/2 <= na && na <= *narray); + return na; +} + + +static int countint (const TValue *key, int *nums) { + int k = arrayindex(key); + if (0 < k && k <= MAXASIZE) { /* is `key' an appropriate array index? */ + nums[ceillog2(k)]++; /* count as such */ + return 1; + } + else + return 0; +} + + +static int numusearray (const Table *t, int *nums) { + int lg; + int ttlg; /* 2^lg */ + int ause = 0; /* summation of `nums' */ + int i = 1; /* count to traverse all array keys */ + for (lg=0, ttlg=1; lg<=MAXBITS; lg++, ttlg*=2) { /* for each slice */ + int lc = 0; /* counter */ + int lim = ttlg; + if (lim > t->sizearray) { + lim = t->sizearray; /* adjust upper limit */ + if (i > lim) + break; /* no more elements to count */ + } + /* count elements in range (2^(lg-1), 2^lg] */ + for (; i <= lim; i++) { + if (!ttisnil(&t->array[i-1])) + lc++; + } + nums[lg] += lc; + ause += lc; + } + return ause; +} + + +static int numusehash (const Table *t, int *nums, int *pnasize) { + int totaluse = 0; /* total number of elements */ + int ause = 0; /* summation of `nums' */ + int i = sizenode(t); + while (i--) { + Node *n = &t->node[i]; + if (!ttisnil(gval(n))) { + ause += countint(key2tval(n), nums); + totaluse++; + } + } + *pnasize += ause; + return totaluse; +} + + +static void setarrayvector (lua_State *L, Table *t, int size) { + int i; + luaM_reallocvector(L, t->array, t->sizearray, size, TValue); + for (i=t->sizearray; iarray[i]); + t->sizearray = size; +} + + +static void setnodevector (lua_State *L, Table *t, int size) { + int lsize; + if (size == 0) { /* no elements to hash part? */ + t->node = cast(Node *, dummynode); /* use common `dummynode' */ + lsize = 0; + } + else { + int i; + lsize = ceillog2(size); + if (lsize > MAXBITS) + luaG_runerror(L, "table overflow"); + size = twoto(lsize); + t->node = luaM_newvector(L, size, Node); + for (i=0; ilsizenode = cast_byte(lsize); + t->lastfree = gnode(t, size); /* all positions are free */ +} + + +static void resize (lua_State *L, Table *t, int nasize, int nhsize) { + int i; + int oldasize = t->sizearray; + int oldhsize = t->lsizenode; + Node *nold = t->node; /* save old hash ... */ + if (nasize > oldasize) /* array part must grow? */ + setarrayvector(L, t, nasize); + /* create new hash part with appropriate size */ + setnodevector(L, t, nhsize); + if (nasize < oldasize) { /* array part must shrink? */ + t->sizearray = nasize; + /* re-insert elements from vanishing slice */ + for (i=nasize; iarray[i])) + setobjt2t(L, luaH_setnum(L, t, i+1), &t->array[i]); + } + /* shrink array */ + luaM_reallocvector(L, t->array, oldasize, nasize, TValue); + } + /* re-insert elements from hash part */ + for (i = twoto(oldhsize) - 1; i >= 0; i--) { + Node *old = nold+i; + if (!ttisnil(gval(old))) + setobjt2t(L, luaH_set(L, t, key2tval(old)), gval(old)); + } + if (nold != dummynode) + luaM_freearray(L, nold, twoto(oldhsize), Node); /* free old array */ +} + + +void luaH_resizearray (lua_State *L, Table *t, int nasize) { + int nsize = (t->node == dummynode) ? 0 : sizenode(t); + resize(L, t, nasize, nsize); +} + + +static void rehash (lua_State *L, Table *t, const TValue *ek) { + int nasize, na; + int nums[MAXBITS+1]; /* nums[i] = number of keys between 2^(i-1) and 2^i */ + int i; + int totaluse; + for (i=0; i<=MAXBITS; i++) nums[i] = 0; /* reset counts */ + nasize = numusearray(t, nums); /* count keys in array part */ + totaluse = nasize; /* all those keys are integer keys */ + totaluse += numusehash(t, nums, &nasize); /* count keys in hash part */ + /* count extra key */ + nasize += countint(ek, nums); + totaluse++; + /* compute new size for array part */ + na = computesizes(nums, &nasize); + /* resize the table to new computed sizes */ + resize(L, t, nasize, totaluse - na); +} + + + +/* +** }============================================================= +*/ + + +Table *luaH_new (lua_State *L, int narray, int nhash) { + Table *t = luaM_new(L, Table); + luaC_link(L, obj2gco(t), LUA_TTABLE); + t->metatable = NULL; + t->flags = cast_byte(~0); + /* temporary values (kept only if some malloc fails) */ + t->array = NULL; + t->sizearray = 0; + t->lsizenode = 0; + t->node = cast(Node *, dummynode); + setarrayvector(L, t, narray); + setnodevector(L, t, nhash); + return t; +} + + +void luaH_free (lua_State *L, Table *t) { + if (t->node != dummynode) + luaM_freearray(L, t->node, sizenode(t), Node); + luaM_freearray(L, t->array, t->sizearray, TValue); + luaM_free(L, t); +} + + +static Node *getfreepos (Table *t) { + while (t->lastfree-- > t->node) { + if (ttisnil(gkey(t->lastfree))) + return t->lastfree; + } + return NULL; /* could not find a free place */ +} + + + +/* +** inserts a new key into a hash table; first, check whether key's main +** position is free. If not, check whether colliding node is in its main +** position or not: if it is not, move colliding node to an empty place and +** put new key in its main position; otherwise (colliding node is in its main +** position), new key goes to an empty position. +*/ +static TValue *newkey (lua_State *L, Table *t, const TValue *key) { + Node *mp = mainposition(t, key); + if (!ttisnil(gval(mp)) || mp == dummynode) { + Node *othern; + Node *n = getfreepos(t); /* get a free place */ + if (n == NULL) { /* cannot find a free place? */ + rehash(L, t, key); /* grow table */ + return luaH_set(L, t, key); /* re-insert key into grown table */ + } + lua_assert(n != dummynode); + othern = mainposition(t, key2tval(mp)); + if (othern != mp) { /* is colliding node out of its main position? */ + /* yes; move colliding node into free position */ + while (gnext(othern) != mp) othern = gnext(othern); /* find previous */ + gnext(othern) = n; /* redo the chain with `n' in place of `mp' */ + *n = *mp; /* copy colliding node into free pos. (mp->next also goes) */ + gnext(mp) = NULL; /* now `mp' is free */ + setnilvalue(gval(mp)); + } + else { /* colliding node is in its own main position */ + /* new node will go into free position */ + gnext(n) = gnext(mp); /* chain new position */ + gnext(mp) = n; + mp = n; + } + } + gkey(mp)->value = key->value; gkey(mp)->tt = key->tt; + luaC_barriert(L, t, key); + lua_assert(ttisnil(gval(mp))); + return gval(mp); +} + + +/* +** search function for integers +*/ +const TValue *luaH_getnum (Table *t, int key) { + /* (1 <= key && key <= t->sizearray) */ + if (cast(unsigned int, key-1) < cast(unsigned int, t->sizearray)) + return &t->array[key-1]; + else { + lua_Number nk = cast_num(key); + Node *n = hashnum(t, nk); + do { /* check whether `key' is somewhere in the chain */ + if (ttisnumber(gkey(n)) && luai_numeq(nvalue(gkey(n)), nk)) + return gval(n); /* that's it */ + else n = gnext(n); + } while (n); + return luaO_nilobject; + } +} + + +/* +** search function for strings +*/ +const TValue *luaH_getstr (Table *t, TString *key) { + Node *n = hashstr(t, key); + do { /* check whether `key' is somewhere in the chain */ + if (ttisstring(gkey(n)) && rawtsvalue(gkey(n)) == key) + return gval(n); /* that's it */ + else n = gnext(n); + } while (n); + return luaO_nilobject; +} + + +/* +** main search function +*/ +const TValue *luaH_get (Table *t, const TValue *key) { + switch (ttype(key)) { + case LUA_TNIL: return luaO_nilobject; + case LUA_TSTRING: return luaH_getstr(t, rawtsvalue(key)); + case LUA_TNUMBER: { + int k; + lua_Number n = nvalue(key); + lua_number2int(k, n); + if (luai_numeq(cast_num(k), nvalue(key))) /* index is int? */ + return luaH_getnum(t, k); /* use specialized version */ + /* else go through */ + } + default: { + Node *n = mainposition(t, key); + do { /* check whether `key' is somewhere in the chain */ + if (luaO_rawequalObj(key2tval(n), key)) + return gval(n); /* that's it */ + else n = gnext(n); + } while (n); + return luaO_nilobject; + } + } +} + + +TValue *luaH_set (lua_State *L, Table *t, const TValue *key) { + const TValue *p = luaH_get(t, key); + t->flags = 0; + if (p != luaO_nilobject) + return cast(TValue *, p); + else { + if (ttisnil(key)) luaG_runerror(L, "table index is nil"); + else if (ttisnumber(key) && luai_numisnan(nvalue(key))) + luaG_runerror(L, "table index is NaN"); + return newkey(L, t, key); + } +} + + +TValue *luaH_setnum (lua_State *L, Table *t, int key) { + const TValue *p = luaH_getnum(t, key); + if (p != luaO_nilobject) + return cast(TValue *, p); + else { + TValue k; + setnvalue(&k, cast_num(key)); + return newkey(L, t, &k); + } +} + + +TValue *luaH_setstr (lua_State *L, Table *t, TString *key) { + const TValue *p = luaH_getstr(t, key); + if (p != luaO_nilobject) + return cast(TValue *, p); + else { + TValue k; + setsvalue(L, &k, key); + return newkey(L, t, &k); + } +} + + +static int unbound_search (Table *t, unsigned int j) { + unsigned int i = j; /* i is zero or a present index */ + j++; + /* find `i' and `j' such that i is present and j is not */ + while (!ttisnil(luaH_getnum(t, j))) { + i = j; + j *= 2; + if (j > cast(unsigned int, MAX_INT)) { /* overflow? */ + /* table was built with bad purposes: resort to linear search */ + i = 1; + while (!ttisnil(luaH_getnum(t, i))) i++; + return i - 1; + } + } + /* now do a binary search between them */ + while (j - i > 1) { + unsigned int m = (i+j)/2; + if (ttisnil(luaH_getnum(t, m))) j = m; + else i = m; + } + return i; +} + + +/* +** Try to find a boundary in table `t'. A `boundary' is an integer index +** such that t[i] is non-nil and t[i+1] is nil (and 0 if t[1] is nil). +*/ +int luaH_getn (Table *t) { + unsigned int j = t->sizearray; + if (j > 0 && ttisnil(&t->array[j - 1])) { + /* there is a boundary in the array part: (binary) search for it */ + unsigned int i = 0; + while (j - i > 1) { + unsigned int m = (i+j)/2; + if (ttisnil(&t->array[m - 1])) j = m; + else i = m; + } + return i; + } + /* else must find a boundary in hash part */ + else if (t->node == dummynode) /* hash part is empty? */ + return j; /* that is easy... */ + else return unbound_search(t, j); +} + + + +#if defined(LUA_DEBUG) + +Node *luaH_mainposition (const Table *t, const TValue *key) { + return mainposition(t, key); +} + +int luaH_isdummy (Node *n) { return n == dummynode; } + +#endif diff --git a/mk/linux/mojosetup/lua/src/ltable.h b/mk/linux/mojosetup/lua/src/ltable.h new file mode 100644 index 00000000..f5b9d5ea --- /dev/null +++ b/mk/linux/mojosetup/lua/src/ltable.h @@ -0,0 +1,40 @@ +/* +** $Id: ltable.h,v 2.10.1.1 2007/12/27 13:02:25 roberto Exp $ +** Lua tables (hash) +** See Copyright Notice in lua.h +*/ + +#ifndef ltable_h +#define ltable_h + +#include "lobject.h" + + +#define gnode(t,i) (&(t)->node[i]) +#define gkey(n) (&(n)->i_key.nk) +#define gval(n) (&(n)->i_val) +#define gnext(n) ((n)->i_key.nk.next) + +#define key2tval(n) (&(n)->i_key.tvk) + + +LUAI_FUNC const TValue *luaH_getnum (Table *t, int key); +LUAI_FUNC TValue *luaH_setnum (lua_State *L, Table *t, int key); +LUAI_FUNC const TValue *luaH_getstr (Table *t, TString *key); +LUAI_FUNC TValue *luaH_setstr (lua_State *L, Table *t, TString *key); +LUAI_FUNC const TValue *luaH_get (Table *t, const TValue *key); +LUAI_FUNC TValue *luaH_set (lua_State *L, Table *t, const TValue *key); +LUAI_FUNC Table *luaH_new (lua_State *L, int narray, int lnhash); +LUAI_FUNC void luaH_resizearray (lua_State *L, Table *t, int nasize); +LUAI_FUNC void luaH_free (lua_State *L, Table *t); +LUAI_FUNC int luaH_next (lua_State *L, Table *t, StkId key); +LUAI_FUNC int luaH_getn (Table *t); + + +#if defined(LUA_DEBUG) +LUAI_FUNC Node *luaH_mainposition (const Table *t, const TValue *key); +LUAI_FUNC int luaH_isdummy (Node *n); +#endif + + +#endif diff --git a/mk/linux/mojosetup/lua/src/ltablib.c b/mk/linux/mojosetup/lua/src/ltablib.c new file mode 100644 index 00000000..b6d9cb4a --- /dev/null +++ b/mk/linux/mojosetup/lua/src/ltablib.c @@ -0,0 +1,287 @@ +/* +** $Id: ltablib.c,v 1.38.1.3 2008/02/14 16:46:58 roberto Exp $ +** Library for Table Manipulation +** See Copyright Notice in lua.h +*/ + + +#include + +#define ltablib_c +#define LUA_LIB + +#include "lua.h" + +#include "lauxlib.h" +#include "lualib.h" + + +#define aux_getn(L,n) (luaL_checktype(L, n, LUA_TTABLE), luaL_getn(L, n)) + + +static int foreachi (lua_State *L) { + int i; + int n = aux_getn(L, 1); + luaL_checktype(L, 2, LUA_TFUNCTION); + for (i=1; i <= n; i++) { + lua_pushvalue(L, 2); /* function */ + lua_pushinteger(L, i); /* 1st argument */ + lua_rawgeti(L, 1, i); /* 2nd argument */ + lua_call(L, 2, 1); + if (!lua_isnil(L, -1)) + return 1; + lua_pop(L, 1); /* remove nil result */ + } + return 0; +} + + +static int foreach (lua_State *L) { + luaL_checktype(L, 1, LUA_TTABLE); + luaL_checktype(L, 2, LUA_TFUNCTION); + lua_pushnil(L); /* first key */ + while (lua_next(L, 1)) { + lua_pushvalue(L, 2); /* function */ + lua_pushvalue(L, -3); /* key */ + lua_pushvalue(L, -3); /* value */ + lua_call(L, 2, 1); + if (!lua_isnil(L, -1)) + return 1; + lua_pop(L, 2); /* remove value and result */ + } + return 0; +} + + +static int maxn (lua_State *L) { + lua_Number max = 0; + luaL_checktype(L, 1, LUA_TTABLE); + lua_pushnil(L); /* first key */ + while (lua_next(L, 1)) { + lua_pop(L, 1); /* remove value */ + if (lua_type(L, -1) == LUA_TNUMBER) { + lua_Number v = lua_tonumber(L, -1); + if (v > max) max = v; + } + } + lua_pushnumber(L, max); + return 1; +} + + +static int getn (lua_State *L) { + lua_pushinteger(L, aux_getn(L, 1)); + return 1; +} + + +static int setn (lua_State *L) { + luaL_checktype(L, 1, LUA_TTABLE); +#ifndef luaL_setn + luaL_setn(L, 1, luaL_checkint(L, 2)); +#else + luaL_error(L, LUA_QL("setn") " is obsolete"); +#endif + lua_pushvalue(L, 1); + return 1; +} + + +static int tinsert (lua_State *L) { + int e = aux_getn(L, 1) + 1; /* first empty element */ + int pos; /* where to insert new element */ + switch (lua_gettop(L)) { + case 2: { /* called with only 2 arguments */ + pos = e; /* insert new element at the end */ + break; + } + case 3: { + int i; + pos = luaL_checkint(L, 2); /* 2nd argument is the position */ + if (pos > e) e = pos; /* `grow' array if necessary */ + for (i = e; i > pos; i--) { /* move up elements */ + lua_rawgeti(L, 1, i-1); + lua_rawseti(L, 1, i); /* t[i] = t[i-1] */ + } + break; + } + default: { + return luaL_error(L, "wrong number of arguments to " LUA_QL("insert")); + } + } + luaL_setn(L, 1, e); /* new size */ + lua_rawseti(L, 1, pos); /* t[pos] = v */ + return 0; +} + + +static int tremove (lua_State *L) { + int e = aux_getn(L, 1); + int pos = luaL_optint(L, 2, e); + if (!(1 <= pos && pos <= e)) /* position is outside bounds? */ + return 0; /* nothing to remove */ + luaL_setn(L, 1, e - 1); /* t.n = n-1 */ + lua_rawgeti(L, 1, pos); /* result = t[pos] */ + for ( ;pos= P */ + while (lua_rawgeti(L, 1, ++i), sort_comp(L, -1, -2)) { + if (i>u) luaL_error(L, "invalid order function for sorting"); + lua_pop(L, 1); /* remove a[i] */ + } + /* repeat --j until a[j] <= P */ + while (lua_rawgeti(L, 1, --j), sort_comp(L, -3, -1)) { + if (j + +#define ltm_c +#define LUA_CORE + +#include "lua.h" + +#include "lobject.h" +#include "lstate.h" +#include "lstring.h" +#include "ltable.h" +#include "ltm.h" + + + +const char *const luaT_typenames[] = { + "nil", "boolean", "userdata", "number", + "string", "table", "function", "userdata", "thread", + "proto", "upval" +}; + + +void luaT_init (lua_State *L) { + static const char *const luaT_eventname[] = { /* ORDER TM */ + "__index", "__newindex", + "__gc", "__mode", "__eq", + "__add", "__sub", "__mul", "__div", "__mod", + "__pow", "__unm", "__len", "__lt", "__le", + "__concat", "__call" + }; + int i; + for (i=0; itmname[i] = luaS_new(L, luaT_eventname[i]); + luaS_fix(G(L)->tmname[i]); /* never collect these names */ + } +} + + +/* +** function to be used with macro "fasttm": optimized for absence of +** tag methods +*/ +const TValue *luaT_gettm (Table *events, TMS event, TString *ename) { + const TValue *tm = luaH_getstr(events, ename); + lua_assert(event <= TM_EQ); + if (ttisnil(tm)) { /* no tag method? */ + events->flags |= cast_byte(1u<metatable; + break; + case LUA_TUSERDATA: + mt = uvalue(o)->metatable; + break; + default: + mt = G(L)->mt[ttype(o)]; + } + return (mt ? luaH_getstr(mt, G(L)->tmname[event]) : luaO_nilobject); +} + diff --git a/mk/linux/mojosetup/lua/src/ltm.h b/mk/linux/mojosetup/lua/src/ltm.h new file mode 100644 index 00000000..64343b78 --- /dev/null +++ b/mk/linux/mojosetup/lua/src/ltm.h @@ -0,0 +1,54 @@ +/* +** $Id: ltm.h,v 2.6.1.1 2007/12/27 13:02:25 roberto Exp $ +** Tag methods +** See Copyright Notice in lua.h +*/ + +#ifndef ltm_h +#define ltm_h + + +#include "lobject.h" + + +/* +* WARNING: if you change the order of this enumeration, +* grep "ORDER TM" +*/ +typedef enum { + TM_INDEX, + TM_NEWINDEX, + TM_GC, + TM_MODE, + TM_EQ, /* last tag method with `fast' access */ + TM_ADD, + TM_SUB, + TM_MUL, + TM_DIV, + TM_MOD, + TM_POW, + TM_UNM, + TM_LEN, + TM_LT, + TM_LE, + TM_CONCAT, + TM_CALL, + TM_N /* number of elements in the enum */ +} TMS; + + + +#define gfasttm(g,et,e) ((et) == NULL ? NULL : \ + ((et)->flags & (1u<<(e))) ? NULL : luaT_gettm(et, e, (g)->tmname[e])) + +#define fasttm(l,et,e) gfasttm(G(l), et, e) + +LUAI_DATA const char *const luaT_typenames[]; + + +LUAI_FUNC const TValue *luaT_gettm (Table *events, TMS event, TString *ename); +LUAI_FUNC const TValue *luaT_gettmbyobj (lua_State *L, const TValue *o, + TMS event); +LUAI_FUNC void luaT_init (lua_State *L); + +#endif diff --git a/mk/linux/mojosetup/lua/src/lua.c b/mk/linux/mojosetup/lua/src/lua.c new file mode 100644 index 00000000..3a466093 --- /dev/null +++ b/mk/linux/mojosetup/lua/src/lua.c @@ -0,0 +1,392 @@ +/* +** $Id: lua.c,v 1.160.1.2 2007/12/28 15:32:23 roberto Exp $ +** Lua stand-alone interpreter +** See Copyright Notice in lua.h +*/ + + +#include +#include +#include +#include + +#define lua_c + +#include "lua.h" + +#include "lauxlib.h" +#include "lualib.h" + + + +static lua_State *globalL = NULL; + +static const char *progname = LUA_PROGNAME; + + + +static void lstop (lua_State *L, lua_Debug *ar) { + (void)ar; /* unused arg. */ + lua_sethook(L, NULL, 0, 0); + luaL_error(L, "interrupted!"); +} + + +static void laction (int i) { + signal(i, SIG_DFL); /* if another SIGINT happens before lstop, + terminate process (default action) */ + lua_sethook(globalL, lstop, LUA_MASKCALL | LUA_MASKRET | LUA_MASKCOUNT, 1); +} + + +static void print_usage (void) { + fprintf(stderr, + "usage: %s [options] [script [args]].\n" + "Available options are:\n" + " -e stat execute string " LUA_QL("stat") "\n" + " -l name require library " LUA_QL("name") "\n" + " -i enter interactive mode after executing " LUA_QL("script") "\n" + " -v show version information\n" + " -- stop handling options\n" + " - execute stdin and stop handling options\n" + , + progname); + fflush(stderr); +} + + +static void l_message (const char *pname, const char *msg) { + if (pname) fprintf(stderr, "%s: ", pname); + fprintf(stderr, "%s\n", msg); + fflush(stderr); +} + + +static int report (lua_State *L, int status) { + if (status && !lua_isnil(L, -1)) { + const char *msg = lua_tostring(L, -1); + if (msg == NULL) msg = "(error object is not a string)"; + l_message(progname, msg); + lua_pop(L, 1); + } + return status; +} + + +static int traceback (lua_State *L) { + if (!lua_isstring(L, 1)) /* 'message' not a string? */ + return 1; /* keep it intact */ + lua_getfield(L, LUA_GLOBALSINDEX, "debug"); + if (!lua_istable(L, -1)) { + lua_pop(L, 1); + return 1; + } + lua_getfield(L, -1, "traceback"); + if (!lua_isfunction(L, -1)) { + lua_pop(L, 2); + return 1; + } + lua_pushvalue(L, 1); /* pass error message */ + lua_pushinteger(L, 2); /* skip this function and traceback */ + lua_call(L, 2, 1); /* call debug.traceback */ + return 1; +} + + +static int docall (lua_State *L, int narg, int clear) { + int status; + int base = lua_gettop(L) - narg; /* function index */ + lua_pushcfunction(L, traceback); /* push traceback function */ + lua_insert(L, base); /* put it under chunk and args */ + signal(SIGINT, laction); + status = lua_pcall(L, narg, (clear ? 0 : LUA_MULTRET), base); + signal(SIGINT, SIG_DFL); + lua_remove(L, base); /* remove traceback function */ + /* force a complete garbage collection in case of errors */ + if (status != 0) lua_gc(L, LUA_GCCOLLECT, 0); + return status; +} + + +static void print_version (void) { + l_message(NULL, LUA_RELEASE " " LUA_COPYRIGHT); +} + + +static int getargs (lua_State *L, char **argv, int n) { + int narg; + int i; + int argc = 0; + while (argv[argc]) argc++; /* count total number of arguments */ + narg = argc - (n + 1); /* number of arguments to the script */ + luaL_checkstack(L, narg + 3, "too many arguments to script"); + for (i=n+1; i < argc; i++) + lua_pushstring(L, argv[i]); + lua_createtable(L, narg, n + 1); + for (i=0; i < argc; i++) { + lua_pushstring(L, argv[i]); + lua_rawseti(L, -2, i - n); + } + return narg; +} + + +static int dofile (lua_State *L, const char *name) { + int status = luaL_loadfile(L, name) || docall(L, 0, 1); + return report(L, status); +} + + +static int dostring (lua_State *L, const char *s, const char *name) { + int status = luaL_loadbuffer(L, s, strlen(s), name) || docall(L, 0, 1); + return report(L, status); +} + + +static int dolibrary (lua_State *L, const char *name) { + lua_getglobal(L, "require"); + lua_pushstring(L, name); + return report(L, docall(L, 1, 1)); +} + + +static const char *get_prompt (lua_State *L, int firstline) { + const char *p; + lua_getfield(L, LUA_GLOBALSINDEX, firstline ? "_PROMPT" : "_PROMPT2"); + p = lua_tostring(L, -1); + if (p == NULL) p = (firstline ? LUA_PROMPT : LUA_PROMPT2); + lua_pop(L, 1); /* remove global */ + return p; +} + + +static int incomplete (lua_State *L, int status) { + if (status == LUA_ERRSYNTAX) { + size_t lmsg; + const char *msg = lua_tolstring(L, -1, &lmsg); + const char *tp = msg + lmsg - (sizeof(LUA_QL("")) - 1); + if (strstr(msg, LUA_QL("")) == tp) { + lua_pop(L, 1); + return 1; + } + } + return 0; /* else... */ +} + + +static int pushline (lua_State *L, int firstline) { + char buffer[LUA_MAXINPUT]; + char *b = buffer; + size_t l; + const char *prmt = get_prompt(L, firstline); + if (lua_readline(L, b, prmt) == 0) + return 0; /* no input */ + l = strlen(b); + if (l > 0 && b[l-1] == '\n') /* line ends with newline? */ + b[l-1] = '\0'; /* remove it */ + if (firstline && b[0] == '=') /* first line starts with `=' ? */ + lua_pushfstring(L, "return %s", b+1); /* change it to `return' */ + else + lua_pushstring(L, b); + lua_freeline(L, b); + return 1; +} + + +static int loadline (lua_State *L) { + int status; + lua_settop(L, 0); + if (!pushline(L, 1)) + return -1; /* no input */ + for (;;) { /* repeat until gets a complete line */ + status = luaL_loadbuffer(L, lua_tostring(L, 1), lua_strlen(L, 1), "=stdin"); + if (!incomplete(L, status)) break; /* cannot try to add lines? */ + if (!pushline(L, 0)) /* no more input? */ + return -1; + lua_pushliteral(L, "\n"); /* add a new line... */ + lua_insert(L, -2); /* ...between the two lines */ + lua_concat(L, 3); /* join them */ + } + lua_saveline(L, 1); + lua_remove(L, 1); /* remove line */ + return status; +} + + +static void dotty (lua_State *L) { + int status; + const char *oldprogname = progname; + progname = NULL; + while ((status = loadline(L)) != -1) { + if (status == 0) status = docall(L, 0, 0); + report(L, status); + if (status == 0 && lua_gettop(L) > 0) { /* any result to print? */ + lua_getglobal(L, "print"); + lua_insert(L, 1); + if (lua_pcall(L, lua_gettop(L)-1, 0, 0) != 0) + l_message(progname, lua_pushfstring(L, + "error calling " LUA_QL("print") " (%s)", + lua_tostring(L, -1))); + } + } + lua_settop(L, 0); /* clear stack */ + fputs("\n", stdout); + fflush(stdout); + progname = oldprogname; +} + + +static int handle_script (lua_State *L, char **argv, int n) { + int status; + const char *fname; + int narg = getargs(L, argv, n); /* collect arguments */ + lua_setglobal(L, "arg"); + fname = argv[n]; + if (strcmp(fname, "-") == 0 && strcmp(argv[n-1], "--") != 0) + fname = NULL; /* stdin */ + status = luaL_loadfile(L, fname); + lua_insert(L, -(narg+1)); + if (status == 0) + status = docall(L, narg, 0); + else + lua_pop(L, narg); + return report(L, status); +} + + +/* check that argument has no extra characters at the end */ +#define notail(x) {if ((x)[2] != '\0') return -1;} + + +static int collectargs (char **argv, int *pi, int *pv, int *pe) { + int i; + for (i = 1; argv[i] != NULL; i++) { + if (argv[i][0] != '-') /* not an option? */ + return i; + switch (argv[i][1]) { /* option */ + case '-': + notail(argv[i]); + return (argv[i+1] != NULL ? i+1 : 0); + case '\0': + return i; + case 'i': + notail(argv[i]); + *pi = 1; /* go through */ + case 'v': + notail(argv[i]); + *pv = 1; + break; + case 'e': + *pe = 1; /* go through */ + case 'l': + if (argv[i][2] == '\0') { + i++; + if (argv[i] == NULL) return -1; + } + break; + default: return -1; /* invalid option */ + } + } + return 0; +} + + +static int runargs (lua_State *L, char **argv, int n) { + int i; + for (i = 1; i < n; i++) { + if (argv[i] == NULL) continue; + lua_assert(argv[i][0] == '-'); + switch (argv[i][1]) { /* option */ + case 'e': { + const char *chunk = argv[i] + 2; + if (*chunk == '\0') chunk = argv[++i]; + lua_assert(chunk != NULL); + if (dostring(L, chunk, "=(command line)") != 0) + return 1; + break; + } + case 'l': { + const char *filename = argv[i] + 2; + if (*filename == '\0') filename = argv[++i]; + lua_assert(filename != NULL); + if (dolibrary(L, filename)) + return 1; /* stop if file fails */ + break; + } + default: break; + } + } + return 0; +} + + +static int handle_luainit (lua_State *L) { + const char *init = getenv(LUA_INIT); + if (init == NULL) return 0; /* status OK */ + else if (init[0] == '@') + return dofile(L, init+1); + else + return dostring(L, init, "=" LUA_INIT); +} + + +struct Smain { + int argc; + char **argv; + int status; +}; + + +static int pmain (lua_State *L) { + struct Smain *s = (struct Smain *)lua_touserdata(L, 1); + char **argv = s->argv; + int script; + int has_i = 0, has_v = 0, has_e = 0; + globalL = L; + if (argv[0] && argv[0][0]) progname = argv[0]; + lua_gc(L, LUA_GCSTOP, 0); /* stop collector during initialization */ + luaL_openlibs(L); /* open libraries */ + lua_gc(L, LUA_GCRESTART, 0); + s->status = handle_luainit(L); + if (s->status != 0) return 0; + script = collectargs(argv, &has_i, &has_v, &has_e); + if (script < 0) { /* invalid args? */ + print_usage(); + s->status = 1; + return 0; + } + if (has_v) print_version(); + s->status = runargs(L, argv, (script > 0) ? script : s->argc); + if (s->status != 0) return 0; + if (script) + s->status = handle_script(L, argv, script); + if (s->status != 0) return 0; + if (has_i) + dotty(L); + else if (script == 0 && !has_e && !has_v) { + if (lua_stdin_is_tty()) { + print_version(); + dotty(L); + } + else dofile(L, NULL); /* executes stdin as a file */ + } + return 0; +} + + +int main (int argc, char **argv) { + int status; + struct Smain s; + lua_State *L = lua_open(); /* create state */ + if (L == NULL) { + l_message(argv[0], "cannot create state: not enough memory"); + return EXIT_FAILURE; + } + s.argc = argc; + s.argv = argv; + status = lua_cpcall(L, &pmain, &s); + report(L, status); + lua_close(L); + return (status || s.status) ? EXIT_FAILURE : EXIT_SUCCESS; +} + diff --git a/mk/linux/mojosetup/lua/src/lua.h b/mk/linux/mojosetup/lua/src/lua.h new file mode 100644 index 00000000..e4bdfd3b --- /dev/null +++ b/mk/linux/mojosetup/lua/src/lua.h @@ -0,0 +1,388 @@ +/* +** $Id: lua.h,v 1.218.1.5 2008/08/06 13:30:12 roberto Exp $ +** Lua - An Extensible Extension Language +** Lua.org, PUC-Rio, Brazil (http://www.lua.org) +** See Copyright Notice at the end of this file +*/ + + +#ifndef lua_h +#define lua_h + +#include +#include + + +#include "luaconf.h" + + +#define LUA_VERSION "Lua 5.1" +#define LUA_RELEASE "Lua 5.1.4" +#define LUA_VERSION_NUM 501 +#define LUA_COPYRIGHT "Copyright (C) 1994-2008 Lua.org, PUC-Rio" +#define LUA_AUTHORS "R. Ierusalimschy, L. H. de Figueiredo & W. Celes" + + +/* mark for precompiled code (`Lua') */ +#define LUA_SIGNATURE "\033Lua" + +/* option for multiple returns in `lua_pcall' and `lua_call' */ +#define LUA_MULTRET (-1) + + +/* +** pseudo-indices +*/ +#define LUA_REGISTRYINDEX (-10000) +#define LUA_ENVIRONINDEX (-10001) +#define LUA_GLOBALSINDEX (-10002) +#define lua_upvalueindex(i) (LUA_GLOBALSINDEX-(i)) + + +/* thread status; 0 is OK */ +#define LUA_YIELD 1 +#define LUA_ERRRUN 2 +#define LUA_ERRSYNTAX 3 +#define LUA_ERRMEM 4 +#define LUA_ERRERR 5 + + +typedef struct lua_State lua_State; + +typedef int (*lua_CFunction) (lua_State *L); + + +/* +** functions that read/write blocks when loading/dumping Lua chunks +*/ +typedef const char * (*lua_Reader) (lua_State *L, void *ud, size_t *sz); + +typedef int (*lua_Writer) (lua_State *L, const void* p, size_t sz, void* ud); + + +/* +** prototype for memory-allocation functions +*/ +typedef void * (*lua_Alloc) (void *ud, void *ptr, size_t osize, size_t nsize); + + +/* +** basic types +*/ +#define LUA_TNONE (-1) + +#define LUA_TNIL 0 +#define LUA_TBOOLEAN 1 +#define LUA_TLIGHTUSERDATA 2 +#define LUA_TNUMBER 3 +#define LUA_TSTRING 4 +#define LUA_TTABLE 5 +#define LUA_TFUNCTION 6 +#define LUA_TUSERDATA 7 +#define LUA_TTHREAD 8 + + + +/* minimum Lua stack available to a C function */ +#define LUA_MINSTACK 20 + + +/* +** generic extra include file +*/ +#if defined(LUA_USER_H) +#include LUA_USER_H +#endif + + +/* type of numbers in Lua */ +typedef LUA_NUMBER lua_Number; + + +/* type for integer functions */ +typedef LUA_INTEGER lua_Integer; + + + +/* +** state manipulation +*/ +LUA_API lua_State *(lua_newstate) (lua_Alloc f, void *ud); +LUA_API void (lua_close) (lua_State *L); +LUA_API lua_State *(lua_newthread) (lua_State *L); + +LUA_API lua_CFunction (lua_atpanic) (lua_State *L, lua_CFunction panicf); + + +/* +** basic stack manipulation +*/ +LUA_API int (lua_gettop) (lua_State *L); +LUA_API void (lua_settop) (lua_State *L, int idx); +LUA_API void (lua_pushvalue) (lua_State *L, int idx); +LUA_API void (lua_remove) (lua_State *L, int idx); +LUA_API void (lua_insert) (lua_State *L, int idx); +LUA_API void (lua_replace) (lua_State *L, int idx); +LUA_API int (lua_checkstack) (lua_State *L, int sz); + +LUA_API void (lua_xmove) (lua_State *from, lua_State *to, int n); + + +/* +** access functions (stack -> C) +*/ + +LUA_API int (lua_isnumber) (lua_State *L, int idx); +LUA_API int (lua_isstring) (lua_State *L, int idx); +LUA_API int (lua_iscfunction) (lua_State *L, int idx); +LUA_API int (lua_isuserdata) (lua_State *L, int idx); +LUA_API int (lua_type) (lua_State *L, int idx); +LUA_API const char *(lua_typename) (lua_State *L, int tp); + +LUA_API int (lua_equal) (lua_State *L, int idx1, int idx2); +LUA_API int (lua_rawequal) (lua_State *L, int idx1, int idx2); +LUA_API int (lua_lessthan) (lua_State *L, int idx1, int idx2); + +LUA_API lua_Number (lua_tonumber) (lua_State *L, int idx); +LUA_API lua_Integer (lua_tointeger) (lua_State *L, int idx); +LUA_API int (lua_toboolean) (lua_State *L, int idx); +LUA_API const char *(lua_tolstring) (lua_State *L, int idx, size_t *len); +LUA_API size_t (lua_objlen) (lua_State *L, int idx); +LUA_API lua_CFunction (lua_tocfunction) (lua_State *L, int idx); +LUA_API void *(lua_touserdata) (lua_State *L, int idx); +LUA_API lua_State *(lua_tothread) (lua_State *L, int idx); +LUA_API const void *(lua_topointer) (lua_State *L, int idx); + + +/* +** push functions (C -> stack) +*/ +LUA_API void (lua_pushnil) (lua_State *L); +LUA_API void (lua_pushnumber) (lua_State *L, lua_Number n); +LUA_API void (lua_pushinteger) (lua_State *L, lua_Integer n); +LUA_API void (lua_pushlstring) (lua_State *L, const char *s, size_t l); +LUA_API void (lua_pushstring) (lua_State *L, const char *s); +LUA_API const char *(lua_pushvfstring) (lua_State *L, const char *fmt, + va_list argp); +LUA_API const char *(lua_pushfstring) (lua_State *L, const char *fmt, ...); +LUA_API void (lua_pushcclosure) (lua_State *L, lua_CFunction fn, int n); +LUA_API void (lua_pushboolean) (lua_State *L, int b); +LUA_API void (lua_pushlightuserdata) (lua_State *L, void *p); +LUA_API int (lua_pushthread) (lua_State *L); + + +/* +** get functions (Lua -> stack) +*/ +LUA_API void (lua_gettable) (lua_State *L, int idx); +LUA_API void (lua_getfield) (lua_State *L, int idx, const char *k); +LUA_API void (lua_rawget) (lua_State *L, int idx); +LUA_API void (lua_rawgeti) (lua_State *L, int idx, int n); +LUA_API void (lua_createtable) (lua_State *L, int narr, int nrec); +LUA_API void *(lua_newuserdata) (lua_State *L, size_t sz); +LUA_API int (lua_getmetatable) (lua_State *L, int objindex); +LUA_API void (lua_getfenv) (lua_State *L, int idx); + + +/* +** set functions (stack -> Lua) +*/ +LUA_API void (lua_settable) (lua_State *L, int idx); +LUA_API void (lua_setfield) (lua_State *L, int idx, const char *k); +LUA_API void (lua_rawset) (lua_State *L, int idx); +LUA_API void (lua_rawseti) (lua_State *L, int idx, int n); +LUA_API int (lua_setmetatable) (lua_State *L, int objindex); +LUA_API int (lua_setfenv) (lua_State *L, int idx); + + +/* +** `load' and `call' functions (load and run Lua code) +*/ +LUA_API void (lua_call) (lua_State *L, int nargs, int nresults); +LUA_API int (lua_pcall) (lua_State *L, int nargs, int nresults, int errfunc); +LUA_API int (lua_cpcall) (lua_State *L, lua_CFunction func, void *ud); +LUA_API int (lua_load) (lua_State *L, lua_Reader reader, void *dt, + const char *chunkname); + +LUA_API int (lua_dump) (lua_State *L, lua_Writer writer, void *data); + + +/* +** coroutine functions +*/ +LUA_API int (lua_yield) (lua_State *L, int nresults); +LUA_API int (lua_resume) (lua_State *L, int narg); +LUA_API int (lua_status) (lua_State *L); + +/* +** garbage-collection function and options +*/ + +#define LUA_GCSTOP 0 +#define LUA_GCRESTART 1 +#define LUA_GCCOLLECT 2 +#define LUA_GCCOUNT 3 +#define LUA_GCCOUNTB 4 +#define LUA_GCSTEP 5 +#define LUA_GCSETPAUSE 6 +#define LUA_GCSETSTEPMUL 7 + +LUA_API int (lua_gc) (lua_State *L, int what, int data); + + +/* +** miscellaneous functions +*/ + +LUA_API int (lua_error) (lua_State *L); + +LUA_API int (lua_next) (lua_State *L, int idx); + +LUA_API void (lua_concat) (lua_State *L, int n); + +LUA_API lua_Alloc (lua_getallocf) (lua_State *L, void **ud); +LUA_API void lua_setallocf (lua_State *L, lua_Alloc f, void *ud); + + + +/* +** =============================================================== +** some useful macros +** =============================================================== +*/ + +#define lua_pop(L,n) lua_settop(L, -(n)-1) + +#define lua_newtable(L) lua_createtable(L, 0, 0) + +#define lua_register(L,n,f) (lua_pushcfunction(L, (f)), lua_setglobal(L, (n))) + +#define lua_pushcfunction(L,f) lua_pushcclosure(L, (f), 0) + +#define lua_strlen(L,i) lua_objlen(L, (i)) + +#define lua_isfunction(L,n) (lua_type(L, (n)) == LUA_TFUNCTION) +#define lua_istable(L,n) (lua_type(L, (n)) == LUA_TTABLE) +#define lua_islightuserdata(L,n) (lua_type(L, (n)) == LUA_TLIGHTUSERDATA) +#define lua_isnil(L,n) (lua_type(L, (n)) == LUA_TNIL) +#define lua_isboolean(L,n) (lua_type(L, (n)) == LUA_TBOOLEAN) +#define lua_isthread(L,n) (lua_type(L, (n)) == LUA_TTHREAD) +#define lua_isnone(L,n) (lua_type(L, (n)) == LUA_TNONE) +#define lua_isnoneornil(L, n) (lua_type(L, (n)) <= 0) + +#define lua_pushliteral(L, s) \ + lua_pushlstring(L, "" s, (sizeof(s)/sizeof(char))-1) + +#define lua_setglobal(L,s) lua_setfield(L, LUA_GLOBALSINDEX, (s)) +#define lua_getglobal(L,s) lua_getfield(L, LUA_GLOBALSINDEX, (s)) + +#define lua_tostring(L,i) lua_tolstring(L, (i), NULL) + + + +/* +** compatibility macros and functions +*/ + +#define lua_open() luaL_newstate() + +#define lua_getregistry(L) lua_pushvalue(L, LUA_REGISTRYINDEX) + +#define lua_getgccount(L) lua_gc(L, LUA_GCCOUNT, 0) + +#define lua_Chunkreader lua_Reader +#define lua_Chunkwriter lua_Writer + + +/* hack */ +LUA_API void lua_setlevel (lua_State *from, lua_State *to); + + +/* +** {====================================================================== +** Debug API +** ======================================================================= +*/ + + +/* +** Event codes +*/ +#define LUA_HOOKCALL 0 +#define LUA_HOOKRET 1 +#define LUA_HOOKLINE 2 +#define LUA_HOOKCOUNT 3 +#define LUA_HOOKTAILRET 4 + + +/* +** Event masks +*/ +#define LUA_MASKCALL (1 << LUA_HOOKCALL) +#define LUA_MASKRET (1 << LUA_HOOKRET) +#define LUA_MASKLINE (1 << LUA_HOOKLINE) +#define LUA_MASKCOUNT (1 << LUA_HOOKCOUNT) + +typedef struct lua_Debug lua_Debug; /* activation record */ + + +/* Functions to be called by the debuger in specific events */ +typedef void (*lua_Hook) (lua_State *L, lua_Debug *ar); + + +LUA_API int lua_getstack (lua_State *L, int level, lua_Debug *ar); +LUA_API int lua_getinfo (lua_State *L, const char *what, lua_Debug *ar); +LUA_API const char *lua_getlocal (lua_State *L, const lua_Debug *ar, int n); +LUA_API const char *lua_setlocal (lua_State *L, const lua_Debug *ar, int n); +LUA_API const char *lua_getupvalue (lua_State *L, int funcindex, int n); +LUA_API const char *lua_setupvalue (lua_State *L, int funcindex, int n); + +LUA_API int lua_sethook (lua_State *L, lua_Hook func, int mask, int count); +LUA_API lua_Hook lua_gethook (lua_State *L); +LUA_API int lua_gethookmask (lua_State *L); +LUA_API int lua_gethookcount (lua_State *L); + + +struct lua_Debug { + int event; + const char *name; /* (n) */ + const char *namewhat; /* (n) `global', `local', `field', `method' */ + const char *what; /* (S) `Lua', `C', `main', `tail' */ + const char *source; /* (S) */ + int currentline; /* (l) */ + int nups; /* (u) number of upvalues */ + int linedefined; /* (S) */ + int lastlinedefined; /* (S) */ + char short_src[LUA_IDSIZE]; /* (S) */ + /* private part */ + int i_ci; /* active function */ +}; + +/* }====================================================================== */ + + +/****************************************************************************** +* Copyright (C) 1994-2008 Lua.org, PUC-Rio. All rights reserved. +* +* Permission is hereby granted, free of charge, to any person obtaining +* a copy of this software and associated documentation files (the +* "Software"), to deal in the Software without restriction, including +* without limitation the rights to use, copy, modify, merge, publish, +* distribute, sublicense, and/or sell copies of the Software, and to +* permit persons to whom the Software is furnished to do so, subject to +* the following conditions: +* +* The above copyright notice and this permission notice shall be +* included in all copies or substantial portions of the Software. +* +* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +******************************************************************************/ + + +#endif diff --git a/mk/linux/mojosetup/lua/src/luac.c b/mk/linux/mojosetup/lua/src/luac.c new file mode 100644 index 00000000..d0701739 --- /dev/null +++ b/mk/linux/mojosetup/lua/src/luac.c @@ -0,0 +1,200 @@ +/* +** $Id: luac.c,v 1.54 2006/06/02 17:37:11 lhf Exp $ +** Lua compiler (saves bytecodes to files; also list bytecodes) +** See Copyright Notice in lua.h +*/ + +#include +#include +#include +#include + +#define luac_c +#define LUA_CORE + +#include "lua.h" +#include "lauxlib.h" + +#include "ldo.h" +#include "lfunc.h" +#include "lmem.h" +#include "lobject.h" +#include "lopcodes.h" +#include "lstring.h" +#include "lundump.h" + +#define PROGNAME "luac" /* default program name */ +#define OUTPUT PROGNAME ".out" /* default output file */ + +static int listing=0; /* list bytecodes? */ +static int dumping=1; /* dump bytecodes? */ +static int stripping=0; /* strip debug information? */ +static char Output[]={ OUTPUT }; /* default output file name */ +static const char* output=Output; /* actual output file name */ +static const char* progname=PROGNAME; /* actual program name */ + +static void fatal(const char* message) +{ + fprintf(stderr,"%s: %s\n",progname,message); + exit(EXIT_FAILURE); +} + +static void cannot(const char* what) +{ + fprintf(stderr,"%s: cannot %s %s: %s\n",progname,what,output,strerror(errno)); + exit(EXIT_FAILURE); +} + +static void usage(const char* message) +{ + if (*message=='-') + fprintf(stderr,"%s: unrecognized option " LUA_QS "\n",progname,message); + else + fprintf(stderr,"%s: %s\n",progname,message); + fprintf(stderr, + "usage: %s [options] [filenames].\n" + "Available options are:\n" + " - process stdin\n" + " -l list\n" + " -o name output to file " LUA_QL("name") " (default is \"%s\")\n" + " -p parse only\n" + " -s strip debug information\n" + " -v show version information\n" + " -- stop handling options\n", + progname,Output); + exit(EXIT_FAILURE); +} + +#define IS(s) (strcmp(argv[i],s)==0) + +static int doargs(int argc, char* argv[]) +{ + int i; + int version=0; + if (argv[0]!=NULL && *argv[0]!=0) progname=argv[0]; + for (i=1; itop+(i))->l.p) + +static const Proto* combine(lua_State* L, int n) +{ + if (n==1) + return toproto(L,-1); + else + { + int i,pc; + Proto* f=luaF_newproto(L); + setptvalue2s(L,L->top,f); incr_top(L); + f->source=luaS_newliteral(L,"=(" PROGNAME ")"); + f->maxstacksize=1; + pc=2*n+1; + f->code=luaM_newvector(L,pc,Instruction); + f->sizecode=pc; + f->p=luaM_newvector(L,n,Proto*); + f->sizep=n; + pc=0; + for (i=0; ip[i]=toproto(L,i-n-1); + f->code[pc++]=CREATE_ABx(OP_CLOSURE,0,i); + f->code[pc++]=CREATE_ABC(OP_CALL,0,1,1); + } + f->code[pc++]=CREATE_ABC(OP_RETURN,0,1,0); + return f; + } +} + +static int writer(lua_State* L, const void* p, size_t size, void* u) +{ + UNUSED(L); + return (fwrite(p,size,1,(FILE*)u)!=1) && (size!=0); +} + +struct Smain { + int argc; + char** argv; +}; + +static int pmain(lua_State* L) +{ + struct Smain* s = (struct Smain*)lua_touserdata(L, 1); + int argc=s->argc; + char** argv=s->argv; + const Proto* f; + int i; + if (!lua_checkstack(L,argc)) fatal("too many input files"); + for (i=0; i1); + if (dumping) + { + FILE* D= (output==NULL) ? stdout : fopen(output,"wb"); + if (D==NULL) cannot("open"); + lua_lock(L); + luaU_dump(L,f,writer,D,stripping); + lua_unlock(L); + if (ferror(D)) cannot("write"); + if (fclose(D)) cannot("close"); + } + return 0; +} + +int main(int argc, char* argv[]) +{ + lua_State* L; + struct Smain s; + int i=doargs(argc,argv); + argc-=i; argv+=i; + if (argc<=0) usage("no input files given"); + L=lua_open(); + if (L==NULL) fatal("not enough memory for state"); + s.argc=argc; + s.argv=argv; + if (lua_cpcall(L,pmain,&s)!=0) fatal(lua_tostring(L,-1)); + lua_close(L); + return EXIT_SUCCESS; +} diff --git a/mk/linux/mojosetup/lua/src/luaconf.h b/mk/linux/mojosetup/lua/src/luaconf.h new file mode 100644 index 00000000..4c1d1f32 --- /dev/null +++ b/mk/linux/mojosetup/lua/src/luaconf.h @@ -0,0 +1,767 @@ +/* +** $Id: luaconf.h,v 1.82.1.7 2008/02/11 16:25:08 roberto Exp $ +** Configuration file for Lua +** See Copyright Notice in lua.h +*/ + + +#ifndef lconfig_h +#define lconfig_h + +#include +#include + + +/* +** ================================================================== +** Search for "@@" to find all configurable definitions. +** =================================================================== +*/ + + +/* +@@ LUA_ANSI controls the use of non-ansi features. +** CHANGE it (define it) if you want Lua to avoid the use of any +** non-ansi feature or library. +*/ +#if defined(__STRICT_ANSI__) +#define LUA_ANSI +#endif + + +#if !defined(LUA_ANSI) && defined(_WIN32) +#define LUA_WIN +#endif + +#if defined(LUA_USE_LINUX) +#define LUA_USE_POSIX +#define LUA_USE_DLOPEN /* needs an extra library: -ldl */ +#define LUA_USE_READLINE /* needs some extra libraries */ +#endif + +#if defined(LUA_USE_MACOSX) +#define LUA_USE_POSIX +#define LUA_DL_DYLD /* does not need extra library */ +#endif + + + +/* +@@ LUA_USE_POSIX includes all functionallity listed as X/Open System +@* Interfaces Extension (XSI). +** CHANGE it (define it) if your system is XSI compatible. +*/ +#if defined(LUA_USE_POSIX) +#define LUA_USE_MKSTEMP +#define LUA_USE_ISATTY +#define LUA_USE_POPEN +#define LUA_USE_ULONGJMP +#endif + + +/* +@@ LUA_PATH and LUA_CPATH are the names of the environment variables that +@* Lua check to set its paths. +@@ LUA_INIT is the name of the environment variable that Lua +@* checks for initialization code. +** CHANGE them if you want different names. +*/ +#define LUA_PATH "LUA_PATH" +#define LUA_CPATH "LUA_CPATH" +#define LUA_INIT "LUA_INIT" + + +/* +@@ LUA_PATH_DEFAULT is the default path that Lua uses to look for +@* Lua libraries. +@@ LUA_CPATH_DEFAULT is the default path that Lua uses to look for +@* C libraries. +** CHANGE them if your machine has a non-conventional directory +** hierarchy or if you want to install your libraries in +** non-conventional directories. +*/ +#if defined(_WIN32) +/* +** In Windows, any exclamation mark ('!') in the path is replaced by the +** path of the directory of the executable file of the current process. +*/ +#define LUA_LDIR "!\\lua\\" +#define LUA_CDIR "!\\" +#define LUA_PATH_DEFAULT \ + ".\\?.lua;" LUA_LDIR"?.lua;" LUA_LDIR"?\\init.lua;" \ + LUA_CDIR"?.lua;" LUA_CDIR"?\\init.lua" +#define LUA_CPATH_DEFAULT \ + ".\\?.dll;" LUA_CDIR"?.dll;" LUA_CDIR"loadall.dll" + +#else +#define LUA_ROOT "/usr/local/" +#define LUA_LDIR LUA_ROOT "share/lua/5.1/" +#define LUA_CDIR LUA_ROOT "lib/lua/5.1/" +#define LUA_PATH_DEFAULT \ + "./?.lua;" LUA_LDIR"?.lua;" LUA_LDIR"?/init.lua;" \ + LUA_CDIR"?.lua;" LUA_CDIR"?/init.lua" +#define LUA_CPATH_DEFAULT \ + "./?.so;" LUA_CDIR"?.so;" LUA_CDIR"loadall.so" +#endif + + +/* +@@ LUA_DIRSEP is the directory separator (for submodules). +** CHANGE it if your machine does not use "/" as the directory separator +** and is not Windows. (On Windows Lua automatically uses "\".) +*/ +#if defined(_WIN32) +#define LUA_DIRSEP "\\" +#else +#define LUA_DIRSEP "/" +#endif + + +/* +@@ LUA_PATHSEP is the character that separates templates in a path. +@@ LUA_PATH_MARK is the string that marks the substitution points in a +@* template. +@@ LUA_EXECDIR in a Windows path is replaced by the executable's +@* directory. +@@ LUA_IGMARK is a mark to ignore all before it when bulding the +@* luaopen_ function name. +** CHANGE them if for some reason your system cannot use those +** characters. (E.g., if one of those characters is a common character +** in file/directory names.) Probably you do not need to change them. +*/ +#define LUA_PATHSEP ";" +#define LUA_PATH_MARK "?" +#define LUA_EXECDIR "!" +#define LUA_IGMARK "-" + + +/* +@@ LUA_INTEGER is the integral type used by lua_pushinteger/lua_tointeger. +** CHANGE that if ptrdiff_t is not adequate on your machine. (On most +** machines, ptrdiff_t gives a good choice between int or long.) +*/ +#define LUA_INTEGER ptrdiff_t + + +/* +@@ LUA_API is a mark for all core API functions. +@@ LUALIB_API is a mark for all standard library functions. +** CHANGE them if you need to define those functions in some special way. +** For instance, if you want to create one Windows DLL with the core and +** the libraries, you may want to use the following definition (define +** LUA_BUILD_AS_DLL to get it). +*/ +#if defined(LUA_BUILD_AS_DLL) + +#if defined(LUA_CORE) || defined(LUA_LIB) +#define LUA_API __declspec(dllexport) +#else +#define LUA_API __declspec(dllimport) +#endif + +#else + +#define LUA_API extern + +#endif + +/* more often than not the libs go together with the core */ +#define LUALIB_API LUA_API + + +/* +@@ LUAI_FUNC is a mark for all extern functions that are not to be +@* exported to outside modules. +@@ LUAI_DATA is a mark for all extern (const) variables that are not to +@* be exported to outside modules. +** CHANGE them if you need to mark them in some special way. Elf/gcc +** (versions 3.2 and later) mark them as "hidden" to optimize access +** when Lua is compiled as a shared library. +*/ +#if defined(luaall_c) +#define LUAI_FUNC static +#define LUAI_DATA /* empty */ + +#elif defined(__GNUC__) && ((__GNUC__*100 + __GNUC_MINOR__) >= 302) && \ + defined(__ELF__) && !defined(sun) +#define LUAI_FUNC __attribute__((visibility("hidden"))) extern +#define LUAI_DATA LUAI_FUNC + +#elif (defined SUNPRO_C) +#define LUAI_FUNC __global +#define LUAI_DATA LUAI_FUNC + +#else +#define LUAI_FUNC extern +#define LUAI_DATA extern +#endif + + + +/* +@@ LUA_QL describes how error messages quote program elements. +** CHANGE it if you want a different appearance. +*/ +#define LUA_QL(x) "'" x "'" +#define LUA_QS LUA_QL("%s") + + +/* +@@ LUA_IDSIZE gives the maximum size for the description of the source +@* of a function in debug information. +** CHANGE it if you want a different size. +*/ +#define LUA_IDSIZE 60 + + +/* +** {================================================================== +** Stand-alone configuration +** =================================================================== +*/ + +#if defined(lua_c) || defined(luaall_c) + +/* +@@ lua_stdin_is_tty detects whether the standard input is a 'tty' (that +@* is, whether we're running lua interactively). +** CHANGE it if you have a better definition for non-POSIX/non-Windows +** systems. +*/ +#if defined(LUA_USE_ISATTY) +#include +#define lua_stdin_is_tty() isatty(0) +#elif defined(LUA_WIN) +#include +#include +#define lua_stdin_is_tty() _isatty(_fileno(stdin)) +#else +#define lua_stdin_is_tty() 1 /* assume stdin is a tty */ +#endif + + +/* +@@ LUA_PROMPT is the default prompt used by stand-alone Lua. +@@ LUA_PROMPT2 is the default continuation prompt used by stand-alone Lua. +** CHANGE them if you want different prompts. (You can also change the +** prompts dynamically, assigning to globals _PROMPT/_PROMPT2.) +*/ +#define LUA_PROMPT "> " +#define LUA_PROMPT2 ">> " + + +/* +@@ LUA_PROGNAME is the default name for the stand-alone Lua program. +** CHANGE it if your stand-alone interpreter has a different name and +** your system is not able to detect that name automatically. +*/ +#define LUA_PROGNAME "lua" + + +/* +@@ LUA_MAXINPUT is the maximum length for an input line in the +@* stand-alone interpreter. +** CHANGE it if you need longer lines. +*/ +#define LUA_MAXINPUT 512 + + +/* +@@ lua_readline defines how to show a prompt and then read a line from +@* the standard input. +@@ lua_saveline defines how to "save" a read line in a "history". +@@ lua_freeline defines how to free a line read by lua_readline. +** CHANGE them if you want to improve this functionality (e.g., by using +** GNU readline and history facilities). +*/ +#if defined(LUA_USE_READLINE) +#include +#include +#include +#define lua_readline(L,b,p) ((void)L, ((b)=readline(p)) != NULL) +#define lua_saveline(L,idx) \ + if (lua_strlen(L,idx) > 0) /* non-empty line? */ \ + add_history(lua_tostring(L, idx)); /* add it to history */ +#define lua_freeline(L,b) ((void)L, free(b)) +#else +#define lua_readline(L,b,p) \ + ((void)L, fputs(p, stdout), fflush(stdout), /* show prompt */ \ + fgets(b, LUA_MAXINPUT, stdin) != NULL) /* get line */ +#define lua_saveline(L,idx) { (void)L; (void)idx; } +#define lua_freeline(L,b) { (void)L; (void)b; } +#endif + +#endif + +/* }================================================================== */ + + +/* +@@ LUAI_GCPAUSE defines the default pause between garbage-collector cycles +@* as a percentage. +** CHANGE it if you want the GC to run faster or slower (higher values +** mean larger pauses which mean slower collection.) You can also change +** this value dynamically. +*/ +#define LUAI_GCPAUSE 200 /* 200% (wait memory to double before next GC) */ + + +/* +@@ LUAI_GCMUL defines the default speed of garbage collection relative to +@* memory allocation as a percentage. +** CHANGE it if you want to change the granularity of the garbage +** collection. (Higher values mean coarser collections. 0 represents +** infinity, where each step performs a full collection.) You can also +** change this value dynamically. +*/ +#define LUAI_GCMUL 200 /* GC runs 'twice the speed' of memory allocation */ + + + +/* +@@ LUA_COMPAT_GETN controls compatibility with old getn behavior. +** CHANGE it (define it) if you want exact compatibility with the +** behavior of setn/getn in Lua 5.0. +*/ +#undef LUA_COMPAT_GETN + +/* +@@ LUA_COMPAT_LOADLIB controls compatibility about global loadlib. +** CHANGE it to undefined as soon as you do not need a global 'loadlib' +** function (the function is still available as 'package.loadlib'). +*/ +#undef LUA_COMPAT_LOADLIB + +/* +@@ LUA_COMPAT_VARARG controls compatibility with old vararg feature. +** CHANGE it to undefined as soon as your programs use only '...' to +** access vararg parameters (instead of the old 'arg' table). +*/ +#define LUA_COMPAT_VARARG + +/* +@@ LUA_COMPAT_MOD controls compatibility with old math.mod function. +** CHANGE it to undefined as soon as your programs use 'math.fmod' or +** the new '%' operator instead of 'math.mod'. +*/ +#define LUA_COMPAT_MOD + +/* +@@ LUA_COMPAT_LSTR controls compatibility with old long string nesting +@* facility. +** CHANGE it to 2 if you want the old behaviour, or undefine it to turn +** off the advisory error when nesting [[...]]. +*/ +#define LUA_COMPAT_LSTR 1 + +/* +@@ LUA_COMPAT_GFIND controls compatibility with old 'string.gfind' name. +** CHANGE it to undefined as soon as you rename 'string.gfind' to +** 'string.gmatch'. +*/ +#define LUA_COMPAT_GFIND + +/* +@@ LUA_COMPAT_OPENLIB controls compatibility with old 'luaL_openlib' +@* behavior. +** CHANGE it to undefined as soon as you replace to 'luaL_register' +** your uses of 'luaL_openlib' +*/ +#define LUA_COMPAT_OPENLIB + + + +/* +@@ luai_apicheck is the assert macro used by the Lua-C API. +** CHANGE luai_apicheck if you want Lua to perform some checks in the +** parameters it gets from API calls. This may slow down the interpreter +** a bit, but may be quite useful when debugging C code that interfaces +** with Lua. A useful redefinition is to use assert.h. +*/ +#if defined(LUA_USE_APICHECK) +#include +#define luai_apicheck(L,o) { (void)L; assert(o); } +#else +#define luai_apicheck(L,o) { (void)L; } +#endif + + +/* +@@ LUAI_BITSINT defines the number of bits in an int. +** CHANGE here if Lua cannot automatically detect the number of bits of +** your machine. Probably you do not need to change this. +*/ +/* avoid overflows in comparison */ +#if INT_MAX-20 < 32760 +#define LUAI_BITSINT 16 +#elif INT_MAX > 2147483640L +/* int has at least 32 bits */ +#define LUAI_BITSINT 32 +#else +#error "you must define LUA_BITSINT with number of bits in an integer" +#endif + + +/* +@@ LUAI_UINT32 is an unsigned integer with at least 32 bits. +@@ LUAI_INT32 is an signed integer with at least 32 bits. +@@ LUAI_UMEM is an unsigned integer big enough to count the total +@* memory used by Lua. +@@ LUAI_MEM is a signed integer big enough to count the total memory +@* used by Lua. +** CHANGE here if for some weird reason the default definitions are not +** good enough for your machine. (The definitions in the 'else' +** part always works, but may waste space on machines with 64-bit +** longs.) Probably you do not need to change this. +*/ +#if LUAI_BITSINT >= 32 +#define LUAI_UINT32 unsigned int +#define LUAI_INT32 int +#define LUAI_MAXINT32 INT_MAX +#define LUAI_UMEM size_t +#define LUAI_MEM ptrdiff_t +#else +/* 16-bit ints */ +#define LUAI_UINT32 unsigned long +#define LUAI_INT32 long +#define LUAI_MAXINT32 LONG_MAX +#define LUAI_UMEM unsigned long +#define LUAI_MEM long +#endif + + +/* +@@ LUAI_MAXCALLS limits the number of nested calls. +** CHANGE it if you need really deep recursive calls. This limit is +** arbitrary; its only purpose is to stop infinite recursion before +** exhausting memory. +*/ +#define LUAI_MAXCALLS 20000 + + +/* +@@ LUAI_MAXCSTACK limits the number of Lua stack slots that a C function +@* can use. +** CHANGE it if you need lots of (Lua) stack space for your C +** functions. This limit is arbitrary; its only purpose is to stop C +** functions to consume unlimited stack space. (must be smaller than +** -LUA_REGISTRYINDEX) +*/ +#define LUAI_MAXCSTACK 8000 + + + +/* +** {================================================================== +** CHANGE (to smaller values) the following definitions if your system +** has a small C stack. (Or you may want to change them to larger +** values if your system has a large C stack and these limits are +** too rigid for you.) Some of these constants control the size of +** stack-allocated arrays used by the compiler or the interpreter, while +** others limit the maximum number of recursive calls that the compiler +** or the interpreter can perform. Values too large may cause a C stack +** overflow for some forms of deep constructs. +** =================================================================== +*/ + + +/* +@@ LUAI_MAXCCALLS is the maximum depth for nested C calls (short) and +@* syntactical nested non-terminals in a program. +*/ +#define LUAI_MAXCCALLS 200 + + +/* +@@ LUAI_MAXVARS is the maximum number of local variables per function +@* (must be smaller than 250). +*/ +#define LUAI_MAXVARS 200 + + +/* +@@ LUAI_MAXUPVALUES is the maximum number of upvalues per function +@* (must be smaller than 250). +*/ +#define LUAI_MAXUPVALUES 60 + + +/* +@@ LUAL_BUFFERSIZE is the buffer size used by the lauxlib buffer system. +*/ +#define LUAL_BUFFERSIZE BUFSIZ + +/* }================================================================== */ + + + + +/* +** {================================================================== +@@ LUA_NUMBER is the type of numbers in Lua. +** CHANGE the following definitions only if you want to build Lua +** with a number type different from double. You may also need to +** change lua_number2int & lua_number2integer. +** =================================================================== +*/ + +#define LUA_NUMBER_DOUBLE +#define LUA_NUMBER double + +/* +@@ LUAI_UACNUMBER is the result of an 'usual argument conversion' +@* over a number. +*/ +#define LUAI_UACNUMBER double + + +/* +@@ LUA_NUMBER_SCAN is the format for reading numbers. +@@ LUA_NUMBER_FMT is the format for writing numbers. +@@ lua_number2str converts a number to a string. +@@ LUAI_MAXNUMBER2STR is maximum size of previous conversion. +@@ lua_str2number converts a string to a number. +*/ +#define LUA_NUMBER_SCAN "%lf" +#define LUA_NUMBER_FMT "%.14g" +#define lua_number2str(s,n) sprintf((s), LUA_NUMBER_FMT, (n)) +#define LUAI_MAXNUMBER2STR 32 /* 16 digits, sign, point, and \0 */ +#define lua_str2number(s,p) strtod((s), (p)) + + +/* +@@ The luai_num* macros define the primitive operations over numbers. +*/ +#if defined(LUA_CORE) +#include +#define luai_numadd(a,b) ((a)+(b)) +#define luai_numsub(a,b) ((a)-(b)) +#define luai_nummul(a,b) ((a)*(b)) +#define luai_numdiv(a,b) ((a)/(b)) +#define luai_nummod(a,b) ((a) - floor((a)/(b))*(b)) +#define luai_numpow(a,b) (pow(a,b)) +#define luai_numunm(a) (-(a)) +#define luai_numeq(a,b) ((a)==(b)) +#define luai_numlt(a,b) ((a)<(b)) +#define luai_numle(a,b) ((a)<=(b)) +#define luai_numisnan(a) (!luai_numeq((a), (a))) +#endif + + +/* +@@ lua_number2int is a macro to convert lua_Number to int. +@@ lua_number2integer is a macro to convert lua_Number to lua_Integer. +** CHANGE them if you know a faster way to convert a lua_Number to +** int (with any rounding method and without throwing errors) in your +** system. In Pentium machines, a naive typecast from double to int +** in C is extremely slow, so any alternative is worth trying. +*/ + +/* On a Pentium, resort to a trick */ +#if defined(LUA_NUMBER_DOUBLE) && !defined(LUA_ANSI) && !defined(__SSE2__) && \ + (defined(__i386) || defined (_M_IX86) || defined(__i386__)) + +/* On a Microsoft compiler, use assembler */ +#if defined(_MSC_VER) + +#define lua_number2int(i,d) __asm fld d __asm fistp i +#define lua_number2integer(i,n) lua_number2int(i, n) + +/* the next trick should work on any Pentium, but sometimes clashes + with a DirectX idiosyncrasy */ +#else + +union luai_Cast { double l_d; long l_l; }; +#define lua_number2int(i,d) \ + { volatile union luai_Cast u; u.l_d = (d) + 6755399441055744.0; (i) = u.l_l; } +#define lua_number2integer(i,n) lua_number2int(i, n) + +#endif + + +/* this option always works, but may be slow */ +#else +#define lua_number2int(i,d) ((i)=(int)(d)) +#define lua_number2integer(i,d) ((i)=(lua_Integer)(d)) + +#endif + +/* }================================================================== */ + + +/* +@@ LUAI_USER_ALIGNMENT_T is a type that requires maximum alignment. +** CHANGE it if your system requires alignments larger than double. (For +** instance, if your system supports long doubles and they must be +** aligned in 16-byte boundaries, then you should add long double in the +** union.) Probably you do not need to change this. +*/ +#define LUAI_USER_ALIGNMENT_T union { double u; void *s; long l; } + + +/* +@@ LUAI_THROW/LUAI_TRY define how Lua does exception handling. +** CHANGE them if you prefer to use longjmp/setjmp even with C++ +** or if want/don't to use _longjmp/_setjmp instead of regular +** longjmp/setjmp. By default, Lua handles errors with exceptions when +** compiling as C++ code, with _longjmp/_setjmp when asked to use them, +** and with longjmp/setjmp otherwise. +*/ +#if defined(__cplusplus) +/* C++ exceptions */ +#define LUAI_THROW(L,c) throw(c) +#define LUAI_TRY(L,c,a) try { a } catch(...) \ + { if ((c)->status == 0) (c)->status = -1; } +#define luai_jmpbuf int /* dummy variable */ + +#elif defined(LUA_USE_ULONGJMP) +/* in Unix, try _longjmp/_setjmp (more efficient) */ +#define LUAI_THROW(L,c) _longjmp((c)->b, 1) +#define LUAI_TRY(L,c,a) if (_setjmp((c)->b) == 0) { a } +#define luai_jmpbuf jmp_buf + +#else +/* default handling with long jumps */ +#define LUAI_THROW(L,c) longjmp((c)->b, 1) +#define LUAI_TRY(L,c,a) if (setjmp((c)->b) == 0) { a } +#define luai_jmpbuf jmp_buf + +#endif + + +/* +@@ LUA_MAXCAPTURES is the maximum number of captures that a pattern +@* can do during pattern-matching. +** CHANGE it if you need more captures. This limit is arbitrary. +*/ +#define LUA_MAXCAPTURES 32 + + +/* +@@ lua_tmpnam is the function that the OS library uses to create a +@* temporary name. +@@ LUA_TMPNAMBUFSIZE is the maximum size of a name created by lua_tmpnam. +** CHANGE them if you have an alternative to tmpnam (which is considered +** insecure) or if you want the original tmpnam anyway. By default, Lua +** uses tmpnam except when POSIX is available, where it uses mkstemp. +*/ +#if defined(loslib_c) || defined(luaall_c) + +#if defined(LUA_USE_MKSTEMP) +#include +#define LUA_TMPNAMBUFSIZE 32 +#define lua_tmpnam(b,e) { \ + strcpy(b, "/tmp/lua_XXXXXX"); \ + e = mkstemp(b); \ + if (e != -1) close(e); \ + e = (e == -1); } + +#else +#define LUA_TMPNAMBUFSIZE L_tmpnam +#define lua_tmpnam(b,e) { e = (tmpnam(b) == NULL); } +#endif + +#endif + + +/* +@@ lua_popen spawns a new process connected to the current one through +@* the file streams. +** CHANGE it if you have a way to implement it in your system. +*/ +#if defined(LUA_USE_POPEN) + +#define lua_popen(L,c,m) ((void)L, fflush(NULL), popen(c,m)) +#define lua_pclose(L,file) ((void)L, (pclose(file) != -1)) + +#elif defined(LUA_WIN) + +#define lua_popen(L,c,m) ((void)L, _popen(c,m)) +#define lua_pclose(L,file) ((void)L, (_pclose(file) != -1)) + +#else + +#define lua_popen(L,c,m) ((void)((void)c, m), \ + luaL_error(L, LUA_QL("popen") " not supported"), (FILE*)0) +#define lua_pclose(L,file) ((void)((void)L, file), 0) + +#endif + +/* +@@ LUA_DL_* define which dynamic-library system Lua should use. +** CHANGE here if Lua has problems choosing the appropriate +** dynamic-library system for your platform (either Windows' DLL, Mac's +** dyld, or Unix's dlopen). If your system is some kind of Unix, there +** is a good chance that it has dlopen, so LUA_DL_DLOPEN will work for +** it. To use dlopen you also need to adapt the src/Makefile (probably +** adding -ldl to the linker options), so Lua does not select it +** automatically. (When you change the makefile to add -ldl, you must +** also add -DLUA_USE_DLOPEN.) +** If you do not want any kind of dynamic library, undefine all these +** options. +** By default, _WIN32 gets LUA_DL_DLL and MAC OS X gets LUA_DL_DYLD. +*/ +#if defined(LUA_USE_DLOPEN) +#define LUA_DL_DLOPEN +#endif + +#if defined(LUA_WIN) +#define LUA_DL_DLL +#endif + + +/* +@@ LUAI_EXTRASPACE allows you to add user-specific data in a lua_State +@* (the data goes just *before* the lua_State pointer). +** CHANGE (define) this if you really need that. This value must be +** a multiple of the maximum alignment required for your machine. +*/ +#define LUAI_EXTRASPACE 0 + + +/* +@@ luai_userstate* allow user-specific actions on threads. +** CHANGE them if you defined LUAI_EXTRASPACE and need to do something +** extra when a thread is created/deleted/resumed/yielded. +*/ +#define luai_userstateopen(L) ((void)L) +#define luai_userstateclose(L) ((void)L) +#define luai_userstatethread(L,L1) ((void)L) +#define luai_userstatefree(L) ((void)L) +#define luai_userstateresume(L,n) ((void)L) +#define luai_userstateyield(L,n) ((void)L) + + +/* +@@ LUA_INTFRMLEN is the length modifier for integer conversions +@* in 'string.format'. +@@ LUA_INTFRM_T is the integer type correspoding to the previous length +@* modifier. +** CHANGE them if your system supports long long or does not support long. +*/ + +#if defined(LUA_USELONGLONG) + +#define LUA_INTFRMLEN "ll" +#define LUA_INTFRM_T long long + +#else + +#define LUA_INTFRMLEN "l" +#define LUA_INTFRM_T long + +#endif + + + +/* =================================================================== */ + +/* +** Local configuration. You can use this space to add your redefinitions +** without modifying the main part of the file. +*/ + + + +#endif + diff --git a/mk/linux/mojosetup/lua/src/lualib.h b/mk/linux/mojosetup/lua/src/lualib.h new file mode 100644 index 00000000..469417f6 --- /dev/null +++ b/mk/linux/mojosetup/lua/src/lualib.h @@ -0,0 +1,53 @@ +/* +** $Id: lualib.h,v 1.36.1.1 2007/12/27 13:02:25 roberto Exp $ +** Lua standard libraries +** See Copyright Notice in lua.h +*/ + + +#ifndef lualib_h +#define lualib_h + +#include "lua.h" + + +/* Key to file-handle type */ +#define LUA_FILEHANDLE "FILE*" + + +#define LUA_COLIBNAME "coroutine" +LUALIB_API int (luaopen_base) (lua_State *L); + +#define LUA_TABLIBNAME "table" +LUALIB_API int (luaopen_table) (lua_State *L); + +#define LUA_IOLIBNAME "io" +LUALIB_API int (luaopen_io) (lua_State *L); + +#define LUA_OSLIBNAME "os" +LUALIB_API int (luaopen_os) (lua_State *L); + +#define LUA_STRLIBNAME "string" +LUALIB_API int (luaopen_string) (lua_State *L); + +#define LUA_MATHLIBNAME "math" +LUALIB_API int (luaopen_math) (lua_State *L); + +#define LUA_DBLIBNAME "debug" +LUALIB_API int (luaopen_debug) (lua_State *L); + +#define LUA_LOADLIBNAME "package" +LUALIB_API int (luaopen_package) (lua_State *L); + + +/* open all previous libraries */ +LUALIB_API void (luaL_openlibs) (lua_State *L); + + + +#ifndef lua_assert +#define lua_assert(x) ((void)0) +#endif + + +#endif diff --git a/mk/linux/mojosetup/lua/src/lundump.c b/mk/linux/mojosetup/lua/src/lundump.c new file mode 100644 index 00000000..8010a457 --- /dev/null +++ b/mk/linux/mojosetup/lua/src/lundump.c @@ -0,0 +1,227 @@ +/* +** $Id: lundump.c,v 2.7.1.4 2008/04/04 19:51:41 roberto Exp $ +** load precompiled Lua chunks +** See Copyright Notice in lua.h +*/ + +#include + +#define lundump_c +#define LUA_CORE + +#include "lua.h" + +#include "ldebug.h" +#include "ldo.h" +#include "lfunc.h" +#include "lmem.h" +#include "lobject.h" +#include "lstring.h" +#include "lundump.h" +#include "lzio.h" + +typedef struct { + lua_State* L; + ZIO* Z; + Mbuffer* b; + const char* name; +} LoadState; + +#ifdef LUAC_TRUST_BINARIES +#define IF(c,s) +#define error(S,s) +#else +#define IF(c,s) if (c) error(S,s) + +static void error(LoadState* S, const char* why) +{ + luaO_pushfstring(S->L,"%s: %s in precompiled chunk",S->name,why); + luaD_throw(S->L,LUA_ERRSYNTAX); +} +#endif + +#define LoadMem(S,b,n,size) LoadBlock(S,b,(n)*(size)) +#define LoadByte(S) (lu_byte)LoadChar(S) +#define LoadVar(S,x) LoadMem(S,&x,1,sizeof(x)) +#define LoadVector(S,b,n,size) LoadMem(S,b,n,size) + +static void LoadBlock(LoadState* S, void* b, size_t size) +{ + size_t r=luaZ_read(S->Z,b,size); + IF (r!=0, "unexpected end"); +} + +static int LoadChar(LoadState* S) +{ + char x; + LoadVar(S,x); + return x; +} + +static int LoadInt(LoadState* S) +{ + int x; + LoadVar(S,x); + IF (x<0, "bad integer"); + return x; +} + +static lua_Number LoadNumber(LoadState* S) +{ + lua_Number x; + LoadVar(S,x); + return x; +} + +static TString* LoadString(LoadState* S) +{ + size_t size; + LoadVar(S,size); + if (size==0) + return NULL; + else + { + char* s=luaZ_openspace(S->L,S->b,size); + LoadBlock(S,s,size); + return luaS_newlstr(S->L,s,size-1); /* remove trailing '\0' */ + } +} + +static void LoadCode(LoadState* S, Proto* f) +{ + int n=LoadInt(S); + f->code=luaM_newvector(S->L,n,Instruction); + f->sizecode=n; + LoadVector(S,f->code,n,sizeof(Instruction)); +} + +static Proto* LoadFunction(LoadState* S, TString* p); + +static void LoadConstants(LoadState* S, Proto* f) +{ + int i,n; + n=LoadInt(S); + f->k=luaM_newvector(S->L,n,TValue); + f->sizek=n; + for (i=0; ik[i]); + for (i=0; ik[i]; + int t=LoadChar(S); + switch (t) + { + case LUA_TNIL: + setnilvalue(o); + break; + case LUA_TBOOLEAN: + setbvalue(o,LoadChar(S)!=0); + break; + case LUA_TNUMBER: + setnvalue(o,LoadNumber(S)); + break; + case LUA_TSTRING: + setsvalue2n(S->L,o,LoadString(S)); + break; + default: + error(S,"bad constant"); + break; + } + } + n=LoadInt(S); + f->p=luaM_newvector(S->L,n,Proto*); + f->sizep=n; + for (i=0; ip[i]=NULL; + for (i=0; ip[i]=LoadFunction(S,f->source); +} + +static void LoadDebug(LoadState* S, Proto* f) +{ + int i,n; + n=LoadInt(S); + f->lineinfo=luaM_newvector(S->L,n,int); + f->sizelineinfo=n; + LoadVector(S,f->lineinfo,n,sizeof(int)); + n=LoadInt(S); + f->locvars=luaM_newvector(S->L,n,LocVar); + f->sizelocvars=n; + for (i=0; ilocvars[i].varname=NULL; + for (i=0; ilocvars[i].varname=LoadString(S); + f->locvars[i].startpc=LoadInt(S); + f->locvars[i].endpc=LoadInt(S); + } + n=LoadInt(S); + f->upvalues=luaM_newvector(S->L,n,TString*); + f->sizeupvalues=n; + for (i=0; iupvalues[i]=NULL; + for (i=0; iupvalues[i]=LoadString(S); +} + +static Proto* LoadFunction(LoadState* S, TString* p) +{ + Proto* f; + if (++S->L->nCcalls > LUAI_MAXCCALLS) error(S,"code too deep"); + f=luaF_newproto(S->L); + setptvalue2s(S->L,S->L->top,f); incr_top(S->L); + f->source=LoadString(S); if (f->source==NULL) f->source=p; + f->linedefined=LoadInt(S); + f->lastlinedefined=LoadInt(S); + f->nups=LoadByte(S); + f->numparams=LoadByte(S); + f->is_vararg=LoadByte(S); + f->maxstacksize=LoadByte(S); + LoadCode(S,f); + LoadConstants(S,f); + LoadDebug(S,f); + IF (!luaG_checkcode(f), "bad code"); + S->L->top--; + S->L->nCcalls--; + return f; +} + +static void LoadHeader(LoadState* S) +{ + char h[LUAC_HEADERSIZE]; + char s[LUAC_HEADERSIZE]; + luaU_header(h); + LoadBlock(S,s,LUAC_HEADERSIZE); + IF (memcmp(h,s,LUAC_HEADERSIZE)!=0, "bad header"); +} + +/* +** load precompiled chunk +*/ +Proto* luaU_undump (lua_State* L, ZIO* Z, Mbuffer* buff, const char* name) +{ + LoadState S; + if (*name=='@' || *name=='=') + S.name=name+1; + else if (*name==LUA_SIGNATURE[0]) + S.name="binary string"; + else + S.name=name; + S.L=L; + S.Z=Z; + S.b=buff; + LoadHeader(&S); + return LoadFunction(&S,luaS_newliteral(L,"=?")); +} + +/* +* make header +*/ +void luaU_header (char* h) +{ + int x=1; + memcpy(h,LUA_SIGNATURE,sizeof(LUA_SIGNATURE)-1); + h+=sizeof(LUA_SIGNATURE)-1; + *h++=(char)LUAC_VERSION; + *h++=(char)LUAC_FORMAT; + *h++=(char)*(char*)&x; /* endianness */ + *h++=(char)sizeof(int); + *h++=(char)sizeof(size_t); + *h++=(char)sizeof(Instruction); + *h++=(char)sizeof(lua_Number); + *h++=(char)(((lua_Number)0.5)==0); /* is lua_Number integral? */ +} diff --git a/mk/linux/mojosetup/lua/src/lundump.h b/mk/linux/mojosetup/lua/src/lundump.h new file mode 100644 index 00000000..c80189db --- /dev/null +++ b/mk/linux/mojosetup/lua/src/lundump.h @@ -0,0 +1,36 @@ +/* +** $Id: lundump.h,v 1.37.1.1 2007/12/27 13:02:25 roberto Exp $ +** load precompiled Lua chunks +** See Copyright Notice in lua.h +*/ + +#ifndef lundump_h +#define lundump_h + +#include "lobject.h" +#include "lzio.h" + +/* load one chunk; from lundump.c */ +LUAI_FUNC Proto* luaU_undump (lua_State* L, ZIO* Z, Mbuffer* buff, const char* name); + +/* make header; from lundump.c */ +LUAI_FUNC void luaU_header (char* h); + +/* dump one chunk; from ldump.c */ +LUAI_FUNC int luaU_dump (lua_State* L, const Proto* f, lua_Writer w, void* data, int strip); + +#ifdef luac_c +/* print one chunk; from print.c */ +LUAI_FUNC void luaU_print (const Proto* f, int full); +#endif + +/* for header of binary files -- this is Lua 5.1 */ +#define LUAC_VERSION 0x51 + +/* for header of binary files -- this is the official format */ +#define LUAC_FORMAT 0 + +/* size of header of binary files */ +#define LUAC_HEADERSIZE 12 + +#endif diff --git a/mk/linux/mojosetup/lua/src/lvm.c b/mk/linux/mojosetup/lua/src/lvm.c new file mode 100644 index 00000000..ee3256ab --- /dev/null +++ b/mk/linux/mojosetup/lua/src/lvm.c @@ -0,0 +1,763 @@ +/* +** $Id: lvm.c,v 2.63.1.3 2007/12/28 15:32:23 roberto Exp $ +** Lua virtual machine +** See Copyright Notice in lua.h +*/ + + +#include +#include +#include + +#define lvm_c +#define LUA_CORE + +#include "lua.h" + +#include "ldebug.h" +#include "ldo.h" +#include "lfunc.h" +#include "lgc.h" +#include "lobject.h" +#include "lopcodes.h" +#include "lstate.h" +#include "lstring.h" +#include "ltable.h" +#include "ltm.h" +#include "lvm.h" + + + +/* limit for table tag-method chains (to avoid loops) */ +#define MAXTAGLOOP 100 + + +const TValue *luaV_tonumber (const TValue *obj, TValue *n) { + lua_Number num; + if (ttisnumber(obj)) return obj; + if (ttisstring(obj) && luaO_str2d(svalue(obj), &num)) { + setnvalue(n, num); + return n; + } + else + return NULL; +} + + +int luaV_tostring (lua_State *L, StkId obj) { + if (!ttisnumber(obj)) + return 0; + else { + char s[LUAI_MAXNUMBER2STR]; + lua_Number n = nvalue(obj); + lua_number2str(s, n); + setsvalue2s(L, obj, luaS_new(L, s)); + return 1; + } +} + + +static void traceexec (lua_State *L, const Instruction *pc) { + lu_byte mask = L->hookmask; + const Instruction *oldpc = L->savedpc; + L->savedpc = pc; + if ((mask & LUA_MASKCOUNT) && L->hookcount == 0) { + resethookcount(L); + luaD_callhook(L, LUA_HOOKCOUNT, -1); + } + if (mask & LUA_MASKLINE) { + Proto *p = ci_func(L->ci)->l.p; + int npc = pcRel(pc, p); + int newline = getline(p, npc); + /* call linehook when enter a new function, when jump back (loop), + or when enter a new line */ + if (npc == 0 || pc <= oldpc || newline != getline(p, pcRel(oldpc, p))) + luaD_callhook(L, LUA_HOOKLINE, newline); + } +} + + +static void callTMres (lua_State *L, StkId res, const TValue *f, + const TValue *p1, const TValue *p2) { + ptrdiff_t result = savestack(L, res); + setobj2s(L, L->top, f); /* push function */ + setobj2s(L, L->top+1, p1); /* 1st argument */ + setobj2s(L, L->top+2, p2); /* 2nd argument */ + luaD_checkstack(L, 3); + L->top += 3; + luaD_call(L, L->top - 3, 1); + res = restorestack(L, result); + L->top--; + setobjs2s(L, res, L->top); +} + + + +static void callTM (lua_State *L, const TValue *f, const TValue *p1, + const TValue *p2, const TValue *p3) { + setobj2s(L, L->top, f); /* push function */ + setobj2s(L, L->top+1, p1); /* 1st argument */ + setobj2s(L, L->top+2, p2); /* 2nd argument */ + setobj2s(L, L->top+3, p3); /* 3th argument */ + luaD_checkstack(L, 4); + L->top += 4; + luaD_call(L, L->top - 4, 0); +} + + +void luaV_gettable (lua_State *L, const TValue *t, TValue *key, StkId val) { + int loop; + for (loop = 0; loop < MAXTAGLOOP; loop++) { + const TValue *tm; + if (ttistable(t)) { /* `t' is a table? */ + Table *h = hvalue(t); + const TValue *res = luaH_get(h, key); /* do a primitive get */ + if (!ttisnil(res) || /* result is no nil? */ + (tm = fasttm(L, h->metatable, TM_INDEX)) == NULL) { /* or no TM? */ + setobj2s(L, val, res); + return; + } + /* else will try the tag method */ + } + else if (ttisnil(tm = luaT_gettmbyobj(L, t, TM_INDEX))) + luaG_typeerror(L, t, "index"); + if (ttisfunction(tm)) { + callTMres(L, val, tm, t, key); + return; + } + t = tm; /* else repeat with `tm' */ + } + luaG_runerror(L, "loop in gettable"); +} + + +void luaV_settable (lua_State *L, const TValue *t, TValue *key, StkId val) { + int loop; + for (loop = 0; loop < MAXTAGLOOP; loop++) { + const TValue *tm; + if (ttistable(t)) { /* `t' is a table? */ + Table *h = hvalue(t); + TValue *oldval = luaH_set(L, h, key); /* do a primitive set */ + if (!ttisnil(oldval) || /* result is no nil? */ + (tm = fasttm(L, h->metatable, TM_NEWINDEX)) == NULL) { /* or no TM? */ + setobj2t(L, oldval, val); + luaC_barriert(L, h, val); + return; + } + /* else will try the tag method */ + } + else if (ttisnil(tm = luaT_gettmbyobj(L, t, TM_NEWINDEX))) + luaG_typeerror(L, t, "index"); + if (ttisfunction(tm)) { + callTM(L, tm, t, key, val); + return; + } + t = tm; /* else repeat with `tm' */ + } + luaG_runerror(L, "loop in settable"); +} + + +static int call_binTM (lua_State *L, const TValue *p1, const TValue *p2, + StkId res, TMS event) { + const TValue *tm = luaT_gettmbyobj(L, p1, event); /* try first operand */ + if (ttisnil(tm)) + tm = luaT_gettmbyobj(L, p2, event); /* try second operand */ + if (ttisnil(tm)) return 0; + callTMres(L, res, tm, p1, p2); + return 1; +} + + +static const TValue *get_compTM (lua_State *L, Table *mt1, Table *mt2, + TMS event) { + const TValue *tm1 = fasttm(L, mt1, event); + const TValue *tm2; + if (tm1 == NULL) return NULL; /* no metamethod */ + if (mt1 == mt2) return tm1; /* same metatables => same metamethods */ + tm2 = fasttm(L, mt2, event); + if (tm2 == NULL) return NULL; /* no metamethod */ + if (luaO_rawequalObj(tm1, tm2)) /* same metamethods? */ + return tm1; + return NULL; +} + + +static int call_orderTM (lua_State *L, const TValue *p1, const TValue *p2, + TMS event) { + const TValue *tm1 = luaT_gettmbyobj(L, p1, event); + const TValue *tm2; + if (ttisnil(tm1)) return -1; /* no metamethod? */ + tm2 = luaT_gettmbyobj(L, p2, event); + if (!luaO_rawequalObj(tm1, tm2)) /* different metamethods? */ + return -1; + callTMres(L, L->top, tm1, p1, p2); + return !l_isfalse(L->top); +} + + +static int l_strcmp (const TString *ls, const TString *rs) { + const char *l = getstr(ls); + size_t ll = ls->tsv.len; + const char *r = getstr(rs); + size_t lr = rs->tsv.len; + for (;;) { + int temp = strcoll(l, r); + if (temp != 0) return temp; + else { /* strings are equal up to a `\0' */ + size_t len = strlen(l); /* index of first `\0' in both strings */ + if (len == lr) /* r is finished? */ + return (len == ll) ? 0 : 1; + else if (len == ll) /* l is finished? */ + return -1; /* l is smaller than r (because r is not finished) */ + /* both strings longer than `len'; go on comparing (after the `\0') */ + len++; + l += len; ll -= len; r += len; lr -= len; + } + } +} + + +int luaV_lessthan (lua_State *L, const TValue *l, const TValue *r) { + int res; + if (ttype(l) != ttype(r)) + return luaG_ordererror(L, l, r); + else if (ttisnumber(l)) + return luai_numlt(nvalue(l), nvalue(r)); + else if (ttisstring(l)) + return l_strcmp(rawtsvalue(l), rawtsvalue(r)) < 0; + else if ((res = call_orderTM(L, l, r, TM_LT)) != -1) + return res; + return luaG_ordererror(L, l, r); +} + + +static int lessequal (lua_State *L, const TValue *l, const TValue *r) { + int res; + if (ttype(l) != ttype(r)) + return luaG_ordererror(L, l, r); + else if (ttisnumber(l)) + return luai_numle(nvalue(l), nvalue(r)); + else if (ttisstring(l)) + return l_strcmp(rawtsvalue(l), rawtsvalue(r)) <= 0; + else if ((res = call_orderTM(L, l, r, TM_LE)) != -1) /* first try `le' */ + return res; + else if ((res = call_orderTM(L, r, l, TM_LT)) != -1) /* else try `lt' */ + return !res; + return luaG_ordererror(L, l, r); +} + + +int luaV_equalval (lua_State *L, const TValue *t1, const TValue *t2) { + const TValue *tm; + lua_assert(ttype(t1) == ttype(t2)); + switch (ttype(t1)) { + case LUA_TNIL: return 1; + case LUA_TNUMBER: return luai_numeq(nvalue(t1), nvalue(t2)); + case LUA_TBOOLEAN: return bvalue(t1) == bvalue(t2); /* true must be 1 !! */ + case LUA_TLIGHTUSERDATA: return pvalue(t1) == pvalue(t2); + case LUA_TUSERDATA: { + if (uvalue(t1) == uvalue(t2)) return 1; + tm = get_compTM(L, uvalue(t1)->metatable, uvalue(t2)->metatable, + TM_EQ); + break; /* will try TM */ + } + case LUA_TTABLE: { + if (hvalue(t1) == hvalue(t2)) return 1; + tm = get_compTM(L, hvalue(t1)->metatable, hvalue(t2)->metatable, TM_EQ); + break; /* will try TM */ + } + default: return gcvalue(t1) == gcvalue(t2); + } + if (tm == NULL) return 0; /* no TM? */ + callTMres(L, L->top, tm, t1, t2); /* call TM */ + return !l_isfalse(L->top); +} + + +void luaV_concat (lua_State *L, int total, int last) { + do { + StkId top = L->base + last + 1; + int n = 2; /* number of elements handled in this pass (at least 2) */ + if (!(ttisstring(top-2) || ttisnumber(top-2)) || !tostring(L, top-1)) { + if (!call_binTM(L, top-2, top-1, top-2, TM_CONCAT)) + luaG_concaterror(L, top-2, top-1); + } else if (tsvalue(top-1)->len == 0) /* second op is empty? */ + (void)tostring(L, top - 2); /* result is first op (as string) */ + else { + /* at least two string values; get as many as possible */ + size_t tl = tsvalue(top-1)->len; + char *buffer; + int i; + /* collect total length */ + for (n = 1; n < total && tostring(L, top-n-1); n++) { + size_t l = tsvalue(top-n-1)->len; + if (l >= MAX_SIZET - tl) luaG_runerror(L, "string length overflow"); + tl += l; + } + buffer = luaZ_openspace(L, &G(L)->buff, tl); + tl = 0; + for (i=n; i>0; i--) { /* concat all strings */ + size_t l = tsvalue(top-i)->len; + memcpy(buffer+tl, svalue(top-i), l); + tl += l; + } + setsvalue2s(L, top-n, luaS_newlstr(L, buffer, tl)); + } + total -= n-1; /* got `n' strings to create 1 new */ + last -= n-1; + } while (total > 1); /* repeat until only 1 result left */ +} + + +static void Arith (lua_State *L, StkId ra, const TValue *rb, + const TValue *rc, TMS op) { + TValue tempb, tempc; + const TValue *b, *c; + if ((b = luaV_tonumber(rb, &tempb)) != NULL && + (c = luaV_tonumber(rc, &tempc)) != NULL) { + lua_Number nb = nvalue(b), nc = nvalue(c); + switch (op) { + case TM_ADD: setnvalue(ra, luai_numadd(nb, nc)); break; + case TM_SUB: setnvalue(ra, luai_numsub(nb, nc)); break; + case TM_MUL: setnvalue(ra, luai_nummul(nb, nc)); break; + case TM_DIV: setnvalue(ra, luai_numdiv(nb, nc)); break; + case TM_MOD: setnvalue(ra, luai_nummod(nb, nc)); break; + case TM_POW: setnvalue(ra, luai_numpow(nb, nc)); break; + case TM_UNM: setnvalue(ra, luai_numunm(nb)); break; + default: lua_assert(0); break; + } + } + else if (!call_binTM(L, rb, rc, ra, op)) + luaG_aritherror(L, rb, rc); +} + + + +/* +** some macros for common tasks in `luaV_execute' +*/ + +#define runtime_check(L, c) { if (!(c)) break; } + +#define RA(i) (base+GETARG_A(i)) +/* to be used after possible stack reallocation */ +#define RB(i) check_exp(getBMode(GET_OPCODE(i)) == OpArgR, base+GETARG_B(i)) +#define RC(i) check_exp(getCMode(GET_OPCODE(i)) == OpArgR, base+GETARG_C(i)) +#define RKB(i) check_exp(getBMode(GET_OPCODE(i)) == OpArgK, \ + ISK(GETARG_B(i)) ? k+INDEXK(GETARG_B(i)) : base+GETARG_B(i)) +#define RKC(i) check_exp(getCMode(GET_OPCODE(i)) == OpArgK, \ + ISK(GETARG_C(i)) ? k+INDEXK(GETARG_C(i)) : base+GETARG_C(i)) +#define KBx(i) check_exp(getBMode(GET_OPCODE(i)) == OpArgK, k+GETARG_Bx(i)) + + +#define dojump(L,pc,i) {(pc) += (i); luai_threadyield(L);} + + +#define Protect(x) { L->savedpc = pc; {x;}; base = L->base; } + + +#define arith_op(op,tm) { \ + TValue *rb = RKB(i); \ + TValue *rc = RKC(i); \ + if (ttisnumber(rb) && ttisnumber(rc)) { \ + lua_Number nb = nvalue(rb), nc = nvalue(rc); \ + setnvalue(ra, op(nb, nc)); \ + } \ + else \ + Protect(Arith(L, ra, rb, rc, tm)); \ + } + + + +void luaV_execute (lua_State *L, int nexeccalls) { + LClosure *cl; + StkId base; + TValue *k; + const Instruction *pc; + reentry: /* entry point */ + lua_assert(isLua(L->ci)); + pc = L->savedpc; + cl = &clvalue(L->ci->func)->l; + base = L->base; + k = cl->p->k; + /* main loop of interpreter */ + for (;;) { + const Instruction i = *pc++; + StkId ra; + if ((L->hookmask & (LUA_MASKLINE | LUA_MASKCOUNT)) && + (--L->hookcount == 0 || L->hookmask & LUA_MASKLINE)) { + traceexec(L, pc); + if (L->status == LUA_YIELD) { /* did hook yield? */ + L->savedpc = pc - 1; + return; + } + base = L->base; + } + /* warning!! several calls may realloc the stack and invalidate `ra' */ + ra = RA(i); + lua_assert(base == L->base && L->base == L->ci->base); + lua_assert(base <= L->top && L->top <= L->stack + L->stacksize); + lua_assert(L->top == L->ci->top || luaG_checkopenop(i)); + switch (GET_OPCODE(i)) { + case OP_MOVE: { + setobjs2s(L, ra, RB(i)); + continue; + } + case OP_LOADK: { + setobj2s(L, ra, KBx(i)); + continue; + } + case OP_LOADBOOL: { + setbvalue(ra, GETARG_B(i)); + if (GETARG_C(i)) pc++; /* skip next instruction (if C) */ + continue; + } + case OP_LOADNIL: { + TValue *rb = RB(i); + do { + setnilvalue(rb--); + } while (rb >= ra); + continue; + } + case OP_GETUPVAL: { + int b = GETARG_B(i); + setobj2s(L, ra, cl->upvals[b]->v); + continue; + } + case OP_GETGLOBAL: { + TValue g; + TValue *rb = KBx(i); + sethvalue(L, &g, cl->env); + lua_assert(ttisstring(rb)); + Protect(luaV_gettable(L, &g, rb, ra)); + continue; + } + case OP_GETTABLE: { + Protect(luaV_gettable(L, RB(i), RKC(i), ra)); + continue; + } + case OP_SETGLOBAL: { + TValue g; + sethvalue(L, &g, cl->env); + lua_assert(ttisstring(KBx(i))); + Protect(luaV_settable(L, &g, KBx(i), ra)); + continue; + } + case OP_SETUPVAL: { + UpVal *uv = cl->upvals[GETARG_B(i)]; + setobj(L, uv->v, ra); + luaC_barrier(L, uv, ra); + continue; + } + case OP_SETTABLE: { + Protect(luaV_settable(L, ra, RKB(i), RKC(i))); + continue; + } + case OP_NEWTABLE: { + int b = GETARG_B(i); + int c = GETARG_C(i); + sethvalue(L, ra, luaH_new(L, luaO_fb2int(b), luaO_fb2int(c))); + Protect(luaC_checkGC(L)); + continue; + } + case OP_SELF: { + StkId rb = RB(i); + setobjs2s(L, ra+1, rb); + Protect(luaV_gettable(L, rb, RKC(i), ra)); + continue; + } + case OP_ADD: { + arith_op(luai_numadd, TM_ADD); + continue; + } + case OP_SUB: { + arith_op(luai_numsub, TM_SUB); + continue; + } + case OP_MUL: { + arith_op(luai_nummul, TM_MUL); + continue; + } + case OP_DIV: { + arith_op(luai_numdiv, TM_DIV); + continue; + } + case OP_MOD: { + arith_op(luai_nummod, TM_MOD); + continue; + } + case OP_POW: { + arith_op(luai_numpow, TM_POW); + continue; + } + case OP_UNM: { + TValue *rb = RB(i); + if (ttisnumber(rb)) { + lua_Number nb = nvalue(rb); + setnvalue(ra, luai_numunm(nb)); + } + else { + Protect(Arith(L, ra, rb, rb, TM_UNM)); + } + continue; + } + case OP_NOT: { + int res = l_isfalse(RB(i)); /* next assignment may change this value */ + setbvalue(ra, res); + continue; + } + case OP_LEN: { + const TValue *rb = RB(i); + switch (ttype(rb)) { + case LUA_TTABLE: { + setnvalue(ra, cast_num(luaH_getn(hvalue(rb)))); + break; + } + case LUA_TSTRING: { + setnvalue(ra, cast_num(tsvalue(rb)->len)); + break; + } + default: { /* try metamethod */ + Protect( + if (!call_binTM(L, rb, luaO_nilobject, ra, TM_LEN)) + luaG_typeerror(L, rb, "get length of"); + ) + } + } + continue; + } + case OP_CONCAT: { + int b = GETARG_B(i); + int c = GETARG_C(i); + Protect(luaV_concat(L, c-b+1, c); luaC_checkGC(L)); + setobjs2s(L, RA(i), base+b); + continue; + } + case OP_JMP: { + dojump(L, pc, GETARG_sBx(i)); + continue; + } + case OP_EQ: { + TValue *rb = RKB(i); + TValue *rc = RKC(i); + Protect( + if (equalobj(L, rb, rc) == GETARG_A(i)) + dojump(L, pc, GETARG_sBx(*pc)); + ) + pc++; + continue; + } + case OP_LT: { + Protect( + if (luaV_lessthan(L, RKB(i), RKC(i)) == GETARG_A(i)) + dojump(L, pc, GETARG_sBx(*pc)); + ) + pc++; + continue; + } + case OP_LE: { + Protect( + if (lessequal(L, RKB(i), RKC(i)) == GETARG_A(i)) + dojump(L, pc, GETARG_sBx(*pc)); + ) + pc++; + continue; + } + case OP_TEST: { + if (l_isfalse(ra) != GETARG_C(i)) + dojump(L, pc, GETARG_sBx(*pc)); + pc++; + continue; + } + case OP_TESTSET: { + TValue *rb = RB(i); + if (l_isfalse(rb) != GETARG_C(i)) { + setobjs2s(L, ra, rb); + dojump(L, pc, GETARG_sBx(*pc)); + } + pc++; + continue; + } + case OP_CALL: { + int b = GETARG_B(i); + int nresults = GETARG_C(i) - 1; + if (b != 0) L->top = ra+b; /* else previous instruction set top */ + L->savedpc = pc; + switch (luaD_precall(L, ra, nresults)) { + case PCRLUA: { + nexeccalls++; + goto reentry; /* restart luaV_execute over new Lua function */ + } + case PCRC: { + /* it was a C function (`precall' called it); adjust results */ + if (nresults >= 0) L->top = L->ci->top; + base = L->base; + continue; + } + default: { + return; /* yield */ + } + } + } + case OP_TAILCALL: { + int b = GETARG_B(i); + if (b != 0) L->top = ra+b; /* else previous instruction set top */ + L->savedpc = pc; + lua_assert(GETARG_C(i) - 1 == LUA_MULTRET); + switch (luaD_precall(L, ra, LUA_MULTRET)) { + case PCRLUA: { + /* tail call: put new frame in place of previous one */ + CallInfo *ci = L->ci - 1; /* previous frame */ + int aux; + StkId func = ci->func; + StkId pfunc = (ci+1)->func; /* previous function index */ + if (L->openupval) luaF_close(L, ci->base); + L->base = ci->base = ci->func + ((ci+1)->base - pfunc); + for (aux = 0; pfunc+aux < L->top; aux++) /* move frame down */ + setobjs2s(L, func+aux, pfunc+aux); + ci->top = L->top = func+aux; /* correct top */ + lua_assert(L->top == L->base + clvalue(func)->l.p->maxstacksize); + ci->savedpc = L->savedpc; + ci->tailcalls++; /* one more call lost */ + L->ci--; /* remove new frame */ + goto reentry; + } + case PCRC: { /* it was a C function (`precall' called it) */ + base = L->base; + continue; + } + default: { + return; /* yield */ + } + } + } + case OP_RETURN: { + int b = GETARG_B(i); + if (b != 0) L->top = ra+b-1; + if (L->openupval) luaF_close(L, base); + L->savedpc = pc; + b = luaD_poscall(L, ra); + if (--nexeccalls == 0) /* was previous function running `here'? */ + return; /* no: return */ + else { /* yes: continue its execution */ + if (b) L->top = L->ci->top; + lua_assert(isLua(L->ci)); + lua_assert(GET_OPCODE(*((L->ci)->savedpc - 1)) == OP_CALL); + goto reentry; + } + } + case OP_FORLOOP: { + lua_Number step = nvalue(ra+2); + lua_Number idx = luai_numadd(nvalue(ra), step); /* increment index */ + lua_Number limit = nvalue(ra+1); + if (luai_numlt(0, step) ? luai_numle(idx, limit) + : luai_numle(limit, idx)) { + dojump(L, pc, GETARG_sBx(i)); /* jump back */ + setnvalue(ra, idx); /* update internal index... */ + setnvalue(ra+3, idx); /* ...and external index */ + } + continue; + } + case OP_FORPREP: { + const TValue *init = ra; + const TValue *plimit = ra+1; + const TValue *pstep = ra+2; + L->savedpc = pc; /* next steps may throw errors */ + if (!tonumber(init, ra)) + luaG_runerror(L, LUA_QL("for") " initial value must be a number"); + else if (!tonumber(plimit, ra+1)) + luaG_runerror(L, LUA_QL("for") " limit must be a number"); + else if (!tonumber(pstep, ra+2)) + luaG_runerror(L, LUA_QL("for") " step must be a number"); + setnvalue(ra, luai_numsub(nvalue(ra), nvalue(pstep))); + dojump(L, pc, GETARG_sBx(i)); + continue; + } + case OP_TFORLOOP: { + StkId cb = ra + 3; /* call base */ + setobjs2s(L, cb+2, ra+2); + setobjs2s(L, cb+1, ra+1); + setobjs2s(L, cb, ra); + L->top = cb+3; /* func. + 2 args (state and index) */ + Protect(luaD_call(L, cb, GETARG_C(i))); + L->top = L->ci->top; + cb = RA(i) + 3; /* previous call may change the stack */ + if (!ttisnil(cb)) { /* continue loop? */ + setobjs2s(L, cb-1, cb); /* save control variable */ + dojump(L, pc, GETARG_sBx(*pc)); /* jump back */ + } + pc++; + continue; + } + case OP_SETLIST: { + int n = GETARG_B(i); + int c = GETARG_C(i); + int last; + Table *h; + if (n == 0) { + n = cast_int(L->top - ra) - 1; + L->top = L->ci->top; + } + if (c == 0) c = cast_int(*pc++); + runtime_check(L, ttistable(ra)); + h = hvalue(ra); + last = ((c-1)*LFIELDS_PER_FLUSH) + n; + if (last > h->sizearray) /* needs more space? */ + luaH_resizearray(L, h, last); /* pre-alloc it at once */ + for (; n > 0; n--) { + TValue *val = ra+n; + setobj2t(L, luaH_setnum(L, h, last--), val); + luaC_barriert(L, h, val); + } + continue; + } + case OP_CLOSE: { + luaF_close(L, ra); + continue; + } + case OP_CLOSURE: { + Proto *p; + Closure *ncl; + int nup, j; + p = cl->p->p[GETARG_Bx(i)]; + nup = p->nups; + ncl = luaF_newLclosure(L, nup, cl->env); + ncl->l.p = p; + for (j=0; jl.upvals[j] = cl->upvals[GETARG_B(*pc)]; + else { + lua_assert(GET_OPCODE(*pc) == OP_MOVE); + ncl->l.upvals[j] = luaF_findupval(L, base + GETARG_B(*pc)); + } + } + setclvalue(L, ra, ncl); + Protect(luaC_checkGC(L)); + continue; + } + case OP_VARARG: { + int b = GETARG_B(i) - 1; + int j; + CallInfo *ci = L->ci; + int n = cast_int(ci->base - ci->func) - cl->p->numparams - 1; + if (b == LUA_MULTRET) { + Protect(luaD_checkstack(L, n)); + ra = RA(i); /* previous call may change the stack */ + b = n; + L->top = ra + n; + } + for (j = 0; j < b; j++) { + if (j < n) { + setobjs2s(L, ra + j, ci->base - n + j); + } + else { + setnilvalue(ra + j); + } + } + continue; + } + } + } +} + diff --git a/mk/linux/mojosetup/lua/src/lvm.h b/mk/linux/mojosetup/lua/src/lvm.h new file mode 100644 index 00000000..bfe4f567 --- /dev/null +++ b/mk/linux/mojosetup/lua/src/lvm.h @@ -0,0 +1,36 @@ +/* +** $Id: lvm.h,v 2.5.1.1 2007/12/27 13:02:25 roberto Exp $ +** Lua virtual machine +** See Copyright Notice in lua.h +*/ + +#ifndef lvm_h +#define lvm_h + + +#include "ldo.h" +#include "lobject.h" +#include "ltm.h" + + +#define tostring(L,o) ((ttype(o) == LUA_TSTRING) || (luaV_tostring(L, o))) + +#define tonumber(o,n) (ttype(o) == LUA_TNUMBER || \ + (((o) = luaV_tonumber(o,n)) != NULL)) + +#define equalobj(L,o1,o2) \ + (ttype(o1) == ttype(o2) && luaV_equalval(L, o1, o2)) + + +LUAI_FUNC int luaV_lessthan (lua_State *L, const TValue *l, const TValue *r); +LUAI_FUNC int luaV_equalval (lua_State *L, const TValue *t1, const TValue *t2); +LUAI_FUNC const TValue *luaV_tonumber (const TValue *obj, TValue *n); +LUAI_FUNC int luaV_tostring (lua_State *L, StkId obj); +LUAI_FUNC void luaV_gettable (lua_State *L, const TValue *t, TValue *key, + StkId val); +LUAI_FUNC void luaV_settable (lua_State *L, const TValue *t, TValue *key, + StkId val); +LUAI_FUNC void luaV_execute (lua_State *L, int nexeccalls); +LUAI_FUNC void luaV_concat (lua_State *L, int total, int last); + +#endif diff --git a/mk/linux/mojosetup/lua/src/lzio.c b/mk/linux/mojosetup/lua/src/lzio.c new file mode 100644 index 00000000..293edd59 --- /dev/null +++ b/mk/linux/mojosetup/lua/src/lzio.c @@ -0,0 +1,82 @@ +/* +** $Id: lzio.c,v 1.31.1.1 2007/12/27 13:02:25 roberto Exp $ +** a generic input stream interface +** See Copyright Notice in lua.h +*/ + + +#include + +#define lzio_c +#define LUA_CORE + +#include "lua.h" + +#include "llimits.h" +#include "lmem.h" +#include "lstate.h" +#include "lzio.h" + + +int luaZ_fill (ZIO *z) { + size_t size; + lua_State *L = z->L; + const char *buff; + lua_unlock(L); + buff = z->reader(L, z->data, &size); + lua_lock(L); + if (buff == NULL || size == 0) return EOZ; + z->n = size - 1; + z->p = buff; + return char2int(*(z->p++)); +} + + +int luaZ_lookahead (ZIO *z) { + if (z->n == 0) { + if (luaZ_fill(z) == EOZ) + return EOZ; + else { + z->n++; /* luaZ_fill removed first byte; put back it */ + z->p--; + } + } + return char2int(*z->p); +} + + +void luaZ_init (lua_State *L, ZIO *z, lua_Reader reader, void *data) { + z->L = L; + z->reader = reader; + z->data = data; + z->n = 0; + z->p = NULL; +} + + +/* --------------------------------------------------------------- read --- */ +size_t luaZ_read (ZIO *z, void *b, size_t n) { + while (n) { + size_t m; + if (luaZ_lookahead(z) == EOZ) + return n; /* return number of missing bytes */ + m = (n <= z->n) ? n : z->n; /* min. between n and z->n */ + memcpy(b, z->p, m); + z->n -= m; + z->p += m; + b = (char *)b + m; + n -= m; + } + return 0; +} + +/* ------------------------------------------------------------------------ */ +char *luaZ_openspace (lua_State *L, Mbuffer *buff, size_t n) { + if (n > buff->buffsize) { + if (n < LUA_MINBUFFER) n = LUA_MINBUFFER; + luaZ_resizebuffer(L, buff, n); + } + return buff->buffer; +} + + diff --git a/mk/linux/mojosetup/lua/src/lzio.h b/mk/linux/mojosetup/lua/src/lzio.h new file mode 100644 index 00000000..51d695d8 --- /dev/null +++ b/mk/linux/mojosetup/lua/src/lzio.h @@ -0,0 +1,67 @@ +/* +** $Id: lzio.h,v 1.21.1.1 2007/12/27 13:02:25 roberto Exp $ +** Buffered streams +** See Copyright Notice in lua.h +*/ + + +#ifndef lzio_h +#define lzio_h + +#include "lua.h" + +#include "lmem.h" + + +#define EOZ (-1) /* end of stream */ + +typedef struct Zio ZIO; + +#define char2int(c) cast(int, cast(unsigned char, (c))) + +#define zgetc(z) (((z)->n--)>0 ? char2int(*(z)->p++) : luaZ_fill(z)) + +typedef struct Mbuffer { + char *buffer; + size_t n; + size_t buffsize; +} Mbuffer; + +#define luaZ_initbuffer(L, buff) ((buff)->buffer = NULL, (buff)->buffsize = 0) + +#define luaZ_buffer(buff) ((buff)->buffer) +#define luaZ_sizebuffer(buff) ((buff)->buffsize) +#define luaZ_bufflen(buff) ((buff)->n) + +#define luaZ_resetbuffer(buff) ((buff)->n = 0) + + +#define luaZ_resizebuffer(L, buff, size) \ + (luaM_reallocvector(L, (buff)->buffer, (buff)->buffsize, size, char), \ + (buff)->buffsize = size) + +#define luaZ_freebuffer(L, buff) luaZ_resizebuffer(L, buff, 0) + + +LUAI_FUNC char *luaZ_openspace (lua_State *L, Mbuffer *buff, size_t n); +LUAI_FUNC void luaZ_init (lua_State *L, ZIO *z, lua_Reader reader, + void *data); +LUAI_FUNC size_t luaZ_read (ZIO* z, void* b, size_t n); /* read next n bytes */ +LUAI_FUNC int luaZ_lookahead (ZIO *z); + + + +/* --------- Private Part ------------------ */ + +struct Zio { + size_t n; /* bytes still unread */ + const char *p; /* current position in buffer */ + lua_Reader reader; + void* data; /* additional data */ + lua_State *L; /* Lua state (for reader) */ +}; + + +LUAI_FUNC int luaZ_fill (ZIO *z); + +#endif diff --git a/mk/linux/mojosetup/lua/src/print.c b/mk/linux/mojosetup/lua/src/print.c new file mode 100644 index 00000000..e240cfc3 --- /dev/null +++ b/mk/linux/mojosetup/lua/src/print.c @@ -0,0 +1,227 @@ +/* +** $Id: print.c,v 1.55a 2006/05/31 13:30:05 lhf Exp $ +** print bytecodes +** See Copyright Notice in lua.h +*/ + +#include +#include + +#define luac_c +#define LUA_CORE + +#include "ldebug.h" +#include "lobject.h" +#include "lopcodes.h" +#include "lundump.h" + +#define PrintFunction luaU_print + +#define Sizeof(x) ((int)sizeof(x)) +#define VOID(p) ((const void*)(p)) + +static void PrintString(const TString* ts) +{ + const char* s=getstr(ts); + size_t i,n=ts->tsv.len; + putchar('"'); + for (i=0; ik[i]; + switch (ttype(o)) + { + case LUA_TNIL: + printf("nil"); + break; + case LUA_TBOOLEAN: + printf(bvalue(o) ? "true" : "false"); + break; + case LUA_TNUMBER: + printf(LUA_NUMBER_FMT,nvalue(o)); + break; + case LUA_TSTRING: + PrintString(rawtsvalue(o)); + break; + default: /* cannot happen */ + printf("? type=%d",ttype(o)); + break; + } +} + +static void PrintCode(const Proto* f) +{ + const Instruction* code=f->code; + int pc,n=f->sizecode; + for (pc=0; pc0) printf("[%d]\t",line); else printf("[-]\t"); + printf("%-9s\t",luaP_opnames[o]); + switch (getOpMode(o)) + { + case iABC: + printf("%d",a); + if (getBMode(o)!=OpArgN) printf(" %d",ISK(b) ? (-1-INDEXK(b)) : b); + if (getCMode(o)!=OpArgN) printf(" %d",ISK(c) ? (-1-INDEXK(c)) : c); + break; + case iABx: + if (getBMode(o)==OpArgK) printf("%d %d",a,-1-bx); else printf("%d %d",a,bx); + break; + case iAsBx: + if (o==OP_JMP) printf("%d",sbx); else printf("%d %d",a,sbx); + break; + } + switch (o) + { + case OP_LOADK: + printf("\t; "); PrintConstant(f,bx); + break; + case OP_GETUPVAL: + case OP_SETUPVAL: + printf("\t; %s", (f->sizeupvalues>0) ? getstr(f->upvalues[b]) : "-"); + break; + case OP_GETGLOBAL: + case OP_SETGLOBAL: + printf("\t; %s",svalue(&f->k[bx])); + break; + case OP_GETTABLE: + case OP_SELF: + if (ISK(c)) { printf("\t; "); PrintConstant(f,INDEXK(c)); } + break; + case OP_SETTABLE: + case OP_ADD: + case OP_SUB: + case OP_MUL: + case OP_DIV: + case OP_POW: + case OP_EQ: + case OP_LT: + case OP_LE: + if (ISK(b) || ISK(c)) + { + printf("\t; "); + if (ISK(b)) PrintConstant(f,INDEXK(b)); else printf("-"); + printf(" "); + if (ISK(c)) PrintConstant(f,INDEXK(c)); else printf("-"); + } + break; + case OP_JMP: + case OP_FORLOOP: + case OP_FORPREP: + printf("\t; to %d",sbx+pc+2); + break; + case OP_CLOSURE: + printf("\t; %p",VOID(f->p[bx])); + break; + case OP_SETLIST: + if (c==0) printf("\t; %d",(int)code[++pc]); + else printf("\t; %d",c); + break; + default: + break; + } + printf("\n"); + } +} + +#define SS(x) (x==1)?"":"s" +#define S(x) x,SS(x) + +static void PrintHeader(const Proto* f) +{ + const char* s=getstr(f->source); + if (*s=='@' || *s=='=') + s++; + else if (*s==LUA_SIGNATURE[0]) + s="(bstring)"; + else + s="(string)"; + printf("\n%s <%s:%d,%d> (%d instruction%s, %d bytes at %p)\n", + (f->linedefined==0)?"main":"function",s, + f->linedefined,f->lastlinedefined, + S(f->sizecode),f->sizecode*Sizeof(Instruction),VOID(f)); + printf("%d%s param%s, %d slot%s, %d upvalue%s, ", + f->numparams,f->is_vararg?"+":"",SS(f->numparams), + S(f->maxstacksize),S(f->nups)); + printf("%d local%s, %d constant%s, %d function%s\n", + S(f->sizelocvars),S(f->sizek),S(f->sizep)); +} + +static void PrintConstants(const Proto* f) +{ + int i,n=f->sizek; + printf("constants (%d) for %p:\n",n,VOID(f)); + for (i=0; isizelocvars; + printf("locals (%d) for %p:\n",n,VOID(f)); + for (i=0; ilocvars[i].varname),f->locvars[i].startpc+1,f->locvars[i].endpc+1); + } +} + +static void PrintUpvalues(const Proto* f) +{ + int i,n=f->sizeupvalues; + printf("upvalues (%d) for %p:\n",n,VOID(f)); + if (f->upvalues==NULL) return; + for (i=0; iupvalues[i])); + } +} + +void PrintFunction(const Proto* f, int full) +{ + int i,n=f->sizep; + PrintHeader(f); + PrintCode(f); + if (full) + { + PrintConstants(f); + PrintLocals(f); + PrintUpvalues(f); + } + for (i=0; ip[i],full); +} diff --git a/mk/linux/mojosetup/lua/test/README b/mk/linux/mojosetup/lua/test/README new file mode 100644 index 00000000..0c7f38bc --- /dev/null +++ b/mk/linux/mojosetup/lua/test/README @@ -0,0 +1,26 @@ +These are simple tests for Lua. Some of them contain useful code. +They are meant to be run to make sure Lua is built correctly and also +to be read, to see how Lua programs look. + +Here is a one-line summary of each program: + + bisect.lua bisection method for solving non-linear equations + cf.lua temperature conversion table (celsius to farenheit) + echo.lua echo command line arguments + env.lua environment variables as automatic global variables + factorial.lua factorial without recursion + fib.lua fibonacci function with cache + fibfor.lua fibonacci numbers with coroutines and generators + globals.lua report global variable usage + hello.lua the first program in every language + life.lua Conway's Game of Life + luac.lua bare-bones luac + printf.lua an implementation of printf + readonly.lua make global variables readonly + sieve.lua the sieve of of Eratosthenes programmed with coroutines + sort.lua two implementations of a sort function + table.lua make table, grouping all data for the same item + trace-calls.lua trace calls + trace-globals.lua trace assigments to global variables + xd.lua hex dump + diff --git a/mk/linux/mojosetup/lua/test/bisect.lua b/mk/linux/mojosetup/lua/test/bisect.lua new file mode 100644 index 00000000..f91e69bf --- /dev/null +++ b/mk/linux/mojosetup/lua/test/bisect.lua @@ -0,0 +1,27 @@ +-- bisection method for solving non-linear equations + +delta=1e-6 -- tolerance + +function bisect(f,a,b,fa,fb) + local c=(a+b)/2 + io.write(n," c=",c," a=",a," b=",b,"\n") + if c==a or c==b or math.abs(a-b) posted to lua-l +-- modified to use ANSI terminal escape sequences +-- modified to use for instead of while + +local write=io.write + +ALIVE="¥" DEAD="þ" +ALIVE="O" DEAD="-" + +function delay() -- NOTE: SYSTEM-DEPENDENT, adjust as necessary + for i=1,10000 do end + -- local i=os.clock()+1 while(os.clock() 0 do + local xm1,x,xp1,xi=self.w-1,self.w,1,self.w + while xi > 0 do + local sum = self[ym1][xm1] + self[ym1][x] + self[ym1][xp1] + + self[y][xm1] + self[y][xp1] + + self[yp1][xm1] + self[yp1][x] + self[yp1][xp1] + next[y][x] = ((sum==2) and self[y][x]) or ((sum==3) and 1) or 0 + xm1,x,xp1,xi = x,xp1,xp1+1,xi-1 + end + ym1,y,yp1,yi = y,yp1,yp1+1,yi-1 + end +end + +-- output the array to screen +function _CELLS:draw() + local out="" -- accumulate to reduce flicker + for y=1,self.h do + for x=1,self.w do + out=out..(((self[y][x]>0) and ALIVE) or DEAD) + end + out=out.."\n" + end + write(out) +end + +-- constructor +function CELLS(w,h) + local c = ARRAY2D(w,h) + c.spawn = _CELLS.spawn + c.evolve = _CELLS.evolve + c.draw = _CELLS.draw + return c +end + +-- +-- shapes suitable for use with spawn() above +-- +HEART = { 1,0,1,1,0,1,1,1,1; w=3,h=3 } +GLIDER = { 0,0,1,1,0,1,0,1,1; w=3,h=3 } +EXPLODE = { 0,1,0,1,1,1,1,0,1,0,1,0; w=3,h=4 } +FISH = { 0,1,1,1,1,1,0,0,0,1,0,0,0,0,1,1,0,0,1,0; w=5,h=4 } +BUTTERFLY = { 1,0,0,0,1,0,1,1,1,0,1,0,0,0,1,1,0,1,0,1,1,0,0,0,1; w=5,h=5 } + +-- the main routine +function LIFE(w,h) + -- create two arrays + local thisgen = CELLS(w,h) + local nextgen = CELLS(w,h) + + -- create some life + -- about 1000 generations of fun, then a glider steady-state + thisgen:spawn(GLIDER,5,4) + thisgen:spawn(EXPLODE,25,10) + thisgen:spawn(FISH,4,12) + + -- run until break + local gen=1 + write("\027[2J") -- ANSI clear screen + while 1 do + thisgen:evolve(nextgen) + thisgen,nextgen = nextgen,thisgen + write("\027[H") -- ANSI home cursor + thisgen:draw() + write("Life - generation ",gen,"\n") + gen=gen+1 + if gen>2000 then break end + --delay() -- no delay + end +end + +LIFE(40,20) diff --git a/mk/linux/mojosetup/lua/test/luac.lua b/mk/linux/mojosetup/lua/test/luac.lua new file mode 100644 index 00000000..96a0a97c --- /dev/null +++ b/mk/linux/mojosetup/lua/test/luac.lua @@ -0,0 +1,7 @@ +-- bare-bones luac in Lua +-- usage: lua luac.lua file.lua + +assert(arg[1]~=nil and arg[2]==nil,"usage: lua luac.lua file.lua") +f=assert(io.open("luac.out","wb")) +assert(f:write(string.dump(assert(loadfile(arg[1]))))) +assert(f:close()) diff --git a/mk/linux/mojosetup/lua/test/printf.lua b/mk/linux/mojosetup/lua/test/printf.lua new file mode 100644 index 00000000..58c63ff5 --- /dev/null +++ b/mk/linux/mojosetup/lua/test/printf.lua @@ -0,0 +1,7 @@ +-- an implementation of printf + +function printf(...) + io.write(string.format(...)) +end + +printf("Hello %s from %s on %s\n",os.getenv"USER" or "there",_VERSION,os.date()) diff --git a/mk/linux/mojosetup/lua/test/readonly.lua b/mk/linux/mojosetup/lua/test/readonly.lua new file mode 100644 index 00000000..85c0b4e0 --- /dev/null +++ b/mk/linux/mojosetup/lua/test/readonly.lua @@ -0,0 +1,12 @@ +-- make global variables readonly + +local f=function (t,i) error("cannot redefine global variable `"..i.."'",2) end +local g={} +local G=getfenv() +setmetatable(g,{__index=G,__newindex=f}) +setfenv(1,g) + +-- an example +rawset(g,"x",3) +x=2 +y=1 -- cannot redefine `y' diff --git a/mk/linux/mojosetup/lua/test/sieve.lua b/mk/linux/mojosetup/lua/test/sieve.lua new file mode 100644 index 00000000..0871bb21 --- /dev/null +++ b/mk/linux/mojosetup/lua/test/sieve.lua @@ -0,0 +1,29 @@ +-- the sieve of of Eratosthenes programmed with coroutines +-- typical usage: lua -e N=1000 sieve.lua | column + +-- generate all the numbers from 2 to n +function gen (n) + return coroutine.wrap(function () + for i=2,n do coroutine.yield(i) end + end) +end + +-- filter the numbers generated by `g', removing multiples of `p' +function filter (p, g) + return coroutine.wrap(function () + while 1 do + local n = g() + if n == nil then return end + if math.mod(n, p) ~= 0 then coroutine.yield(n) end + end + end) +end + +N=N or 1000 -- from command line +x = gen(N) -- generate primes up to N +while 1 do + local n = x() -- pick a number until done + if n == nil then break end + print(n) -- must be a prime number + x = filter(n, x) -- now remove its multiples +end diff --git a/mk/linux/mojosetup/lua/test/sort.lua b/mk/linux/mojosetup/lua/test/sort.lua new file mode 100644 index 00000000..0bcb15f8 --- /dev/null +++ b/mk/linux/mojosetup/lua/test/sort.lua @@ -0,0 +1,66 @@ +-- two implementations of a sort function +-- this is an example only. Lua has now a built-in function "sort" + +-- extracted from Programming Pearls, page 110 +function qsort(x,l,u,f) + if ly end) + show("after reverse selection sort",x) + qsort(x,1,n,function (x,y) return x>> ",string.rep(" ",level)) + if t~=nil and t.currentline>=0 then io.write(t.short_src,":",t.currentline," ") end + t=debug.getinfo(2) + if event=="call" then + level=level+1 + else + level=level-1 if level<0 then level=0 end + end + if t.what=="main" then + if event=="call" then + io.write("begin ",t.short_src) + else + io.write("end ",t.short_src) + end + elseif t.what=="Lua" then +-- table.foreach(t,print) + io.write(event," ",t.name or "(Lua)"," <",t.linedefined,":",t.short_src,">") + else + io.write(event," ",t.name or "(C)"," [",t.what,"] ") + end + io.write("\n") +end + +debug.sethook(hook,"cr") +level=0 diff --git a/mk/linux/mojosetup/lua/test/trace-globals.lua b/mk/linux/mojosetup/lua/test/trace-globals.lua new file mode 100644 index 00000000..295e670c --- /dev/null +++ b/mk/linux/mojosetup/lua/test/trace-globals.lua @@ -0,0 +1,38 @@ +-- trace assigments to global variables + +do + -- a tostring that quotes strings. note the use of the original tostring. + local _tostring=tostring + local tostring=function(a) + if type(a)=="string" then + return string.format("%q",a) + else + return _tostring(a) + end + end + + local log=function (name,old,new) + local t=debug.getinfo(3,"Sl") + local line=t.currentline + io.write(t.short_src) + if line>=0 then io.write(":",line) end + io.write(": ",name," is now ",tostring(new)," (was ",tostring(old),")","\n") + end + + local g={} + local set=function (t,name,value) + log(name,g[name],value) + g[name]=value + end + setmetatable(getfenv(),{__index=g,__newindex=set}) +end + +-- an example + +a=1 +b=2 +a=10 +b=20 +b=nil +b=200 +print(a,b,c) diff --git a/mk/linux/mojosetup/lua/test/xd.lua b/mk/linux/mojosetup/lua/test/xd.lua new file mode 100644 index 00000000..ebc3effc --- /dev/null +++ b/mk/linux/mojosetup/lua/test/xd.lua @@ -0,0 +1,14 @@ +-- hex dump +-- usage: lua xd.lua < file + +local offset=0 +while true do + local s=io.read(16) + if s==nil then return end + io.write(string.format("%08X ",offset)) + string.gsub(s,"(.)", + function (c) io.write(string.format("%02X ",string.byte(c))) end) + io.write(string.rep(" ",3*(16-string.len(s)))) + io.write(" ",string.gsub(s,"%c","."),"\n") + offset=offset+16 +end diff --git a/mk/linux/mojosetup/lua_glue.c b/mk/linux/mojosetup/lua_glue.c new file mode 100644 index 00000000..14adb8d3 --- /dev/null +++ b/mk/linux/mojosetup/lua_glue.c @@ -0,0 +1,1926 @@ +/** + * MojoSetup; a portable, flexible installation application. + * + * Please see the file LICENSE.txt in the source's root directory. + * + * This file written by Ryan C. Gordon. + */ + +#include "universal.h" +#include "lua_glue.h" +#include "platform.h" +#include "fileio.h" +#include "lua.h" +#include "lauxlib.h" +#include "lualib.h" +#include "gui.h" + +#define MOJOSETUP_NAMESPACE "MojoSetup" + +static lua_State *luaState = NULL; + +// Allocator interface for internal Lua use. +static void *MojoLua_alloc(void *ud, void *ptr, size_t osize, size_t nsize) +{ + if (nsize == 0) + { + free(ptr); + return NULL; + } // if + return xrealloc(ptr, nsize); +} // MojoLua_alloc + + +// Read data from a MojoInput when loading Lua code. +static const char *MojoLua_reader(lua_State *L, void *data, size_t *size) +{ + MojoInput *in = (MojoInput *) data; + char *retval = (char *) scratchbuf_128k; + int64 br = in->read(in, scratchbuf_128k, sizeof (scratchbuf_128k)); + if (br <= 0) // eof or error? (lua doesn't care which?!) + { + br = 0; + retval = NULL; + } // if + + *size = (size_t) br; + return retval; +} // MojoLua_reader + + +// Sets t[sym]=f, where t is on the top of the Lua stack. +// !!! FIXME: why is this a different naming convention? +static inline void set_cfunc(lua_State *L, lua_CFunction f, const char *sym) +{ + lua_pushcfunction(L, f); + lua_setfield(L, -2, sym); +} // set_cfunc + + +// Sets t[sym]=f, where t is on the top of the Lua stack. +// !!! FIXME: why is this a different naming convention? +static inline void set_cptr(lua_State *L, void *ptr, const char *sym) +{ + lua_pushlightuserdata(L, ptr); + lua_setfield(L, -2, sym); +} // set_cptr + + +// Sets t[sym]=f, where t is on the top of the Lua stack. +// !!! FIXME: why is this a different naming convention? +static inline void set_string(lua_State *L, const char *str, const char *sym) +{ + if (str == NULL) + lua_pushnil(L); + else + lua_pushstring(L, str); + lua_setfield(L, -2, sym); +} // set_string + + +// Sets t[sym]=f, where t is on the top of the Lua stack. +// !!! FIXME: why is this a different naming convention? +static inline void set_number(lua_State *L, lua_Number x, const char *sym) +{ + lua_pushnumber(L, x); + lua_setfield(L, -2, sym); +} // set_number + + +// Sets t[sym]=f, where t is on the top of the Lua stack. +// !!! FIXME: why is this a different naming convention? +static inline void set_integer(lua_State *L, lua_Integer x, const char *sym) +{ + lua_pushinteger(L, x); + lua_setfield(L, -2, sym); +} // set_integer + + +// Sets t[sym]=f, where t is on the top of the Lua stack. +// !!! FIXME: why is this a different naming convention? +static inline void set_boolean(lua_State *L, boolean x, const char *sym) +{ + lua_pushboolean(L, x); + lua_setfield(L, -2, sym); +} // set_boolean + + +// !!! FIXME: why is this a different naming convention? +static inline void set_string_array(lua_State *L, int argc, const char **argv, + const char *sym) +{ + int i; + lua_newtable(L); + for (i = 0; i < argc; i++) + { + lua_pushinteger(L, i+1); // lua is option base 1! + lua_pushstring(L, argv[i]); + lua_settable(L, -3); + } // for + lua_setfield(L, -2, sym); +} // set_string_array + + +void MojoLua_setString(const char *str, const char *sym) +{ + lua_getglobal(luaState, MOJOSETUP_NAMESPACE); + set_string(luaState, str, sym); + lua_pop(luaState, 1); +} // MojoLua_setString + + +void MojoLua_setStringArray(int argc, const char **argv, const char *sym) +{ + lua_getglobal(luaState, MOJOSETUP_NAMESPACE); + set_string_array(luaState, argc, argv, sym); + lua_pop(luaState, 1); +} // MojoLua_setStringArray + + +static inline int retvalString(lua_State *L, const char *str) +{ + if (str != NULL) + lua_pushstring(L, str); + else + lua_pushnil(L); + return 1; +} // retvalString + + +static inline int retvalBoolean(lua_State *L, boolean b) +{ + lua_pushboolean(L, b); + return 1; +} // retvalBoolean + + +static inline int retvalNumber(lua_State *L, lua_Number n) +{ + lua_pushnumber(L, n); + return 1; +} // retvalNumber + + +static inline int retvalLightUserData(lua_State *L, void *data) +{ + if (data != NULL) + lua_pushlightuserdata(L, data); + else + lua_pushnil(L); + return 1; +} // retvalLightUserData + + +static int retvalChecksums(lua_State *L, const MojoChecksums *sums) +{ + lua_newtable(L); + + #if SUPPORT_CRC32 + { + char buf[64]; + snprintf(buf, sizeof (buf), "%X", (unsigned int) sums->crc32); + set_string(L, buf, "crc32"); + } + #endif + + #if SUPPORT_MD5 + { + char buf[64]; + const uint8 *dig = sums->md5; + snprintf(buf, sizeof (buf), "%X%X%X%X%X%X%X%X%X%X%X%X%X%X%X%X", + (int) dig[0], (int) dig[1], (int) dig[2], (int) dig[3], + (int) dig[4], (int) dig[5], (int) dig[6], (int) dig[7], + (int) dig[8], (int) dig[9], (int) dig[10], (int) dig[11], + (int) dig[12], (int) dig[13], (int) dig[14], (int) dig[15]); + set_string(L, buf, "md5"); + } + #endif + + #if SUPPORT_SHA1 + { + char buf[64]; + const uint8 *dig = sums->sha1; + snprintf(buf, sizeof (buf), "%X%X%X%X%X%X%X%X%X%X%X%X%X%X%X%X%X%X%X%X", + (int) dig[0], (int) dig[1], (int) dig[2], (int) dig[3], + (int) dig[4], (int) dig[5], (int) dig[6], (int) dig[7], + (int) dig[8], (int) dig[9], (int) dig[10], (int) dig[11], + (int) dig[12], (int) dig[13], (int) dig[14], (int) dig[15], + (int) dig[16], (int) dig[17], (int) dig[18], (int) dig[19]); + set_string(L, buf, "sha1"); + } + #endif + + return 1; +} // retvalChecksums + + +static inline int snprintfcat(char **ptr, size_t *len, const char *fmt, ...) +{ + int bw = 0; + va_list ap; + va_start(ap, fmt); + bw = vsnprintf(*ptr, *len, fmt, ap); + va_end(ap); + *ptr += bw; + *len -= bw; + return bw; +} // snprintfcat + + +static int luahook_stackwalk(lua_State *L) +{ + const char *errstr = lua_tostring(L, 1); + lua_Debug ldbg; + int i = 0; + + if (errstr != NULL) + logDebug("%0", errstr); + + logDebug("Lua stack backtrace:"); + + // start at 1 to skip this function. + for (i = 1; lua_getstack(L, i, &ldbg); i++) + { + char *ptr = (char *) scratchbuf_128k; + size_t len = sizeof (scratchbuf_128k); + int bw = snprintfcat(&ptr, &len, "#%d", i-1); + const int maxspacing = 4; + int spacing = maxspacing - bw; + while (spacing-- > 0) + snprintfcat(&ptr, &len, " "); + + if (!lua_getinfo(L, "nSl", &ldbg)) + { + snprintfcat(&ptr, &len, "???\n"); + logDebug("%0", (const char *) scratchbuf_128k); + continue; + } // if + + if (ldbg.namewhat[0]) + snprintfcat(&ptr, &len, "%s ", ldbg.namewhat); + + if ((ldbg.name) && (ldbg.name[0])) + snprintfcat(&ptr, &len, "function %s ()", ldbg.name); + else + { + if (strcmp(ldbg.what, "main") == 0) + snprintfcat(&ptr, &len, "mainline of chunk"); + else if (strcmp(ldbg.what, "tail") == 0) + snprintfcat(&ptr, &len, "tail call"); + else + snprintfcat(&ptr, &len, "unidentifiable function"); + } // if + + logDebug("%0", (const char *) scratchbuf_128k); + ptr = (char *) scratchbuf_128k; + len = sizeof (scratchbuf_128k); + + for (spacing = 0; spacing < maxspacing; spacing++) + snprintfcat(&ptr, &len, " "); + + if (strcmp(ldbg.what, "C") == 0) + snprintfcat(&ptr, &len, "in native code"); + else if (strcmp(ldbg.what, "tail") == 0) + snprintfcat(&ptr, &len, "in Lua code"); + else if ( (strcmp(ldbg.source, "=?") == 0) && (ldbg.currentline == 0) ) + snprintfcat(&ptr, &len, "in Lua code (debug info stripped)"); + else + { + snprintfcat(&ptr, &len, "in Lua code at %s", ldbg.short_src); + if (ldbg.currentline != -1) + snprintfcat(&ptr, &len, ":%d", ldbg.currentline); + } // else + logDebug("%0", (const char *) scratchbuf_128k); + } // for + + return retvalString(L, errstr ? errstr : ""); +} // luahook_stackwalk + + +// This just lets you punch in one-liners and Lua will run them as individual +// chunks, but you can completely access all Lua state, including calling C +// functions and altering tables. At this time, it's more of a "console" +// than a debugger. You can do "p MojoLua_debugger()" from gdb to launch this +// from a breakpoint in native code, or call MojoSetup.debugger() to launch +// it from Lua code (with stacktrace intact, too: type 'bt' to see it). +static int luahook_debugger(lua_State *L) +{ +#if DISABLE_LUA_PARSER + logError("Lua debugger is disabled in this build (no parser)."); +#else + int origtop; + const MojoSetupLogLevel origloglevel = MojoLog_logLevel; + + lua_pushcfunction(luaState, luahook_stackwalk); + origtop = lua_gettop(L); + + printf("Quick and dirty Lua debugger. Type 'exit' to quit.\n"); + + while (true) + { + char *buf = (char *) scratchbuf_128k; + int len = 0; + printf("> "); + fflush(stdout); + if (fgets(buf, sizeof (scratchbuf_128k), stdin) == NULL) + { + printf("\n\n fgets() on stdin failed: "); + break; + } // if + + len = (int) (strlen(buf) - 1); + while ( (len >= 0) && ((buf[len] == '\n') || (buf[len] == '\r')) ) + buf[len--] = '\0'; + + if (strcmp(buf, "q") == 0) + break; + else if (strcmp(buf, "quit") == 0) + break; + else if (strcmp(buf, "exit") == 0) + break; + else if (strcmp(buf, "bt") == 0) + { + MojoLog_logLevel = MOJOSETUP_LOG_EVERYTHING; + strcpy(buf, "MojoSetup.stackwalk()"); + } // else if + + if ( (luaL_loadstring(L, buf) != 0) || + (lua_pcall(luaState, 0, LUA_MULTRET, -2) != 0) ) + { + printf("%s\n", lua_tostring(L, -1)); + lua_pop(L, 1); + } // if + else + { + printf("Returned %d values.\n", lua_gettop(L) - origtop); + while (lua_gettop(L) != origtop) + { + // !!! FIXME: dump details of values to stdout here. + lua_pop(L, 1); + } // while + printf("\n"); + } // else + + MojoLog_logLevel = origloglevel; + } // while + + lua_pop(L, 1); + printf("exiting debugger...\n"); +#endif + + return 0; +} // luahook_debugger + + +void MojoLua_debugger(void) +{ + luahook_debugger(luaState); +} // MojoLua_debugger + + +boolean MojoLua_callProcedure(const char *funcname) +{ + boolean called = false; + lua_State *L = luaState; + int popcount = 0; + + if (L != NULL) + { + lua_getglobal(L, MOJOSETUP_NAMESPACE); popcount++; + if (lua_istable(L, -1)) // namespace is sane? + { + lua_getfield(L, -1, funcname); popcount++; + if (lua_isfunction(L, -1)) + { + lua_call(L, 0, 0); + called = true; + } // if + } // if + lua_pop(L, popcount); + } // if + + return called; +} // MojoLua_callProcedure + + +boolean MojoLua_runFileFromDir(const char *dir, const char *name) +{ + MojoArchive *ar = GBaseArchive; // in case we want to generalize later. + const MojoArchiveEntry *entinfo = NULL; + boolean retval = false; + char *clua = format("%0/%1.luac", dir, name); // compiled filename. + char *ulua = format("%0/%1.lua", dir, name); // uncompiled filename. + int rc = 0; + MojoInput *io = NULL; + + if (ar->enumerate(ar)) + { + while ((io == NULL) && ((entinfo = ar->enumNext(ar)) != NULL)) + { + boolean match = false; + + if (entinfo->type != MOJOARCHIVE_ENTRY_FILE) + continue; + + match = (strcmp(entinfo->filename, clua) == 0); + #if !DISABLE_LUA_PARSER + if (!match) + match = (strcmp(entinfo->filename, ulua) == 0); + #endif + + if (match) + io = ar->openCurrentEntry(ar); + } // while + } // if + + free(ulua); + free(clua); + + if (io != NULL) + { + char *realfname = (char *) xmalloc(strlen(entinfo->filename) + 2); + sprintf(realfname, "@%s", entinfo->filename); + lua_pushcfunction(luaState, luahook_stackwalk); + rc = lua_load(luaState, MojoLua_reader, io, realfname); + free(realfname); + io->close(io); + + if (rc != 0) + lua_error(luaState); + else + { + // Call new chunk on top of the stack (lua_pcall will pop it off). + if (lua_pcall(luaState, 0, 0, -2) != 0) // retvals are dumped. + lua_error(luaState); // error on stack has debug info. + else + retval = true; // if this didn't panic, we succeeded. + } // if + lua_pop(luaState, 1); // dump stackwalker. + } // if + + return retval; +} // MojoLua_runFileFromDir + + +boolean MojoLua_runFile(const char *name) +{ + return MojoLua_runFileFromDir("scripts", name); +} // MojoLua_runFile + + +void MojoLua_collectGarbage(void) +{ + lua_State *L = luaState; + uint32 ticks = 0; + int pre = 0; + int post = 0; + + lua_getglobal(L, MOJOSETUP_NAMESPACE); + if (lua_istable(L, -1)) // namespace is sane? + set_integer(L, 0, "garbagecounter"); + lua_pop(L, 1); + + pre = (lua_gc(L, LUA_GCCOUNT, 0) * 1024) + lua_gc(L, LUA_GCCOUNTB, 0); + logDebug("Collecting garbage (currently using %0 bytes).", numstr(pre)); + ticks = MojoPlatform_ticks(); + lua_gc (L, LUA_GCCOLLECT, 0); + profile("Garbage collection", ticks); + post = (lua_gc(L, LUA_GCCOUNT, 0) * 1024) + lua_gc(L, LUA_GCCOUNTB, 0); + logDebug("Now using %0 bytes (%1 bytes savings).", + numstr(post), numstr(pre - post)); +} // MojoLua_collectGarbage + + +// You can trigger the garbage collector with more control in the standard +// Lua runtime, but this notes profiling and statistics via logDebug(), +// and resets MojoSetup.garbagecounter to zero. +static int luahook_collectgarbage(lua_State *L) +{ + MojoLua_collectGarbage(); + return 0; +} // luahook_collectgarbage + + +// Since localization is kept in Lua tables, I stuck this in the Lua glue. +const char *translate(const char *str) +{ + const char *retval = str; + + if (luaState != NULL) // No translations before Lua is initialized. + { + if (lua_checkstack(luaState, 3)) + { + int popcount = 0; + lua_getglobal(luaState, MOJOSETUP_NAMESPACE); popcount++; + if (lua_istable(luaState, -1)) // namespace is sane? + { + lua_getfield(luaState, -1, "translations"); popcount++; + if (lua_istable(luaState, -1)) // translation table is sane? + { + const char *tr = NULL; + lua_getfield(luaState, -1, str); popcount++; + tr = lua_tostring(luaState, -1); + if (tr != NULL) // translated for this locale? + { + char *dst = (char *) scratchbuf_128k; + xstrncpy(dst, tr, sizeof(scratchbuf_128k)); + retval = dst; + } // if + } // if + } // if + lua_pop(luaState, popcount); // remove our stack salsa. + } // if + } // if + + return retval; +} // translate + + +// Lua interface to format(). +static int luahook_format(lua_State *L) +{ + const int argc = lua_gettop(L); + const char *fmt = luaL_checkstring(L, 1); + char *formatted = NULL; + char *s[10]; + int i; + + assert(argc <= 11); // fmt, plus %0 through %9. + + for (i = 0; i < STATICARRAYLEN(s); i++) + { + const char *str = NULL; + if ((i+2) <= argc) + str = lua_tostring(L, i+2); + s[i] = (str == NULL) ? NULL : xstrdup(str); + } // for + + // I think this is legal (but probably not moral) C code. + formatted = format(fmt,s[0],s[1],s[2],s[3],s[4],s[5],s[6],s[7],s[8],s[9]); + + for (i = 0; i < STATICARRAYLEN(s); i++) + free(s[i]); + + lua_pushstring(L, formatted); + free(formatted); + return 1; +} // luahook_format + + +// Use this instead of Lua's error() function if you don't have a +// programatic error, so you don't get stack callback stuff: +// MojoSetup.fatal("You need the base game to install this expansion pack.") +// This will also handle cleanup of half-written installations. +// Doesn't actually return. +static int luahook_fatal(lua_State *L) +{ + const char *errstr = lua_tostring(L, 1); + if (errstr == NULL) + return fatal(NULL); // doesn't actually return. + return fatal("%0", errstr); // doesn't actually return. +} // luahook_fatal + + +// Lua interface to MojoLua_runFile(). This is needed instead of Lua's +// require(), since it can access scripts inside an archive. +static int luahook_runfile(lua_State *L) +{ + const char *fname = luaL_checkstring(L, 1); + return retvalBoolean(L, MojoLua_runFile(fname)); +} // luahook_runfile + + +// Lua interface to MojoLua_runFileFromDir(). This is needed instead of Lua's +// require(), since it can access scripts inside an archive. +static int luahook_runfilefromdir(lua_State *L) +{ + const char *dir = luaL_checkstring(L, 1); + const char *fname = luaL_checkstring(L, 2); + return retvalBoolean(L, MojoLua_runFileFromDir(dir, fname)); +} // luahook_runfile + + +// Lua interface to translate(). +static int luahook_translate(lua_State *L) +{ + const char *str = luaL_checkstring(L, 1); + return retvalString(L, translate(str)); +} // luahook_translate + + +static int luahook_ticks(lua_State *L) +{ + return retvalNumber(L, MojoPlatform_ticks()); +} // luahook_ticks + + +static int luahook_launchbrowser(lua_State *L) +{ + const char *url = luaL_checkstring(L, 1); + return retvalBoolean(L, MojoPlatform_launchBrowser(url)); +} // luahook_launchbrowser + + +static int luahook_verifyproductkey(lua_State *L) +{ + boolean retval = false; + + // ATTENTION: you can use this function to do your CD key verification + // in C code. Just remove the #if 0, and then process the ASCII string + // in (key), setting (retval) to (true) if the key is valid, and (false) + // if it isn't. Then when filling in a Setup.ProductKey in your + // config.lua, set (verify) to "MojoSetup.verifyproductkey". + #if 0 + const char *key = luaL_checkstring(L, 1); + #endif + + return retvalBoolean(L, retval); +} // luahook_verifyproductkey + + +static int luahook_msgbox(lua_State *L) +{ + if (GGui != NULL) + { + const char *title = luaL_checkstring(L, 1); + const char *text = luaL_checkstring(L, 2); + GGui->msgbox(title, text); + } // if + return 0; +} // luahook_msgbox + + +static int luahook_promptyn(lua_State *L) +{ + boolean rc = false; + if (GGui != NULL) + { + const char *title = luaL_checkstring(L, 1); + const char *text = luaL_checkstring(L, 2); + const boolean defval = lua_toboolean(L, 3); + rc = GGui->promptyn(title, text, defval); + } // if + + return retvalBoolean(L, rc); +} // luahook_promptyn + + +static int luahook_promptynan(lua_State *L) +{ + MojoGuiYNAN rc = MOJOGUI_NO; + if (GGui != NULL) + { + const char *title = luaL_checkstring(L, 1); + const char *text = luaL_checkstring(L, 2); + const boolean defval = lua_toboolean(L, 3); + rc = GGui->promptynan(title, text, defval); + } // if + + // Never localize these strings! + switch (rc) + { + case MOJOGUI_YES: return retvalString(L, "yes"); + case MOJOGUI_NO: return retvalString(L, "no"); + case MOJOGUI_ALWAYS: return retvalString(L, "always"); + case MOJOGUI_NEVER: return retvalString(L, "never"); + } // switch + + assert(false && "BUG: unhandled case in switch statement"); + return 0; // shouldn't hit this. +} // luahook_promptynan + + +static int luahook_logwarning(lua_State *L) +{ + logWarning("%0", luaL_checkstring(L, 1)); + return 0; +} // luahook_logwarning + + +static int luahook_logerror(lua_State *L) +{ + logError("%0", luaL_checkstring(L, 1)); + return 0; +} // luahook_logerror + + +static int luahook_loginfo(lua_State *L) +{ + logInfo("%0", luaL_checkstring(L, 1)); + return 0; +} // luahook_loginfo + + +static int luahook_logdebug(lua_State *L) +{ + logDebug("%0", luaL_checkstring(L, 1)); + return 0; +} // luahook_logdebug + + +static int luahook_cmdline(lua_State *L) +{ + const char *arg = luaL_checkstring(L, 1); + return retvalBoolean(L, cmdline(arg)); +} // luahook_cmdline + + +static int luahook_cmdlinestr(lua_State *L) +{ + const int argc = lua_gettop(L); + const char *arg = luaL_checkstring(L, 1); + const char *envr = (argc < 2) ? NULL : lua_tostring(L, 2); // may be nil + const char *deflt = (argc < 3) ? NULL : lua_tostring(L, 3); // may be nil + return retvalString(L, cmdlinestr(arg, envr, deflt)); +} // luahook_cmdlinestr + + +static int luahook_truncatenum(lua_State *L) +{ + const lua_Number dbl = lua_tonumber(L, 1); + return retvalNumber(L, (lua_Number) ((int64) dbl)); +} // luahook_truncatenum + + +static int luahook_wildcardmatch(lua_State *L) +{ + const char *str = luaL_checkstring(L, 1); + const char *pattern = luaL_checkstring(L, 2); + return retvalBoolean(L, wildcardMatch(str, pattern)); +} // luahook_wildcardmatch + + +// Do a regular C strcmp(), don't let the locale get in the way like it does +// in Lua's string comparison operators (which uses strcoll()). +static int luahook_strcmp(lua_State *L) +{ + const char *a = luaL_checkstring(L, 1); + const char *b = luaL_checkstring(L, 2); + return retvalNumber(L, strcmp(a, b)); +} // luahook_strcmp + + +static int luahook_findmedia(lua_State *L) +{ + // Let user specify overrides of directories to act as drives. + // This is good if for some reason MojoSetup can't find them, or they + // want to pretend a copy on the filesystem is really a CD, etc. + // Put your anti-piracy crap in your OWN program. :) + // + // You can specify with command lines or environment variables, command + // lines taking precedence: + // MOJOSETUP_MEDIA0=/my/patch ./installer --media1=/over/there + // + // --media and MOJOSETUP_MEDIA are checked first, then --media0 and + // MOJOSETUP_MEDIA0, etc until you find the media or run out of + // overrides. + // + // After the overrides, we ask the platform layer to find the media. + + const char *unique = luaL_checkstring(L, 1); + const char *override = cmdlinestr("media", "MOJOSETUP_MEDIA", NULL); + char *physical = NULL; + char cmdbuf[64]; + char envrbuf[64]; + int i = 0; + + do + { + if ( (override) && (MojoPlatform_exists(override, unique)) ) + return retvalString(L, override); + + snprintf(cmdbuf, sizeof (cmdbuf), "media%d", i); + snprintf(envrbuf, sizeof (envrbuf), "MOJOSETUP_MEDIA%d", i); + } while ((override = cmdlinestr(cmdbuf, envrbuf, NULL)) != NULL); + + // No override. Try platform layer for real media... + physical = MojoPlatform_findMedia(unique); + retvalString(L, physical); // may push nil. + free(physical); + return 1; +} // luahook_findmedia + + +static boolean writeCallback(uint32 ticks, int64 justwrote, int64 bw, + int64 total, void *data) +{ + boolean retval = false; + lua_State *L = (lua_State *) data; + // Lua callback is on top of stack... + if (lua_isnil(L, -1)) + retval = true; + else + { + lua_pushvalue(L, -1); + lua_pushnumber(L, (lua_Number) ticks); + lua_pushnumber(L, (lua_Number) justwrote); + lua_pushnumber(L, (lua_Number) bw); + lua_pushnumber(L, (lua_Number) total); + lua_call(L, 4, 1); + retval = lua_toboolean(L, -1); + lua_pop(L, 1); + } // if + return retval; +} // writeCallback + + +// !!! FIXME: push this into Lua, make things fatal. +static int do_writefile(lua_State *L, MojoInput *in, uint16 perms) +{ + const char *path = luaL_checkstring(L, 2); + int retval = 0; + boolean rc = false; + MojoChecksums sums; + int64 maxbytes = -1; + + if (in != NULL) + { + if (!lua_isnil(L, 3)) + { + boolean valid = false; + const char *permstr = luaL_checkstring(L, 3); + perms = MojoPlatform_makePermissions(permstr, &valid); + if (!valid) + fatal(_("BUG: '%0' is not a valid permission string"), permstr); + } // if + + if (!lua_isnil(L, 4)) + maxbytes = luaL_checkinteger(L, 4); + + rc = MojoInput_toPhysicalFile(in, path, perms, &sums, maxbytes, + writeCallback, L); + } // if + + retval += retvalBoolean(L, rc); + if (rc) + retval += retvalChecksums(L, &sums); + return retval; +} // do_writefile + + +static int luahook_writefile(lua_State *L) +{ + MojoArchive *archive = (MojoArchive *) lua_touserdata(L, 1); + uint16 perms = archive->prevEnum.perms; + MojoInput *in = archive->openCurrentEntry(archive); + return do_writefile(L, in, perms); +} // luahook_writefile + + +static int luahook_download(lua_State *L) +{ + const char *src = luaL_checkstring(L, 1); + MojoInput *in = MojoInput_newFromURL(src); + return do_writefile(L, in, MojoPlatform_defaultFilePerms()); +} // luahook_download + + +static int luahook_copyfile(lua_State *L) +{ + const char *src = luaL_checkstring(L, 1); + MojoInput *in = MojoInput_newFromFile(src); + return do_writefile(L, in, MojoPlatform_defaultFilePerms()); +} // luahook_copyfile + + +static int luahook_stringtofile(lua_State *L) +{ + const char *str = luaL_checkstring(L, 1); + MojoInput *in = NULL; + size_t len = 0; + str = lua_tolstring(L, 1, &len); + in = MojoInput_newFromMemory((const uint8 *) str, (uint32) len, 1); + assert(in != NULL); // xmalloc() would fatal(), should not return NULL. + return do_writefile(L, in, MojoPlatform_defaultFilePerms()); +} // luahook_stringtofile + + +static int luahook_isvalidperms(lua_State *L) +{ + boolean valid = false; + const char *permstr = NULL; + if (!lua_isnil(L, 1)) + permstr = luaL_checkstring(L, 1); + MojoPlatform_makePermissions(permstr, &valid); + return retvalBoolean(L, valid); +} // luahook_isvalidperms + + +static int do_checksum(lua_State *L, MojoInput *in) +{ + MojoChecksumContext ctx; + MojoChecksums sums; + int64 br = 0; + + MojoChecksum_init(&ctx); + + while (1) + { + br = in->read(in, scratchbuf_128k, sizeof (scratchbuf_128k)); + if (br <= 0) + break; + MojoChecksum_append(&ctx, scratchbuf_128k, (uint32) br); + } // while + + MojoChecksum_finish(&ctx, &sums); + + in->close(in); + + return (br < 0) ? 0 : retvalChecksums(L, &sums); +} // do_checksum + + +static int luahook_checksum(lua_State *L) +{ + const char *fname = luaL_checkstring(L, 1); + MojoInput *in = MojoInput_newFromFile(fname); + return do_checksum(L, in); +} // luahook_checksum + + +static int luahook_archive_fromdir(lua_State *L) +{ + const char *path = luaL_checkstring(L, 1); + return retvalLightUserData(L, MojoArchive_newFromDirectory(path)); +} // luahook_archive_fromdir + + +static int luahook_archive_fromfile(lua_State *L) +{ + const char *path = luaL_checkstring(L, 1); + MojoInput *io = MojoInput_newFromFile(path); + MojoArchive *archive = NULL; + if (io != NULL) + archive = MojoArchive_newFromInput(io, path); + return retvalLightUserData(L, archive); +} // luahook_archive_fromfile + + +static int luahook_archive_fromentry(lua_State *L) +{ + MojoArchive *ar = (MojoArchive *) lua_touserdata(L, 1); + MojoInput *io = ar->openCurrentEntry(ar); + MojoArchive *archive = NULL; + if (io != NULL) + archive = MojoArchive_newFromInput(io, ar->prevEnum.filename); + return retvalLightUserData(L, archive); +} // luahook_archive_fromentry + + +static int luahook_archive_enumerate(lua_State *L) +{ + MojoArchive *archive = (MojoArchive *) lua_touserdata(L, 1); + return retvalBoolean(L, archive->enumerate(archive)); +} // luahook_archive_enumerate + + +static int luahook_archive_enumnext(lua_State *L) +{ + MojoArchive *archive = (MojoArchive *) lua_touserdata(L, 1); + const MojoArchiveEntry *entinfo = archive->enumNext(archive); + if (entinfo == NULL) + lua_pushnil(L); + else + { + const char *typestr = NULL; + if (entinfo->type == MOJOARCHIVE_ENTRY_FILE) + typestr = "file"; + else if (entinfo->type == MOJOARCHIVE_ENTRY_DIR) + typestr = "dir"; + else if (entinfo->type == MOJOARCHIVE_ENTRY_SYMLINK) + typestr = "symlink"; + else + typestr = "unknown"; + + lua_newtable(L); + set_string(L, entinfo->filename, "filename"); + set_string(L, entinfo->linkdest, "linkdest"); + set_number(L, (lua_Number) entinfo->filesize, "filesize"); + set_string(L, typestr, "type"); + } // else + + return 1; +} // luahook_archive_enumnext + + +static int luahook_archive_close(lua_State *L) +{ + MojoArchive *archive = (MojoArchive *) lua_touserdata(L, 1); + archive->close(archive); + return 0; +} // luahook_archive_close + + +static int luahook_archive_offsetofstart(lua_State *L) +{ + MojoArchive *archive = (MojoArchive *) lua_touserdata(L, 1); + return retvalNumber(L, (lua_Number) archive->offsetOfStart); +} // luahook_archive_offsetofstart + + +static int luahook_platform_unlink(lua_State *L) +{ + const char *path = luaL_checkstring(L, 1); + return retvalBoolean(L, MojoPlatform_unlink(path)); +} // luahook_platform_unlink + + +static int luahook_platform_exists(lua_State *L) +{ + const char *dir = luaL_checkstring(L, 1); + const char *fname = lua_tostring(L, 2); // can be nil. + return retvalBoolean(L, MojoPlatform_exists(dir, fname)); +} // luahook_platform_exists + + +static int luahook_platform_writable(lua_State *L) +{ + const char *fname = luaL_checkstring(L, 1); + return retvalBoolean(L, MojoPlatform_writable(fname)); +} // luahook_platform_writable + + +static int luahook_platform_isdir(lua_State *L) +{ + const char *dir = luaL_checkstring(L, 1); + return retvalBoolean(L, MojoPlatform_isdir(dir)); +} // luahook_platform_isdir + + +static int luahook_platform_issymlink(lua_State *L) +{ + const char *fname = luaL_checkstring(L, 1); + return retvalBoolean(L, MojoPlatform_issymlink(fname)); +} // luahook_platform_issymlink + + +static int luahook_platform_isfile(lua_State *L) +{ + const char *fname = luaL_checkstring(L, 1); + return retvalBoolean(L, MojoPlatform_isfile(fname)); +} // luahook_platform_isfile + + +static int luahook_platform_symlink(lua_State *L) +{ + const char *src = luaL_checkstring(L, 1); + const char *dst = luaL_checkstring(L, 2); + return retvalBoolean(L, MojoPlatform_symlink(src, dst)); +} // luahook_platform_symlink + + +static int luahook_platform_mkdir(lua_State *L) +{ + const int argc = lua_gettop(L); + const char *dir = luaL_checkstring(L, 1); + uint16 perms = 0; + if ( (argc < 2) || (lua_isnil(L, 2)) ) + perms = MojoPlatform_defaultDirPerms(); + else + { + boolean valid = false; + const char *permstr = luaL_checkstring(L, 2); + perms = MojoPlatform_makePermissions(permstr, &valid); + if (!valid) + fatal(_("BUG: '%0' is not a valid permission string"), permstr); + } // if + return retvalBoolean(L, MojoPlatform_mkdir(dir, perms)); +} // luahook_platform_mkdir + + +static int luahook_platform_installdesktopmenuitem(lua_State *L) +{ + const char *data = luaL_checkstring(L, 1); + return retvalBoolean(L, MojoPlatform_installDesktopMenuItem(data)); +} // luahook_platform_installdesktopmenuitem + + +static int luahook_platform_uninstalldesktopmenuitem(lua_State *L) +{ + const char *data = luaL_checkstring(L, 1); + return retvalBoolean(L, MojoPlatform_uninstallDesktopMenuItem(data)); +} // luahook_platform_uninstalldesktopmenuitem + + +static int luahook_movefile(lua_State *L) +{ + boolean retval = false; + const char *src = luaL_checkstring(L, 1); + const char *dst = luaL_checkstring(L, 2); + retval = MojoPlatform_rename(src, dst); + if (!retval) + { + MojoInput *in = MojoInput_newFromFile(src); + if (in != NULL) + { + uint16 perms = 0; + MojoPlatform_perms(src, &perms); + retval = MojoInput_toPhysicalFile(in,dst,perms,NULL,-1,NULL,NULL); + if (retval) + { + retval = MojoPlatform_unlink(src); + if (!retval) + MojoPlatform_unlink(dst); // oh well. + } // if + } // if + } // if + + return retvalBoolean(L, retval); +} // luahook_movefile + + +static void prepareSplash(MojoGuiSplash *splash, const char *fname, + const char *splashpos) +{ + MojoInput *io = NULL; + int64 len = 0; + + memset(splash, '\0', sizeof (*splash)); + + if (fname == NULL) + return; + + io = MojoInput_newFromArchivePath(GBaseArchive, fname); + if (io == NULL) + return; + + len = io->length(io); + if ((len > 0) && (len < 0xFFFFFFFF)) + { + const uint32 size = (uint32) len; + uint8 *data = (uint8 *) xmalloc(size); + if (io->read(io, data, size) == len) + { + splash->rgba = decodeImage(data, size, &splash->w, &splash->h); + if (splash->rgba != NULL) + { + const uint32 w = splash->w; + const uint32 h = splash->h; + const MojoGuiSplashPos defpos = + ((w >= h) ? MOJOGUI_SPLASH_TOP : MOJOGUI_SPLASH_LEFT); + + if (splashpos == NULL) + splash->position = defpos; + else if ((splashpos == NULL) && (splash->w < splash->h)) + splash->position = MOJOGUI_SPLASH_LEFT; + else if (strcmp(splashpos, "top") == 0) + splash->position = MOJOGUI_SPLASH_TOP; + else if (strcmp(splashpos, "left") == 0) + splash->position = MOJOGUI_SPLASH_LEFT; + else if (strcmp(splashpos, "bottom") == 0) + splash->position = MOJOGUI_SPLASH_BOTTOM; + else if (strcmp(splashpos, "right") == 0) + splash->position = MOJOGUI_SPLASH_RIGHT; + else if (strcmp(splashpos, "background") == 0) + splash->position = MOJOGUI_SPLASH_BACKGROUND; + else + splash->position = defpos; // oh well. + } // if + } // if + free(data); + } // if + + io->close(io); +} // prepareSplash + + +static int luahook_gui_start(lua_State *L) +{ + const char *title = luaL_checkstring(L, 1); + const char *splashfname = lua_tostring(L, 2); + const char *splashpos = lua_tostring(L, 3); + boolean rc = false; + MojoGuiSplash splash; + + prepareSplash(&splash, splashfname, splashpos); + rc = GGui->start(title, &splash); + if (splash.rgba != NULL) + free((void *) splash.rgba); + + return retvalBoolean(L, rc); +} // luahook_gui_start + + +static const uint8 *loadFile(const char *fname, size_t *len) +{ + uint8 *retval = NULL; + MojoInput *io = MojoInput_newFromArchivePath(GBaseArchive, fname); + if (io != NULL) + { + int64 len64 = io->length(io); + *len = (size_t) len64; + if (*len == len64) + { + retval = (uint8 *) xmalloc(*len + 1); + if (io->read(io, retval, *len) == *len) + retval[*len] = '\0'; + else + { + free(retval); + retval = NULL; + } // else + } // if + io->close(io); + } // if + + return retval; +} // loadFile + +static inline boolean canGoBack(int thisstage) +{ + return (thisstage > 1); +} // canGoBack + +static inline boolean canGoForward(int thisstage, int maxstage) +{ + return (thisstage < maxstage); +} // canGoForward + + +static int luahook_gui_readme(lua_State *L) +{ + size_t len = 0; + const char *name = luaL_checkstring(L, 1); + const char *fname = luaL_checkstring(L, 2); + const int thisstage = luaL_checkinteger(L, 3); + const int maxstage = luaL_checkinteger(L, 4); + const uint8 *data = loadFile(fname, &len); + const boolean can_go_back = canGoBack(thisstage); + const boolean can_go_fwd = canGoForward(thisstage, maxstage); + + if (data == NULL) + fatal(_("failed to load file '%0'"), fname); + + lua_pushnumber(L, GGui->readme(name, data, len, can_go_back, can_go_fwd)); + free((void *) data); + return 1; +} // luahook_gui_readme + + +static int luahook_gui_stop(lua_State *L) +{ + GGui->stop(); + return 0; +} // luahook_gui_stop + + +// !!! FIXME: would like to push all this tree walking into Lua, and just +// !!! FIXME: build the final C tree without any validating here. +typedef MojoGuiSetupOptions GuiOptions; // a little less chatty. + +// forward declare this for recursive magic... +static GuiOptions *build_gui_options(lua_State *L, GuiOptions *parent); + +// An option table (from Setup.Option{} or Setup.OptionGroup{}) must be at +// the top of the Lua stack. +static GuiOptions *build_one_gui_option(lua_State *L, GuiOptions *opts, + boolean is_option_group) +{ + GuiOptions *newopt = NULL; + boolean required = false; + boolean skipopt = false; + + lua_getfield(L, -1, "required"); + if (lua_toboolean(L, -1)) + { + lua_pushboolean(L, true); + lua_setfield(L, -3, "value"); + required = skipopt = true; // don't pass to GUI. + } // if + lua_pop(L, 1); // remove "required" from stack. + + // "disabled=true" trumps "required=true" + lua_getfield(L, -1, "disabled"); + if (lua_toboolean(L, -1)) + { + if (required) + { + lua_getfield(L, -2, "description"); + logWarning("Option '%0' is both required and disabled!", + lua_tostring(L, -1)); + lua_pop(L, 1); + } // if + lua_pushboolean(L, false); + lua_setfield(L, -3, "value"); + skipopt = true; // don't pass to GUI. + } // if + lua_pop(L, 1); // remove "disabled" from stack. + + if (skipopt) // Skip this option, but look for children in required opts. + { + if (required) + newopt = build_gui_options(L, opts); + } // if + + else // add this option. + { + newopt = (GuiOptions *) xmalloc(sizeof (GuiOptions)); + newopt->is_group_parent = is_option_group; + newopt->value = true; + + lua_getfield(L, -1, "description"); + newopt->description = xstrdup(lua_tostring(L, -1)); + lua_pop(L, 1); + + lua_getfield(L, -1, "tooltip"); + if (!lua_isnil(L, -1)) + newopt->tooltip = xstrdup(lua_tostring(L, -1)); + lua_pop(L, 1); + + if (!is_option_group) + { + lua_getfield(L, -1, "value"); + newopt->value = (lua_toboolean(L, -1) ? true : false); + lua_pop(L, 1); + lua_getfield(L, -1, "bytes"); + newopt->size = (int64) lua_tonumber(L, -1); + lua_pop(L, 1); + newopt->opaque = ((int) lua_objlen(L, 4)) + 1; + lua_pushinteger(L, newopt->opaque); + lua_pushvalue(L, -2); + lua_settable(L, 4); // position #4 is our local lookup table. + } // if + + newopt->child = build_gui_options(L, newopt); // look for children... + if ((is_option_group) && (!newopt->child)) // skip empty groups. + { + free((void *) newopt->description); + free((void *) newopt->tooltip); + free(newopt); + newopt = NULL; + } // if + } // else + + if (newopt != NULL) + { + GuiOptions *prev = NULL; // find the end of the list... + GuiOptions *i = newopt; + do + { + prev = i; + i = i->next_sibling; + } while (i != NULL); + prev->next_sibling = opts; + opts = newopt; // prepend to list (we'll reverse it later...) + } // if + + return opts; +} // build_one_gui_option + + +static inline GuiOptions *cleanup_gui_option_list(GuiOptions *opts, + GuiOptions *parent) +{ + const boolean is_group = ((parent) && (parent->is_group_parent)); + GuiOptions *seen_enabled = NULL; + GuiOptions *prev = NULL; + GuiOptions *tmp = NULL; + + while (opts != NULL) + { + // !!! FIXME: schema should check? + if ((is_group) && (opts->is_group_parent)) + { + fatal("OptionGroup '%0' inside OptionGroup '%1'.", + opts->description, parent->description); + } // if + + if ((is_group) && (opts->value)) + { + if (seen_enabled) + { + logWarning("Options '%0' and '%1' are both enabled in group '%2'.", + seen_enabled->description, opts->description, + parent->description); + seen_enabled->value = false; + } // if + seen_enabled = opts; + } // if + + // Reverse the linked list, since we added these backwards before... + tmp = opts->next_sibling; + opts->next_sibling = prev; + prev = opts; + opts = tmp; + } // while + + if ((prev) && (is_group) && (!seen_enabled)) + { + logWarning("Option group '%0' has no enabled items, choosing first ('%1').", + parent->description, prev->description); + prev->value = true; + } // if + + return prev; +} // cleanup_gui_option_list + + +// the top of the stack must be the lua table with options/optiongroups. +// We build onto (opts) "child" field. +static GuiOptions *build_gui_options(lua_State *L, GuiOptions *parent) +{ + int i = 0; + GuiOptions *opts = NULL; + const struct { const char *fieldname; boolean is_group; } opttype[] = + { + { "options", false }, + { "optiongroups", true } + }; + + for (i = 0; i < STATICARRAYLEN(opttype); i++) + { + const boolean is_group = opttype[i].is_group; + lua_getfield(L, -1, opttype[i].fieldname); + if (!lua_isnil(L, -1)) + { + lua_pushnil(L); // first key for iteration... + while (lua_next(L, -2)) // replaces key, pushes value. + { + opts = build_one_gui_option(L, opts, is_group); + lua_pop(L, 1); // remove table, keep key for next iteration. + } // while + opts = cleanup_gui_option_list(opts, parent); + } // if + lua_pop(L, 1); // pop options/optiongroups table. + } // for + + return opts; +} // build_gui_options + + +// Free the tree of C structs we generated, and update the mirrored Lua tables +// with new values... +static void done_gui_options(lua_State *L, GuiOptions *opts) +{ + if (opts != NULL) + { + done_gui_options(L, opts->next_sibling); + done_gui_options(L, opts->child); + + if (opts->opaque) + { + // Update Lua table for this option... + lua_pushinteger(L, opts->opaque); + lua_gettable(L, 4); // #4 is our local table + lua_pushboolean(L, opts->value); + lua_setfield(L, -2, "value"); + lua_pop(L, 1); + } // if + + free((void *) opts->description); + free((void *) opts->tooltip); + free(opts); + } // if +} // done_gui_options + + +static int luahook_gui_options(lua_State *L) +{ + // The options table is arg #1 (hence the assert below). + const int thisstage = luaL_checkint(L, 2); + const int maxstage = luaL_checkint(L, 3); + const boolean can_go_back = canGoBack(thisstage); + const boolean can_go_fwd = canGoForward(thisstage, maxstage); + int rc = 1; + GuiOptions *opts = NULL; + + assert(lua_gettop(L) == 3); + + lua_newtable(L); // we'll use this for updating the tree later. + + // Now we need to build a tree of C structs from the hierarchical table + // we got from Lua... + lua_pushvalue(L, 1); // get the Lua table onto the top of the stack... + opts = build_gui_options(L, NULL); + lua_pop(L, 1); // pop the Lua table off the top of the stack... + + if (opts != NULL) // if nothing to do, we'll go directly to next stage. + rc = GGui->options(opts, can_go_back, can_go_fwd); + + done_gui_options(L, opts); // free C structs, update Lua tables... + lua_pop(L, 1); // pop table we created. + + return retvalNumber(L, rc); +} // luahook_gui_options + + +static int luahook_gui_destination(lua_State *L) +{ + const int thisstage = luaL_checkinteger(L, 2); + const int maxstage = luaL_checkinteger(L, 3); + const boolean can_go_back = canGoBack(thisstage); + const boolean can_go_fwd = canGoForward(thisstage, maxstage); + char **recommend = NULL; + size_t reccount = 0; + char *rc = NULL; + int command = 0; + size_t i = 0; + + if (lua_istable(L, 1)) + { + reccount = lua_objlen(L, 1); + recommend = (char **) xmalloc(reccount * sizeof (char *)); + for (i = 0; i < reccount; i++) + { + lua_pushinteger(L, i+1); + lua_gettable(L, 1); + recommend[i] = xstrdup(lua_tostring(L, -1)); + lua_pop(L, 1); + } // for + } // if + + rc = GGui->destination((const char **) recommend, reccount, + &command, can_go_back, can_go_fwd); + + if (recommend != NULL) + { + for (i = 0; i < reccount; i++) + free(recommend[i]); + free(recommend); + } // if + + retvalNumber(L, command); + retvalString(L, rc); // may push nil. + free(rc); + return 2; +} // luahook_gui_destination + + +// make sure spaces and dashes make it into the string. +// this counts on (buf) being correctly allocated! +static void sanitize_productkey(const char *fmt, char *buf) +{ + char fmtch; + + if (fmt == NULL) + return; + + while ((fmtch = *(fmt++)) != '\0') + { + const char bufch = *buf; + if ((fmtch == ' ') || (fmtch == '-')) + { + if ((bufch != ' ') && (bufch != '-')) + memmove(buf + 1, buf, strlen(buf) + 1); + *buf = fmtch; + } // else if + + if (bufch != '\0') + buf++; + } // while +} // sanitize_productkey + + +static int luahook_gui_productkey(lua_State *L) +{ + const char *desc = luaL_checkstring(L, 1); + const char *fmt = lua_tostring(L, 2); + const char *defval = lua_tostring(L, 3); + const int thisstage = luaL_checkinteger(L, 4); + const int maxstage = luaL_checkinteger(L, 5); + const boolean can_go_back = canGoBack(thisstage); + const boolean can_go_fwd = canGoForward(thisstage, maxstage); + const int fmtlen = fmt ? ((int) strlen(fmt) + 1) : 32; + char *buf = (char *) xmalloc(fmtlen); + int cmd = 0; + + assert((defval == NULL) || (((int)strlen(defval)) < fmtlen)); + strcpy(buf, (defval == NULL) ? "" : defval); + + cmd = GGui->productkey(desc, fmt, buf, fmtlen, can_go_back, can_go_fwd); + if (cmd == 1) + sanitize_productkey(fmt, buf); + else + { + free(buf); + buf = NULL; + } // else + lua_pushinteger(L, cmd); + lua_pushstring(L, buf); // may be NULL + free(buf); + return 2; +} // luahook_gui_productkey + + +static int luahook_gui_insertmedia(lua_State *L) +{ + const char *unique = luaL_checkstring(L, 1); + return retvalBoolean(L, GGui->insertmedia(unique)); +} // luahook_gui_insertmedia + + +static int luahook_gui_progressitem(lua_State *L) +{ + GGui->progressitem(); + return 0; +} // luahook_gui_progressitem + + +static int luahook_gui_progress(lua_State *L) +{ + const char *type = luaL_checkstring(L, 1); + const char *component = luaL_checkstring(L, 2); + const int percent = luaL_checkint(L, 3); + const char *item = luaL_checkstring(L, 4); + const boolean canstop = lua_toboolean(L, 5); + const boolean rc = GGui->progress(type, component, percent, item, canstop); + return retvalBoolean(L, rc); +} // luahook_gui_progress + + +static int luahook_gui_final(lua_State *L) +{ + const char *msg = luaL_checkstring(L, 1); + GGui->final(msg); + return 0; +} // luahook_gui_final + + +static const char *logLevelString(void) +{ + switch (MojoLog_logLevel) + { + case MOJOSETUP_LOG_NOTHING: return "nothing"; + case MOJOSETUP_LOG_ERRORS: return "errors"; + case MOJOSETUP_LOG_WARNINGS: return "warnings"; + case MOJOSETUP_LOG_INFO: return "info"; + case MOJOSETUP_LOG_DEBUG: return "debug"; + case MOJOSETUP_LOG_EVERYTHING: default: return "everything"; + } // switch +} // logLevelString + + +static void registerLuaLibs(lua_State *L) +{ + // We always need the string and base libraries (although base has a + // few we could trim). The rest you can compile in if you want/need them. + int i; + static const luaL_Reg lualibs[] = { + {"", luaopen_base}, + {LUA_STRLIBNAME, luaopen_string}, + {LUA_TABLIBNAME, luaopen_table}, + #if SUPPORT_LUALIB_PACKAGE + {LUA_LOADLIBNAME, luaopen_package}, + #endif + #if SUPPORT_LUALIB_IO + {LUA_IOLIBNAME, luaopen_io}, + #endif + #if SUPPORT_LUALIB_OS + {LUA_OSLIBNAME, luaopen_os}, + #endif + #if SUPPORT_LUALIB_MATH + {LUA_MATHLIBNAME, luaopen_math}, + #endif + #if SUPPORT_LUALIB_DB + {LUA_DBLIBNAME, luaopen_debug}, + #endif + }; + + for (i = 0; i < STATICARRAYLEN(lualibs); i++) + { + lua_pushcfunction(L, lualibs[i].func); + lua_pushstring(L, lualibs[i].name); + lua_call(L, 1, 0); + } // for +} // registerLuaLibs + + +// !!! FIXME: platform layer? +static int luahook_date(lua_State *L) +{ + const char *datefmt = "%c"; // workaround stupid gcc warning. + char buf[128]; + time_t t = time(NULL); + strftime(buf, sizeof (buf), datefmt, gmtime(&t)); + return retvalString(L, buf); +} // luahook_date + + +boolean MojoLua_initLua(void) +{ + const char *envr = cmdlinestr("locale", "MOJOSETUP_LOCALE", NULL); + char *homedir = MojoPlatform_homedir(); + char *binarypath = MojoPlatform_appBinaryPath(); + char *locale = (envr != NULL) ? xstrdup(envr) : MojoPlatform_locale(); + char *ostype = MojoPlatform_osType(); + char *osversion = MojoPlatform_osVersion(); + lua_Integer uid = (lua_Integer) MojoPlatform_getuid(); + lua_Integer euid = (lua_Integer) MojoPlatform_geteuid(); + lua_Integer gid = (lua_Integer) MojoPlatform_getgid(); + + #if DISABLE_LUA_PARSER + const boolean luaparser = false; + #else + const boolean luaparser = true; + #endif + + if (locale == NULL) locale = xstrdup("???"); + if (ostype == NULL) ostype = xstrdup("???"); + if (osversion == NULL) osversion = xstrdup("???"); + + assert(luaState == NULL); + luaState = lua_newstate(MojoLua_alloc, NULL); // calls fatal() on failure. + lua_atpanic(luaState, luahook_fatal); + assert(lua_checkstack(luaState, 20)); // Just in case. + registerLuaLibs(luaState); + + // !!! FIXME: I'd like to change the function name case for the lua hooks. + + // Build MojoSetup namespace for Lua to access and fill in C bridges... + lua_newtable(luaState); + // Set up initial C functions, etc we want to expose to Lua code... + set_cfunc(luaState, luahook_runfile, "runfile"); + set_cfunc(luaState, luahook_runfilefromdir, "runfilefromdir"); + set_cfunc(luaState, luahook_translate, "translate"); + set_cfunc(luaState, luahook_ticks, "ticks"); + set_cfunc(luaState, luahook_format, "format"); + set_cfunc(luaState, luahook_fatal, "fatal"); + set_cfunc(luaState, luahook_launchbrowser, "launchbrowser"); + set_cfunc(luaState, luahook_verifyproductkey, "verifyproductkey"); + set_cfunc(luaState, luahook_msgbox, "msgbox"); + set_cfunc(luaState, luahook_promptyn, "promptyn"); + set_cfunc(luaState, luahook_promptynan, "promptynan"); + set_cfunc(luaState, luahook_stackwalk, "stackwalk"); + set_cfunc(luaState, luahook_logwarning, "logwarning"); + set_cfunc(luaState, luahook_logerror, "logerror"); + set_cfunc(luaState, luahook_loginfo, "loginfo"); + set_cfunc(luaState, luahook_logdebug, "logdebug"); + set_cfunc(luaState, luahook_cmdline, "cmdline"); + set_cfunc(luaState, luahook_cmdlinestr, "cmdlinestr"); + set_cfunc(luaState, luahook_collectgarbage, "collectgarbage"); + set_cfunc(luaState, luahook_debugger, "debugger"); + set_cfunc(luaState, luahook_findmedia, "findmedia"); + set_cfunc(luaState, luahook_writefile, "writefile"); + set_cfunc(luaState, luahook_copyfile, "copyfile"); + set_cfunc(luaState, luahook_stringtofile, "stringtofile"); + set_cfunc(luaState, luahook_download, "download"); + set_cfunc(luaState, luahook_movefile, "movefile"); + set_cfunc(luaState, luahook_wildcardmatch, "wildcardmatch"); + set_cfunc(luaState, luahook_truncatenum, "truncatenum"); + set_cfunc(luaState, luahook_date, "date"); + set_cfunc(luaState, luahook_isvalidperms, "isvalidperms"); + set_cfunc(luaState, luahook_checksum, "checksum"); + set_cfunc(luaState, luahook_strcmp, "strcmp"); + + // Set some information strings... + lua_newtable(luaState); + set_string(luaState, locale, "locale"); + set_string(luaState, PLATFORM_NAME, "platform"); + set_string(luaState, PLATFORM_ARCH, "arch"); + set_string(luaState, ostype, "ostype"); + set_string(luaState, osversion, "osversion"); + set_string(luaState, GGui->name(), "ui"); + set_string(luaState, GBuildVer, "buildver"); + set_string(luaState, GMojoSetupLicense, "license"); + set_string(luaState, GLuaLicense, "lualicense"); + set_string(luaState, logLevelString(), "loglevel"); + set_string(luaState, homedir, "homedir"); + set_string(luaState, binarypath, "binarypath"); + set_string(luaState, GBaseArchivePath, "basearchivepath"); + set_boolean(luaState, luaparser, "luaparser"); + set_integer(luaState, uid, "uid"); + set_integer(luaState, euid, "euid"); + set_integer(luaState, gid, "gid"); + set_string_array(luaState, GArgc, GArgv, "argv"); + lua_newtable(luaState); + set_string(luaState, "base", "base"); + set_string(luaState, "media", "media"); + #if SUPPORT_URL_FTP + set_string(luaState, "ftp", "ftp"); + #endif + #if SUPPORT_URL_HTTP + set_string(luaState, "http", "http"); + #endif + #if SUPPORT_URL_HTTP + set_string(luaState, "https", "https"); + #endif + lua_setfield(luaState, -2, "supportedurls"); + lua_setfield(luaState, -2, "info"); + + // Set the platform functions... + lua_newtable(luaState); + set_cfunc(luaState, luahook_platform_unlink, "unlink"); + set_cfunc(luaState, luahook_platform_exists, "exists"); + set_cfunc(luaState, luahook_platform_writable, "writable"); + set_cfunc(luaState, luahook_platform_isdir, "isdir"); + set_cfunc(luaState, luahook_platform_issymlink, "issymlink"); + set_cfunc(luaState, luahook_platform_isfile, "isfile"); + set_cfunc(luaState, luahook_platform_symlink, "symlink"); + set_cfunc(luaState, luahook_platform_mkdir, "mkdir"); + set_cfunc(luaState, luahook_platform_installdesktopmenuitem, "installdesktopmenuitem"); + set_cfunc(luaState, luahook_platform_uninstalldesktopmenuitem, "uninstalldesktopmenuitem"); + lua_setfield(luaState, -2, "platform"); + + // Set the GUI functions... + lua_newtable(luaState); + set_cfunc(luaState, luahook_gui_start, "start"); + set_cfunc(luaState, luahook_gui_readme, "readme"); + set_cfunc(luaState, luahook_gui_options, "options"); + set_cfunc(luaState, luahook_gui_destination, "destination"); + set_cfunc(luaState, luahook_gui_productkey, "productkey"); + set_cfunc(luaState, luahook_gui_insertmedia, "insertmedia"); + set_cfunc(luaState, luahook_gui_progressitem, "progressitem"); + set_cfunc(luaState, luahook_gui_progress, "progress"); + set_cfunc(luaState, luahook_gui_final, "final"); + set_cfunc(luaState, luahook_gui_stop, "stop"); + lua_setfield(luaState, -2, "gui"); + + // Set the i/o functions... + lua_newtable(luaState); + set_cfunc(luaState, luahook_archive_fromdir, "fromdir"); + set_cfunc(luaState, luahook_archive_fromfile, "fromfile"); + set_cfunc(luaState, luahook_archive_fromentry, "fromentry"); + set_cfunc(luaState, luahook_archive_enumerate, "enumerate"); + set_cfunc(luaState, luahook_archive_enumnext, "enumnext"); + set_cfunc(luaState, luahook_archive_close, "close"); + set_cfunc(luaState, luahook_archive_offsetofstart, "offsetofstart"); + set_cptr(luaState, GBaseArchive, "base"); + lua_setfield(luaState, -2, "archive"); + lua_setglobal(luaState, MOJOSETUP_NAMESPACE); + + free(osversion); + free(ostype); + free(locale); + free(binarypath); + free(homedir); + + // Transfer control to Lua to setup some APIs and state... + if (!MojoLua_runFile("mojosetup_init")) + return false; + + MojoLua_collectGarbage(); // get rid of old init crap we don't need. + + return true; +} // MojoLua_initLua + + +boolean MojoLua_initialized(void) +{ + return (luaState != NULL); +} // MojoLua_initialized + + +void MojoLua_deinitLua(void) +{ + if (luaState != NULL) + { + lua_close(luaState); + luaState = NULL; + } // if +} // MojoLua_deinitLua + + + +const char *GMojoSetupLicense = +"Copyright (c) 2007 Ryan C. Gordon and others.\n" +"\n" +"This software is provided 'as-is', without any express or implied warranty.\n" +"In no event will the authors be held liable for any damages arising from\n" +"the use of this software.\n" +"\n" +"Permission is granted to anyone to use this software for any purpose,\n" +"including commercial applications, and to alter it and redistribute it\n" +"freely, subject to the following restrictions:\n" +"\n" +"1. The origin of this software must not be misrepresented; you must not\n" +"claim that you wrote the original software. If you use this software in a\n" +"product, an acknowledgment in the product documentation would be\n" +"appreciated but is not required.\n" +"\n" +"2. Altered source versions must be plainly marked as such, and must not be\n" +"misrepresented as being the original software.\n" +"\n" +"3. This notice may not be removed or altered from any source distribution.\n" +"\n" +" Ryan C. Gordon \n" +"\n"; + + +const char *GLuaLicense = +"Lua:\n" +"\n" +"Copyright (C) 1994-2008 Lua.org, PUC-Rio.\n" +"\n" +"Permission is hereby granted, free of charge, to any person obtaining a copy\n" +"of this software and associated documentation files (the \"Software\"), to deal\n" +"in the Software without restriction, including without limitation the rights\n" +"to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n" +"copies of the Software, and to permit persons to whom the Software is\n" +"furnished to do so, subject to the following conditions:\n" +"\n" +"The above copyright notice and this permission notice shall be included in\n" +"all copies or substantial portions of the Software.\n" +"\n" +"THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n" +"IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n" +"FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n" +"AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n" +"LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n" +"OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n" +"THE SOFTWARE.\n" +"\n"; + +// !!! FIXME: need BSD and MIT licenses...put all the licenses in one string. + +// end of lua_glue.c ... + diff --git a/mk/linux/mojosetup/lua_glue.h b/mk/linux/mojosetup/lua_glue.h new file mode 100644 index 00000000..14465aba --- /dev/null +++ b/mk/linux/mojosetup/lua_glue.h @@ -0,0 +1,69 @@ +/** + * MojoSetup; a portable, flexible installation application. + * + * Please see the file LICENSE.txt in the source's root directory. + * + * This file written by Ryan C. Gordon. + */ + +#ifndef _INCL_LUA_GLUE_H_ +#define _INCL_LUA_GLUE_H_ + +#include "universal.h" + +#ifdef __cplusplus +extern "C" { +#endif + +// License text for MojoSetup. +extern const char *GMojoSetupLicense; + +// License text for Lua. +extern const char *GLuaLicense; + + +boolean MojoLua_initLua(void); +void MojoLua_deinitLua(void); +boolean MojoLua_initialized(void); + +// Run the code in a given Lua file. This is JUST the base filename. +// We will look for it in GBaseArchive in the (dir) directory, both as +// fname.luac and fname.lua. This code chunk will accept no arguments, and +// return no results, but it can change the global state and alter tables, +// etc, so it can have lasting side effects. +// Will return false if the file couldn't be loaded, or true if the chunk +// successfully ran. Will not return if there's a runtime error in the +// chunk, as it will call fatal() instead. +boolean MojoLua_runFileFromDir(const char *dir, const char *name); + +// This is shorthand for MojoLua_runFileFromDir("scripts", fname); +boolean MojoLua_runFile(const char *fname); + +// Call a function in Lua. This calls MojoSetup.funcname, if it exists and +// is a function. It will not pass any parameters and it will not return +// any values. The call is made unprotected, so if Lua triggers an error, +// this C function will not return. Don't use this if you don't know what +// you're doing. +// Returns true if function was called, false otherwise. +boolean MojoLua_callProcedure(const char *funcname); + +// Set a Lua variable in the MojoSetup namespace to a string: +// MojoLua_setString("bob", "name"); +// in Lua: print(MojoSetup.name) -- outputs: bob +void MojoLua_setString(const char *str, const char *sym); + +// Same as MojoLua_setString, but it creates an ordered table (array). +void MojoLua_setStringArray(int argc, const char **argv, const char *sym); + +void MojoLua_collectGarbage(void); + +void MojoLua_debugger(void); + +#ifdef __cplusplus +} +#endif + +#endif + +// end of lua_glue.h ... + diff --git a/mk/linux/mojosetup/megaglest-installer/make.sh b/mk/linux/mojosetup/megaglest-installer/make.sh new file mode 100755 index 00000000..44bd8773 --- /dev/null +++ b/mk/linux/mojosetup/megaglest-installer/make.sh @@ -0,0 +1,323 @@ +#!/bin/bash + +# This script is not robust for all platforms or situations. Use as a rough +# example, but invest effort in what it's trying to do, and what it produces. +# (make sure you don't build in features you don't need, etc). + +# below is the branch to build and installer from +megaglest_release_folder="trunk" +#megaglest_release_folder="release-3.3.4.1" + +# below describe various folder paths relative to the installer root folder +megaglest_project_root=../../../../../ +megaglest_data_path=${megaglest_project_root}${megaglest_release_folder}/data/glest_game/ +megaglest_linux_path=${megaglest_project_root}${megaglest_release_folder}/mk/linux/ + +# Below is the name of the archive to create and tack onto the installer. +# *NOTE: The filename's extension is of critical importance as the installer +# does a patch on extension to figure out how to decompress! +# +# static const MojoArchiveType archives[] = +# { +# { "zip", MojoArchive_createZIP, true }, +# { "tar", MojoArchive_createTAR, true }, +# { "tar.gz", MojoArchive_createTAR, true }, +# { "tar.bz2", MojoArchive_createTAR, true }, +# { "tgz", MojoArchive_createTAR, true }, +# { "tbz2", MojoArchive_createTAR, true }, +# { "tb2", MojoArchive_createTAR, true }, +# { "tbz", MojoArchive_createTAR, true }, +# { "uz2", MojoArchive_createUZ2, false }, +# { "pck", MojoArchive_createPCK, true }, +# }; +# +megaglest_archiver_app="zip -9r " +megaglest_archivefilename="mgdata.zip" +#megaglest_archiver_app="tar -c --bzip2 -f " +#megaglest_archivefilename="mgdata.tar.bz2" + +# Grab the version # from autoconf +# +pushd "`pwd`/${megaglest_linux_path}" +echo "Linux project root path [`pwd`/${megaglest_linux_path}]" +VERSION=`autoconf -t AC_INIT | sed -e 's/[^:]*:[^:]*:[^:]*:[^:]*:\([^:]*\):.*/\1/g'` +echo "About to build Installer for $VERSION" +popd + +# Stop if anything produces an error. +set -e + +REPACKONLY=0 +DEBUG=0 +if [ "$1" = "--debug" ]; then + echo "debug build!" + DEBUG=1 +elif [ "$1" = "--repackonly" ]; then + echo "reacking installer only!" + REPACKONLY=1 +fi + +APPNAME="MegaGlest Installer" + +# I use a "cross compiler" to build binaries that are isolated from the +# particulars of my Linux workstation's current distribution. This both +# keeps me at a consistent ABI for generated binaries and prevent subtle +# dependencies from leaking in. +# You may not care about this at all. In which case, just use the +# CC=gcc and CXX=g++ lines instead. +CC=/usr/bin/gcc +CXX=/usr/bin/g++ +#CC=/opt/crosstool/gcc-3.3.6-glibc-2.3.5/i686-unknown-linux-gnu/i686-unknown-linux-gnu/bin/gcc +#CXX=/opt/crosstool/gcc-3.3.6-glibc-2.3.5/i686-unknown-linux-gnu/i686-unknown-linux-gnu/bin/g++ + +OSTYPE=`uname -s` +if [ "$OSTYPE" = "Linux" ]; then + NCPU=`cat /proc/cpuinfo |grep vendor_id |wc -l` + let NCPU=$NCPU+1 +elif [ "$OSTYPE" = "Darwin" ]; then + NCPU=`sysctl -n hw.ncpu` +elif [ "$OSTYPE" = "SunOS" ]; then + NCPU=`/usr/sbin/psrinfo |wc -l |sed -e 's/^ *//g;s/ *$//g'` +else + NCPU=1 +fi + +if [ "x$NCPU" = "x" ]; then + NCPU=1 +fi +if [ "x$NCPU" = "x0" ]; then + NCPU=1 +fi + +echo "Will use make -j$NCPU. If this is wrong, check NCPU at top of script." + +# Show everything that we do here on stdout. +set -x + +if [ "$DEBUG" = "1" ]; then + LUASTRIPOPT= + BUILDTYPE=Debug + TRUEIFDEBUG=TRUE + FALSEIFDEBUG=FALSE +else + LUASTRIPOPT=-s + BUILDTYPE=MinSizeRel + TRUEIFDEBUG=FALSE + FALSEIFDEBUG=TRUE +fi + +# Clean up previous run, build fresh dirs for Base Archive. +rm -rf image megaglest-installer ${megaglest_archivefilename} +mkdir image +mkdir image/guis +mkdir image/scripts +mkdir image/data +mkdir image/meta + +# This next section copies live data from the mega-glest folders +if [ $REPACKONLY -eq 0 ]; then + + rm -rf data + mkdir data + mkdir data/bin + + INSTALL_ROOTDIR="`pwd`/" + INSTALLDATADIR="${INSTALL_ROOTDIR}data/" + + # Now copy all glest binaries + echo Copying live Mega Glest binary files... + + pushd "`pwd`/$megaglest_linux_path" + + find glest -exec cp -p --parents "{}" $INSTALLDATADIR ';' + find glest.bin -exec cp -p --parents "{}" ${INSTALLDATADIR}bin ';' + find glest.ini -exec cp -p --parents "{}" $INSTALLDATADIR ';' + find glest_configurator -exec cp -p --parents "{}" $INSTALLDATADIR ';' + find glest_editor -exec cp -p --parents "{}" $INSTALLDATADIR ';' + find glest_g3dviewer -exec cp -p --parents "{}" $INSTALLDATADIR ';' + find servers.ini -exec cp -p --parents "{}" $INSTALLDATADIR ';' + find makedeps_folder.sh -exec cp -p --parents "{}" $INSTALL_ROOTDIR ';' + + popd + + # Now copy all glest data + echo Copying live Mega Glest data files... + + pushd "`pwd`/$megaglest_data_path" + + find configuration.xml -exec cp -p --parents "{}" $INSTALLDATADIR ';' + find glest.ico -exec cp -p --parents "{}" $INSTALLDATADIR ';' + find data/ \( -name "*.*" \) -exec cp -p --parents "{}" $INSTALLDATADIR ';' + find docs/ \( -name "*.*" \) -exec cp -p --parents "{}" $INSTALLDATADIR ';' + find maps/ \( -name "*.*" \) -exec cp -p --parents "{}" $INSTALLDATADIR ';' + find scenarios/ \( -name "*.*" \) -exec cp -p --parents "{}" $INSTALLDATADIR ';' + find screens/ \( -name "*.*" \) -exec cp -p --parents "{}" $INSTALLDATADIR ';' + find techs/ \( -name "*.*" \) -exec cp -p --parents "{}" $INSTALLDATADIR ';' + find tilesets/ \( -name "*.*" \) -exec cp -p --parents "{}" $INSTALLDATADIR ';' + find tutorials/ \( -name "*.*" \) -exec cp -p --parents "{}" $INSTALLDATADIR ';' + + popd + + # Now remove svn and temp files + echo removing temp and svn files... + + find data/ -name "\.svn" -type d -depth -exec rm -rf {} \; + find data/ -name "*~" -exec rm -rf {} \; + + # Copy shared lib dependencies for glest.bin + cd data + copyGlestDeptsCmd="${INSTALL_ROOTDIR}makedeps_folder.sh bin/glest.bin" + $copyGlestDeptsCmd + cd .. +fi + +if [ ! -d data/docs ]; then + echo "We don't see data/docs ..." + echo " Either you're in the wrong directory, or you didn't copy the" + echo " install data into here (it's unreasonably big to store it in" + echo " revision control for no good reason)." + exit 1 +fi + + +# Build MojoSetup binaries from scratch. +# YOU ALWAYS NEED THE LUA PARSER IF YOU WANT UNINSTALL SUPPORT! +cd ../ +rm -rf cmake-build +mkdir cmake-build +cd cmake-build +cmake \ + -DCMAKE_BUILD_TYPE=$BUILDTYPE \ + -DCMAKE_C_COMPILER=$CC \ + -DCMAKE_CXX_COMPILER=$CXX \ + -DMOJOSETUP_MULTIARCH=FALSE \ + -DMOJOSETUP_ARCHIVE_ZIP=TRUE \ + -DMOJOSETUP_ARCHIVE_TAR=TRUE \ + -DMOJOSETUP_ARCHIVE_TAR_BZ2=TRUE \ + -DMOJOSETUP_ARCHIVE_TAR_GZ=TRUE \ + -DMOJOSETUP_GUI_GTKPLUS2=TRUE \ + -DMOJOSETUP_GUI_GTKPLUS2_STATIC=TRUE \ + -DMOJOSETUP_GUI_NCURSES=TRUE \ + -DMOJOSETUP_GUI_NCURSES_STATIC=TRUE \ + -DMOJOSETUP_GUI_STDIO=TRUE \ + -DMOJOSETUP_GUI_STDIO_STATIC=TRUE \ + -DMOJOSETUP_GUI_WWW=FALSE \ + -DMOJOSETUP_GUI_WWW_STATIC=FALSE \ + -DMOJOSETUP_LUALIB_DB=FALSE \ + -DMOJOSETUP_LUALIB_IO=FALSE \ + -DMOJOSETUP_LUALIB_MATH=FALSE \ + -DMOJOSETUP_LUALIB_OS=FALSE \ + -DMOJOSETUP_LUALIB_PACKAGE=FALSE \ + -DMOJOSETUP_LUA_PARSER=TRUE \ + -DMOJOSETUP_IMAGE_BMP=TRUE \ + -DMOJOSETUP_IMAGE_JPG=FALSE \ + -DMOJOSETUP_IMAGE_PNG=FALSE \ + -DMOJOSETUP_INTERNAL_BZLIB=TRUE \ + -DMOJOSETUP_INTERNAL_ZLIB=TRUE \ + -DMOJOSETUP_URL_HTTP=FALSE \ + -DMOJOSETUP_URL_FTP=FALSE \ + .. + +# Perhaps needed to remove compiler / linker warnings considered as errors +# sed -i 's/-Werror//' Makefile + +make -j$NCPU + +# Strip the binaries and GUI plugins, put them somewhere useful. +if [ "$DEBUG" != "1" ]; then + strip ./mojosetup +fi + +mv ./mojosetup ../megaglest-installer/megaglest-installer +for feh in *.so *.dll *.dylib ; do + if [ -f $feh ]; then + if [ "$DEBUG" != "1" ]; then + strip $feh + fi + mv $feh ../megaglest-installer/image/guis + fi +done + +# Compile the Lua scripts, put them in the base archive. +for feh in ../scripts/*.lua ; do + ./mojoluac $LUASTRIPOPT -o ../megaglest-installer/image/scripts/${feh}c $feh +done + +# Don't want the example config...use our's instead. +rm -f ../megaglest-installer/image/scripts/config.luac +./mojoluac $LUASTRIPOPT -o ../megaglest-installer/image/scripts/config.luac ../megaglest-installer/scripts/config.lua + +# Don't want the example app_localization...use our's instead. +rm -f ../megaglest-installer/image/scripts/app_localization.luac +./mojoluac $LUASTRIPOPT -o ../megaglest-installer/image/scripts/app_localization.luac ../megaglest-installer/scripts/app_localization.lua + +# Fill in the rest of the Base Archive... +cd ../megaglest-installer + +cp -R data/* image/data/ + +# remove svn files +echo removing temp and svn files +find image/data/ -name "\.svn" -type d -depth -exec rm -rf {} \; +find image/data/ -name "*~" -exec rm -rf {} \; +cp meta/* image/meta/ + +# Need these scripts to do things like install menu items, etc, on Unix. +if [ "$OSTYPE" = "Linux" ]; then + USE_XDG_UTILS=1 +fi +if [ "$OSTYPE" = "SunOS" ]; then + USE_XDG_UTILS=1 +fi + +if [ "x$USE_XDG_UTILS" = "x1" ]; then + mkdir image/meta/xdg-utils + cp ../meta/xdg-utils/* image/meta/xdg-utils/ + chmod a+rx image/meta/xdg-utils/* +fi + +if [ "$OSTYPE" = "Darwin" ]; then + # Build up the application bundle for Mac OS X... + APPBUNDLE="$APPNAME.app" + rm -rf "$APPBUNDLE" + cp -Rv ../misc/MacAppBundleSkeleton "$APPBUNDLE" + perl -w -pi -e 's/YOUR_APPLICATION_NAME_HERE/'"$APPNAME"'/g;' "${APPBUNDLE}/Contents/Info.plist" + mv megaglest-installer "${APPBUNDLE}/Contents/MacOS/mojosetup" + mv image/* "${APPBUNDLE}/Contents/MacOS/" + rmdir image + ibtool --compile "${APPBUNDLE}/Contents/Resources/MojoSetup.nib" ../misc/MojoSetup.xib +else + # Make an archive of the Base Archive dirs and nuke the originals... + cd image + +# create the compressed image for the installer +# zip -9r ../${megaglest_archivefilename} * + ${megaglest_archiver_app} ../${megaglest_archivefilename} * + + cd .. + rm -rf image + # Append the archive to the mojosetup binary, so it's "self-extracting." + cat ${megaglest_archivefilename} >> ./megaglest-installer + rm -f ${megaglest_archivefilename} +fi + +# ...and that's that. +set +e +set +x +echo "Successfully built!" + +if [ "$DEBUG" = "1" ]; then + echo + echo + echo + echo 'ATTENTION: THIS IS A DEBUG BUILD!' + echo " DON'T DISTRIBUTE TO THE PUBLIC." + echo ' THIS IS PROBABLY BIGGER AND SLOWER THAN IT SHOULD BE.' + echo ' YOU HAVE BEEN WARNED!' + echo + echo + echo +fi + +exit 0 + diff --git a/mk/linux/mojosetup/megaglest-installer/makedeps_folder.sh b/mk/linux/mojosetup/megaglest-installer/makedeps_folder.sh new file mode 100755 index 00000000..04412a7f --- /dev/null +++ b/mk/linux/mojosetup/megaglest-installer/makedeps_folder.sh @@ -0,0 +1,77 @@ +#!/bin/bash +set -e +# Use this script to copy shared (libs) files to specified location +# ---------------------------------------------------------------------------- +# Written by Vivek Gite +# (c) 2006 nixCraft under GNU GPL v2.0+ +# Last updated on: Apr/06/2010 by Vivek Gite +# ---------------------------------------------------------------------------- +# + Modified for glest deployment - Softcoder +# + Added ld-linux support +# + Added error checking support +# + Added for loop so that we can process all files on cmd +# ---------------------------------------------------------------------------- +# Set libs output directory name +BASE="lib" +file="$@" + +sync_support_libs(){ + local d="$1" # folder to copy dependencies to + local pFILE="$2" # bin file to scan for dependencies from + local files="" + local _cp="/bin/cp" + local skip_deps="libm.so libpthread.so libstdc++.so libgcc_s.so libc.so libdl.so libX11.so libpulse libfusion libdirect libnvidia libXext librt libxcb libICE libSM libXtst libwrap libdbus libXau libXdmcp libnsl libFLAC libGL" + + # get rid of blanks and (0x00007fff0117f000) + files="$(ldd $pFILE | awk '{ print $3 }' | sed -e '/^$/d' -e '/(*)$/d')" + + for i in $files + do + dcc="${i%/*}" # get dirname only +# [ ! -d ${d}${dcc} ] && mkdir -p ${d}${dcc} +# ${_cp} -f $i ${d}${dcc} +# ${_cp} -f $i ${d} +# echo ${_cp} -f $i ${d} + + skipfile=0 + for j in $(echo $skip_deps) + do + if [ `awk "BEGIN {print index(\"$i\", \"$j\")}"` -ne 0 ]; then +# echo Skipping file = [$i] + skipfile=1 +break + fi + done + + if [ $skipfile -eq 0 ]; then + echo Including file = [$i] + ${_cp} -f $i ${d} + fi + done + + # Works with 32 and 64 bit ld-linux + #sldl="$(ldd $pFILE | grep 'ld-linux' | awk '{ print $1}')" + #sldlsubdir="${sldl%/*}" +# [ ! -f ${d}${sldl} ] && ${_cp} -f ${sldl} ${d}${sldlsubdir} + #if [ ! -f ${d}${sldl} ] ; then + # echo Including file = [${sldl}] + # ${_cp} -f ${sldl} ${d} + #fi +} + +usage(){ + echo "Syntax : $0 glest.bin + echo "Example: $0 glest.bin + exit 1 +} + +[ $# -eq 0 ] && usage +#[ ! -d $BASE ] && mkdir -p $BASE +[ -d $BASE ] && rm -r $BASE +mkdir -p $BASE + +# copy all files +for f in $file +do + sync_support_libs "${BASE}" "${f}" +done diff --git a/mk/linux/mojosetup/megaglest-installer/meta/glestforumsheader.bmp b/mk/linux/mojosetup/megaglest-installer/meta/glestforumsheader.bmp new file mode 100644 index 00000000..71fb511c Binary files /dev/null and b/mk/linux/mojosetup/megaglest-installer/meta/glestforumsheader.bmp differ diff --git a/mk/linux/mojosetup/megaglest-installer/meta/glestforumsheader.jpg b/mk/linux/mojosetup/megaglest-installer/meta/glestforumsheader.jpg new file mode 100755 index 00000000..a22f9ff3 Binary files /dev/null and b/mk/linux/mojosetup/megaglest-installer/meta/glestforumsheader.jpg differ diff --git a/mk/linux/mojosetup/megaglest-installer/meta/megaglestinstallscreen.jpg b/mk/linux/mojosetup/megaglest-installer/meta/megaglestinstallscreen.jpg new file mode 100755 index 00000000..1f16190b Binary files /dev/null and b/mk/linux/mojosetup/megaglest-installer/meta/megaglestinstallscreen.jpg differ diff --git a/mk/linux/mojosetup/megaglest-installer/scripts/app_localization.lua b/mk/linux/mojosetup/megaglest-installer/scripts/app_localization.lua new file mode 100644 index 00000000..55ff0b6c --- /dev/null +++ b/mk/linux/mojosetup/megaglest-installer/scripts/app_localization.lua @@ -0,0 +1,39 @@ +-- Lines starting with "--" are comments in this file. +-- You should add your installer's strings here, instead of localization.lua, +-- but localization.lua has instructions on how this file is formatted. + +MojoSetup.applocalization = { + ["Uninstall complete"] = { + en = "Uninstall complete.", + de = "Deinstallation komplett.", + es = "Desinstalación completa.", + pl = "Usuwanie zakoÅ„czone.", + it = "Disinstallazione completata.", + }; + + ["Megaglest README"] = { + de = "Megaglest-README", + es = "LEEME", + pl = "Megaglest README", + it = "Informazioni su Megaglest", + }; + + ["docs/readme.txt"] = { + }; + + ["Megaglest License"] = { + en_GB = "Megaglest Licence", + en_CA = "Megaglest Licence", + de = "Megaglest-Lizenz", + es = "Licencia de uso de Megaglest", + pl = "Licencja Megaglest", + it = "Licenza di Megaglest", + }; + + ["docs/code_license.txt"] = { + }; + +}; + +-- end of app_localization.lua ... + diff --git a/mk/linux/mojosetup/megaglest-installer/scripts/config.lua b/mk/linux/mojosetup/megaglest-installer/scripts/config.lua new file mode 100644 index 00000000..a726bacd --- /dev/null +++ b/mk/linux/mojosetup/megaglest-installer/scripts/config.lua @@ -0,0 +1,66 @@ +local GAME_INSTALL_SIZE = 510000000; + +local _ = MojoSetup.translate + +Setup.Package +{ + vendor = "glest.org", + id = "megaglest", + description = _("Mega Glest"), + version = "3.3.4", + splash = "glestforumsheader.bmp", + superuser = false, + write_manifest = true, + support_uninstall = true, + recommended_destinations = + { + MojoSetup.info.homedir, + "/opt/games", + "/usr/local/games" + }, + + postinstall = function(package) + MojoSetup.launchbrowser(MojoSetup.destination .. "http://glest.org/glest_board/index.php?topic=4930.0") + end, + + Setup.Eula + { + description = _("Megaglest License"), + source = _("docs/license.txt") + }, + + Setup.Readme + { + description = _("Megaglest README"), + source = _("docs/readme.txt") + }, + + Setup.Option + { + value = true, + required = true, + disabled = false, + bytes = GAME_INSTALL_SIZE, + description = _("Mega Glest"), + + Setup.File + { + -- Just install everything we see... + }, + + Setup.DesktopMenuItem + { + disabled = false, + name = _("MegaGlest"), + genericname = _("MegaGlest"), + tooltip = _("A real time strategy game."), + builtin_icon = false, + icon = "glest.ico", + commandline = "%0/glest", + category = "Game" + } + } +} + +-- end of config.lua ... + diff --git a/mk/linux/mojosetup/meta/xdg-utils/xdg-desktop-menu b/mk/linux/mojosetup/meta/xdg-utils/xdg-desktop-menu new file mode 100755 index 00000000..e77d3824 --- /dev/null +++ b/mk/linux/mojosetup/meta/xdg-utils/xdg-desktop-menu @@ -0,0 +1,1264 @@ +#!/bin/sh +#--------------------------------------------- +# xdg-desktop-menu +# +# Utility script to install menu items on a Linux desktop. +# Refer to the usage() function below for usage. +# +# Copyright 2006, Kevin Krammer +# Copyright 2006, Jeremy White +# +# LICENSE: +# +# Permission is hereby granted, free of charge, to any person obtaining a +# copy of this software and associated documentation files (the "Software"), +# to deal in the Software without restriction, including without limitation +# the rights to use, copy, modify, merge, publish, distribute, sublicense, +# and/or sell copies of the Software, and to permit persons to whom the +# Software is furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included +# in all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR +# OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, +# ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +# OTHER DEALINGS IN THE SOFTWARE. +# +#--------------------------------------------- + +manualpage() +{ +cat << _MANUALPAGE +Name + +xdg-desktop-menu - command line tool for (un)installing desktop menu items + +Synopsis + +xdg-desktop-menu install [--noupdate] [--novendor] [--mode mode] directory-file +(s) desktop-file(s) + +xdg-desktop-menu uninstall [--noupdate] [--mode mode] directory-file(s) +desktop-file(s) + +xdg-desktop-menu forceupdate [--mode mode] + +xdg-desktop-menu { --help | --manual | --version } + +Description + +The xdg-desktop-menu program can be used to install new menu entries to the +desktop's application menu. + +The application menu works according to the XDG Desktop Menu Specification at +http://www.freedesktop.org/Standards/menu-spec + +Commands + +install + + Install one or more applications in a submenu of the desktop menu system. + + desktop-file: A desktop file represents a single menu entry in the menu. + Desktop files are defined by the freedesktop.org Desktop Entry + Specification. The most important aspects of *.desktop files are summarized + below. + + Menu entries can be added to the menu system in two different ways. They + can either be added to a predefined submenu in the menu system based on one + or more category keywords, or they can be added to a new submenu. + + To add a menu entry to a predefined submenu the desktop file that + represents the menu entry must have a Categories= entry that lists one or + more keywords. The menu item will be included in an appropriate submenu + based on the included keywords. + + To add menu items to a new submenu the desktop-files must be preceded by a + directory-file that describes the submenu. If multiple desktop-files are + specified, all entries will be added to the same menu. If entries are + installed to a menu that has been created with a previous call to + xdg-desktop-menu the entries will be installed in addition to any already + existing entries. + + directory-file: The *.directory file indicated by directory-file represents + a submenu. The directory file provides the name and icon for a submenu. The + name of the directory file is used to identify the submenu. + + If multiple directory files are provided each file will represent a submenu + within the menu that preceeds it, creating a nested menu hierarchy + (sub-sub-menus). The menu entries themselves will be added to the last + submenu. + + Directory files follow the syntax defined by the freedesktop.org Desktop + Entry Specification. + +uninstall + + Remove applications or submenus from the desktop menu system previously + installed with xdg-desktop-menu install. + + A submenu and the associated directory file is only removed when the + submenu no longer contains any menu entries. + +forceupdate + + Force an update of the menu system. + + This command is only useful if the last call to xdg-desktop-menu included + the --noupdate option. + +Options + +--noupdate + Postpone updating the menu system. If multiple updates to the menu system + are made in sequence this flag can be used to indicate that additional + changes will follow and that it is not necassery to update the menu system + right away. +--novendor + + Normally, xdg-desktop-menu checks to ensure that any *.directory and + *.desktop files to be installed has a vendor prefix. This option can be + used to disable that check. + + A vendor prefix consists of alpha characters ([a-zA-Z]) and is terminated + with a dash ("-"). Companies and organizations are encouraged to use a word + or phrase, preferably the organizations name, for which they hold a + trademark as their vendor prefix. The purpose of the vendor prefix is to + prevent name conflicts. + +--mode mode + + mode can be user or system. In user mode the file is (un)installed for the + current user only. In system mode the file is (un)installed for all users + on the system. Usually only root is allowed to install in system mode. + + The default is to use system mode when called by root and to use user mode + when called by a non-root user. + +--help + Show command synopsis. +--manual + Show this manualpage. +--version + Show the xdg-utils version information. + +Desktop Files + +An application item in the application menu is represented by a *.desktop file. +A *.desktop file consists of a [Desktop Entry] header followed by several Key= +Value lines. + +A *.desktop file can provide a name and description for an application in +several different languages. This is done by adding a language code as used by +LC_MESSAGES in square brackets behind the Key. This way one can specify +different values for the same Key depending on the currently selected language. + +The following keys are often used: + +Value=1.0 + This is a mandatory field to indicate that the *.desktop file follows the + 1.0 version of the specification. +Type=Application + This is a mandatory field that indicates that the *.desktop file describes + an application launcher. +Name=Application Name + The name of the application. For example Mozilla +GenericName=Generic Name + A generic description of the application. For example Web Browser +Comment=Comment + Optional field to specify a tooltip for the application. For example Visit + websites on the Internet +Icon=Icon File + The icon to use for the application. This can either be an absolute path to + an image file or an icon-name. If an icon-name is provided an image lookup + by name is done in the user's current icon theme. The xdg-icon-resource + command can be used to install image files into icon themes. The advantage + of using an icon-name instead of an absolute path is that with an icon-name + the application icon can be provided in several different sizes as well as + in several differently themed styles. +Exec=Command Line + The command line to start the application. If the application can open + files the %f placeholder should be specified. When a file is dropped on the + application launcher the %f is replaced with the file path of the dropped + file. If multiple files can be specified on the command line the %F + placeholder should be used instead of %f. If the application is able to + open URLs in addition to local files then %u or %U can be used instead of + %f or %F. +Categories=Categories + + A list of categories separated by semi-colons. A category is a keyword that + describes and classifies the application. By default applications are + organized in the application menu based on category. When menu entries are + explicitly assigned to a new submenu it is not necassery to list any + categories. + + When using categories it is recommended to include one of the following + categories: AudioVideo, Development, Education, Game, Graphics, Network, + Office, Settings, System, Utility. + + See Appendix A of the XDG Desktop Menu Specification for information about + additional categories. http://standards.freedesktop.org/menu-spec/ + menu-spec-1.0.html + +MimeType=Mimetypes + A list of mimetypes separated by semi-colons. This field is used to + indicate which file types the application is able to open. + +For a complete oveview of the *.desktop file format please visit http:// +www.freedesktop.org/wiki/Standards/desktop-entry-spec + +Directory Files + +The appearance of submenu in the application menu is provided by a *.directory +file. In particular it provides the title of the submenu and a possible icon. A +*.directory file consists of a [Desktop Entry] header followed by several Key= +Value lines. + +A *.directory file can provide a title (name) for the submenu in several +different languages. This is done by adding a language code as used by +LC_MESSAGES in square brackets behind the Key. This way one can specify +different values for the same Key depending on the currently selected language. + +The following keys are relevqnt for submenus: + +Value=1.0 + This is a mandatory field to indicate that the *.directory file follows the + 1.0 version of the Desktop Entry specification. +Type=Directory + This is a mandatory field that indicates that the *.directory file + describes a submenu. +Name=Menu Name + The title of submenu. For example Mozilla +Comment=Comment + Optional field to specify a tooltip for the submenu. +Icon=Icon File + The icon to use for the submenu. This can either be an absolute path to an + image file or an icon-name. If an icon-name is provided an image lookup by + name is done in the user's current icon theme. The xdg-icon-resource + command can be used to install image files into icon themes. The advantage + of using an icon-name instead of an absolute path is that with an icon-name + the submenu icon can be provided in several different sizes as well as in + several differently themed styles. + +Environment Variables + +xdg-desktop-menu honours the following environment variables: + +XDG_UTILS_DEBUG_LEVEL + Setting this environment variable to a non-zero numerical value makes + xdg-desktop-menu do more verbose reporting on stderr. Setting a higher + value increases the verbosity. +XDG_UTILS_INSTALL_MODE + This environment variable can be used by the user or administrator to + override the installation mode. Valid values are user and system. + +Exit Codes + +An exit code of 0 indicates success while a non-zero exit code indicates +failure. The following failure codes can be returned: + +1 + Error in command line syntax. +2 + One of the files passed on the command line did not exist. +3 + A required tool could not be found. +4 + The action failed. +5 + No permission to read one of the files passed on the command line. + +See Also + +xdg-desktop-icon(1), xdg-icon-resource(1), xdg-mime(1) + +Examples + +The company ShinyThings Inc. has developed an application named "WebMirror" and +would like to add it to the application menu. The company will use +"shinythings" as its vendor id. In order to add the application to the menu +there needs to be a .desktop file with a suitable Categories entry: + +shinythings-webmirror.desktop: + + [Desktop Entry] + Encoding=UTF-8 + Type=Application + + Exec=webmirror + Icon=webmirror + + Name=WebMirror + Name[nl]=WebSpiegel + + Categories=Network;WebDevelopment; + +Now the xdg-desktop-menu tool can be used to add the +shinythings-webmirror.desktop file to the desktop application menu: + +xdg-desktop-menu install ./shinythings-webmirror.desktop + +Note that for the purpose of this example the menu items are available in two +languages, English and Dutch. The language code for Dutch is nl. + +In the next example the company ShinyThings Inc. will add its own submenu to +the desktop application menu consisting of a "WebMirror" menu item and a +"WebMirror Admin Tool" menu item. + +First the company needs to create two .desktop files that describe the two menu +items. Since the items are to be added to a new submenu it is not necassery to +include a Categories= line: + +shinythings-webmirror.desktop: + + [Desktop Entry] + Encoding=UTF-8 + Type=Application + + Exec=webmirror + Icon=shinythings-webmirror + + Name=WebMirror + Name[nl]=WebSpiegel + + +shinythings-webmirror-admin.desktop: + + [Desktop Entry] + Encoding=UTF-8 + Type=Application + + Exec=webmirror-admintool + Icon=shinythings-webmirror-admintool + + Name=WebMirror Admin Tool + Name[nl]=WebSpiegel Administratie Tool + +In addition a .directory file needs to be created to provide a title and icon +for the sub-menu itself: + +shinythings-webmirror.directory: + + [Desktop Entry] + Encoding=UTF-8 + + Icon=shinythings-webmirror-menu + + Name=WebMirror + Name[nl]=WebSpiegel + +These file can now be installed with: + +xdg-desktop-menu install ./shinythings-webmirror.directory \ + ./shinythings-webmirror.desktop ./shinythings-webmirror-admin.desktop + +The menu entries could also be installed one by one: + +xdg-desktop-menu install --noupdate ./shinythings-webmirror.directory \ + ./shinythings-webmirror.desktop +xdg-desktop-menu install --noupdate ./shinythings-webmirror.directory \ + ./shinythings-webmirror-admin.desktop +xdg-desktop-menu forceupdate + +Although the result is the same it is slightly more efficient to install all +files at the same time. + +The *.desktop and *.directory files reference icons with the names webmirror, +webmirror-admin and webmirror-menu which should also be installed. In this +example the icons are installed in two different sizes, once with a size of +22x22 pixels and once with a size of 64x64 pixels: + +xdg-icon-resource install --size 22 ./wmicon-22.png shinythings-webmirror +xdg-icon-resource install --size 22 ./wmicon-menu-22.png shinythings-webmirror-menu +xdg-icon-resource install --size 22 ./wmicon-admin-22.png shinythings-webmirror-admin +xdg-icon-resource install --size 64 ./wmicon-64.png shinythings-webmirror +xdg-icon-resource install --size 64 ./wmicon-menu-64.png shinythings-webmirror-menu +xdg-icon-resource install --size 64 ./wmicon-admin-64.png shinythings-webmirror-admin + +_MANUALPAGE +} + +usage() +{ +cat << _USAGE +xdg-desktop-menu - command line tool for (un)installing desktop menu items + +Synopsis + +xdg-desktop-menu install [--noupdate] [--novendor] [--mode mode] directory-file +(s) desktop-file(s) + +xdg-desktop-menu uninstall [--noupdate] [--mode mode] directory-file(s) +desktop-file(s) + +xdg-desktop-menu forceupdate [--mode mode] + +xdg-desktop-menu { --help | --manual | --version } + +_USAGE +} + +#@xdg-utils-common@ + +#---------------------------------------------------------------------------- +# Common utility functions included in all XDG wrapper scripts +#---------------------------------------------------------------------------- + +DEBUG() +{ + [ -z "${XDG_UTILS_DEBUG_LEVEL}" ] && return 0; + [ ${XDG_UTILS_DEBUG_LEVEL} -lt $1 ] && return 0; + shift + echo "$@" >&2 +} + +#------------------------------------------------------------- +# Exit script on successfully completing the desired operation + +exit_success() +{ + if [ $# -gt 0 ]; then + echo "$@" + echo + fi + + exit 0 +} + + +#----------------------------------------- +# Exit script on malformed arguments, not enough arguments +# or missing required option. +# prints usage information + +exit_failure_syntax() +{ + if [ $# -gt 0 ]; then + echo "xdg-desktop-menu: $@" >&2 + echo "Try 'xdg-desktop-menu --help' for more information." >&2 + else + usage + echo "Use 'man xdg-desktop-menu' or 'xdg-desktop-menu --manual' for additional info." + fi + + exit 1 +} + +#------------------------------------------------------------- +# Exit script on missing file specified on command line + +exit_failure_file_missing() +{ + if [ $# -gt 0 ]; then + echo "xdg-desktop-menu: $@" >&2 + fi + + exit 2 +} + +#------------------------------------------------------------- +# Exit script on failure to locate necessary tool applications + +exit_failure_operation_impossible() +{ + if [ $# -gt 0 ]; then + echo "xdg-desktop-menu: $@" >&2 + fi + + exit 3 +} + +#------------------------------------------------------------- +# Exit script on failure returned by a tool application + +exit_failure_operation_failed() +{ + if [ $# -gt 0 ]; then + echo "xdg-desktop-menu: $@" >&2 + fi + + exit 4 +} + +#------------------------------------------------------------ +# Exit script on insufficient permission to read a specified file + +exit_failure_file_permission_read() +{ + if [ $# -gt 0 ]; then + echo "xdg-desktop-menu: $@" >&2 + fi + + exit 5 +} + +#------------------------------------------------------------ +# Exit script on insufficient permission to read a specified file + +exit_failure_file_permission_write() +{ + if [ $# -gt 0 ]; then + echo "xdg-desktop-menu: $@" >&2 + fi + + exit 6 +} + +check_input_file() +{ + if [ ! -e "$1" ]; then + exit_failure_file_missing "file '$1' does not exist" + fi + if [ ! -r "$1" ]; then + exit_failure_file_permission_read "no permission to read file '$1'" + fi +} + +check_vendor_prefix() +{ + file_label="$2" + [ -n "$file_label" ] || file_label="filename" + file=`basename "$1"` + case "$file" in + [a-zA-Z]*-*) + return + ;; + esac + + echo "xdg-desktop-menu: $file_label '$file' does not have a proper vendor prefix" >&2 + echo 'A vendor prefix consists of alpha characters ([a-zA-Z]) and is terminated' >&2 + echo 'with a dash ("-"). An example '"$file_label"' is '"'example-$file'" >&2 + echo "Use --novendor to override or 'xdg-desktop-menu --manual' for additional info." >&2 + exit 1 +} + +check_output_file() +{ + # if the file exists, check if it is writeable + # if it does not exists, check if we are allowed to write on the directory + if [ -e "$1" ]; then + if [ ! -w "$1" ]; then + exit_failure_file_permission_write "no permission to write to file '$1'" + fi + else + DIR=`dirname "$1"` + if [ ! -w "$DIR" -o ! -x "$DIR" ]; then + exit_failure_file_permission_write "no permission to create file '$1'" + fi + fi +} + +#---------------------------------------- +# Checks for shared commands, e.g. --help + +check_common_commands() +{ + while [ $# -gt 0 ] ; do + parm="$1" + shift + + case "$parm" in + --help) + usage + echo "Use 'man xdg-desktop-menu' or 'xdg-desktop-menu --manual' for additional info." + exit_success + ;; + + --manual) + manualpage + exit_success + ;; + + --version) + echo "xdg-desktop-menu 1.0.1" + exit_success + ;; + esac + done +} + +check_common_commands "$@" + +[ -z "${XDG_UTILS_DEBUG_LEVEL}" ] && unset XDG_UTILS_DEBUG_LEVEL; +if [ ${XDG_UTILS_DEBUG_LEVEL-0} -lt 1 ]; then + # Be silent + xdg_redirect_output=" > /dev/null 2> /dev/null" +else + # All output to stderr + xdg_redirect_output=" >&2" +fi + +#-------------------------------------- +# Checks for known desktop environments +# set variable DE to the desktop environments name, lowercase + +detectDE() +{ + if [ x"$KDE_FULL_SESSION" = x"true" ]; then DE=kde; + elif [ x"$GNOME_DESKTOP_SESSION_ID" != x"" ]; then DE=gnome; + elif xprop -root _DT_SAVE_MODE | grep ' = \"xfce4\"$' >/dev/null 2>&1; then DE=xfce; + fi +} + +#---------------------------------------------------------------------------- +# kfmclient exec/openURL can give bogus exit value in KDE <= 3.5.4 +# It also always returns 1 in KDE 3.4 and earlier +# Simply return 0 in such case + +kfmclient_fix_exit_code() +{ + version=`kde-config --version 2>/dev/null | grep KDE` + major=`echo $version | sed 's/KDE: \([0-9]\).*/\1/'` + minor=`echo $version | sed 's/KDE: [0-9]*\.\([0-9]\).*/\1/'` + release=`echo $version | sed 's/KDE: [0-9]*\.[0-9]*\.\([0-9]\).*/\1/'` + test "$major" -gt 3 && return $1 + test "$minor" -gt 5 && return $1 + test "$release" -gt 4 && return $1 + return 0 +} + +update_desktop_database() +{ +# echo Update desktop database: $mode + if [ "$mode" = "system" ] ; then + for x in `echo $PATH | sed 's/:/ /g'` /opt/gnome/bin; do + if [ -x $x/update-desktop-database ] ; then + DEBUG 1 "Running $x/update-desktop-database" + eval '$x/update-desktop-database'$xdg_redirect_output + return + fi + done + fi +} + +fixup_mandriva_categories() +{ + DEBUG 1 "fixup_mandriva_categories $1" + awk ' +BEGIN { + xlat["AudioVideo"]="X-Mandrakelinux-Multimedia;X-MandrivaLinux-Multimedia" + xlat["Development"]="X-Mandrakelinux-MoreApplications-Development;X-MandrivaLinux-MoreApplications-Development" + xlat["Education"]="X-Mandrakelinux-MoreApplications;X-MandrivaLinux-MoreApplications-Education" + xlat["Game"]="X-Mandrakelinux-MoreApplications;X-MandrivaLinux-MoreApplications-Games" + xlat["Graphics"]="X-Mandrakelinux-Multimedia-Graphics" + xlat["Network"]="X-Mandrakelinux-Internet;X-MandrivaLinux-Internet" + xlat["Office"]="X-Mandrakelinux-Office;X-MandrivaLinux-Office" + xlat["System"]="X-Mandrakelinux-System;X-MandrivaLinux-System" + xlat["Utility"]="X-Mandrakelinux-Office-Accessories;X-MandrivaLinux-Office-Accessories" +} +{ + if (match($0,/Categories=/)) { + split(substr($0,RSTART+11),categories,";") + result="" + for (n in categories) + { + if (categories[n] in xlat) + categories[n]=categories[n] ";" xlat[categories[n]] + if (categories[n]) + result=result categories[n] ";" + } + print "Categories=" result + } + else + { + print $0 + } +}' $1 > $1.new + mv $1.new $1 +} + +# Make application $1/$2 the default for all the mimetypes it support, +# iff such mimetype didn't had a default application already. +# $1 Install dir for desktop file +# $2 base name of desktop file +make_lazy_default() +{ + local mimetypes + local xdg_user_dir + local xdg_default_dirs + + DEBUG 1 "make_lazy_default $1/$2" + mimetypes=`awk ' +{ + if (match($0,/MimeType=/)) { + split(substr($0,RSTART+9),mimetypes,";") + for (n in mimetypes) + { + if (mimetypes[n]) + print mimetypes[n] + } + } +}' "$1/$2" 2> /dev/null` + + for MIME in $mimetypes ; do + xdg_default_dirs="$XDG_DATA_DIRS" + [ -n "$xdg_default_dirs" ] || xdg_default_dirs=/usr/local/share/:/usr/share/ + if [ x"$mode" = x"user" ] ; then + xdg_user_dir="$XDG_DATA_HOME" + [ -n "$xdg_user_dir" ] || xdg_user_dir="$HOME/.local/share" + xdg_default_dirs="$xdg_user_dir:$xdg_default_dirs" + fi + local default_app + for x in `echo "$xdg_default_dirs" | sed 's/:/ /g'`; do + DEBUG 2 "Checking $x/applications/defaults.list" + default_app=`grep "$MIME=" $x/applications/defaults.list 2> /dev/null | cut -d '=' -f 2` + if [ -n "$default_app" ] ; then + DEBUG 2 "Found default apps for $MIME: $default_app" + default_app="$default_app;" + break; + fi + done + DEBUG 2 "Current default apps for $MIME: $default_app" + if echo "$default_app" | grep "$2" > /dev/null 2> /dev/null; then + # App already listed as default + continue; + fi + default_file="$1/defaults.list" + DEBUG 1 "Updating $default_file" + grep -v "$MIME=" $default_file > ${default_file}.new 2> /dev/null + if ! grep "[Default Applications]" ${default_file}.new > /dev/null; then + echo "[Default Applications]" >> ${default_file}.new + fi + echo $MIME="$default_app$2" >> ${default_file}.new + mv ${default_file}.new $default_file + done +} + +update_submenu() +{ + DEBUG 1 "update_submenu $1" + menu_file="$1" + + xdg_dir_name=menus + xdg_user_dir="$XDG_CONFIG_HOME" + [ -n "$xdg_user_dir" ] || xdg_user_dir="$HOME/.config" + xdg_user_dir="$xdg_user_dir/$xdg_dir_name" + + xdg_system_dirs="$XDG_CONFIG_DIRS" + [ -n "$xdg_system_dirs" ] || xdg_system_dirs=/etc/xdg + xdg_global_dir= + for x in `echo $xdg_system_dirs | sed 's/:/ /g'` ; do + if [ -w $x/$xdg_dir_name ] ; then + xdg_global_dir="$x/$xdg_dir_name" + break + fi + done + xdg_user_dir="$xdg_user_dir/applications-merged" + xdg_global_dir="$xdg_global_dir/applications-merged" + + DEBUG 3 "Install locations for *.menu file:" + DEBUG 3 "xdg_user_dir: $xdg_user_dir" + DEBUG 3 "xdg_global_dir: $xdg_global_dir" + DEBUG 3 "kde_user_dir: $kde_user_dir" + DEBUG 3 "kde_global_dir: $kde_global_dir" + DEBUG 3 "gnome_user_dir: $gnome_user_dir" + DEBUG 3 "gnome_global_dir: $gnome_global_dir" + + if [ x"$mode" = x"user" ] ; then + xdg_dir="$xdg_user_dir" + kde_dir="$kde_user_dir" + gnome_dir="$gnome_user_dir" + my_umask=077 + my_chmod=0600 + else + xdg_dir="$xdg_global_dir" + kde_dir="$kde_global_dir" + gnome_dir="$gnome_global_dir" + my_umask=022 + my_chmod=0644 + if [ -z "${xdg_dir}${kde_dir}${gnome_dir}" ] ; then + exit_failure_operation_impossible "No writable system menu directory found." + fi + fi + + if [ -z "$menu_file" ] ; then + # Work around for SUSE/gnome 2.12 to pick up new ~/.local/share/applications + save_umask=`umask` + umask $my_umask + + mkdir -p $xdg_dir + touch $xdg_dir/xdg-desktop-menu-dummy.menu + + umask $save_umask + return + fi + + if [ $action = "install" -a -f "/etc/xdg/menus/gnome-applications.menu" ] ; then + # Work around for Debian Gnome + gnome_xdg_dir=`echo "$xdg_dir" | sed -e 's^/applications-merged^/gnome-applications-merged^'` + if [ ! -e "$gnome_xdg_dir" ] ; then + DEBUG 1 "Debian Workaround: Link '$xdg_dir' to '$gnome_xdg_dir'" + mkdir -p `dirname "$gnome_xdg_dir"` + eval 'ln -s "applications-merged" "$gnome_xdg_dir"'$xdg_redirect_output + fi + fi + if [ $action = "install" -a -f "/etc/mandrake-release" ] ; then + # Work around for Mandriva 2006 + mandrake_xdg_dir=`echo "$xdg_dir" | sed -e 's^/applications-merged^/applications-mdk-merged^'` + if [ ! -e "$mandrake_xdg_dir" ] ; then + DEBUG 1 "Mandriva Workaround: Link '$xdg_dir' to '$mandrake_xdg_dir'" + mkdir -p `dirname "$mandrake_xdg_dir"` + eval 'ln -s "applications-merged" "$mandrake_xdg_dir"'$xdg_redirect_output + fi + fi + if [ $action = "install" -a x"$mode" = x"user" -a -d "/etc/xdg/menus/kde-applications-merged" ] ; then + # Work around for Fedora Core 5 + patched KDE + kde_xdg_dir=`echo "$xdg_dir" | sed -e 's^/applications-merged^/kde-applications-merged^'` + if [ ! -e "$kde_xdg_dir" ] ; then + DEBUG 1 "Fedora Workaround: Link '$xdg_dir' to '$kde_xdg_dir'" + mkdir -p `dirname "$kde_xdg_dir"` + eval 'ln -s "applications-merged" "$kde_xdg_dir"'$xdg_redirect_output + fi + fi + if [ $action = "install" -a x"$mode" = x"system" -a -d "/etc/xdg/menus/kde-applications-merged" -a ! -d "/etc/xdg/menus/applications-merged" ] ; then + # Work around for Kubuntu 6.06 + kde_xdg_dir=`echo "$xdg_dir" | sed -e 's^/applications-merged^/kde-applications-merged^'` + DEBUG 1 "Kubuntu Workaround: Link '$xdg_dir' to 'kde-applications-merged'" + eval 'ln -s "kde-applications-merged" "$xdg_dir"'$xdg_redirect_output + fi + + orig_menu_file=$xdg_dir/$menu_file + + DEBUG 1 "Updating $orig_menu_file ($action)" + + test "${TMPDIR+set}" = set || TMPDIR=/tmp + tmpfile=`mktemp $TMPDIR/tmp.XXXXXXXXXX` + orig_desktop_files= + if [ -r "$orig_menu_file" ] ; then + awk ' +# List all files within tags +BEGIN { + RS="<" +} +/^Filename/ { + if (match($0,/>/)) { + print substr($0,RSTART+1) + } +}' $orig_menu_file > $tmpfile + fi + + orig_desktop_files=`cat $tmpfile` + new_desktop_files= + if [ $action = "install" ] ; then + for desktop_file in $desktop_files; do + basefile=`basename $desktop_file` + if ! grep '^'$basefile'$' $tmpfile > /dev/null 2> /dev/null ; then + # Append + echo "$basefile" >> $tmpfile + fi + done + new_desktop_files=`cat $tmpfile` + fi + if [ $action = "uninstall" ] ; then + echo > $tmpfile + for desktop_file in $desktop_files; do + echo "$desktop_file" >> $tmpfile + done + # Files to uninstall are listed in $tmpfile + # Existing files are in $orig_desktop_files + for desktop_file in $orig_desktop_files; do + if ! grep '^'$desktop_file'$' $tmpfile > /dev/null 2> /dev/null; then + # Keep this file, it's not in the uninstall list + new_desktop_files="$new_desktop_files $desktop_file" + fi + done + fi + rm -f "$tmpfile" + + DEBUG 3 "Files to list in $menu_file: $new_desktop_files" + + if [ -n "$new_desktop_files" ] ; then + # Install/update + test "${TMPDIR+set}" = set || TMPDIR=/tmp + tmpfile=`mktemp $TMPDIR/tmp.XXXXXXXXXX` + ( + echo '' + echo '' + echo '

' + echo ' Applications' + + for desktop_file in $directory_files; do + basefile=`basename $desktop_file` + basefilename=`echo "$basefile"|cut -d '.' -f 1` + echo "" + echo " $basefilename" + echo " $basefile" + done + + echo " " + for desktop_file in $new_desktop_files; do + echo " $desktop_file" + done + echo " " + + for desktop_file in $directory_files; do + echo "" + done + + echo '' + ) > $tmpfile + chmod $my_chmod $tmpfile + + save_umask=`umask` + umask $my_umask + + mkdir -p $xdg_dir + eval 'cp $tmpfile $xdg_dir/$menu_file'$xdg_redirect_output + + umask $save_umask + rm -f "$tmpfile" + else + # Uninstall + rm -f $xdg_dir/$menu_file + fi + + # Uninstall .directory files only if no longer referenced + if [ $action = "uninstall" ] ; then + test "${TMPDIR+set}" = set || TMPDIR=/tmp + tmpfile=`mktemp $TMPDIR/tmp.XXXXXXXXXX` + for menu_file in $xdg_dir/*; do + if grep 'generated and managed by xdg-desktop-menu' $menu_file > /dev/null 2> /dev/null; then + awk ' +# List all files within tags +BEGIN { + RS="<" +} +/^Directory/ { + if (match($0,/>/)) { + print substr($0,RSTART+1) + } +}' $menu_file >> $tmpfile + fi + done + orig_directory_files="$directory_files" + directory_files= + for desktop_file in $orig_directory_files; do + if ! grep '^'$desktop_file'$' $tmpfile > /dev/null 2> /dev/null; then + # No longer in use, safe to delete + directory_files="$directory_files $desktop_file" + fi + done + rm -f "$tmpfile" + fi +} + + +[ x"$1" != x"" ] || exit_failure_syntax + +mode= +action= +update=yes +desktop_files= +directory_files= + +case $1 in + install) + action=install + ;; + + uninstall) + action=uninstall + ;; + + forceupdate) + action=forceupdate + ;; + + *) + exit_failure_syntax "unknown command '$1'" + ;; +esac + +shift + +vendor=true +while [ $# -gt 0 ] ; do + parm="$1" + shift + + case "$parm" in + --noupdate) + update=no + ;; + + --mode) + if [ -z "$1" ] ; then + exit_failure_syntax "mode argument missing for --mode" + fi + case "$1" in + user) + mode="user" + ;; + + system) + mode="system" + ;; + + *) + exit_failure_syntax "unknown mode '$1'" + ;; + esac + shift + ;; + + --novendor) + vendor=false + ;; + + -*) + exit_failure_syntax "unexpected option '$parm'" + ;; + + *) + if [ "$action" = "install" ] ; then + check_input_file "$parm" + fi + case "$parm" in + *.directory) + if [ -n "$desktop_files" ] ; then + exit_failure_syntax "'$parm' must preceed any *.desktop file" + fi + directory_files="$directory_files $parm" + ;; + *.desktop) + desktop_files="$desktop_files $parm" + ;; + *) + exit_failure_syntax "file to $action must be a *.directory or *.desktop file" + ;; + esac + ;; + esac +done + +# Shouldn't happen +if [ -z "$action" ] ; then + exit_failure_syntax "command argument missing" +fi + +if [ -n "$XDG_UTILS_INSTALL_MODE" ] ; then + if [ "$XDG_UTILS_INSTALL_MODE" = "system" ] ; then + mode="system" + elif [ "$XDG_UTILS_INSTALL_MODE" = "user" ] ; then + mode="user" + fi +fi + +if [ -z "$mode" ] ; then + if [ `whoami` = "root" ] ; then + mode="system" + else + mode="user" + fi +fi + +if [ x"$action" = x"forceupdate" ] ; then + update_desktop_database + exit_success +fi + +if [ -z "$desktop_files" ] ; then + exit_failure_syntax "desktop-file argument missing" +fi + +menu_name= +for desktop_file in $directory_files; do + if [ "$vendor" = "true" -a "$action" = "install" ] ; then + check_vendor_prefix "$desktop_file" + fi + + basefilename=`basename "$desktop_file"|cut -d '.' -f 1` + if [ -z "$menu_name" ] ; then + menu_name="$basefilename" + else + menu_name="$menu_name-$basefilename" + fi +done + +if [ -n "$menu_name" ] ; then + if [ x"$mode" = x"user" ] ; then + update_submenu "user-$menu_name.menu" + else + update_submenu "$menu_name.menu" + fi +else + # Work around for SUSE/gnome 2.12 to pick up new ~/.local/share/applications + if [ x"$mode" = x"user" ] ; then + update_submenu + fi +fi + +# Install *.directory files + +xdg_dir_name=desktop-directories + +xdg_user_dir="$XDG_DATA_HOME" +[ -n "$xdg_user_dir" ] || xdg_user_dir="$HOME/.local/share" +xdg_user_dir="$xdg_user_dir/$xdg_dir_name" + +xdg_system_dirs="$XDG_DATA_DIRS" +[ -n "$xdg_system_dirs" ] || xdg_system_dirs=/usr/local/share/:/usr/share/ +xdg_global_dir= +for x in `echo $xdg_system_dirs | sed 's/:/ /g'` ; do + if [ -w $x/$xdg_dir_name ] ; then + xdg_global_dir="$x/$xdg_dir_name" + break + fi +done + +DEBUG 3 "Install locations for *.directory files:" +DEBUG 3 "xdg_user_dir: $xdg_user_dir" +DEBUG 3 "xdg_global_dir: $xdg_global_dir" +DEBUG 3 "kde_user_dir: $kde_user_dir" +DEBUG 3 "kde_global_dir: $kde_global_dir" +DEBUG 3 "gnome_user_dir: $gnome_user_dir" +DEBUG 3 "gnome_global_dir: $gnome_global_dir" + +if [ x"$mode" = x"user" ] ; then + xdg_dir="$xdg_user_dir" + kde_dir="$kde_user_dir" + gnome_dir="$gnome_user_dir" + my_umask=077 +else + xdg_dir="$xdg_global_dir" + kde_dir="$kde_global_dir" + gnome_dir="$gnome_global_dir" + my_umask=022 + if [ -z "${xdg_dir}${kde_dir}${gnome_dir}" ] ; then + exit_failure_operation_impossible "No writable system menu directory found." + fi +fi + +for desktop_file in $directory_files; do + basefile=`basename $desktop_file` + + DEBUG 1 "$action $desktop_file in $xdg_dir $kde_dir $gnome_dir" + + case $action in + install) + save_umask=`umask` + umask $my_umask + + for x in $xdg_dir $kde_dir $gnome_dir ; do + mkdir -p $x + eval 'cp $desktop_file $x/$basefile'$xdg_redirect_output + done + + umask $save_umask + ;; + + uninstall) + for x in $xdg_dir $kde_dir $gnome_dir ; do + rm -f $x/$basefile + done + + ;; + esac +done + +# Install *.desktop files +xdg_dir_name=applications + +xdg_user_dir="$XDG_DATA_HOME" +[ -n "$xdg_user_dir" ] || xdg_user_dir="$HOME/.local/share" +xdg_user_dir="$xdg_user_dir/$xdg_dir_name" + +xdg_system_dirs="$XDG_DATA_DIRS" +[ -n "$xdg_system_dirs" ] || xdg_system_dirs=/usr/local/share/:/usr/share/ +xdg_global_dir= +for x in `echo $xdg_system_dirs | sed 's/:/ /g'` ; do + if [ -w $x/$xdg_dir_name ] ; then + xdg_global_dir="$x/$xdg_dir_name" + break + fi +done + +kde_user_dir="$HOME/.kde/share/applnk" +kde_global_dir="/usr/share/applnk" +[ -w $kde_global_dir ] || kde_global_dir= + +gnome_user_dir="$HOME/.gnome/apps" +gnome_global_dir="/usr/share/gnome/apps" +[ -w $gnome_global_dir ] || gnome_global_dir= + +[ -f /etc/mandriva-release ] && need_mandriva_fix=true +[ -n "$need_mandriva_fix" ] && DEBUG 1 "Fixing up .desktop categories (Mandriva work around)" + +DEBUG 3 "Install locations for *.desktop files:" +DEBUG 3 "xdg_user_dir: $xdg_user_dir" +DEBUG 3 "xdg_global_dir: $xdg_global_dir" +DEBUG 3 "kde_user_dir: $kde_user_dir" +DEBUG 3 "kde_global_dir: $kde_global_dir" +DEBUG 3 "gnome_user_dir: $gnome_user_dir" +DEBUG 3 "gnome_global_dir: $gnome_global_dir" + +if [ x"$mode" = x"user" ] ; then + xdg_dir="$xdg_user_dir" + kde_dir="$kde_user_dir" + gnome_dir="$gnome_user_dir" + my_umask=077 +else + xdg_dir="$xdg_global_dir" + kde_dir="$kde_global_dir" + gnome_dir="$gnome_global_dir" + my_umask=022 + if [ -z "${xdg_dir}${kde_dir}${gnome_dir}" ] ; then + exit_failure_operation_impossible "No writable system menu directory found." + fi +fi + +for desktop_file in $desktop_files; do + if [ "$vendor" = "true" -a "$action" = "install" ] ; then + check_vendor_prefix "$desktop_file" + fi + + basefile=`basename $desktop_file` + + DEBUG 1 "$action $desktop_file in $xdg_dir $kde_dir $gnome_dir" + + case $action in + install) + save_umask=`umask` + umask $my_umask + + for x in $xdg_dir $kde_dir $gnome_dir ; do + mkdir -p $x + eval 'cp $desktop_file $x/$basefile'$xdg_redirect_output + done + + if [ -n "$need_mandriva_fix" ] ; then + fixup_mandriva_categories $xdg_dir/$basefile + fi + + if [ -f $kde_dir/$basefile ] ; then + echo "OnlyShowIn=Old;" >> $kde_dir/$basefile + fi + + if [ -f $gnome_dir/$basefile ] ; then + echo "OnlyShowIn=Old;" >> $gnome_dir/$basefile + fi + + make_lazy_default "$xdg_dir" "$basefile" + + umask $save_umask + ;; + + uninstall) + for x in $xdg_dir $kde_dir $gnome_dir ; do + rm -f $x/$basefile + done + + ;; + esac +done + +if [ x"$update" = x"yes" ] ; then + update_desktop_database +fi + +exit_success diff --git a/mk/linux/mojosetup/meta/xdg-utils/xdg-open b/mk/linux/mojosetup/meta/xdg-utils/xdg-open new file mode 100755 index 00000000..6797948f --- /dev/null +++ b/mk/linux/mojosetup/meta/xdg-utils/xdg-open @@ -0,0 +1,145 @@ +#!/bin/sh +#(obfuscated for size by shrinksh.sh) +#Copyright 2006, Kevin Krammer +#Copyright 2006, Jeremy White +#LICENSE: +#Permission is hereby granted, free of charge, to any person obtaining a +#copy of this software and associated documentation files (the "Software"), +#to deal in the Software without restriction, including without limitation +#the rights to use, copy, modify, merge, publish, distribute, sublicense, +#and/or sell copies of the Software, and to permit persons to whom the +#Software is furnished to do so, subject to the following conditions: +#The above copyright notice and this permission notice shall be included +#in all copies or substantial portions of the Software. +#THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +#OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +#FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +#THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR +#OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, +#ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +#OTHER DEALINGS IN THE SOFTWARE. +f1() +{ +if [ $# -gt 0 ]; then +echo "$@" +echo +fi +exit 0 +} +f2() +{ +exit 1 +} +f3() +{ +exit 3 +} +f4() +{ +exit 4 +} +f5() +{ +if [ x"$KDE_FULL_SESSION" = x"true" ]; then DE=kde; +elif [ x"$GNOME_DESKTOP_SESSION_ID" != x"" ]; then DE=gnome; +elif xprop -root _DT_SAVE_MODE | grep ' = \"xfce4\"$' >/dev/null 2>&1; then DE=xfce; +fi +} +f6() +{ +version=`kde-config --version 2>/dev/null | grep KDE` +major=`echo $version | sed 's/KDE: \([0-9]\).*/\1/'` +minor=`echo $version | sed 's/KDE: [0-9]*\.\([0-9]\).*/\1/'` +release=`echo $version | sed 's/KDE: [0-9]*\.[0-9]*\.\([0-9]\).*/\1/'` +test "$major" -gt 3 && return $1 +test "$minor" -gt 5 && return $1 +test "$release" -gt 4 && return $1 +return 0 +} +f7() +{ +kfmclient exec "$1" +f6 $? +if [ $? -eq 0 ]; then +f1 +else +f4 +fi +} +f8() +{ +gnome-open "$1" +if [ $? -eq 0 ]; then +f1 +else +f4 +fi +} +f9() +{ +exo-open "$1" +if [ $? -eq 0 ]; then +f1 +else +f4 +fi +} +f10() +{ +IFS=":" +for browser in $BROWSER; do +if [ x"$browser" != x"" ]; then +browser_with_arg=`echo "$browser" | sed s#%s#"$1"#` +if [ x"$browser_with_arg" = x"$browser" ]; then "$browser" "$1"; +else $browser_with_arg; +fi +if [ $? -eq 0 ]; then f1; +fi +fi +done +f3 +} +[ x"$1" != x"" ] || f2 +url= +while [ $# -gt 0 ] ; do +parm="$1" +shift +case "$parm" in +-*) +f2 +;; +*) +if [ -n "$url" ] ; then +f2 +fi +url="$parm" +;; +esac +done +if [ -z "${url}" ] ; then +f2 +fi +f5 +if [ x"$DE" = x"" ]; then +if [ x"$BROWSER" = x"" ]; then +BROWSER=firefox:mozilla:netscape +fi +DE=generic +fi +case "$DE" in +kde) +f7 "$url" +;; +gnome) +f8 "$url" +;; +xfce) +f9 "$url" +;; +generic) +f10 "$url" +;; +*) +f3 +;; +esac diff --git a/mk/linux/mojosetup/misc/FindCurses.cmake b/mk/linux/mojosetup/misc/FindCurses.cmake new file mode 100644 index 00000000..3107d758 --- /dev/null +++ b/mk/linux/mojosetup/misc/FindCurses.cmake @@ -0,0 +1,179 @@ +# - Find the curses include file and library +# +# CURSES_FOUND - system has Curses +# CURSES_INCLUDE_DIR - the Curses include directory +# CURSES_LIBRARIES - The libraries needed to use Curses +# CURSES_HAVE_CURSES_H - true if curses.h is available +# CURSES_HAVE_NCURSES_H - true if ncurses.h is available +# CURSES_HAVE_NCURSES_NCURSES_H - true if ncurses/ncurses.h is available +# CURSES_HAVE_NCURSES_CURSES_H - true if ncurses/curses.h is available +# CURSES_LIBRARY - set for backwards compatibility with 2.4 CMake +# +# Set CURSES_NEED_NCURSES to TRUE before the FIND_PACKAGE() command if NCurses +# functionality is required. + +# Set CURSES_NEED_WIDE to TRUE before the FIND_PACKAGE() command if unicode +# functionality is required + +SET(CURSES_LIBRARY_NAME "curses") +SET(NCURSES_LIBRARY_NAME "ncurses") +IF(CURSES_NEED_WIDE) + SET(CURSES_LIBRARY_NAME "cursesw") + SET(NCURSES_LIBRARY_NAME "ncursesw") +ENDIF(CURSES_NEED_WIDE) + +FIND_LIBRARY(CURSES_CURSES_LIBRARY "${CURSES_LIBRARY_NAME}") +# MESSAGE(STATUS "CURSES! " ${CURSES_CURSES_LIBRARY}) + +FIND_LIBRARY(CURSES_NCURSES_LIBRARY "${NCURSES_LIBRARY_NAME}") +# MESSAGE(STATUS "NCURSES! " ${CURSES_NCURSES_LIBRARY}) + +SET(CURSES_USE_NCURSES FALSE) + +IF(CURSES_NCURSES_LIBRARY AND NOT CURSES_CURSES_LIBRARY) + SET(CURSES_USE_NCURSES TRUE) +ENDIF(CURSES_NCURSES_LIBRARY AND NOT CURSES_CURSES_LIBRARY) + + +# Not sure the logic is correct here. +# If NCurses is required, use the function wsyncup() to check if the library +# has NCurses functionality (at least this is where it breaks on NetBSD). +# If wsyncup is in curses, use this one. +# If not, try to find ncurses and check if this has the symbol. +# Once the ncurses library is found, search the ncurses.h header first, but +# some web pages also say that even with ncurses there is not always a ncurses.h: +# http://osdir.com/ml/gnome.apps.mc.devel/2002-06/msg00029.html +# So at first try ncurses.h, if not found, try to find curses.h under the same +# prefix as the library was found, if still not found, try curses.h with the +# default search paths. +IF(CURSES_CURSES_LIBRARY AND CURSES_NEED_NCURSES) + INCLUDE(CheckLibraryExists) + CHECK_LIBRARY_EXISTS("${CURSES_CURSES_LIBRARY}" + wsyncup "" CURSES_CURSES_HAS_WSYNCUP) + + IF(CURSES_NCURSES_LIBRARY AND NOT CURSES_CURSES_HAS_WSYNCUP) + CHECK_LIBRARY_EXISTS("${CURSES_NCURSES_LIBRARY}" + wsyncup "" CURSES_NCURSES_HAS_WSYNCUP) + IF( CURSES_NCURSES_HAS_WSYNCUP) + SET(CURSES_USE_NCURSES TRUE) + ENDIF( CURSES_NCURSES_HAS_WSYNCUP) + ENDIF(CURSES_NCURSES_LIBRARY AND NOT CURSES_CURSES_HAS_WSYNCUP) + +ENDIF(CURSES_CURSES_LIBRARY AND CURSES_NEED_NCURSES) + + +IF(NOT CURSES_USE_NCURSES) + FIND_FILE(CURSES_HAVE_CURSES_H curses.h ) + FIND_FILE(CURSES_HAVE_CURSESW_H cursesw.h ) + FIND_PATH(CURSES_CURSES_H_PATH curses.h ) + FIND_PATH(CURSES_CURSESW_H_PATH cursesw.h ) + GET_FILENAME_COMPONENT(_cursesLibDir "${CURSES_CURSES_LIBRARY}" PATH) + GET_FILENAME_COMPONENT(_cursesParentDir "${_cursesLibDir}" PATH) + + # for compatibility with older FindCurses.cmake this has to be in the cache + # FORCE must not be used since this would break builds which preload a cache wqith these variables set + SET(CURSES_INCLUDE_PATH "${CURSES_CURSES_H_PATH} ${CURSES_CURSESW_H_PATH}" + CACHE FILEPATH "The curses include path") + SET(CURSES_LIBRARY "${CURSES_CURSES_LIBRARY}" + CACHE FILEPATH "The curses library") +ELSE(NOT CURSES_USE_NCURSES) +# we need to find ncurses + GET_FILENAME_COMPONENT(_cursesLibDir "${CURSES_NCURSES_LIBRARY}" PATH) + GET_FILENAME_COMPONENT(_cursesParentDir "${_cursesLibDir}" PATH) + + FIND_FILE(CURSES_HAVE_NCURSES_H ncurses.h) + FIND_FILE(CURSES_HAVE_NCURSES_NCURSES_H ncurses/ncurses.h) + FIND_FILE(CURSES_HAVE_NCURSES_CURSES_H ncurses/curses.h) + FIND_FILE(CURSES_HAVE_CURSES_H curses.h + HINTS "${_cursesParentDir}/include") + + FIND_FILE(CURSES_HAVE_NCURSESW_H ncursesw.h) + FIND_FILE(CURSES_HAVE_NCURSESW_NCURSES_H ncursesw/ncurses.h) + FIND_FILE(CURSES_HAVE_NCURSESW_CURSES_H ncursesw/curses.h) + FIND_FILE(CURSES_HAVE_CURSESW_H cursesw.h + HINTS "${_cursesParentDir}/include") + + FIND_PATH(CURSES_NCURSES_INCLUDE_PATH ncurses.h ncurses/ncurses.h + ncurses/curses.h ncursesw.h ncursesw/ncurses.h ncursesw/curses.h cursesw.h) + FIND_PATH(CURSES_NCURSES_INCLUDE_PATH curses.h + HINTS "${_cursesParentDir}/include") + + # for compatibility with older FindCurses.cmake this has to be in the cache + # FORCE must not be used since this would break builds which preload + # a cache wqith these variables set + # only put ncurses include and library into + # variables if they are found + IF(CURSES_NCURSES_INCLUDE_PATH AND CURSES_NCURSES_LIBRARY) + + SET(CURSES_INCLUDE_PATH "${CURSES_NCURSES_INCLUDE_PATH} ${CURSES_NCURSESW_INCLUDE_PATH}" + CACHE FILEPATH "The curses include path") + SET(CURSES_LIBRARY "${CURSES_NCURSES_LIBRARY}" + CACHE FILEPATH "The curses library") + ENDIF(CURSES_NCURSES_INCLUDE_PATH AND CURSES_NCURSES_LIBRARY) + +ENDIF(NOT CURSES_USE_NCURSES) + + + +FIND_LIBRARY(CURSES_EXTRA_LIBRARY cur_colr HINTS "${_cursesLibDir}") +FIND_LIBRARY(CURSES_EXTRA_LIBRARY cur_colr ) + +SET(CURSES_FORM_LIBRARY_NAME "form") +IF(CURSES_NEED_WIDE) + SET(CURSES_FORM_LIBRARY_NAME "formw") +ENDIF(CURSES_NEED_WIDE) + +FIND_LIBRARY(CURSES_CURSES_LIBRARY "${CURSES_LIBRARY_NAME}") +FIND_LIBRARY(CURSES_FORM_LIBRARY "${CURSES_FORM_LIBRARY_NAME}" HINTS "${_cursesLibDir}") +FIND_LIBRARY(CURSES_FORM_LIBRARY "${CURSES_FORM_LIBRARY_NAME}" ) + +# for compatibility with older FindCurses.cmake this has to be in the cache +# FORCE must not be used since this would break builds which preload a cache +# qith these variables set +SET(FORM_LIBRARY "${CURSES_FORM_LIBRARY}" + CACHE FILEPATH "The curses form library") + +# Need to provide the *_LIBRARIES +SET(CURSES_LIBRARIES ${CURSES_LIBRARY}) + +IF(CURSES_EXTRA_LIBRARY) + SET(CURSES_LIBRARIES ${CURSES_LIBRARIES} ${CURSES_EXTRA_LIBRARY}) +ENDIF(CURSES_EXTRA_LIBRARY) + +IF(CURSES_FORM_LIBRARY) + SET(CURSES_LIBRARIES ${CURSES_LIBRARIES} ${CURSES_FORM_LIBRARY}) +ENDIF(CURSES_FORM_LIBRARY) + +# Proper name is *_INCLUDE_DIR +SET(CURSES_INCLUDE_DIR ${CURSES_INCLUDE_PATH}) + +# handle the QUIETLY and REQUIRED arguments and set CURSES_FOUND to TRUE if +# all listed variables are TRUE +INCLUDE(FindPackageHandleStandardArgs) +FIND_PACKAGE_HANDLE_STANDARD_ARGS(Curses DEFAULT_MSG + CURSES_LIBRARY CURSES_INCLUDE_PATH) + +MARK_AS_ADVANCED( + CURSES_INCLUDE_PATH + CURSES_LIBRARY + CURSES_CURSES_INCLUDE_PATH + CURSES_CURSES_LIBRARY + CURSES_NCURSES_INCLUDE_PATH + CURSES_NCURSES_LIBRARY + CURSES_EXTRA_LIBRARY + FORM_LIBRARY + CURSES_FORM_LIBRARY + CURSES_LIBRARIES + CURSES_INCLUDE_DIR + CURSES_CURSES_HAS_WSYNCUP + CURSES_NCURSES_HAS_WSYNCUP + CURSES_HAVE_CURSESW_H + CURSES_HAVE_CURSES_H + CURSES_HAVE_NCURSESW_CURSES_H + CURSES_HAVE_NCURSESW_H + CURSES_HAVE_NCURSESW_NCURSES_H + CURSES_HAVE_NCURSES_CURSES_H + CURSES_HAVE_NCURSES_H + CURSES_HAVE_NCURSES_NCURSES_H + ) + diff --git a/mk/linux/mojosetup/misc/MacAppBundleSkeleton/Contents/Info.plist b/mk/linux/mojosetup/misc/MacAppBundleSkeleton/Contents/Info.plist new file mode 100644 index 00000000..8de91ae2 --- /dev/null +++ b/mk/linux/mojosetup/misc/MacAppBundleSkeleton/Contents/Info.plist @@ -0,0 +1,27 @@ + + + + + CFBundleDevelopmentRegion + English + CFBundleExecutable + mojosetup + CFBundleIdentifier + org.icculus.mojosetup + CFBundleIconFile + mojosetup.icns + CFBundleInfoDictionaryVersion + 6.0 + CFBundlePackageType + APPL + CFBundleSignature + MjSt + CFBundleShortVersionString + 1.0 + CSResourcesFileMapped + + CFBundleName + YOUR_APPLICATION_NAME_HERE + + + \ No newline at end of file diff --git a/mk/linux/mojosetup/misc/MacAppBundleSkeleton/Contents/PkgInfo b/mk/linux/mojosetup/misc/MacAppBundleSkeleton/Contents/PkgInfo new file mode 100644 index 00000000..d9bd9a94 --- /dev/null +++ b/mk/linux/mojosetup/misc/MacAppBundleSkeleton/Contents/PkgInfo @@ -0,0 +1 @@ +APPLMjSt \ No newline at end of file diff --git a/mk/linux/mojosetup/misc/MacAppBundleSkeleton/Contents/Resources/mojosetup.icns b/mk/linux/mojosetup/misc/MacAppBundleSkeleton/Contents/Resources/mojosetup.icns new file mode 100644 index 00000000..4b1e5a23 Binary files /dev/null and b/mk/linux/mojosetup/misc/MacAppBundleSkeleton/Contents/Resources/mojosetup.icns differ diff --git a/mk/linux/mojosetup/misc/MojoSetup.xib b/mk/linux/mojosetup/misc/MojoSetup.xib new file mode 100644 index 00000000..0d3e2e6c --- /dev/null +++ b/mk/linux/mojosetup/misc/MojoSetup.xib @@ -0,0 +1,1918 @@ + + + + 1050 + 9G55 + 677 + 949.43 + 353.00 + + YES + + + + + YES + com.apple.InterfaceBuilder.CocoaPlugin + + + YES + + YES + + + YES + + + + YES + + NSApplication + + + FirstResponder + + + NSApplication + + + NSFontManager + + + AMainMenu + + YES + + + MojoSetup + + 2147483647 + + NSImage + NSMenuCheckmark + + + NSImage + NSMenuMixedState + + submenuAction: + + MojoSetup + + YES + + + About MojoSetup + + 2147483647 + + + + + + YES + YES + + + 2147483647 + + + + + + Services + + 2147483647 + + + submenuAction: + + Services + + YES + + _NSServicesMenu + + + + + YES + YES + + + 2147483647 + + + + + + Hide MojoSetup + h + 1048576 + 2147483647 + + + + + + Hide Others + h + 1572864 + 2147483647 + + + + + + Show All + + 2147483647 + + + + + + YES + YES + + + 2147483647 + + + + + + Quit MojoSetup + q + 1048576 + 2147483647 + + + + + _NSAppleMenu + + + + + Window + + 2147483647 + + + submenuAction: + + Window + + YES + + + Minimize + m + 1048576 + 2147483647 + + + + + + Zoom + + 2147483647 + + + + + + YES + YES + + + 2147483647 + + + + + + Bring All to Front + + 2147483647 + + + + + _NSWindowsMenu + + + + _NSMainMenu + + + 15 + 2 + {{510, 200}, {508, 450}} + 603979776 + MojoSetup + NSWindow + + {3.40282e+38, 3.40282e+38} + + + 256 + + YES + + + 289 + {{374, 19}, {120, 32}} + + YES + + 67239424 + 134217728 + Next + + LucidaGrande + 1.300000e+01 + 1044 + + + -2038284033 + 129 + + + 200 + 25 + + + + + 274 + {{19, 67}, {469, 363}} + + + YES + + Empty + + + 274 + {469, 363} + + Empty + + 6 + System + controlColor + + 3 + MC42NjY2NjY2OQA + + + + + + Readme + + + 274 + + YES + + + 274 + + YES + + + 2304 + + YES + + + 2322 + {452, 12} + + + + + + + + + + + YES + + + 6 + + + + 4.520000e+02 + 1 + + + 2305 + + 3 + MQA + + + 3 + MAA + + + YES + + YES + NSBackgroundColor + NSColor + + + YES + + 6 + System + selectedTextBackgroundColor + + + + 6 + System + selectedTextColor + + + + + + + YES + + YES + NSColor + NSUnderline + + + YES + + 1 + MCAwIDEAA + + + + + + + 6 + {767, 1e+07} + {223, 0} + + + + {{1, 1}, {452, 361}} + + + + + {4, -5} + 1 + + 4 + + + + 256 + {{453, 1}, {15, 361}} + + + _doScroller: + 9.679145e-01 + + + + 256 + {{-100, -100}, {87, 18}} + + 1 + + _doScroller: + 1.000000e+00 + 9.456522e-01 + + + {469, 363} + + 18 + + + + + + {469, 363} + + Readme + + + + + Options + + + 274 + {469, 363} + + Options + + + + + Destination + + + 274 + + YES + + + 270 + {{0, 319}, {354, 26}} + + YES + + 343014976 + 272630784 + + + + YES + + 6 + System + textBackgroundColor + + + + 6 + System + controlTextColor + + + 5 + YES + + + + 274 + {15, 0} + + + YES + + YES + + + 1.200000e+01 + 1.000000e+01 + 1.000000e+03 + + 75628032 + 0 + + + LucidaGrande + 1.200000e+01 + 16 + + + 3 + MC4zMzMzMzI5OQA + + + + + 338820672 + 1024 + + + YES + + 6 + System + controlBackgroundColor + + + + + 3 + YES + + + + 3.000000e+00 + 2.000000e+00 + + + 6 + System + gridColor + + 3 + MC41AA + + + 1.900000e+01 + tableViewAction: + -767524864 + + + + 1 + 15 + 0 + YES + + + + + + 265 + {{353, 315}, {122, 32}} + + YES + + -2080244224 + 134217728 + Browse + + + -2038284033 + 129 + + + 200 + 25 + + + + {469, 363} + + Destination + + + + + ProductKey + + + 274 + + YES + + + 274 + + YES + + YES + Apple PDF pasteboard type + Apple PICT pasteboard type + Apple PNG pasteboard type + NSFilenamesPboardType + NeXT Encapsulated PostScript v1.2 pasteboard type + NeXT TIFF v4.0 pasteboard type + + + {469, 363} + + YES + + 130560 + 33554432 + + NSImage + NSStopProgressFreestandingTemplate + + 0 + 0 + 0 + YES + + YES + + + {469, 363} + + ProductKey + + + + + Progress + + + 274 + + YES + + + 1322 + + {{35, 166}, {398, 20}} + + 16394 + 1.000000e+02 + + + + 298 + {{34, 194}, {400, 17}} + + YES + + 68288064 + 272630784 + + + Component + + + + + + + + 298 + {{34, 151}, {400, 11}} + + YES + + 68288064 + 272892928 + + + LucidaGrande + 9.000000e+00 + 3614 + + Item + + + + + + + {469, 363} + + Progress + + + + + Final + + + 274 + + YES + + + 274 + {{34, 79}, {401, 205}} + + YES + + 67239424 + 138412032 + + + LucidaGrande + 1.300000e+01 + 16 + + Final Text + + YES + + + + + + {469, 363} + + + Final + + + + + + + 6 + YES + YES + + YES + + + + + + 289 + {{254, 19}, {120, 32}} + + YES + + -1543373312 + 134217728 + Back + + + -2038284033 + 129 + + + 200 + 25 + + + + + 298 + {{17, 433}, {474, 17}} + + YES + + 67239488 + 138414080 + + + Title + + + + + + + + 289 + {{134, 19}, {120, 32}} + + YES + + 67239424 + 134217728 + Cancel + + + -2038284033 + 129 + + + 200 + 25 + + + + {508, 450} + + + {{0, 0}, {1440, 878}} + {3.40282e+38, 3.40282e+38} + + + MojoSetupController + + + + + YES + + + performMiniaturize: + + + + 37 + + + + arrangeInFront: + + + + 39 + + + + orderFrontStandardAboutPanel: + + + + 142 + + + + performZoom: + + + + 240 + + + + hide: + + + + 369 + + + + hideOtherApplications: + + + + 370 + + + + unhideAllApplications: + + + + 372 + + + + nextClicked: + + + + 502 + + + + backClicked: + + + + 503 + + + + cancelClicked: + + + + 512 + + + + BackButton + + + + 513 + + + + NextButton + + + + 514 + + + + CancelButton + + + + 515 + + + + delegate + + + + 517 + + + + MainWindow + + + + 519 + + + + TabView + + + + 520 + + + + ReadmeText + + + + 523 + + + + TitleLabel + + + + 528 + + + + DestinationCombo + + + + 542 + + + + browseClicked: + + + + 543 + + + + FinalText + + + + 546 + + + + ProgressBar + + + + 552 + + + + ProgressComponentLabel + + + + 553 + + + + ProgressItemLabel + + + + 554 + + + + menuQuit: + + + + 555 + + + + QuitMenuItem + + + + 556 + + + + AboutMenuItem + + + + 557 + + + + HideMenuItem + + + + 560 + + + + WindowMenuItem + + + + 561 + + + + HideOthersMenuItem + + + + 562 + + + + ShowAllMenuItem + + + + 563 + + + + ServicesMenuItem + + + + 564 + + + + MinimizeMenuItem + + + + 565 + + + + ZoomMenuItem + + + + 566 + + + + BringAllToFrontMenuItem + + + + 567 + + + + OptionsView + + + + 568 + + + + + YES + + 0 + + YES + + + + + + -2 + + + RmlsZSdzIE93bmVyA + + + -1 + + + First Responder + + + -3 + + + Application + + + 29 + + + YES + + + + + Main Menu + + + 19 + + + YES + + + + + + 56 + + + YES + + + + + + 57 + + + YES + + + + + + + + + + + + + + 58 + + + + + 134 + + + + + 150 + + + + + 136 + + + + + 144 + + + + + 236 + + + + + 131 + + + YES + + + + + + 149 + + + + + 145 + + + + + 130 + + + + + 24 + + + YES + + + + + + + + + 92 + + + + + 5 + + + + + 239 + + + + + 23 + + + + + 367 + + + YES + + + + MainWindow + + + 368 + + + YES + + + + + + + + + + 373 + + + + + 449 + + + YES + + + + NextButton + + + 450 + + + + + 457 + + + YES + + + + + + + + + + + + 458 + + + YES + + + + + + 459 + + + YES + + + + + + 460 + + + YES + + + + + 461 + + + YES + + + + + + 463 + + + YES + + + + + + 464 + + + YES + + + + + + + 465 + + + YES + + + + + + 466 + + + YES + + + + + + 467 + + + YES + + + + + + 468 + + + YES + + + + + + + + 483 + + + YES + + + + + + 484 + + + YES + + + + + + 489 + + + YES + + + + + + 490 + + + + + 496 + + + YES + + + + BackButton + + + 497 + + + + + 495 + + + MojoSetupController + + + 524 + + + YES + + + + + + 525 + + + + + 526 + + + YES + + + + + + 527 + + + + + 507 + + + YES + + + + + + + + 510 + + + + + 509 + + + + + 508 + + + + + 537 + + + YES + + + + DestinationCombo + + + 538 + + + + + 539 + + + YES + + + + DestinationBrowseButton + + + 540 + + + + + 544 + + + YES + + + + + + 545 + + + + + 547 + + + ProgressBar + + + 548 + + + YES + + + + ProgressComponentLabel + + + 549 + + + + + 550 + + + YES + + + + ProgressItemLabel + + + 551 + + + + + 504 + + + YES + + + + CancelButton + + + 505 + + + + + + + YES + + YES + -1.IBPluginDependency + -2.IBPluginDependency + -3.IBPluginDependency + 130.IBEditorWindowLastContentRect + 130.IBPluginDependency + 130.ImportedFromIB2 + 130.editorWindowContentRectSynchronizationRect + 131.IBPluginDependency + 131.ImportedFromIB2 + 134.IBPluginDependency + 134.ImportedFromIB2 + 136.IBPluginDependency + 136.ImportedFromIB2 + 144.IBPluginDependency + 144.ImportedFromIB2 + 145.IBPluginDependency + 145.ImportedFromIB2 + 149.IBPluginDependency + 149.ImportedFromIB2 + 150.IBPluginDependency + 150.ImportedFromIB2 + 19.IBPluginDependency + 19.ImportedFromIB2 + 23.IBPluginDependency + 23.ImportedFromIB2 + 236.IBPluginDependency + 236.ImportedFromIB2 + 239.IBPluginDependency + 239.ImportedFromIB2 + 24.IBEditorWindowLastContentRect + 24.IBPluginDependency + 24.ImportedFromIB2 + 24.editorWindowContentRectSynchronizationRect + 29.IBEditorWindowLastContentRect + 29.IBPluginDependency + 29.ImportedFromIB2 + 29.WindowOrigin + 29.editorWindowContentRectSynchronizationRect + 367.IBEditorWindowLastContentRect + 367.IBWindowTemplateEditedContentRect + 367.NSWindowTemplate.visibleAtLaunch + 367.editorWindowContentRectSynchronizationRect + 368.CustomClassName + 368.IBPluginDependency + 373.IBPluginDependency + 449.IBPluginDependency + 450.IBPluginDependency + 457.IBAttributePlaceholdersKey + 457.IBPluginDependency + 458.IBPluginDependency + 459.IBPluginDependency + 460.IBPluginDependency + 461.IBPluginDependency + 463.IBPluginDependency + 464.IBPluginDependency + 465.IBPluginDependency + 466.IBPluginDependency + 467.IBPluginDependency + 468.IBPluginDependency + 483.IBPluginDependency + 484.IBPluginDependency + 489.IBPluginDependency + 490.IBPluginDependency + 495.IBPluginDependency + 496.IBPluginDependency + 497.IBPluginDependency + 5.IBPluginDependency + 5.ImportedFromIB2 + 504.IBPluginDependency + 505.IBPluginDependency + 507.IBPluginDependency + 508.IBPluginDependency + 509.IBPluginDependency + 510.IBPluginDependency + 526.IBPluginDependency + 527.IBPluginDependency + 537.IBPluginDependency + 538.IBPluginDependency + 539.IBPluginDependency + 540.IBPluginDependency + 544.IBPluginDependency + 545.IBPluginDependency + 547.IBPluginDependency + 548.IBPluginDependency + 549.IBPluginDependency + 550.IBPluginDependency + 551.IBPluginDependency + 56.IBPluginDependency + 56.ImportedFromIB2 + 57.IBEditorWindowLastContentRect + 57.IBPluginDependency + 57.ImportedFromIB2 + 57.editorWindowContentRectSynchronizationRect + 58.IBPluginDependency + 58.ImportedFromIB2 + 92.IBPluginDependency + 92.ImportedFromIB2 + + + YES + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + {{643, 753}, {64, 6}} + com.apple.InterfaceBuilder.CocoaPlugin + + {{436, 809}, {64, 6}} + com.apple.InterfaceBuilder.CocoaPlugin + + com.apple.InterfaceBuilder.CocoaPlugin + + com.apple.InterfaceBuilder.CocoaPlugin + + com.apple.InterfaceBuilder.CocoaPlugin + + com.apple.InterfaceBuilder.CocoaPlugin + + com.apple.InterfaceBuilder.CocoaPlugin + + com.apple.InterfaceBuilder.CocoaPlugin + + com.apple.InterfaceBuilder.CocoaPlugin + + com.apple.InterfaceBuilder.CocoaPlugin + + com.apple.InterfaceBuilder.CocoaPlugin + + com.apple.InterfaceBuilder.CocoaPlugin + + {{527, 716}, {197, 73}} + com.apple.InterfaceBuilder.CocoaPlugin + + {{525, 802}, {197, 73}} + {{421, 789}, {189, 20}} + com.apple.InterfaceBuilder.CocoaPlugin + + {74, 862} + {{11, 977}, {478, 20}} + {{334, 294}, {508, 450}} + {{334, 294}, {508, 450}} + + {{11, 666}, {480, 270}} + MojoSetupController + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + + YES + + YES + + + YES + + + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + + {{433, 636}, {210, 153}} + com.apple.InterfaceBuilder.CocoaPlugin + + {{23, 794}, {245, 183}} + com.apple.InterfaceBuilder.CocoaPlugin + + com.apple.InterfaceBuilder.CocoaPlugin + + + + + YES + + YES + + + YES + + + + + YES + + YES + + + YES + + + + 580 + + + + YES + + MojoSetupController + NSObject + + YES + + YES + backClicked: + browseClicked: + cancelClicked: + menuQuit: + nextClicked: + + + YES + NSButton + NSButton + NSButton + NSMenuItem + NSButton + + + + YES + + YES + AboutMenuItem + BackButton + BringAllToFrontMenuItem + CancelButton + DestinationCombo + FinalText + HideMenuItem + HideOthersMenuItem + MainWindow + MinimizeMenuItem + NextButton + OptionsView + ProgressBar + ProgressComponentLabel + ProgressItemLabel + QuitMenuItem + ReadmeText + ServicesMenuItem + ShowAllMenuItem + TabView + TitleLabel + WindowMenuItem + ZoomMenuItem + + + YES + NSMenuItem + NSButton + NSMenuItem + NSButton + NSComboBox + NSTextField + NSMenuItem + NSMenuItem + NSWindow + NSMenuItem + NSButton + NSView + NSProgressIndicator + NSTextField + NSTextField + NSMenuItem + NSTextView + NSMenuItem + NSMenuItem + NSTabView + NSTextField + NSMenuItem + NSMenuItem + + + + IBUserSource + + + + + + 0 + + 3 + + diff --git a/mk/linux/mojosetup/misc/cp.cmake b/mk/linux/mojosetup/misc/cp.cmake new file mode 100644 index 00000000..a2d5858d --- /dev/null +++ b/mk/linux/mojosetup/misc/cp.cmake @@ -0,0 +1,29 @@ +# CMake 2.4.3 lacks a "CMake -E copy" command that handles wildcards. +# +# INPUT: +# +# FROM - absolute pathname with wildcards to copy +# TO - absolute pathname of directory to copy to +# +# TYPICAL USAGE, from inside a custom target or rule: +# +# COMMAND ${CMAKE_COMMAND} +# -D FROM=${mydirectory}/*.dll +# -D TO=${yourdirectory} +# -P ${CMAKE_HOME_DIRECTORY}/cp.cmake + +FILE(GLOB FILELIST "${FROM}") + +FOREACH(LOOPER ${FILELIST}) + MESSAGE(STATUS "Copying ${LOOPER} to ${TO}") + EXEC_PROGRAM("${CMAKE_COMMAND}" ARGS "-E copy '${LOOPER}' '${TO}'" + OUTPUT_VARIABLE EXECOUT + RETURN_VALUE RC + ) + # !!! FIXME: how do you do NOT EQUALS? + IF(NOT RC EQUAL 0) + MESSAGE(STATUS "${EXECOUT}") + MESSAGE(FATAL_ERROR "Copy of '${LOOPER}' failed!") + ENDIF(NOT RC EQUAL 0) +ENDFOREACH(LOOPER) + diff --git a/mk/linux/mojosetup/misc/find_localizable_strings.sh b/mk/linux/mojosetup/misc/find_localizable_strings.sh new file mode 100755 index 00000000..d07c07e1 --- /dev/null +++ b/mk/linux/mojosetup/misc/find_localizable_strings.sh @@ -0,0 +1,4 @@ +#!/bin/sh + +grep -n '_("' *.[chm] scripts/*.lua |perl -w -p -e 's/\A.*?_\((".*?")\).*?\Z/$1/;' |sort |uniq |perl -w -p -e 'chomp; $_ = " [$_] = {\n };\n\n";' + diff --git a/mk/linux/mojosetup/misc/launchpad-import.sh b/mk/linux/mojosetup/misc/launchpad-import.sh new file mode 100755 index 00000000..00300d7a --- /dev/null +++ b/mk/linux/mojosetup/misc/launchpad-import.sh @@ -0,0 +1,21 @@ +#!/bin/bash + +set -e +set -x + +cd `hg root` +hg fetch # will only work on a unmodified working directory. +rm -rf launchpad +mkdir $_ +cd $_ +tar -xzf ~/launchpad-export.tar.gz +../misc/po2localization.pl *.po mojosetup/mojosetup.pot >../scripts/localization.lua +hg diff ../scripts/localization.lua |less +set +x +echo "enter to commit, ctrl-c to abort." +read +set -x +hg commit -m "Latest translations from launchpad.net ..." ../scripts/localization.lua +cd .. +rm -rf launchpad ~/launchpad-export.tar.gz +exit 0 diff --git a/mk/linux/mojosetup/misc/localization2pot.pl b/mk/linux/mojosetup/misc/localization2pot.pl new file mode 100755 index 00000000..ec33a9dc --- /dev/null +++ b/mk/linux/mojosetup/misc/localization2pot.pl @@ -0,0 +1,110 @@ +#!/usr/bin/perl -w + +use warnings; +use strict; +use Encode qw( decode_utf8 ); + +# Fixes unicode dumping to stdio...hopefully you have a utf-8 terminal by now. +binmode(STDIN, ":utf8"); +binmode(STDOUT, ":utf8"); +binmode(STDERR, ":utf8"); + +my $now = `date '+%Y-%m-%d %H:%M:%S%z'`; +chomp($now); + +my $hgver = `hg tip --template 'hg-{rev}:{node|short}' 2>/dev/null`; +$hgver = '???' if ($hgver eq ''); + +my $exportdate = ''; +my $generator = ''; +while () { + chomp; + if (s/\A\-\-\s*(X-Launchpad-Export-Date: .*?)\Z/"$1\\n"/) { + $exportdate = $_; + next; + } + if (s/\A\-\-\s*(X-Generator: .*?)\Z/"$1\\n"/) { + $generator = $_; + next; + } + last if (/MojoSetup.localization = {/); +} + + +print <<__EOF__; +# MojoSetup; a portable, flexible installation application. +# http://icculus.org/mojosetup/ +# +# Please see the file LICENSE.txt in the source's root directory. +# +# This file generated by localization2pot.pl, version $hgver ... +# +# +# NOTE: If you care about Unicode or ASCII chars above 127, this file _MUST_ +# be UTF-8 encoded! If you think you're using a certain high-ascii codepage, +# you're wrong! +# +# Whenever you see a %x sequence, that is replaced with a string at runtime. +# So if you see, "Hello, %0, my name is %1.", then this might become +# "Hello, Alice, my name is Bob." at runtime. If your culture would find +# introducing yourself second to be rude, you might translate this to: +# "My name is %1, hello %0." If you need a literal '%' char, write "%%": +# "Operation is %0%% complete" might give "Operation is 3% complete." +# All strings, from your locale or otherwise, are checked for formatter +# correctness at startup. This is to prevent the installer working fine +# in all reasonable tests, then finding out that one guy in Ghana has a +# crashing installer because his localization forgot to add a %1 somewhere. +# +# Occasionally you might see a "\\n" ... that's a newline character. "\\t" is +# a tab character, and "\\\\" turns into a single "\\" character. +# +# Questions about the intent of a specific string can go to Ryan C. Gordon +# (icculus\@icculus.org). + +#, fuzzy +msgid "" +msgstr "" +"Project-Id-Version: mojosetup $hgver\\n" +"Report-Msgid-Bugs-To: icculus\@icculus.org\\n" +"POT-Creation-Date: $now\\n" +"PO-Revision-Date: $now\\n" +"Last-Translator: Ryan C. Gordon \\n" +"Language-Team: Ryan C. Gordon \\n" +"MIME-Version: 1.0\\n" +"Content-Type: text/plain; charset=UTF-8\\n" +"Content-Transfer-Encoding: 8bit\\n" +$exportdate +$generator + +__EOF__ + + +my $looking_for_end = 0; + +while () { + chomp; + s/\A\s+//; + s/\s+\Z//; + next if ($_ eq ''); + if (/\A};\Z/) { + last if (not $looking_for_end); + $looking_for_end = 0; + next; + } else { + next if $looking_for_end; + } + + if (s/\A\[(\".*?\")\] = {\Z/msgid $1\nmsgstr ""\n/) { + print("$_\n"); + $looking_for_end = 1; + } elsif (s/\A--\s+(.*?)\Z/#. $1/) { + print("$_\n"); + } else { + die("unhandled string: '$_'\n"); + } +} + +print "# end of localization.pot ...\n\n"; + +# end of localization2pot.pl ... + diff --git a/mk/linux/mojosetup/misc/mkdir.cmake b/mk/linux/mojosetup/misc/mkdir.cmake new file mode 100644 index 00000000..3461d042 --- /dev/null +++ b/mk/linux/mojosetup/misc/mkdir.cmake @@ -0,0 +1,18 @@ +# CMake 2.4.3 lacks a "CMake -E mkdir" command. +# It does have a MAKE_DIRECTORY command, but we cannot run it from inside +# a custom rule or target. So, we wrap it in a script, which we can then +# call from a custom command or target. +# +# INPUT: +# +# DIR - absolute pathname of directory to be created +# +# TYPICAL USAGE, from inside a custom target or rule: +# +# COMMAND ${CMAKE_COMMAND} +# -D DIR=${mydirectory} +# -P ${CMAKE_HOME_DIRECTORY}/mkdir.cmake + +MESSAGE(STATUS "Creating directory ${DIR}") +FILE(MAKE_DIRECTORY "${DIR}") + diff --git a/mk/linux/mojosetup/misc/po2localization.pl b/mk/linux/mojosetup/misc/po2localization.pl new file mode 100755 index 00000000..7a0bbf47 --- /dev/null +++ b/mk/linux/mojosetup/misc/po2localization.pl @@ -0,0 +1,182 @@ +#!/usr/bin/perl -w + +use warnings; +use strict; +use Encode qw( decode_utf8 ); + +# Fixes unicode dumping to stdio...hopefully you have a utf-8 terminal by now. +binmode(STDIN, ":utf8"); +binmode(STDOUT, ":utf8"); +binmode(STDERR, ":utf8"); + +my $now = `date '+%Y-%m-%d %H:%M:%S%z'`; +chomp($now); + +my $hgver = `hg tip --template 'hg-{rev}:{node|short}' 2>/dev/null`; +$hgver = '???' if ($hgver eq ''); + +my %languages; +my %comments; +my %msgstrs; +my @strings; +my $saw_template = 0; +my $exportdate = ''; +my $generator = ''; + +foreach (@ARGV) { + my $fname = $_; + my $template = /\.pot\Z/; + + open(POIO, '<', $fname) or die("Failed to open $_: $!\n"); + binmode(POIO, ":utf8"); + + if ($template) { + die("multiple .pot files specified\n") if ($saw_template); + $saw_template = 1; + } + + my $comment = ''; + my $currentlang = ''; + + while () { + chomp; + s/\A\s+//; + s/\s+\Z//; + next if ($_ eq ''); + + if (s/\A\#\.\s*(.*)\Z/$1/) { + if ($template) { + my $txt = $_; + $txt = " $txt" if ($comment ne ''); + $comment .= " -- $txt\n"; + } + next; + } + + next if /\A\#/; + + if (s/msgid\s*\"(.*?)\"\Z/$1/) { + if (($_ eq '') and ($currentlang eq '')) { # initial string. + while () { # Skip most of the metadata. + chomp; + s/\A\s+//; + s/\s+\Z//; + last if ($_ eq ''); + if (/\A\"Language-Team: (.*?) \<(.*?)\@.*?\>\\n"\Z/) { + $currentlang = $2; + if (defined $languages{$currentlang}) { + die("Same language twice: $currentlang\n"); + } elsif ($currentlang eq 'en') { + die("Found an 'en' translation.\n"); + } elsif ($currentlang eq 'en_US') { + die("Found an 'en_US' translation.\n"); + } + $languages{$currentlang} = $1 if (not $template); + } elsif (s/\A\"(X-Launchpad-Export-Date: .*?)\\n\"/$1/) { + $exportdate = $_ if ($template); + } elsif (s/\A"(X-Generator: .*?)\\n\"\Z/$1/) { + $generator = $_ if ($template); + } + } + } elsif ($currentlang eq '') { + die("No current language!\n"); + } else { # new string + my $msgstr = ''; + my $msgid = $_; + while () { # check for multiline msgid strings. + chomp; + s/\A\s+//; + s/\s+\Z//; + if (s/\Amsgstr \"(.*?)\"\Z/$1/) { + $msgstr = $_; + last; + } + if (s/\A\"(.*?)\"\Z/$1/) { + $msgid .= $_; + } else { + die("unexpected line: $_\n"); + } + } + while () { # check for multiline msgstr strings. + chomp; + s/\A\s+//; + s/\s+\Z//; + last if ($_ eq ''); + if (s/\A\"(.*?)\"\Z/$1/) { + $msgstr .= $_; + } else { + die("unexpected line: $_\n"); + } + } + + if ($template) { + push @strings, $msgid; # This is a list, to keep original order. + $comments{$msgid} = $comment; + $comment = ''; + } elsif ($msgstr ne '') { + $msgstrs{$currentlang}{$msgid} = $msgstr; + } + } + } + } + + close(POIO); +} + +die("no template seen\n") if (not $saw_template); + + +print <<__EOF__; +-- MojoSetup; a portable, flexible installation application. +-- +-- Please see the file LICENSE.txt in the source's root directory. +-- +-- DO NOT EDIT BY HAND. +-- This file was generated with po2localization.pl, version $hgver ... +-- on $now +-- +-- Your own installer's localizations go into app_localization.lua instead. +-- If you want to add strings to be translated to this file, contact Ryan +-- (icculus\@icculus.org). If you want to add or change a translation for +-- existing strings, please use our nice web interface here for your work: +-- +-- https://translations.launchpad.net/mojosetup/ +-- +-- ...and that work eventually ends up in this file. +-- +-- $exportdate +-- $generator + +MojoSetup.languages = { +__EOF__ + +print " en_US = \"English (United States)\""; + +foreach (sort keys %languages) { + my $k = $_; + my $v = $languages{$k}; + print ",\n $k = \"$v\"" +} +print "\n};\n\nMojoSetup.localization = {"; + +foreach (@strings) { + my $msgid = $_; + print "\n"; + print $comments{$msgid}; + print " [\"$msgid\"] = {\n"; + my $first = 1; + foreach (sort keys %languages) { + my $k = $_; + my $str = $msgstrs{$k}{$msgid}; + next if ((not defined $str) or ($str eq '')); + print ",\n" if (not $first); + print " $k = \"$str\""; + $first = 0; + } + print "\n };\n"; +} + +print "};\n\n-- end of localization.lua ...\n\n"; + +# end of po2localization.pl ... + diff --git a/mk/linux/mojosetup/misc/rm_recurse.cmake b/mk/linux/mojosetup/misc/rm_recurse.cmake new file mode 100644 index 00000000..910c38b0 --- /dev/null +++ b/mk/linux/mojosetup/misc/rm_recurse.cmake @@ -0,0 +1,18 @@ +# CMake 2.4.5 lacks a "CMake -E 'rm -rf'" command. +# It does have a MAKE_DIRECTORY command, but we cannot run it from inside +# a custom rule or target. So, we wrap it in a script, which we can then +# call from a custom command or target. +# +# INPUT: +# +# DIR - absolute pathname of directory to be created +# +# TYPICAL USAGE, from inside a custom target or rule: +# +# COMMAND ${CMAKE_COMMAND} +# -D DIR=${mydirectory} +# -P ${CMAKE_HOME_DIRECTORY}/rm_recurse.cmake + +MESSAGE(STATUS "Removing directory ${DIR}") +FILE(REMOVE_RECURSE "${DIR}") + diff --git a/mk/linux/mojosetup/misc/shrinksh.pl b/mk/linux/mojosetup/misc/shrinksh.pl new file mode 100755 index 00000000..1f31b7ac --- /dev/null +++ b/mk/linux/mojosetup/misc/shrinksh.pl @@ -0,0 +1,98 @@ +#!/usr/bin/perl + +use strict; +use Shell::Parser; + +my $sawnewline = 1; +my $sawwhitespace = 1; +my $funccount = 0; +my $braces = 0; +my $currentfn = undef; +my %funcmap; +my %funcstart; +my %funcend; +my %funcused; +my @output; + +my $parser = new Shell::Parser handlers => { default => \&dumpnode }; +$parser->parse(join '', <>); + +sub dumpnode { + my $self = shift; + my %args = @_; + + my $token = $args{token}; + my $type = $args{type}; + + if (($type eq 'comment') or ($token eq '')) { + return; + } elsif ($token eq "\n") { + return if ($sawnewline); + $sawnewline = 1; + $sawwhitespace = 1; + push @output, "\n"; + return; + } elsif ($token =~ /\A\s+\Z/) { + return if ($sawwhitespace); + $sawwhitespace = 1; + push @output, ' '; + return; + } else { + $sawnewline = 0; + $sawwhitespace = 0; + + # shrink function names down to "fX" + if ($token eq ')') { + my $prev1 = pop @output; + if ((not defined $prev1) or ($prev1 ne '(')) { + push @output, $prev1; + } else { + my $prev2 = pop @output; + if (defined $prev2) { + $funccount = $funccount + 1; + my $mappedfn = "f${funccount}"; + $currentfn = $prev2; + $funcmap{$currentfn} = $mappedfn; + $funcused{$currentfn} = 0; + $funcstart{$currentfn} = scalar(@output); + $prev2 = $mappedfn; + } + push @output, $prev2; + push @output, $prev1; + } + } elsif ($token eq '{') { + $braces++; + } elsif ($token eq '}') { + $braces--; + if (($braces == 0) and (defined $currentfn)) { + $funcend{$currentfn} = scalar(@output) + 1; + $currentfn = undef; + } + } elsif (defined $funcmap{$token}) { + $funcused{$token} = 1; + $token = $funcmap{$token}; + } + + push @output, $token; + } +} + +foreach my $fn (keys(%funcused)) { + #print STDERR "funcused{'" . $fn . "'} == '" . $funcused{$fn} . "';\n"; + #print STDERR "funcstart{'" . $fn . "'} == '" . $funcstart{$fn} . "';\n"; + #print STDERR "funcend{'" . $fn . "'} == '" . $funcend{$fn} . "';\n"; + #print STDERR "\n"; + next if $funcused{$fn}; + my $fnstart = $funcstart{$fn}; + my $fnend = $funcend{$fn}; + my $len = $fnend - $fnstart; + for (my $i = $fnstart; $i <= $fnend; $i++) { + $output[$i] = undef; + } + #print STDERR "Removed unused function $fn ($len tokens)\n"; +} + +foreach (@output) { + print($_) if defined $_; +} + diff --git a/mk/linux/mojosetup/mojosetup.c b/mk/linux/mojosetup/mojosetup.c new file mode 100644 index 00000000..6aec12b8 --- /dev/null +++ b/mk/linux/mojosetup/mojosetup.c @@ -0,0 +1,1260 @@ +/** + * MojoSetup; a portable, flexible installation application. + * + * Please see the file LICENSE.txt in the source's root directory. + * + * This file written by Ryan C. Gordon. + */ + +#include + +#include "universal.h" +#include "platform.h" +#include "gui.h" +#include "lua_glue.h" +#include "fileio.h" + +#define TEST_LAUNCH_BROWSER_CODE 0 +int MojoSetup_testLaunchBrowserCode(int argc, char **argv); + +#define TEST_ARCHIVE_CODE 0 +int MojoSetup_testArchiveCode(int argc, char **argv); + +#define TEST_NETWORK_CODE 0 +int MojoSetup_testNetworkCode(int argc, char **argv); + + +uint8 scratchbuf_128k[128 * 1024]; +MojoSetupEntryPoints GEntryPoints = +{ + xmalloc, + xrealloc, + xstrdup, + xstrncpy, + translate, + logWarning, + logError, + logInfo, + logDebug, + format, + numstr, + MojoPlatform_ticks, + utf8codepoint, + utf8len, + splitText, + isValidProductKey, +}; + +int GArgc = 0; +const char **GArgv = NULL; + +static char *crashedmsg = NULL; +static char *termedmsg = NULL; + +void MojoSetup_crashed(void) +{ + if (crashedmsg == NULL) + panic("BUG: crash at startup"); + else + fatal(crashedmsg); +} // MojoSetup_crash + + +void MojoSetup_terminated(void) +{ + if (termedmsg == NULL) // no translation yet. + panic("The installer has been stopped by the system."); + else + fatal(termedmsg); +} // MojoSetup_crash + + +#if !SUPPORT_MULTIARCH +#define trySwitchBinaries() +#else +static void trySwitchBinary(MojoArchive *ar) +{ + MojoInput *io = ar->openCurrentEntry(ar); + if (io != NULL) + { + const uint32 imglen = (uint32) io->length(io); + uint8 *img = (uint8 *) xmalloc(imglen); + const uint32 br = io->read(io, img, imglen); + io->close(io); + if (br == imglen) + { + logInfo("Switching binary with '%0'...", ar->prevEnum.filename); + MojoPlatform_switchBin(img, imglen); // no return on success. + logError("...Switch binary failed."); + } // if + free(img); + } // if +} // trySwitchBinary + + +static void trySwitchBinaries(void) +{ + if (cmdlinestr("nobinswitch", "MOJOSETUP_NOBINSWITCH", NULL) != NULL) + return; // we are already switched or the user is preventing it. + + setenv("MOJOSETUP_NOBINSWITCH", "1", 1); + setenv("MOJOSETUP_BASE", GBaseArchivePath, 1); + + if (GBaseArchive->enumerate(GBaseArchive)) + { + const MojoArchiveEntry *entinfo; + while ((entinfo = GBaseArchive->enumNext(GBaseArchive)) != NULL) + { + if (entinfo->type != MOJOARCHIVE_ENTRY_FILE) + continue; + + if (strncmp(entinfo->filename, "arch/", 5) != 0) + continue; + + trySwitchBinary(GBaseArchive); + } // while + } // if + +} // trySwitchBinaries +#endif + + +static boolean trySpawnTerminalGui(void) +{ + if (cmdlinestr("notermspawn", "MOJOSETUP_NOTERMSPAWN", NULL) != NULL) + return false; // we already spawned or the user is preventing it. + + if (MojoPlatform_istty()) // maybe we can spawn a terminal for stdio? + return false; // We're a terminal already, no need to spawn one. + + logInfo("No usable GUI found. Trying to spawn a terminal..."); + if (!MojoPlatform_spawnTerminal()) + { + logError("...Terminal spawning failed."); + return false; + } // if + + assert(MojoPlatform_istty()); + return (MojoGui_initGuiPlugin() != NULL); +} // trySpawnTerminalGui + + +static boolean initEverything(void) +{ + MojoLog_initLogging(); + + logInfo("MojoSetup starting up..."); + + // We have to panic on errors until the GUI is ready. Try to make things + // "succeed" unless they are catastrophic, and report problems later. + + // Start with the base archive work, since it might have GUI plugins. + // None of these panic() calls are localized, since localization isn't + // functional until MojoLua_initLua() succeeds. + if (!MojoArchive_initBaseArchive()) + panic("Initial setup failed. Cannot continue."); + + trySwitchBinaries(); // may not return. + + if (!MojoGui_initGuiPlugin()) + { + // This could terminate the process (and relaunch). + if (!trySpawnTerminalGui()) + panic("Initial GUI setup failed. Cannot continue."); + } // if + + else if (!MojoLua_initLua()) + { + panic("Initial Lua setup failed. Cannot continue."); + } // else if + + crashedmsg = xstrdup(_("The installer has crashed due to a bug.")); + termedmsg = xstrdup(_("The installer has been stopped by the system.")); + + return true; +} // initEverything + + +static void deinitEverything(void) +{ + char *tmp = NULL; + + logInfo("MojoSetup shutting down..."); + MojoLua_deinitLua(); + MojoGui_deinitGuiPlugin(); + MojoArchive_deinitBaseArchive(); + MojoLog_deinitLogging(); + + tmp = crashedmsg; + crashedmsg = NULL; + free(tmp); + tmp = termedmsg; + termedmsg = NULL; + free(tmp); +} // deinitEverything + + +void MojoChecksum_init(MojoChecksumContext *ctx) +{ + memset(ctx, '\0', sizeof (MojoChecksumContext)); + #if SUPPORT_CRC32 + MojoCrc32_init(&ctx->crc32); + #endif + #if SUPPORT_MD5 + MojoMd5_init(&ctx->md5); + #endif + #if SUPPORT_SHA1 + MojoSha1_init(&ctx->sha1); + #endif +} // MojoChecksum_init + + +void MojoChecksum_append(MojoChecksumContext *ctx, const uint8 *d, uint32 len) +{ + #if SUPPORT_CRC32 + MojoCrc32_append(&ctx->crc32, d, len); + #endif + #if SUPPORT_MD5 + MojoMd5_append(&ctx->md5, d, len); + #endif + #if SUPPORT_SHA1 + MojoSha1_append(&ctx->sha1, d, len); + #endif +} // MojoChecksum_append + + +void MojoChecksum_finish(MojoChecksumContext *ctx, MojoChecksums *sums) +{ + memset(sums, '\0', sizeof (MojoChecksums)); + #if SUPPORT_CRC32 + MojoCrc32_finish(&ctx->crc32, &sums->crc32); + #endif + #if SUPPORT_MD5 + MojoMd5_finish(&ctx->md5, sums->md5); + #endif + #if SUPPORT_SHA1 + MojoSha1_finish(&ctx->sha1, sums->sha1); + #endif +} // MojoChecksum_finish + + +boolean cmdline(const char *arg) +{ + int argc = GArgc; + const char **argv = GArgv; + int i; + + if ((arg == NULL) || (argv == NULL)) + return false; + + while (*arg == '-') // Skip all '-' chars, so "--nosound" == "-nosound" + arg++; + + for (i = 1; i < argc; i++) + { + const char *thisarg = argv[i]; + if (*thisarg != '-') + continue; // no dash in the string, skip it. + while (*(++thisarg) == '-') { /* keep looping. */ } + if (strcmp(arg, thisarg) == 0) + return true; + } // for + + return false; +} // cmdline + + +const char *cmdlinestr(const char *arg, const char *envr, const char *deflt) +{ + uint32 len = 0; + int argc = GArgc; + const char **argv = GArgv; + int i; + + if (envr != NULL) + { + const char *val = getenv(envr); + if (val != NULL) + return val; + } // if + + if (arg == NULL) + return deflt; + + while (*arg == '-') // Skip all '-' chars, so "--nosound" == "-nosound" + arg++; + + len = strlen(arg); + + for (i = 1; i < argc; i++) + { + const char *thisarg = argv[i]; + if (*thisarg != '-') + continue; // no dash in the string, skip it. + + while (*(++thisarg) == '-') { /* keep looping. */ } + if (strncmp(arg, thisarg, len) != 0) + continue; // not us. + + thisarg += len; // skip ahead in string to end of match. + + if (*thisarg == '=') // --a=b format. + return (thisarg + 1); + else if (*thisarg == '\0') // --a b format. + return ((argv[i+1] == NULL) ? deflt : argv[i+1]); + } // for + + return deflt; +} // cmdlinestr + + +boolean wildcardMatch(const char *str, const char *pattern) +{ + char sch = *(str++); + while (true) + { + const char pch = *(pattern++); + if (pch == '?') + { + if ((sch == '\0') || (sch == '/')) + return false; + sch = *(str++); + } // else if + + else if (pch == '*') + { + char nextpch = *pattern; + if ((nextpch != '?') && (nextpch != '*')) + { + while ((sch != '\0') && (sch != nextpch)) + sch = *(str++); + } // if + } // else if + + else + { + if (pch != sch) + return false; + else if (pch == '\0') + break; + sch = *(str++); + } // else + } // while + + return true; +} // wildcardMatch + + +const char *numstr(int val) +{ + static int pos = 0; + char *ptr = ((char *) scratchbuf_128k) + (pos * 128); + snprintf(ptr, 128, "%d", val); + pos = (pos + 1) % 1000; + return ptr; +} // numstr + + +static char *format_internal(const char *fmt, va_list ap) +{ + // This is kinda nasty. String manipulation in C always is. + char *retval = NULL; + const char *strs[10]; // 0 through 9. + const char *ptr = NULL; + char *wptr = NULL; + size_t len = 0; + int maxfmtid = -2; + int i; + + // figure out what this format string contains... + for (ptr = fmt; *ptr; ptr++) + { + if (*ptr == '%') + { + const char ch = *(++ptr); + if (ch == '%') // a literal '%' + maxfmtid = (maxfmtid == -2) ? -1 : maxfmtid; + else if ((ch >= '0') && (ch <= '9')) + maxfmtid = ((maxfmtid > (ch - '0')) ? maxfmtid : (ch - '0')); + else + fatal(_("BUG: Invalid format() string")); + } // if + } // while + + if (maxfmtid == -2) // no formatters present at all. + return xstrdup(fmt); // just copy it, we're done. + + for (i = 0; i <= maxfmtid; i++) // referenced varargs --> linear array. + { + strs[i] = va_arg(ap, const char *); + if (strs[i] == NULL) + strs[i] = "(null)"; // just to match sprintf() behaviour... + } // for + + // allocate the string we'll need in one shot, so we don't have to resize. + for (ptr = fmt; *ptr; ptr++) + { + if (*ptr != '%') + len++; + else + { + const char ch = *(++ptr); + if (ch == '%') // a literal '%' + len++; // just want '%' char. + else //if ((ch >= '0') && (ch <= '9')) + len += strlen(strs[ch - '0']); + } // else + } // while + + // Now write the formatted string... + wptr = retval = (char *) xmalloc(len+1); + for (ptr = fmt; *ptr; ptr++) + { + const char strch = *ptr; + if (strch != '%') + *(wptr++) = strch; + else + { + const char ch = *(++ptr); + if (ch == '%') // a literal '%' + *(wptr++) = '%'; + else //if ((ch >= '0') && (ch <= '9')) + { + const char *str = strs[ch - '0']; + strcpy(wptr, str); + wptr += strlen(str); + } // else + } // else + } // while + *wptr = '\0'; + + return retval; +} // format_internal + + +char *format(const char *fmt, ...) +{ + char *retval = NULL; + va_list ap; + va_start(ap, fmt); + retval = format_internal(fmt, ap); + va_end(ap); + return retval; +} // format + + +#if ((defined _NDEBUG) || (defined NDEBUG)) +#define DEFLOGLEV "info" +#else +#define DEFLOGLEV "everything" +#endif +MojoSetupLogLevel MojoLog_logLevel = MOJOSETUP_LOG_EVERYTHING; +static void *logFile = NULL; + +void MojoLog_initLogging(void) +{ + const char *level = cmdlinestr("loglevel","MOJOSETUP_LOGLEVEL", DEFLOGLEV); + const char *fname = cmdlinestr("log", "MOJOSETUP_LOG", NULL); + + if (strcmp(level, "nothing") == 0) + MojoLog_logLevel = MOJOSETUP_LOG_NOTHING; + else if (strcmp(level, "errors") == 0) + MojoLog_logLevel = MOJOSETUP_LOG_ERRORS; + else if (strcmp(level, "warnings") == 0) + MojoLog_logLevel = MOJOSETUP_LOG_WARNINGS; + else if (strcmp(level, "info") == 0) + MojoLog_logLevel = MOJOSETUP_LOG_INFO; + else if (strcmp(level, "debug") == 0) + MojoLog_logLevel = MOJOSETUP_LOG_DEBUG; + else // Unknown string gets everything...that'll teach you. + MojoLog_logLevel = MOJOSETUP_LOG_EVERYTHING; + + if ((fname != NULL) && (strcmp(fname, "-") == 0)) + logFile = MojoPlatform_stdout(); + else if (fname != NULL) + { + const uint32 flags = MOJOFILE_WRITE|MOJOFILE_CREATE|MOJOFILE_TRUNCATE; + const uint16 mode = MojoPlatform_defaultFilePerms(); + logFile = MojoPlatform_open(fname, flags, mode); + } // if +} // MojoLog_initLogging + + +void MojoLog_deinitLogging(void) +{ + if (logFile != NULL) + { + MojoPlatform_close(logFile); + logFile = NULL; + } // if +} // MojoLog_deinitLogging + + +static inline void addLog(MojoSetupLogLevel level, char levelchar, + const char *fmt, va_list ap) +{ + if (level <= MojoLog_logLevel) + { + char *str = format_internal(fmt, ap); + //int len = vsnprintf(buf + 2, sizeof (buf) - 2, fmt, ap) + 2; + //buf[0] = levelchar; + //buf[1] = ' '; + int len = strlen(str); + while ( (--len >= 0) && ((str[len] == '\n') || (str[len] == '\r')) ) {} + str[len+1] = '\0'; // delete trailing newline crap. + MojoPlatform_log(str); + if (logFile != NULL) + { + const char *endl = MOJOPLATFORM_ENDLINE; + MojoPlatform_write(logFile, str, strlen(str)); + MojoPlatform_write(logFile, endl, strlen(endl)); + MojoPlatform_flush(logFile); + } // if + free(str); + } // if +} // addLog + + +void logWarning(const char *fmt, ...) +{ + va_list ap; + va_start(ap, fmt); + addLog(MOJOSETUP_LOG_WARNINGS, '-', fmt, ap); + va_end(ap); +} // logWarning + + +void logError(const char *fmt, ...) +{ + va_list ap; + va_start(ap, fmt); + addLog(MOJOSETUP_LOG_ERRORS, '!', fmt, ap); + va_end(ap); +} // logError + + +void logInfo(const char *fmt, ...) +{ + va_list ap; + va_start(ap, fmt); + addLog(MOJOSETUP_LOG_INFO, '*', fmt, ap); + va_end(ap); +} // logInfo + + +void logDebug(const char *fmt, ...) +{ + va_list ap; + va_start(ap, fmt); + addLog(MOJOSETUP_LOG_DEBUG, '#', fmt, ap); + va_end(ap); +} // logDebug + + +uint32 profile(const char *what, uint32 start_time) +{ + uint32 retval = MojoPlatform_ticks() - start_time; + if (what != NULL) + logDebug("%0 took %1 ms.", what, numstr((int) retval)); + return retval; +} // profile_start + + +int fatal(const char *fmt, ...) +{ + static boolean in_fatal = false; + + if (in_fatal) + return panic("BUG: fatal() called more than once!"); + + in_fatal = true; + + // may not want to show a message, since we displayed one elsewhere, etc. + if (fmt != NULL) + { + char *buf = NULL; + va_list ap; + va_start(ap, fmt); + buf = format_internal(fmt, ap); + va_end(ap); + + logError("FATAL: %0", buf); + + if (GGui != NULL) + GGui->msgbox(_("Fatal error"), buf); + + free(buf); + } // if + + // Shouldn't call fatal() before app is initialized! + if ( (GGui == NULL) || (!MojoLua_initialized()) ) + panic("fatal() called before app is initialized! Panicking..."); + + MojoLua_callProcedure("revertinstall"); + + deinitEverything(); + exit(23); + return 0; +} // fatal + + +int panic(const char *err) +{ + static int panic_runs = 0; + + panic_runs++; + if (panic_runs == 1) + { + logError("PANIC: %0", err); + panic(err); + } // if + + else if (panic_runs == 2) + { + boolean domsgbox = ((GGui != NULL) && (GGui->msgbox != NULL)); + if (domsgbox) + GGui->msgbox(_("PANIC"), err); + + if ((GGui != NULL) && (GGui->deinit != NULL)) + GGui->deinit(); + + if (!domsgbox) + panic(err); /* no GUI plugin...double-panic. */ + } // if + + else if (panic_runs == 3) // no GUI or panic panicked...write to stderr... + fprintf(stderr, "\n\n\n%s\n %s\n\n\n", _("PANIC"), err); + + else // panic is panicking in a loop, terminate without any cleanup... + MojoPlatform_die(); + + exit(22); + return 0; // shouldn't hit this. +} // panic + + +char *xstrncpy(char *dst, const char *src, size_t len) +{ + snprintf(dst, len, "%s", src); + return dst; +} // xstrncpy + + +uint32 utf8codepoint(const char **_str) +{ + const char *str = *_str; + uint32 retval = 0; + uint32 octet = (uint32) ((uint8) *str); + uint32 octet2, octet3, octet4; + + if (octet == 0) // null terminator, end of string. + return 0; + + else if (octet < 128) // one octet char: 0 to 127 + { + (*_str)++; // skip to next possible start of codepoint. + return octet; + } // else if + + else if ((octet > 127) && (octet < 192)) // bad (starts with 10xxxxxx). + { + // Apparently each of these is supposed to be flagged as a bogus + // char, instead of just resyncing to the next valid codepoint. + (*_str)++; // skip to next possible start of codepoint. + return UNICODE_BOGUS_CHAR_VALUE; + } // else if + + else if (octet < 224) // two octets + { + octet -= (128+64); + octet2 = (uint32) ((uint8) *(++str)); + if ((octet2 & (128+64)) != 128) // Format isn't 10xxxxxx? + return UNICODE_BOGUS_CHAR_VALUE; + + *_str += 2; // skip to next possible start of codepoint. + retval = ((octet << 6) | (octet2 - 128)); + if ((retval >= 0x80) && (retval <= 0x7FF)) + return retval; + } // else if + + else if (octet < 240) // three octets + { + octet -= (128+64+32); + octet2 = (uint32) ((uint8) *(++str)); + if ((octet2 & (128+64)) != 128) // Format isn't 10xxxxxx? + return UNICODE_BOGUS_CHAR_VALUE; + + octet3 = (uint32) ((uint8) *(++str)); + if ((octet3 & (128+64)) != 128) // Format isn't 10xxxxxx? + return UNICODE_BOGUS_CHAR_VALUE; + + *_str += 3; // skip to next possible start of codepoint. + retval = ( ((octet << 12)) | ((octet2-128) << 6) | ((octet3-128)) ); + + // There are seven "UTF-16 surrogates" that are illegal in UTF-8. + switch (retval) + { + case 0xD800: + case 0xDB7F: + case 0xDB80: + case 0xDBFF: + case 0xDC00: + case 0xDF80: + case 0xDFFF: + return UNICODE_BOGUS_CHAR_VALUE; + } // switch + + // 0xFFFE and 0xFFFF are illegal, too, so we check them at the edge. + if ((retval >= 0x800) && (retval <= 0xFFFD)) + return retval; + } // else if + + else if (octet < 248) // four octets + { + octet -= (128+64+32+16); + octet2 = (uint32) ((uint8) *(++str)); + if ((octet2 & (128+64)) != 128) // Format isn't 10xxxxxx? + return UNICODE_BOGUS_CHAR_VALUE; + + octet3 = (uint32) ((uint8) *(++str)); + if ((octet3 & (128+64)) != 128) // Format isn't 10xxxxxx? + return UNICODE_BOGUS_CHAR_VALUE; + + octet4 = (uint32) ((uint8) *(++str)); + if ((octet4 & (128+64)) != 128) // Format isn't 10xxxxxx? + return UNICODE_BOGUS_CHAR_VALUE; + + *_str += 4; // skip to next possible start of codepoint. + retval = ( ((octet << 18)) | ((octet2 - 128) << 12) | + ((octet3 - 128) << 6) | ((octet4 - 128)) ); + if ((retval >= 0x10000) && (retval <= 0x10FFFF)) + return retval; + } // else if + + // Five and six octet sequences became illegal in rfc3629. + // We throw the codepoint away, but parse them to make sure we move + // ahead the right number of bytes and don't overflow the buffer. + + else if (octet < 252) // five octets + { + octet = (uint32) ((uint8) *(++str)); + if ((octet & (128+64)) != 128) // Format isn't 10xxxxxx? + return UNICODE_BOGUS_CHAR_VALUE; + + octet = (uint32) ((uint8) *(++str)); + if ((octet & (128+64)) != 128) // Format isn't 10xxxxxx? + return UNICODE_BOGUS_CHAR_VALUE; + + octet = (uint32) ((uint8) *(++str)); + if ((octet & (128+64)) != 128) // Format isn't 10xxxxxx? + return UNICODE_BOGUS_CHAR_VALUE; + + octet = (uint32) ((uint8) *(++str)); + if ((octet & (128+64)) != 128) // Format isn't 10xxxxxx? + return UNICODE_BOGUS_CHAR_VALUE; + + *_str += 5; // skip to next possible start of codepoint. + return UNICODE_BOGUS_CHAR_VALUE; + } // else if + + else // six octets + { + octet = (uint32) ((uint8) *(++str)); + if ((octet & (128+64)) != 128) // Format isn't 10xxxxxx? + return UNICODE_BOGUS_CHAR_VALUE; + + octet = (uint32) ((uint8) *(++str)); + if ((octet & (128+64)) != 128) // Format isn't 10xxxxxx? + return UNICODE_BOGUS_CHAR_VALUE; + + octet = (uint32) ((uint8) *(++str)); + if ((octet & (128+64)) != 128) // Format isn't 10xxxxxx? + return UNICODE_BOGUS_CHAR_VALUE; + + octet = (uint32) ((uint8) *(++str)); + if ((octet & (128+64)) != 128) // Format isn't 10xxxxxx? + return UNICODE_BOGUS_CHAR_VALUE; + + octet = (uint32) ((uint8) *(++str)); + if ((octet & (128+64)) != 128) // Format isn't 10xxxxxx? + return UNICODE_BOGUS_CHAR_VALUE; + + *_str += 6; // skip to next possible start of codepoint. + return UNICODE_BOGUS_CHAR_VALUE; + } // else if + + return UNICODE_BOGUS_CHAR_VALUE; +} // utf8codepoint + + +int utf8len(const char *str) +{ + int retval = 0; + while (utf8codepoint(&str)) + retval++; + return retval; +} // utf8len + + +static char *strfrombuf(const char *text, int len) +{ + char *retval = xmalloc(len + 1); + memcpy(retval, text, len); + retval[len] = '\0'; + return retval; +} // strfrombuf + + +char **splitText(const char *text, int scrw, int *_count, int *_w) +{ + int i = 0; + int j = 0; + char **retval = NULL; + int count = 0; + int w = 0; + + *_count = *_w = 0; + while (*text) + { + const char *utf8text = text; + uint32 ch = 0; + int pos = 0; + int furthest = 0; + + for (i = 0; ((ch = utf8codepoint(&utf8text))) && (i < scrw); i++) + { + if ((ch == '\r') || (ch == '\n')) + { + const char nextbyte = *utf8text; + count++; + retval = (char **) xrealloc(retval, count * sizeof (char *)); + retval[count-1] = strfrombuf(text, utf8text - text); + if ((ch == '\r') && (nextbyte == '\n')) // DOS endlines! + utf8text++; // skip it. + text = (char *) utf8text; // update to start of new line. + + if (i > w) + w = i; + i = -1; // will be zero on next iteration... + } // if + else if ((ch == ' ') || (ch == '\t')) + { + if (i != 0) // trim spaces from start of line... + furthest = i; + else + { + text++; + i = -1; // it'll be zero on next iteration. + } // else + } // else if + } // for + + // line overflow or end of stream... + pos = (ch) ? furthest : i; + if ((ch) && (furthest == 0)) // uhoh, no split at all...hack it. + { + pos = utf8len(text); + if (pos > scrw) // too big, have to chop a string in the middle. + pos = scrw; + } // if + + if (pos > 0) + { + utf8text = text; // adjust pointer by redecoding from start... + for (j = 0; j < pos; j++) + utf8codepoint(&utf8text); + + count++; + retval = (char **) xrealloc(retval, count * sizeof (char*)); + retval[count-1] = strfrombuf(text, utf8text - text); + text = (char *) utf8text; + if (pos > w) + w = pos; + } // if + } // while + + *_count = count; + *_w = w; + return retval; +} // splitText + + +static void outOfMemory(void) +{ + // Try to translate "out of memory", but not if it causes recursion. + static boolean already_panicked = false; + const char *errstr = "out of memory"; + if (!already_panicked) + { + already_panicked = true; + errstr = translate(errstr); + } // if + panic(errstr); +} // outOfMemory + + +#undef calloc +void *xmalloc(size_t bytes) +{ + void *retval = calloc(1, bytes); + if (retval == NULL) + outOfMemory(); + return retval; +} // xmalloc +#define calloc(x,y) DO_NOT_CALL_CALLOC__USE_XMALLOC_INSTEAD + +#undef realloc +void *xrealloc(void *ptr, size_t bytes) +{ + void *retval = realloc(ptr, bytes); + if (retval == NULL) + outOfMemory(); + return retval; +} // xrealloc +#define realloc(x,y) DO_NOT_CALL_REALLOC__USE_XREALLOC_INSTEAD + +char *xstrdup(const char *str) +{ + char *retval = (char *) xmalloc(strlen(str) + 1); + strcpy(retval, str); + return retval; +} // xstrdup + + +// We have to supply this function under certain build types. +#if MOJOSETUP_INTERNAL_BZLIB && BZ_NO_STDIO +void bz_internal_error(int errcode) +{ + fatal(_("bzlib triggered an internal error: %0"), numstr(errcode)); +} // bz_internal_error +#endif + + +#if SUPPORT_STBIMAGE +unsigned char *stbi_load_from_memory(unsigned char *buffer, int len, int *x, + int *y, int *comp, int req_comp); +#endif + +uint8 *decodeImage(const uint8 *data, uint32 size, uint32 *w, uint32 *h) +{ + uint8 *retval = MojoPlatform_decodeImage(data, size, w, h); + + #if SUPPORT_STBIMAGE + if (retval == NULL) // try our built-in routines. + { + const int siz = (int) size; + unsigned char *buf = (unsigned char *) data; + int x = 0, y = 0, comp = 0; + retval = (uint8 *) stbi_load_from_memory(buf, siz, &x, &y, &comp, 4); + *w = (uint32) x; + *h = (uint32) y; + } // if + #endif + + if (retval == NULL) + *w = *h = 0; + + return retval; +} // decodeImage + + +boolean isValidProductKey(const char *fmt, const char *key) +{ + if (fmt == NULL) + return true; + else if (key == NULL) + return false; + + while (*fmt) + { + const char fmtch = *(fmt++); + const char keych = *(key++); + switch (fmtch) + { + case '-': + case ' ': + if ((keych == ' ') || (keych == '-')) + break; + key--; // user didn't type this, roll back. + break; + + case '#': + if ((keych >= '0') && (keych <= '9')) + break; + return false; + + case 'X': + if ( ((keych >= 'A') && (keych <= 'Z')) || + ((keych >= 'a') && (keych <= 'z')) ) + break; + return false; + + case '?': + if ( ((keych >= 'A') && (keych <= 'Z')) || + ((keych >= 'a') && (keych <= 'z')) || + ((keych >= '0') && (keych <= '9')) ) + break; + return false; + + case '*': + break; + + default: + // this should have been caught by schema sanitize. + assert(false && "Invalid product key format."); + return false; + } // switch + } // while + + return (*key == '\0'); +} // isValidProductKey + + +// This is called from main()/WinMain()/whatever. +int MojoSetup_main(int argc, char **argv) +{ + GArgc = argc; + GArgv = (const char **) argv; + + if (cmdline("buildver")) + { + printf("%s\n", GBuildVer); + return 0; + } // if + + #if TEST_LAUNCH_BROWSER_CODE + return MojoSetup_testLaunchBrowserCode(argc, argv); + #endif + + #if TEST_ARCHIVE_CODE + return MojoSetup_testArchiveCode(argc, argv); + #endif + + #if TEST_NETWORK_CODE + return MojoSetup_testNetworkCode(argc, argv); + #endif + + if (!initEverything()) + return 1; + + // Jump into Lua for the heavy lifting. + MojoLua_runFile("mojosetup_mainline"); + deinitEverything(); + + return 0; +} // MojoSetup_main + + + +#if TEST_LAUNCH_BROWSER_CODE +int MojoSetup_testLaunchBrowserCode(int argc, char **argv) +{ + int i; + + if (!MojoArchive_initBaseArchive()) // Maybe need for xdg-open script. + panic("Initial setup failed. Cannot continue."); + + printf("Testing browser launching code...\n\n"); + for (i = 1; i < argc; i++) + { + const boolean rc = MojoPlatform_launchBrowser(argv[i]); + printf("Launch '%s': %s\n", argv[i], rc ? "success" : "failure"); + } // for + + MojoArchive_deinitBaseArchive(); + return 0; +} // MojoSetup_testLaunchBrowserCode +#endif + + +#if TEST_ARCHIVE_CODE +int MojoSetup_testArchiveCode(int argc, char **argv) +{ + int i; + printf("Testing archiver code...\n\n"); + for (i = 1; i < argc; i++) + { + MojoArchive *archive = MojoArchive_newFromDirectory(argv[i]); + if (archive != NULL) + printf("directory '%s'...\n", argv[i]); + else + { + MojoInput *io = MojoInput_newFromFile(argv[i]); + if (io != NULL) + { + archive = MojoArchive_newFromInput(io, argv[i]); + if (archive != NULL) + printf("archive '%s'...\n", argv[i]); + } // if + } // else + + if (archive == NULL) + fprintf(stderr, "Couldn't handle '%s'\n", argv[i]); + else + { + if (!archive->enumerate(archive)) + fprintf(stderr, "enumerate() failed.\n"); + else + { + const MojoArchiveEntry *ent; + while ((ent = archive->enumNext(archive)) != NULL) + { + printf("%s ", ent->filename); + if (ent->type == MOJOARCHIVE_ENTRY_FILE) + { + printf("(file, %d bytes, %o)\n", + (int) ent->filesize, ent->perms); + + MojoInput *input = archive->openCurrentEntry(archive); + + if(&archive->prevEnum != ent) + { + fprintf(stderr, "Address of MojoArchiveEntry pointer differs\n"); + exit(EXIT_FAILURE); + } // if + + if(!input) + { + fprintf(stderr, "Could not open current entry\n"); + exit(EXIT_FAILURE); + } // if + + if(!input->ready(input)) + { + input->close(input); + continue; + } // if + + uint64 pos = input->tell(input); + if(0 != pos) + { + fprintf(stderr, "position has to be 0 on start, is: %d\n", (int) pos); + exit(EXIT_FAILURE); + } // if + + int64 filesize = input->length(input); + if(filesize != ent->filesize) + { + fprintf(stderr, "file size mismatch %d != %d\n", + (int) filesize, (int) ent->filesize); + exit(EXIT_FAILURE); + } // if + + boolean ret = input->seek(input, filesize - 1); + if(!ret) + { + fprintf(stderr, "seek() has to return 'true'.\n"); + exit(EXIT_FAILURE); + } // if + + ret = input->seek(input, filesize); + if(ret) + { + fprintf(stderr, "seek() has to return 'false'.\n"); + exit(EXIT_FAILURE); + } // if + + pos = input->tell(input); + if(filesize -1 != pos) + { + fprintf(stderr, "position should be %d after seek(), is: %d\n", + (int) filesize - 1, (int) pos); + exit(EXIT_FAILURE); + } // if + + input->close(input); + } // if + else if (ent->type == MOJOARCHIVE_ENTRY_DIR) + printf("(dir, %o)\n", ent->perms); + else if (ent->type == MOJOARCHIVE_ENTRY_SYMLINK) + printf("(symlink -> '%s')\n", ent->linkdest); + else + { + printf("(UNKNOWN?!, %d bytes, -> '%s', %o)\n", + (int) ent->filesize, ent->linkdest, + ent->perms); + } // else + } // while + } // else + archive->close(archive); + printf("\n\n"); + } // else + } // for + + return 0; +} // MojoSetup_testArchiveCode +#endif + + +#if TEST_NETWORK_CODE +int MojoSetup_testNetworkCode(int argc, char **argv) +{ + int i; + fprintf(stderr, "Testing networking code...\n\n"); + for (i = 1; i < argc; i++) + { + static char buf[64 * 1024]; + uint32 start = 0; + const char *url = argv[i]; + int64 length = -1; + int64 total_br = 0; + int64 br = 0; + printf("\n\nFetching '%s' ...\n", url); + MojoInput *io = MojoInput_newFromURL(url); + if (io == NULL) + { + fprintf(stderr, "failed!\n"); + continue; + } // if + + start = MojoPlatform_ticks(); + while (!io->ready(io)) + MojoPlatform_sleep(10); + fprintf(stderr, "took about %d ticks to get started\n", + (int) (MojoPlatform_ticks() - start)); + + length = io->length(io); + fprintf(stderr, "Ready to read (%lld) bytes.\n", + (long long) length); + + do + { + start = MojoPlatform_ticks(); + if (!io->ready(io)) + { + fprintf(stderr, "Not ready!\n"); + while (!io->ready(io)) + MojoPlatform_sleep(10); + fprintf(stderr, "took about %d ticks to get ready\n", + (int) (MojoPlatform_ticks() - start)); + } // if + + start = MojoPlatform_ticks(); + br = io->read(io, buf, sizeof (buf)); + fprintf(stderr, "read blocked for about %d ticks\n", + (int) (MojoPlatform_ticks() - start)); + if (br > 0) + { + total_br += br; + fprintf(stderr, "read %lld bytes\n", (long long) br); + fwrite(buf, br, 1, stdout); + } // if + } while (br > 0); + + if (br < 0) + fprintf(stderr, "ERROR IN TRANSMISSION.\n\n"); + else + { + fprintf(stderr, "TRANSMISSION COMPLETE!\n\n"); + fprintf(stderr, "(Read %lld bytes, expected %lld.)\n", + (long long) total_br, length); + } // else + io->close(io); + } // for + + return 0; +} // MojoSetup_testNetworkCode +#endif + +// end of mojosetup.c ... + diff --git a/mk/linux/mojosetup/platform.h b/mk/linux/mojosetup/platform.h new file mode 100644 index 00000000..1262147b --- /dev/null +++ b/mk/linux/mojosetup/platform.h @@ -0,0 +1,350 @@ +/** + * MojoSetup; a portable, flexible installation application. + * + * Please see the file LICENSE.txt in the source's root directory. + * + * This file written by Ryan C. Gordon. + */ + +#ifndef _INCL_PLATFORM_H_ +#define _INCL_PLATFORM_H_ + +#include "universal.h" + +#ifdef __cplusplus +extern "C" { +#endif + +// this is called by your mainline. +int MojoSetup_main(int argc, char **argv); + +// Caller must free returned string! +char *MojoPlatform_appBinaryPath(void); + +// Caller must free returned string! +char *MojoPlatform_currentWorkingDir(void); + +// Caller must free returned string! +char *MojoPlatform_homedir(void); + +uint32 MojoPlatform_ticks(void); + +// Make current process kill itself immediately, without any sort of internal +// cleanup, like atexit() handlers or static destructors...the OS will have +// to sort out the freeing of any resources, and no more code in this +// process than necessary should run. This function does not return. Try to +// avoid calling this. +void MojoPlatform_die(void); + +// Delete a file from the physical filesystem. This should remove empty +// directories as well as files. Returns true on success, false on failure. +boolean MojoPlatform_unlink(const char *fname); + +// Resolve symlinks, relative paths, etc. Caller free()'s buffer. Returns +// NULL if path couldn't be resolved. +char *MojoPlatform_realpath(const char *path); + +// Create a symlink in the physical filesystem. (src) is the NAME OF THE LINK +// and (dst) is WHAT IT POINTS TO. This is backwards from the unix symlink() +// syscall! Returns true if link was created, false otherwise. +boolean MojoPlatform_symlink(const char *src, const char *dst); + +// Read the destination from symlink (linkname). Returns a pointer +// allocated with xmalloc() containing the linkdest on success, and NULL +// on failure. The caller is responsible for freeing the returned pointer! +char *MojoPlatform_readlink(const char *linkname); + +// !!! FIXME: we really can't do this in a 16-bit value...non-Unix platforms +// !!! FIXME: and Extended Attributes need more. +// Create a directory in the physical filesystem, with (perms) permissions. +// returns true if directory is created, false otherwise. +boolean MojoPlatform_mkdir(const char *path, uint16 perms); + +// Move a file to a new name. This has to be a fast (if not atomic) operation, +// so if it would require a legitimate copy to another filesystem or device, +// this should fail, as the standard Unix rename() function does. +// Returns true on successful rename, false otherwise. +boolean MojoPlatform_rename(const char *src, const char *dst); + +// Determine if dir/fname exists in the native filesystem. It doesn't matter +// if it's a directory, file, symlink, etc, we're just looking for the +// existance of the entry itself. (fname) may be NULL, in which case, +// (dir) contains the whole path, otherwise, the platform layer needs to +// build the path: (on Unix: dir/path, on Windows: dir\\path, etc). +// This is a convenience thing for the caller. +// Returns true if path in question exists, false otherwise. +boolean MojoPlatform_exists(const char *dir, const char *fname); + +// Returns true if (fname) in the native filesystem is writable. If (fname) +// is a directory, this means that the contents of the directory can be +// added to (create files, delete files, etc). If (fname) is a file, this +// means that this process has write access to the file. +// Returns false if (fname) isn't writable. +boolean MojoPlatform_writable(const char *fname); + +// Returns true if (dir) is a directory in the physical filesystem, false +// otherwise (including if (dir) doesn't exist). Don't follow symlinks. +boolean MojoPlatform_isdir(const char *dir); + +// Returns true if (fname) is a symlink in the physical filesystem, false +// otherwise (including if (fname) doesn't exist). Don't follow symlinks. +boolean MojoPlatform_issymlink(const char *fname); + +// Returns true if stdin and stdout are connected to a tty. +boolean MojoPlatform_istty(void); + +// Returns true if (fname) is a regular file in the physical filesystem, false +// otherwise (including if (fname) doesn't exist). Don't follow symlinks. +boolean MojoPlatform_isfile(const char *fname); + +// Returns size, in bytes, of the file (fname) in the physical filesystem. +// Return -1 if file is missing or not a file. Don't follow symlinks. +int64 MojoPlatform_filesize(const char *fname); + +// !!! FIXME: we really can't do this in a 16-bit value...non-Unix platforms +// !!! FIXME: and Extended Attributes need more. +// !!! FIXME: comment me. +boolean MojoPlatform_perms(const char *fname, uint16 *p); + +// !!! FIXME: we really can't do this in a 16-bit value...non-Unix platforms +// !!! FIXME: and Extended Attributes need more. +// !!! FIXME: comment me. +boolean MojoPlatform_chmod(const char *fname, uint16 p); + +// Try to locate a specific piece of media (usually an inserted CD or DVD). +// (uniquefile) is a path that should exist on the media; its presence +// should uniquely identify the media. +// Returns the path of the media's mount point in the physical filesystem +// (something like "E:\\" on Windows or "/mnt/cdrom" on Unix), or NULL if +// the media isn't found (needed disc isn't inserted, etc). +// Caller must free return value! +char *MojoPlatform_findMedia(const char *uniquefile); + +// Flag values for MojoPlatform_fopen(). +typedef enum +{ + MOJOFILE_READ=(1<<0), + MOJOFILE_WRITE=(1<<1), + MOJOFILE_CREATE=(1<<2), + MOJOFILE_EXCLUSIVE=(1<<3), + MOJOFILE_TRUNCATE=(1<<4), + MOJOFILE_APPEND=(1<<5), +} MojoFileFlags; + +typedef enum +{ + MOJOSEEK_SET, + MOJOSEEK_CURRENT, + MOJOSEEK_END +} MojoFileSeek; + +// !!! FIXME: we really can't do this in a 16-bit value...non-Unix platforms +// !!! FIXME: and Extended Attributes need more. +// Open file (fname). This wraps a subset of the Unix open() syscall. Use +// MojoFileFlags for (flags). If creating a file, use (mode) for the new +// file's permissions. +// Returns an opaque handle on success, NULL on error. Caller must free +// handle with MojoPlatform_close() when done with it. +void *MojoPlatform_open(const char *fname, uint32 flags, uint16 mode); + +// Return a handle that's compatible with MojoPlatform_open()'s return values +// that represents stdout. May return NULL for platforms that don't support +// this concept. You need to make sure that stdout itself doesn't really +// close in MojoPlatform_close(), at least for now. +void *MojoPlatform_stdout(void); + +// Read (bytes) bytes from (fd) into (buf). This wraps the Unix read() syscall. +// Returns number of bytes read, -1 on error. +int64 MojoPlatform_read(void *fd, void *buf, uint32 bytes); + +// Write (bytes) bytes from (buf) into (fd). This wraps the Unix write() +// syscall. Returns number of bytes read, -1 on error. +int64 MojoPlatform_write(void *fd, const void *buf, uint32 bytes); + +// Reports byte offset of file pointer in (fd), or -1 on error. +int64 MojoPlatform_tell(void *fd); + +// Seek to (offset) byte offset of file pointer in (fd), relative to (whence). +// This wraps the Unix lseek() syscall. Returns byte offset from the start +// of the file, -1 on error. +int64 MojoPlatform_seek(void *fd, int64 offset, MojoFileSeek whence); + +// Get the size, in bytes, of a file, referenced by its opaque handle. +// (This pulls the data through an fstat() on Unix.) Retuns -1 on error. +int64 MojoPlatform_flen(void *fd); + +// Force any pending data to disk, returns true on success, false if there +// was an i/o error. +boolean MojoPlatform_flush(void *fd); + +// Free any resources associated with (fd), flushing any pending data to disk, +// and closing the file. (fd) becomes invalid after this call returns +// successfully. This wraps the Unix close() syscall. Returns true on +// success, false on i/o error. +boolean MojoPlatform_close(void *fd); + +// Enumerate a directory. Returns an opaque pointer that can be used with +// repeated calls to MojoPlatform_readdir() to enumerate the names of +// directory entries. Returns NULL on error. Non-NULL values should be passed +// to MojoPlatform_closedir() for cleanup when you are done with them. +void *MojoPlatform_opendir(const char *dirname); + +// Get the next entry in the directory. (dirhandle) is an opaque pointer +// returned by MojoPlatform_opendir(). Returns NULL if we're at the end of +// the directory, or a null-terminated UTF-8 string otherwise. The order of +// results are not guaranteed, and may change between two iterations. +// Caller must free returned string! +char *MojoPlatform_readdir(void *dirhandle); + +// Clean up resources used by a directory enumeration. (dirhandle) is an +// opaque pointer returned by MojoPlatform_opendir(), and becomes invalid +// after this call. +void MojoPlatform_closedir(void *dirhandle); + +// Convert a string into a permissions bitmask. On Unix, this is currently +// expected to be an octal string like "0755", but may expect other forms +// in the future, and other platforms may need to interpret permissions +// differently. (str) may be NULL for defaults, and is considered valid. +// If (str) is not valid, return a reasonable default and set (*valid) to +// false. Otherwise, set (*valid) to true and return the converted value. +uint16 MojoPlatform_makePermissions(const char *str, boolean *valid); + +// Return a default, sane set of permissions for a newly-created file. +uint16 MojoPlatform_defaultFilePerms(void); + +// Return a default, sane set of permissions for a newly-created directory. +uint16 MojoPlatform_defaultDirPerms(void); + +// Wrappers for Unix dlopen/dlsym/dlclose, sort of. Instead of a filename, +// these take a memory buffer for the library. If you can't load this +// directly in RAM, the platform should write it to a temporary file first, +// and deal with cleanup in MojoPlatform_dlclose(). The memory buffer must be +// dereferenced in MojoPlatform_dlopen(), as the caller may free() it upon +// return. Everything else works like the usual Unix calls. +void *MojoPlatform_dlopen(const uint8 *img, size_t len); +void *MojoPlatform_dlsym(void *lib, const char *sym); +void MojoPlatform_dlclose(void *lib); + +// Launch the user's preferred browser to view the URL (url). +// Returns true if the browser launched, false otherwise. We can't know +// if the URL actually loaded, just if the browser launched. The hope is that +// the browser will inform the user if there's a problem loading the URL. +boolean MojoPlatform_launchBrowser(const char *url); + +// Add a menu item to the Application menu or Start bar or whatever. +// (data) is 100% platform dependent right now, and this interface will +// likely change as we come to understand various systems' needs better. +// On Unix, it expects this to be a path to a FreeDesktop .desktop file. +// Returns (true) on success and (false) on failure. +boolean MojoPlatform_installDesktopMenuItem(const char *data); + +// Remove a menu item from the Application menu or Start bar or whatever. +// (data) is 100% platform dependent right now, and this interface will +// likely change as we come to understand various systems' needs better. +// On Unix, it expects this to be a path to a FreeDesktop .desktop file. +// Returns (true) on success and (false) on failure. +boolean MojoPlatform_uninstallDesktopMenuItem(const char *data); + +#if !SUPPORT_MULTIARCH +#define MojoPlatform_switchBin(img, len) +#else +void MojoPlatform_switchBin(const uint8 *img, size_t len); +#endif + +// Try to spawn a terminal, and possibly relaunch MojoSetup within it. +// If we can attach to a terminal without relaunching, do so and +// return true. false for failure to attach/spawn. +// May not return on success (process replaces itself). +boolean MojoPlatform_spawnTerminal(void); + +// Put the calling process to sleep for at least (ticks) milliseconds. +// This is meant to yield the CPU while spinning in a loop that is polling +// for input, etc. Pumping the GUI event queue happens elsewhere, not here. +void MojoPlatform_sleep(uint32 ticks); + +// Put a line of text to the the system log, whatever that might be on a +// given platform. (str) is a complete line, but won't end with any newline +// characters. You should supply if needed. +void MojoPlatform_log(const char *str); + +// This tries to decode a graphic file in memory into an RGBA framebuffer. +// Most platforms return NULL here. No one should call this; use decodeImage() +// instead, which will try included platform-independent code if this fails. +// This function is just here to allow a platform with the appropriate +// functionality to work without compiling in stb_image.c, or supply more +// formats over the built-in code. +// (data) points to the compressed data, (size) is the number of bytes +// of compressed data. (*w) and (*h) will contain the images dimensions on +// return. +// Returns NULL on failure (unsupported, etc) and a pointer to the +// uncompressed data on success. Caller must free() the returned pointer! +uint8 *MojoPlatform_decodeImage(const uint8 *data, uint32 size, + uint32 *w, uint32 *h); + +// Get the current locale, in the format "xx_YY" where "xx" is the language +// (en, fr, de...) and "_YY" is the country. (_US, _CA, etc). The country +// can be omitted. Don't include encoding, it's always UTF-8 at this time. +// Returns locale string, or NULL if it couldn't be determined. +// Caller must free() the returned pointer! +char *MojoPlatform_locale(void); + +// !!! FIXME: document me. +// Caller must free() the returned pointer! +char *MojoPlatform_osType(void); + +// !!! FIXME: document me. +// Caller must free() the returned pointer! +char *MojoPlatform_osVersion(void); + +// !!! FIXME: document me. +uint64 MojoPlatform_getuid(void); + +// !!! FIXME: document me. +uint64 MojoPlatform_geteuid(void); + +// !!! FIXME: document me. +uint64 MojoPlatform_getgid(void); + + +// Basic platform detection. +#if PLATFORM_WINDOWS +#define PLATFORM_NAME "windows" +#elif PLATFORM_MACOSX +#define PLATFORM_NAME "macosx" +#elif PLATFORM_UNIX +#define PLATFORM_NAME "unix" +#elif PLATFORM_BEOS +#define PLATFORM_NAME "beos" +#else +#error Unknown platform. +#endif + +// Basic architecture detection. + +#if defined(__powerpc64__) +#define PLATFORM_ARCH "powerpc64" +#elif defined(__ppc__) || defined(__powerpc__) || defined(__POWERPC__) +#define PLATFORM_ARCH "powerpc" +#elif defined(__x86_64__) || defined(_M_X64) +#define PLATFORM_ARCH "x86-64" +#elif defined(__X86__) || defined(__i386__) || defined(i386) || defined (_M_IX86) || defined(__386__) +#define PLATFORM_ARCH "x86" +#else +#error Unknown processor architecture. +#endif + +// Other basic truths... +#if PLATFORM_WINDOWS +#define MOJOPLATFORM_ENDLINE "\r\n" +#else +#define MOJOPLATFORM_ENDLINE "\n" +#endif + +#ifdef __cplusplus +} +#endif + +#endif + +// end of platform.h ... + diff --git a/mk/linux/mojosetup/platform_beos.cpp b/mk/linux/mojosetup/platform_beos.cpp new file mode 100644 index 00000000..793cf6d5 --- /dev/null +++ b/mk/linux/mojosetup/platform_beos.cpp @@ -0,0 +1,92 @@ +/** + * MojoSetup; a portable, flexible installation application. + * + * Please see the file LICENSE.txt in the source's root directory. + * + * This file written by Ryan C. Gordon. + */ + +// You also need to compile unix.c, but this lets us add some things that +// cause conflicts between the Be headers and MojoSetup, and use C++. These +// are largely POSIX things that are missing from BeOS 5...keeping them here +// even on Zeta lets us be binary compatible across everything, I think. + +#if PLATFORM_BEOS + +#include +#include +#include +#include +#include + +extern "C" { int beos_launchBrowser(const char *url); } +int beos_launchBrowser(const char *url) +{ + static struct { const char *prot, const char *mime } protmimemap[] = + { + { "http://", "text/html" }, + { "https://", "text/html" }, + { "file://", "text/html" }, // let the web browser handle this. + { "ftp://", "application/x-vnd.Be.URL.ftp" }, + { "mailto:", "text/x-email" }, + { NULL, NULL } + }; + + const char *mime = NULL; + + for (int i = 0; protmimemap[i].prot != NULL; i++) + { + const char *prot = protmimemap[i].prot; + if (strncmp(url, prot, strlen(prot)) == 0) + { + mime = protmimemap[i].mime; + break; + } // if + } // for + + if (mime == NULL) + return false; // no handler for this protocol. + + // be_roster is a global object supplied by the system runtime. + return (be_roster->Launch(mime, 1, &url) == B_OK); +} // beos_launchBrowser + + +extern "C" { void *beos_dlopen(const char *fname, int unused); } +void *beos_dlopen(const char *fname, int unused) +{ + const image_id lib = load_add_on(fname); + (void) unused; + if (lib < 0) + return NULL; + return (void *) lib; +} // beos_dlopen + + +extern "C" { void *beos_dlsym(void *lib, const char *sym); } +void *beos_dlsym(void *lib, const char *sym) +{ + void *addr = NULL; + if (get_image_symbol((image_id) lib, sym, B_SYMBOL_TYPE_TEXT, &addr)) + return NULL; + return addr; +} // beos_dlsym + + +extern "C" { void beos_dlclose(void *lib); } +void beos_dlclose(void *lib) +{ + unload_add_on((image_id) lib); +} // beos_dlclose + + +extern "C" { void beos_usleep(unsigned long microseconds); } +void beos_usleep(unsigned long microseconds) +{ + snooze(microseconds); +} // beos_usleep + +#endif // PLATFORM_BEOS + +// end of beos.c ... + diff --git a/mk/linux/mojosetup/platform_unix.c b/mk/linux/mojosetup/platform_unix.c new file mode 100644 index 00000000..5d6fe999 --- /dev/null +++ b/mk/linux/mojosetup/platform_unix.c @@ -0,0 +1,1515 @@ +/** + * MojoSetup; a portable, flexible installation application. + * + * Please see the file LICENSE.txt in the source's root directory. + * + * This file written by Ryan C. Gordon. + */ + +#if PLATFORM_UNIX + +#if PLATFORM_MACOSX +#include +#undef true +#undef false +#endif + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#if MOJOSETUP_HAVE_SYS_UCRED_H +# ifdef MOJOSETUP_HAVE_MNTENT_H +# undef MOJOSETUP_HAVE_MNTENT_H /* don't do both... */ +# endif +# include +#endif + +#if MOJOSETUP_HAVE_MNTENT_H +# include +#endif + +#if MOJOSETUP_HAVE_SYS_MNTTAB_H +# include +#endif + +#if PLATFORM_BEOS +#define DLOPEN_ARGS 0 +void *beos_dlopen(const char *fname, int unused); +void *beos_dlsym(void *lib, const char *sym); +void beos_dlclose(void *lib); +void beos_usleep(unsigned long ticks); +#define dlopen beos_dlopen +#define dlsym beos_dlsym +#define dlclose beos_dlclose +#define usleep beos_usleep +#else +#include +#define DLOPEN_ARGS (RTLD_NOW | RTLD_GLOBAL) +#endif + +#include "platform.h" +#include "gui.h" +#include "fileio.h" + +static struct timeval startup_time; + +boolean MojoPlatform_istty(void) +{ + static boolean already_checked = false; // this never changes in a run. + static boolean retval = false; + if (!already_checked) + { + retval = isatty(0) && isatty(1) ? true : false; + already_checked = true; + } // if + + return retval; +} // MojoPlatform_istty + + +char *MojoPlatform_currentWorkingDir(void) +{ + char *retval = NULL; + size_t len; + + // loop a few times in case we don't have a large enough buffer. + for (len = 128; len <= (16*1024); len *= 2) + { + retval = (char *) xrealloc(retval, len); + if (getcwd(retval, len-1) != NULL) + { + size_t slen = strlen(retval); + if (retval[slen-1] != '/') // make sure this ends with '/' ... + { + retval[slen] = '/'; + retval[slen+1] = '\0'; + } // if + return retval; + } // if + } // for + + free(retval); + return NULL; +} // MojoPlatform_currentWorkingDir + + +char *MojoPlatform_readlink(const char *linkname) +{ + size_t alloclen = 16; + char *retval = NULL; + char *buf = NULL; + ssize_t len = -1; + + do + { + alloclen *= 2; + buf = xrealloc(buf, alloclen); + len = readlink(linkname, buf, alloclen-1); + if ( (len != -1) && (len < (alloclen-1)) ) // !error && !overflow + { + buf[len] = '\0'; // readlink() doesn't null-terminate! + retval = xrealloc(buf, (size_t) (len+1)); // shrink it down. + } // if + } while (len >= (alloclen-1)); // loop if we need a bigger buffer. + + return retval; // caller must free() this. +} // MojoPlatform_readlink + + +static void *guaranteeAllocation(void *ptr, size_t len, size_t *_alloclen) +{ + void *retval = NULL; + size_t alloclen = *_alloclen; + if (alloclen > len) + return ptr; + + if (!alloclen) + alloclen = 1; + + while (alloclen <= len) + alloclen *= 2; + + retval = xrealloc(ptr, alloclen); + if (retval != NULL) + *_alloclen = alloclen; + + return retval; +} // guaranteeAllocation + + +// This is a mess, but I'm not sure it can be done more cleanly. +static char *realpathInternal(char *path, const char *cwd, int linkloop) +{ + char *linkname = NULL; + char *retval = NULL; + size_t len = 0; + size_t alloclen = 0; + + if (*path == '/') // absolute path. + { + retval = xstrdup("/"); + path++; + len = 1; + } // if + else // relative path. + { + if (cwd != NULL) + retval = xstrdup(cwd); + else + { + if ((retval = MojoPlatform_currentWorkingDir()) == NULL) + return NULL; + } // else + len = strlen(retval); + } // else + + while (true) + { + struct stat statbuf; + size_t newlen; + + char *nextpath = strchr(path, '/'); + if (nextpath != NULL) + *nextpath = '\0'; + + newlen = strlen(path); + retval = guaranteeAllocation(retval, len + newlen + 2, &alloclen); + strcpy(retval + len, path); + + if (*path == '\0') + retval[--len] = '\0'; // chop ending "/" bit, it gets readded later. + + else if (strcmp(path, ".") == 0) + { + retval[--len] = '\0'; // chop ending "/." bit + newlen = 0; + } // else if + + else if (strcmp(path, "..") == 0) + { + char *ptr; + retval[--len] = '\0'; // chop ending "/.." bit + ptr = strrchr(retval, '/'); + if ((ptr == NULL) || (ptr == retval)) + { + strcpy(retval, "/"); + len = 0; + } // if + else + { + *ptr = '\0'; + len -= (size_t) ((retval+len)-ptr); + } // else + newlen = 0; + } // else if + + // it may be a symlink...check it. + else if (lstat(retval, &statbuf) == -1) + goto realpathInternal_failed; + + else if (S_ISLNK(statbuf.st_mode)) + { + char *newresolve = NULL; + if (linkloop > 255) + goto realpathInternal_failed; + + linkname = MojoPlatform_readlink(retval); + if (linkname == NULL) + goto realpathInternal_failed; + + // chop off symlink name for its cwd. + retval[len] = '\0'; + + // resolve the link... + newresolve = realpathInternal(linkname, retval, linkloop + 1); + if (newresolve == NULL) + goto realpathInternal_failed; + + len = strlen(newresolve); + retval = guaranteeAllocation(retval, len + 2, &alloclen); + strcpy(retval, newresolve); + free(newresolve); + free(linkname); + linkname = NULL; + } // else if + + else + { + len += newlen; + } // else + + if (nextpath == NULL) + break; // holy crap we're done! + else // append a '/' before the next path element. + { + path = nextpath + 1; + retval[len++] = '/'; + retval[len] = '\0'; + } // else + } // while + + // Shrink string if we're using more memory than necessary... + if (alloclen > len+1) + retval = (char *) xrealloc(retval, len+1); + + return retval; + +realpathInternal_failed: + free(linkname); + free(retval); + return NULL; +} // realpathInternal + + +// Rolling my own realpath, even if the runtime has one, since apparently +// the spec is a little flakey, and it can overflow PATH_MAX. On BeOS <= 5, +// we'd have to resort to BPath to do this, too, and I'd rather avoid the C++ +// dependencies and headers. +char *MojoPlatform_realpath(const char *_path) +{ + char *path = xstrdup(_path); + char *retval = realpathInternal(path, NULL, 0); + free(path); + return retval; +} // MojoPlatform_realpath + + +// (Stolen from physicsfs: http://icculus.org/physfs/ ...) +/* + * See where program (bin) resides in the $PATH. Returns a copy of the first + * element in $PATH that contains it, or NULL if it doesn't exist or there + * were other problems. + * + * You are expected to free() the return value when you're done with it. + */ +static char *findBinaryInPath(const char *bin) +{ + const char *_envr = getenv("PATH"); + size_t alloc_size = 0; + char *envr = NULL; + char *exe = NULL; + char *start = NULL; + char *ptr = NULL; + + if ((_envr == NULL) || (bin == NULL)) + return NULL; + + envr = xstrdup(_envr); + start = envr; + + do + { + size_t size; + ptr = strchr(start, ':'); // find next $PATH separator. + if (ptr) + *ptr = '\0'; + + size = strlen(start) + strlen(bin) + 2; + if (size > alloc_size) + { + char *x = (char *) xrealloc(exe, size); + alloc_size = size; + exe = x; + } // if + + // build full binary path... + strcpy(exe, start); + if ((exe[0] == '\0') || (exe[strlen(exe) - 1] != '/')) + strcat(exe, "/"); + strcat(exe, bin); + + if (access(exe, X_OK) == 0) // Exists as executable? We're done. + { + strcpy(exe, start); // i'm lazy. piss off. + free(envr); + return(exe); + } // if + + start = ptr + 1; // start points to beginning of next element. + } while (ptr != NULL); + + if (exe != NULL) + free(exe); + + free(envr); + + return(NULL); // doesn't exist in path. +} // findBinaryInPath + + +char *MojoPlatform_appBinaryPath(void) +{ + const char *argv0 = GArgv[0]; + char *retval = NULL; + + if (strchr(argv0, '/') != NULL) + retval = MojoPlatform_realpath(argv0); // argv[0] contains a path? + else // slow path...have to search the whole $PATH for this one... + { + char *found = findBinaryInPath(argv0); + if (found) + retval = MojoPlatform_realpath(found); + free(found); + } // else + + return retval; +} // MojoPlatform_appBinaryPath + + +char *MojoPlatform_homedir(void) +{ + const char *envr = getenv("HOME"); + return xstrdup(envr ? envr : "/"); +} // MojoPlatform_homedir + + +// This implementation is a bit naive. +char *MojoPlatform_locale(void) +{ + char *retval = NULL; + char *ptr = NULL; + const char *envr = getenv("LANG"); + if (envr != NULL) + { + retval = xstrdup(envr); + ptr = strchr(retval, '.'); // chop off encoding if explicitly listed. + if (ptr != NULL) + *ptr = '\0'; + ptr = strchr(retval, '@'); // chop off extra bits if explicitly listed. + if (ptr != NULL) + *ptr = '\0'; + } // if + + #if PLATFORM_MACOSX + else if (CFLocaleCreateCanonicalLocaleIdentifierFromString == NULL) + retval = NULL; // !!! FIXME: 10.2 compatibility? + + else if (CFLocaleCreateCanonicalLocaleIdentifierFromString != NULL) + { + CFPropertyListRef languages = CFPreferencesCopyAppValue( + CFSTR("AppleLanguages"), + kCFPreferencesCurrentApplication); + if (languages != NULL) + { + CFStringRef primary = CFArrayGetValueAtIndex(languages, 0); + if (primary != NULL) + { + CFStringRef locale = + CFLocaleCreateCanonicalLocaleIdentifierFromString( + kCFAllocatorDefault, primary); + if (locale != NULL) + { + const CFIndex len = (CFStringGetLength(locale) + 1) * 6; + ptr = (char*) xmalloc(len); + CFStringGetCString(locale, ptr, len, kCFStringEncodingUTF8); + CFRelease(locale); + retval = xrealloc(ptr, strlen(ptr) + 1); + // !!! FIXME: this may not be 100% right, but change + // !!! FIXME: xx-YY to xx_YY (lang_country). + if (retval[2] == '-') + retval[2] = '_'; + if (retval[3] == '-') + retval[3] = '_'; + } // if + } // if + CFRelease(languages); + } // if + } // else if + #endif + + return retval; +} // MojoPlatform_locale + + +char *MojoPlatform_osType(void) +{ +#if PLATFORM_MACOSX + return xstrdup("macosx"); +#elif PLATFORM_BEOS + return xstrdup("beos"); // !!! FIXME: zeta? haiku? +#elif defined(linux) || defined(__linux) || defined(__linux__) + return xstrdup("linux"); +#elif defined(__FreeBSD__) || defined(__DragonFly__) + return xstrdup("freebsd"); +#elif defined(__NetBSD__) + return xstrdup("netbsd"); +#elif defined(__OpenBSD__) + return xstrdup("openbsd"); +#elif defined(bsdi) || defined(__bsdi) || defined(__bsdi__) + return xstrdup("bsdi"); +#elif defined(_AIX) + return xstrdup("aix"); +#elif defined(hpux) || defined(__hpux) || defined(__hpux__) + return xstrdup("hpux"); +#elif defined(sgi) || defined(__sgi) || defined(__sgi__) || defined(_SGI_SOURCE) + return xstrdup("irix"); +#elif defined(sun) + return xstrdup("solaris"); +#else +# error Please define your platform. + return NULL; +#endif +} // MojoPlatform_ostype + + +char *MojoPlatform_osVersion() +{ +#if PLATFORM_MACOSX + SInt32 ver, major, minor, patch; + boolean convert = false; + char *buf = NULL; + char dummy = 0; + int len = 0; + + if (Gestalt(gestaltSystemVersion, &ver) != noErr) + return NULL; + + if (ver < 0x1030) + convert = true; // split (ver) into (major),(minor),(patch). + else + { + // presumably this won't fail. But if it does, we'll just use the + // original version value. This might cut the value--10.12.11 will + // come out to 10.9.9, for example--but it's better than nothing. + if (Gestalt(gestaltSystemVersionMajor, &major) != noErr) + convert = true; + if (Gestalt(gestaltSystemVersionMinor, &minor) != noErr) + convert = true; + if (Gestalt(gestaltSystemVersionBugFix, &patch) != noErr) + convert = true; + } /* else */ + + if (convert) + { + major = ((ver & 0xFF00) >> 8); + major = (((major / 16) * 10) + (major % 16)); + minor = ((ver & 0xF0) >> 4); + patch = (ver & 0xF); + } /* if */ + + len = snprintf(&dummy, sizeof (dummy), "%d.%d.%d", + (int) major, (int) minor, (int) patch); + buf = (char *) xmalloc(len+1); + snprintf(buf, len+1, "%d.%d.%d", (int) major, (int) minor, (int) patch); + return buf; + +#else + // This information may or may not actually MEAN anything. On BeOS, it's + // useful, but on other things, like Linux, it'll give you the kernel + // version, which doesn't necessarily help. + struct utsname un; + if (uname(&un) == 0) + return xstrdup(un.release); +#endif + + return NULL; +} // MojoPlatform_osversion + + +void MojoPlatform_sleep(uint32 ticks) +{ + usleep(ticks * 1000); +} // MojoPlatform_sleep + + +uint32 MojoPlatform_ticks(void) +{ + uint64 then_ms, now_ms; + struct timeval now; + gettimeofday(&now, NULL); + then_ms = (((uint64) startup_time.tv_sec) * 1000) + + (((uint64) startup_time.tv_usec) / 1000); + now_ms = (((uint64) now.tv_sec) * 1000) + (((uint64) now.tv_usec) / 1000); + return ((uint32) (now_ms - then_ms)); +} // MojoPlatform_ticks + + +void MojoPlatform_die(void) +{ + _exit(86); +} // MojoPlatform_die + + +boolean MojoPlatform_unlink(const char *fname) +{ + boolean retval = false; + struct stat statbuf; + if (lstat(fname, &statbuf) != -1) + { + if (S_ISDIR(statbuf.st_mode)) + retval = (rmdir(fname) == 0); + else + retval = (unlink(fname) == 0); + } // if + return retval; +} // MojoPlatform_unlink + + +boolean MojoPlatform_symlink(const char *src, const char *dst) +{ + return (symlink(dst, src) == 0); +} // MojoPlatform_symlink + + +boolean MojoPlatform_mkdir(const char *path, uint16 perms) +{ + // !!! FIXME: error if already exists? + return (mkdir(path, perms) == 0); +} // MojoPlatform_mkdir + + +boolean MojoPlatform_rename(const char *src, const char *dst) +{ + return (rename(src, dst) == 0); +} // MojoPlatform_rename + + +boolean MojoPlatform_exists(const char *dir, const char *fname) +{ + boolean retval = false; + if (fname == NULL) + retval = (access(dir, F_OK) != -1); + else + { + const size_t len = strlen(dir) + strlen(fname) + 2; + char *buf = (char *) xmalloc(len); + snprintf(buf, len, "%s/%s", dir, fname); + retval = (access(buf, F_OK) != -1); + free(buf); + } // else + return retval; +} // MojoPlatform_exists + + +boolean MojoPlatform_writable(const char *fname) +{ + return (access(fname, W_OK) == 0); +} // MojoPlatform_writable + + +boolean MojoPlatform_isdir(const char *dir) +{ + boolean retval = false; + struct stat statbuf; + if (lstat(dir, &statbuf) != -1) + { + if (S_ISDIR(statbuf.st_mode)) + retval = true; + } // if + return retval; +} // MojoPlatform_isdir + + +boolean MojoPlatform_issymlink(const char *dir) +{ + boolean retval = false; + struct stat statbuf; + if (lstat(dir, &statbuf) != -1) + { + if (S_ISLNK(statbuf.st_mode)) + retval = true; + } // if + return retval; +} // MojoPlatform_issymlink + + +boolean MojoPlatform_isfile(const char *dir) +{ + boolean retval = false; + struct stat statbuf; + if (lstat(dir, &statbuf) != -1) + { + if (S_ISREG(statbuf.st_mode)) + retval = true; + } // if + return retval; +} // MojoPlatform_isfile + + +void *MojoPlatform_stdout(void) +{ + int *retval = (int *) xmalloc(sizeof (int)); + *retval = 1; // stdout. + return retval; +} // MojoPlatform_stdout + + +void *MojoPlatform_open(const char *fname, uint32 flags, uint16 mode) +{ + void *retval = NULL; + int fd = -1; + int unixflags = 0; + + if ((flags & MOJOFILE_READ) && (flags & MOJOFILE_WRITE)) + unixflags |= O_RDWR; + else if (flags & MOJOFILE_READ) + unixflags |= O_RDONLY; + else if (flags & MOJOFILE_WRITE) + unixflags |= O_WRONLY; + else + return NULL; // have to specify SOMETHING. + + if (flags & MOJOFILE_APPEND) + unixflags |= O_APPEND; + if (flags & MOJOFILE_TRUNCATE) + unixflags |= O_TRUNC; + if (flags & MOJOFILE_CREATE) + unixflags |= O_CREAT; + if (flags & MOJOFILE_EXCLUSIVE) + unixflags |= O_EXCL; + + fd = open(fname, unixflags, (mode_t) mode); + if (fd != -1) + { + int *intptr = (int *) xmalloc(sizeof (int)); + *intptr = fd; + retval = intptr; + } // if + + return retval; +} // MojoPlatform_open + + +int64 MojoPlatform_read(void *fd, void *buf, uint32 bytes) +{ + return (int64) read(*((int *) fd), buf, bytes); +} // MojoPlatform_read + + +int64 MojoPlatform_write(void *fd, const void *buf, uint32 bytes) +{ + return (int64) write(*((int *) fd), buf, bytes); +} // MojoPlatform_write + + +int64 MojoPlatform_tell(void *fd) +{ + return (int64) lseek(*((int *) fd), 0, SEEK_CUR); +} // MojoPlatform_tell + + +int64 MojoPlatform_seek(void *fd, int64 offset, MojoFileSeek whence) +{ + int unixwhence; + switch (whence) + { + case MOJOSEEK_SET: unixwhence = SEEK_SET; break; + case MOJOSEEK_CURRENT: unixwhence = SEEK_CUR; break; + case MOJOSEEK_END: unixwhence = SEEK_END; break; + default: return -1; // !!! FIXME: maybe just abort? + } // switch + + return (int64) lseek(*((int *) fd), offset, unixwhence); +} // MojoPlatform_seek + + +int64 MojoPlatform_flen(void *fd) +{ + struct stat statbuf; + if (fstat(*((int *) fd), &statbuf) == -1) + return -1; + return((int64) statbuf.st_size); +} // MojoPlatform_flen + + +boolean MojoPlatform_flush(void *fd) +{ + return (fsync(*((int *) fd)) == 0); +} // MojoPlatform_flush + + +boolean MojoPlatform_close(void *fd) +{ + boolean retval = false; + int handle = *((int *) fd); + + // don't close stdin, stdout, or stderr. + if ((handle == 0) || (handle == 1) || (handle == 2)) + { + free(fd); + return true; + } // if + + if (close(handle) == 0) + free(fd); + return retval; +} // MojoPlatform_close + + +void *MojoPlatform_opendir(const char *dirname) +{ + return opendir(dirname); +} // MojoPlatform_opendir + + +char *MojoPlatform_readdir(void *_dirhandle) +{ + DIR *dirhandle = (DIR *) _dirhandle; + struct dirent *dent = NULL; + + while ((dent = readdir(dirhandle)) != NULL) + { + if (strcmp(dent->d_name, ".") == 0) + continue; // skip these. + + else if (strcmp(dent->d_name, "..") == 0) + continue; // skip these, too. + + else + break; // found a valid entry, go on. + } // while + + return ((dent) ? xstrdup(dent->d_name) : NULL); +} // MojoPlatform_readdir + + +void MojoPlatform_closedir(void *dirhandle) +{ + closedir((DIR *) dirhandle); +} // MojoPlatform_closedir + + +int64 MojoPlatform_filesize(const char *fname) +{ + int retval = -1; + struct stat statbuf; + if ( (lstat(fname, &statbuf) != -1) && (S_ISREG(statbuf.st_mode)) ) + retval = (int64) statbuf.st_size; + return retval; +} // MojoPlatform_filesize + + +boolean MojoPlatform_perms(const char *fname, uint16 *p) +{ + boolean retval = false; + struct stat statbuf; + if (stat(fname, &statbuf) != -1) + { + *p = statbuf.st_mode; + retval = true; + } // if + return retval; +} // MojoPlatform_perms + + +uint16 MojoPlatform_defaultFilePerms(void) +{ + return 0644; +} // MojoPlatform_defaultFilePerms + + +uint16 MojoPlatform_defaultDirPerms(void) +{ + return 0755; +} // MojoPlatform_defaultDirPerms + + +uint16 MojoPlatform_makePermissions(const char *str, boolean *_valid) +{ + uint16 retval = 0644; + boolean valid = true; + if (str != NULL) + { + char *endptr = NULL; + long strval = strtol(str, &endptr, 8); + // complete string was a valid number? + valid = ((*endptr == '\0') && (strval >= 0) && (strval <= 0xFFFF)); + if (valid) + retval = (uint16) strval; + } // if + + *_valid = valid; + return retval; +} // MojoPlatform_makePermissions + + +boolean MojoPlatform_chmod(const char *fname, uint16 p) +{ + return (chmod(fname, p) != -1); +} // MojoPlatform_chmod + + +char *MojoPlatform_findMedia(const char *uniquefile) +{ +#if MOJOSETUP_HAVE_SYS_UCRED_H + int i = 0; + struct statfs *mntbufp = NULL; + int mounts = getmntinfo(&mntbufp, MNT_WAIT); + for (i = 0; i < mounts; i++) + { + const char *mnt = mntbufp[i].f_mntonname; + if (MojoPlatform_exists(mnt, uniquefile)) + return xstrdup(mnt); + } // for + +#elif MOJOSETUP_HAVE_MNTENT_H + FILE *mounts = setmntent("/etc/mtab", "r"); + if (mounts != NULL) + { + struct mntent *ent = NULL; + while ((ent = getmntent(mounts)) != NULL) + { + const char *mnt = ent->mnt_dir; + if (MojoPlatform_exists(mnt, uniquefile)) + { + endmntent(mounts); + return xstrdup(mnt); + } // if + } // while + endmntent(mounts); + } // if + +#elif MOJOSETUP_HAVE_SYS_MNTTAB_H + FILE *mounts = fopen(MNTTAB, "r"); + if (mounts != NULL) + { + struct mnttab ent; + while (getmntent(mounts, &ent) == 0) + { + const char *mnt = ent.mnt_mountp; + if (MojoPlatform_exists(mnt, uniquefile)) + { + fclose(mounts); + return xstrdup(mnt); + } // if + } // while + fclose(mounts); + } // if + +#else +# warning No mountpoint detection on this platform... +#endif + + return NULL; +} // MojoPlatform_findMedia + + +void MojoPlatform_log(const char *str) +{ + syslog(LOG_USER | LOG_INFO, "%s", str); + +#if PLATFORM_MACOSX + // put to stdout too, if this isn't the stdio UI. + // This will let the info show up in /Applications/Utilities/Console.app + if ((GGui != NULL) && (strcmp(GGui->name(), "stdio") != 0)) + printf("%s\n", str); +#endif +} // MojoPlatform_log + + +static boolean testTmpDir(const char *dname, char *buf, + size_t len, const char *tmpl) +{ + boolean retval = false; + if ( (dname != NULL) && (access(dname, R_OK | W_OK | X_OK) == 0) ) + { + struct stat statbuf; + if ( (stat(dname, &statbuf) == 0) && (S_ISDIR(statbuf.st_mode)) ) + { + const size_t rc = snprintf(buf, len, "%s/%s", dname, tmpl); + if (rc < len) + retval = true; + } // if + } // if + + return retval; +} // testTmpDir + + +void *MojoPlatform_dlopen(const uint8 *img, size_t len) +{ + // Write the image to a temporary file, dlopen() it, and delete it + // immediately. The inode will be kept around by the Unix kernel until + // we either dlclose() it or the process terminates, but we don't have + // to worry about polluting the /tmp directory or cleaning this up later. + // We'll try every reasonable temp directory location until we find one + // that works, in case (say) one lets us write a file, but there + // isn't enough space for the data. + + // /dev/shm may be able to avoid writing to physical media...try it first. + const char *dirs[] = { "/dev/shm", getenv("TMPDIR"), P_tmpdir, "/tmp" }; + const char *tmpl = "mojosetup-plugin-XXXXXX"; + char fname[PATH_MAX]; + void *retval = NULL; + int i = 0; + + if (dlopen == NULL) // weak symbol on older Mac OS X + return NULL; + + #ifndef P_tmpdir // glibc defines this, maybe others. + #define P_tmpdir NULL + #endif + + for (i = 0; (i < STATICARRAYLEN(dirs)) && (retval == NULL); i++) + { + if (testTmpDir(dirs[i], fname, sizeof (fname), tmpl)) + { + const int fd = mkstemp(fname); + if (fd != -1) + { + const size_t bw = write(fd, img, len); + const int rc = close(fd); + if ((bw == len) && (rc != -1)) + retval = dlopen(fname, DLOPEN_ARGS); + unlink(fname); + } // if + } // if + } // for + + return retval; +} // MojoPlatform_dlopen + + +void *MojoPlatform_dlsym(void *lib, const char *sym) +{ + #if PLATFORM_MACOSX + if (dlsym == NULL) return NULL; // weak symbol on older Mac OS X + #endif + + return dlsym(lib, sym); +} // MojoPlatform_dlsym + + +void MojoPlatform_dlclose(void *lib) +{ + #if PLATFORM_MACOSX + if (dlclose == NULL) return; // weak symbol on older Mac OS X + #endif + + dlclose(lib); +} // MojoPlatform_dlclose + + +#if !PLATFORM_MACOSX && !PLATFORM_BEOS +static int runScriptString(const char *str, boolean devnull, const char **_argv) +{ + int retval = 127; + pid_t pid = 0; + int pipes[2]; + + if (pipe(pipes) == -1) + return retval; + + pid = fork(); + if (pid == -1) // -1 == fork() failed. + { + close(pipes[0]); + close(pipes[1]); + return retval; + } // if + + else if (pid == 0) // we're the child process. + { + int argc = 0; + const char **argv = NULL; + + close(pipes[1]); // close the writing end. + dup2(pipes[0], 0); // replace stdin. + if (devnull) + { + dup2(open("/dev/null", O_WRONLY), 1); // replace stdout + dup2(open("/dev/null", O_WRONLY), 2); // replace stderr + } // if + + while (_argv[argc++] != NULL) { /* no-op */ } + argv = (const char **) xmalloc(sizeof (char *) * argc+3); + argv[0] = "/bin/sh"; + argv[1] = "-s"; + for (argc = 0; _argv[argc] != NULL; argc++) + argv[argc+2] = _argv[argc]; + argv[argc+2] = NULL; + + execv(argv[0], (char **) argv); + _exit(retval); // uhoh, failed. + } // else if + + else // we're the parent (pid == child process id). + { + int status = 0; + size_t len = strlen(str); + boolean failed = false; + close(pipes[0]); // close the reading end. + failed |= (write(pipes[1], str, len) != len); + failed |= (close(pipes[1]) == -1); + + // !!! FIXME: we need a GGui->pump() or something here if we'll block. + if (waitpid(pid, &status, 0) != -1) + { + if (WIFEXITED(status)) + retval = WEXITSTATUS(status); + } // if + } // else + + return retval; +} // runScriptString + + +static int runScript(const char *script, boolean devnull, const char **argv) +{ + int retval = 127; + char *str = NULL; + MojoInput *in = MojoInput_newFromArchivePath(GBaseArchive, script); + if (in != NULL) + { + int64 len = in->length(in); + if (len > 0) + { + str = (char *) xmalloc(len + 1); + if (in->read(in, str, len) == len) + str[len] = '\0'; + else + { + free(str); + str = NULL; + } // else + } // if + + in->close(in); + } // if + + if (str != NULL) + retval = runScriptString(str, devnull, argv); + + free(str); + return retval; +} // runScript + + +static char *shellEscape(const char *str) +{ + size_t len = 0; + char *retval = NULL; + const char *ptr = NULL; + char *dst = NULL; + + for (ptr = str; *ptr; ptr++) + len += (*ptr == '\'') ? 4 : 1; + + retval = (char *) xmalloc(len + 3); // +2 single quotes and a null char. + dst = retval; + *(dst++) = '\''; + + for (ptr = str; *ptr; ptr++) + { + const char ch = *ptr; + if (ch != '\'') + *(dst++) = ch; + else + { + *(dst++) = '\''; + *(dst++) = '\\'; + *(dst++) = '\''; + *(dst++) = '\''; + } // else + } // for + + *(dst++) = '\''; + *(dst++) = '\0'; + return retval; +} // shellEscape + + +static boolean unix_launchXdgUtil(const char *util, const char **argv) +{ + char *path = findBinaryInPath(util); + int rc = 0; + + // !!! FIXME: do I really need to be using system() and + // !!! FIXME: suffering with shell escaping? + + if (path != NULL) // it's installed on the system; use that. + { + char *cmd = shellEscape(util); + char *tmp = NULL; + int i; + + // just in case there's a space in the $PATH entry... + tmp = shellEscape(path); + free(path); + path = tmp; + + for (i = 0; argv[i]; i++) + { + char *escaped = shellEscape(argv[i]); + tmp = format("%0 %1", cmd, escaped); + free(escaped); + free(cmd); + cmd = tmp; + } // for + + tmp = format("%0/%1 >/dev/null 2>&1", path, cmd); + free(cmd); + cmd = tmp; + rc = system(cmd); + logDebug("system( %0 ) returned %1", cmd, numstr(rc)); + free(cmd); + free(path); + } // if + + else // try our fallback copy of xdg-utils in GBaseArchive? + { + char *script = format("meta/xdg-utils/%0", util); + rc = runScript(script, true, argv); + logDebug("internal script '%0' returned %1", script, numstr(rc)); + free(script); + } // if + + return (rc == 0); +} // unix_launchXdgUtil + + +static boolean unix_launchBrowser(const char *url) +{ + const char *argv[] = { url, NULL }; + return unix_launchXdgUtil("xdg-open", argv); +} // unix_launchBrowser + + +boolean xdgDesktopMenuItem(const char *action, const char *data) +{ + // xdg-utils, being shell scripts, don't do well with paths containing + // spaces. We attempt to mitigate this by chdir()'ing to the directory + // with the file to install. + const char *ptr = strrchr(data, '/'); + boolean retval = false; + if (ptr == NULL) + { + const char *argv[] = { action, data, NULL }; + retval = unix_launchXdgUtil("xdg-desktop-menu", argv); + } + else + { + char *working_dir = MojoPlatform_currentWorkingDir(); + if (working_dir != NULL) + { + char *cpy = xstrdup(data); + char *fname = cpy + ((size_t)(ptr-data)); + const char *argv[] = { action, fname+1, NULL }; + *(fname++) = '\0'; + if (chdir(cpy) == 0) + { + retval = unix_launchXdgUtil("xdg-desktop-menu", argv); + if (chdir(working_dir) == -1) // deep trouble! + fatal("Failed to chdir to '%0'", working_dir); + } // if + free(cpy); + free(working_dir); + } // if + } // else + return retval; +} // xdgDesktopMenuItem +#endif + + +boolean MojoPlatform_launchBrowser(const char *url) +{ +#if PLATFORM_MACOSX + CFURLRef cfurl = CFURLCreateWithBytes(NULL, (const UInt8 *) url, + strlen(url), kCFStringEncodingUTF8, NULL); + const OSStatus err = LSOpenCFURLRef(cfurl, NULL); + CFRelease(cfurl); + return (err == noErr); +#elif PLATFORM_BEOS + extern int beos_launchBrowser(const char *url); + return beos_launchBrowser(url) ? true : false; +#else + return unix_launchBrowser(url); +#endif +} // MojoPlatform_launchBrowser + + +boolean MojoPlatform_installDesktopMenuItem(const char *data) +{ +#if PLATFORM_MACOSX || PLATFORM_BEOS + // !!! FIXME: write me. + STUBBED("desktop menu support"); + return false; +#else + return xdgDesktopMenuItem("install", data); +#endif +} // MojoPlatform_installDesktopMenuItem + + +boolean MojoPlatform_uninstallDesktopMenuItem(const char *data) +{ +#if PLATFORM_MACOSX || PLATFORM_BEOS + // !!! FIXME: write me. + STUBBED("desktop menu support"); + return false; +#else + return xdgDesktopMenuItem("uninstall", data); +#endif +} // MojoPlatform_uninstallDesktopMenuItem + + +#if SUPPORT_MULTIARCH +void MojoPlatform_switchBin(const uint8 *img, size_t len) +{ + const char *dirs[] = { "/dev/shm", getenv("TMPDIR"), P_tmpdir, "/tmp" }; + const char *tmpl = "mojosetup-switch-bin-XXXXXX"; + char fname[PATH_MAX]; + int i = 0; + + for (i = 0; i < STATICARRAYLEN(dirs); i++) + { + if (testTmpDir(dirs[i], fname, len, tmpl)) + { + const int fd = mkstemp(fname); + if (fd != -1) + { + const size_t bw = write(fd, img, len); + const int rc = close(fd); + if ((bw == len) && (rc != -1)) + { + const char *tmpstr = GArgv[0]; + chmod(fname, 0700); + GArgv[0] = fname; + execv(fname, (char * const *) GArgv); + // only hits this line if process wasn't replaced. + GArgv[0] = tmpstr; + } // if + unlink(fname); + } // if + } // if + } // for + + // couldn't replace current process. +} // MojoPlatform_switchBin +#endif + + +boolean MojoPlatform_spawnTerminal(void) +{ +#if PLATFORM_BEOS + #error write me. + // "/boot/apps/Terminal" + +#elif PLATFORM_MACOSX + // this is nasty...it'd be nice if Terminal.app just took command lines. + boolean failed = false; + FILE *io = NULL; + char *cmd = NULL; + char *ptr = NULL; + char *binpath = MojoPlatform_appBinaryPath(); + size_t len = (strlen(binpath) * 5) + 3; + int i = 0; + for (i = 1; i < GArgc; i++) + len += (strlen(GArgv[i]) * 5) + 3; + + ptr = cmd = (char *) xmalloc(len+1); + for (i = 0; i < GArgc; i++) + { + const char *str = (i == 0) ? binpath : GArgv[i]; + if (i != 0) + *(ptr++) = ' '; + *(ptr++) = '\''; + while (*str) + { + const char ch = *(str++); + if (ch == '\'') + { + // have to escape for both AppleScript and /bin/sh. :/ + *(ptr++) = '\''; + *(ptr++) = '\\'; + *(ptr++) = '\\'; + *(ptr++) = '\''; + *(ptr++) = '\''; + } // if + else + { + *(ptr++) = ch; + } // else + } // while + *(ptr++) = '\''; + } // for + + free(binpath); + + *ptr = '\0'; + ptr = format( + "ignoring application responses\n" + "tell application \"Terminal\" to do script \"clear ; echo %0 -notermspawn=1 ; exit\"\n" + "tell application \"Terminal\" to tell its front window to set its custom title to \"MojoSetup\"\n" + "tell application \"Terminal\" to tell its front window to set its title displays device name to false\n" + "tell application \"Terminal\" to tell its front window to set its title displays shell path to false\n" + "tell application \"Terminal\" to tell its front window to set its title displays window size to false\n" + "tell application \"Terminal\" to tell its front window to set its title displays file name to false\n" + "tell application \"Terminal\" to tell its front window to set its title displays custom title to true\n" + "tell application \"Terminal\" to activate\n" + "end ignoring\n", cmd); + + free(cmd); + + io = popen("osascript -", "w"); + if (io == NULL) + failed = true; + else + { + failed |= (fwrite(ptr, strlen(ptr), 1, io) != 1); + failed |= (pclose(io) != 0); + } // else + + free(ptr); + + if (!failed) + exit(0); + + // we'll return false at the end to note we failed. + +#else + + // urgh + static const char *terms[] = { + "gnome-terminal", "konsole", "kvt", "xterm", "rxvt", + "dtterm", "eterm", "Eterm", "aterm" + }; + + char *binpath = MojoPlatform_appBinaryPath(); + const char *tryfirst = NULL; + const int max_added_args = 5; + const unsigned int argc = GArgc + max_added_args; + const char **argv = NULL; + int i = 0; + int startarg = 0; + + if (getenv("DISPLAY") == NULL) + return false; // don't bother if we don't have X. + + else if (getenv("GNOME_DESKTOP_SESSION_ID") != NULL) // this is gnome? + tryfirst = "gnome-terminal"; + + else if (getenv("KDE_FULL_SESSION") != NULL) // this KDE >= 3.2? + tryfirst = "konsole"; + + argv = xmalloc((argc + 1) * sizeof(char *)); + + for (i = -1; i < ((int) STATICARRAYLEN(terms)); i++) + { + int is_gnome_term = false; + int argi = 0; + const char *trythis = (i == -1) ? tryfirst : terms[i]; + if (trythis == NULL) + continue; + + // !!! FIXME: hack. I'm sure other terminal emulators have needs, too. + is_gnome_term = (strcmp(trythis, "gnome-terminal") == 0); + + argv[argi++] = trythis; + argv[argi++] = is_gnome_term ? "--title" : "-title"; + argv[argi++] = "MojoSetup"; + argv[argi++] = is_gnome_term ? "-x" : "-e"; + argv[argi++] = binpath; + argv[argi++] = "-notermspawn=1"; + assert(argi-1 <= max_added_args); + + for (startarg = argi-1; argi <= argc; argi++) // include ending NULL. + { + argv[argi] = GArgv[argi - startarg]; + if (argv[argi] == NULL) + break; + } // for + + execvp(trythis, (char * const *) argv); + } // for + + // Still here? We failed. Mankind is wiped out in the Robot Wars. + + free(argv); + free(binpath); +#endif + + return false; +} // MojoPlatform_spawnTerminal + + +uint8 *MojoPlatform_decodeImage(const uint8 *data, uint32 size, + uint32 *w, uint32 *h) +{ + // !!! FIXME: try Quartz APIs on Mac OS X? + return NULL; // no platform-specific APIs. Just use the built-in ones. +} // MojoPlatform_decodeImage + + +uint64 MojoPlatform_getuid(void) +{ + return (uint64) getuid(); +} // MojoPlatform_getuid + + +uint64 MojoPlatform_geteuid(void) +{ + return (uint64) geteuid(); +} // MojoPlatform_geteuid + + +uint64 MojoPlatform_getgid(void) +{ + return (uint64) getgid(); +} // MojoPlatform_getgid + + +static void signal_catcher(int sig) +{ + static boolean first_shot = true; + if (first_shot) + { + first_shot = false; + logError("Caught signal #%0", numstr(sig)); + } // if +} // signal_catcher + +static void crash_catcher(int sig) +{ + signal_catcher(sig); + MojoSetup_crashed(); +} // crash_catcher + +static void termination_catcher(int sig) +{ + signal_catcher(sig); + MojoSetup_terminated(); +} // termination_catcher + + +static void install_signals(void) +{ + static int crash_sigs[] = { SIGSEGV,SIGILL,SIGBUS,SIGFPE,SIGTRAP,SIGABRT }; + static int term_sigs[] = { SIGQUIT, SIGINT, SIGTERM, SIGHUP }; + static int ignore_sigs[] = { SIGPIPE }; + int i; + + for (i = 0; i < STATICARRAYLEN(crash_sigs); i++) + signal(crash_sigs[i], crash_catcher); + for (i = 0; i < STATICARRAYLEN(term_sigs); i++) + signal(term_sigs[i], termination_catcher); + for (i = 0; i < STATICARRAYLEN(ignore_sigs); i++) + signal(ignore_sigs[i], SIG_IGN); +} // install_signals + + +int main(int argc, char **argv) +{ + gettimeofday(&startup_time, NULL); + openlog("mojosetup", LOG_PID, LOG_USER); + atexit(closelog); + install_signals(); + return MojoSetup_main(argc, argv); +} // main + +#endif // PLATFORM_UNIX + +// end of unix.c ... + diff --git a/mk/linux/mojosetup/platform_windows.c b/mk/linux/mojosetup/platform_windows.c new file mode 100644 index 00000000..142838a4 --- /dev/null +++ b/mk/linux/mojosetup/platform_windows.c @@ -0,0 +1,1610 @@ +/** + * MojoSetup; a portable, flexible installation application. + * + * Please see the file LICENSE.txt in the source's root directory. + * + * This file written by Ryan C. Gordon. + */ + +#if PLATFORM_WINDOWS + +#include "platform.h" +#include "gui.h" + +// Much of this file was lifted from PhysicsFS, http://icculus.org/physfs/ ... +// I wrote all this code under the same open source license, and own the +// copyright on it anyhow, so transferring it here is "safe". + +// Forcibly disable UNICODE, since we manage this ourselves. +#ifdef UNICODE +#undef UNICODE +#endif + +#define WIN32_LEAN_AND_MEAN 1 +#include +#include + +// !!! FIXME: this is for stdio redirection crap. +#include +#include + +// is Win95/Win98/WinME? (no Unicode, etc) +static boolean osIsWin9x = false; +static uint32 osMajorVer = 0; +static uint32 osMinorVer = 0; +static uint32 osBuildVer = 0; + +static uint32 startupTime = 0; + +// These allocation macros are much more complicated in PhysicsFS. +#define smallAlloc(x) xmalloc(x) +#define smallFree(x) free(x) + +// ...so is this. +#define BAIL_IF_MACRO(cond, err, ret) if (cond) return ret; +#define BAIL_MACRO(err, ret) return ret; + +#define LOWORDER_UINT64(pos) ((uint32) (pos & 0xFFFFFFFF)) +#define HIGHORDER_UINT64(pos) ((uint32) ((pos >> 32) & 0xFFFFFFFF)) + +// Users without the platform SDK don't have this defined. The original docs +// for SetFilePointer() just said to compare with 0xFFFFFFFF, so this should +// work as desired. +#ifndef INVALID_SET_FILE_POINTER +#define INVALID_SET_FILE_POINTER 0xFFFFFFFF +#endif + +// just in case... +#ifndef INVALID_FILE_ATTRIBUTES +#define INVALID_FILE_ATTRIBUTES 0xFFFFFFFF +#endif + +// Not defined before the Vista SDK. +#ifndef IO_REPARSE_TAG_SYMLINK +#define IO_REPARSE_TAG_SYMLINK 0xA000000C +#endif + +// This is in shlobj.h, but we can't include it due to universal.h conflicts. +#ifndef CSIDL_PERSONAL +#define CSIDL_PERSONAL 0x0005 +#endif + +// This is in shlobj.h, but we can't include it due to universal.h conflicts. +#ifndef SHGFP_TYPE_CURRENT +#define SHGFP_TYPE_CURRENT 0x0000 +#endif + + +// these utf-8 functions may move to mojosetup.c some day... + +void utf8ToUcs2(const char *src, uint16 *dst, uint64 len) +{ + len -= sizeof (uint16); // save room for null char. + while (len >= sizeof (uint16)) + { + uint32 cp = utf8codepoint(&src); + if (cp == 0) + break; + else if (cp == UNICODE_BOGUS_CHAR_VALUE) + cp = UNICODE_BOGUS_CHAR_CODEPOINT; + + // !!! FIXME: UTF-16 surrogates? + if (cp > 0xFFFF) + cp = UNICODE_BOGUS_CHAR_CODEPOINT; + + *(dst++) = cp; + len -= sizeof (uint16); + } // while + + *dst = 0; +} // utf8ToUcs2 + +static void utf8fromcodepoint(uint32 cp, char **_dst, uint64 *_len) +{ + char *dst = *_dst; + uint64 len = *_len; + + if (len == 0) + return; + + if (cp > 0x10FFFF) + cp = UNICODE_BOGUS_CHAR_CODEPOINT; + else if ((cp == 0xFFFE) || (cp == 0xFFFF)) // illegal values. + cp = UNICODE_BOGUS_CHAR_CODEPOINT; + else + { + // There are seven "UTF-16 surrogates" that are illegal in UTF-8. + switch (cp) + { + case 0xD800: + case 0xDB7F: + case 0xDB80: + case 0xDBFF: + case 0xDC00: + case 0xDF80: + case 0xDFFF: + cp = UNICODE_BOGUS_CHAR_CODEPOINT; + } // switch + } // else + + // Do the encoding... + if (cp < 0x80) + { + *(dst++) = (char) cp; + len--; + } // if + + else if (cp < 0x800) + { + if (len < 2) + len = 0; + else + { + *(dst++) = (char) ((cp >> 6) | 128 | 64); + *(dst++) = (char) (cp & 0x3F) | 128; + len -= 2; + } // else + } // else if + + else if (cp < 0x10000) + { + if (len < 3) + len = 0; + else + { + *(dst++) = (char) ((cp >> 12) | 128 | 64 | 32); + *(dst++) = (char) ((cp >> 6) & 0x3F) | 128; + *(dst++) = (char) (cp & 0x3F) | 128; + len -= 3; + } // else + } // else if + + else + { + if (len < 4) + len = 0; + else + { + *(dst++) = (char) ((cp >> 18) | 128 | 64 | 32 | 16); + *(dst++) = (char) ((cp >> 12) & 0x3F) | 128; + *(dst++) = (char) ((cp >> 6) & 0x3F) | 128; + *(dst++) = (char) (cp & 0x3F) | 128; + len -= 4; + } // else if + } // else + + *_dst = dst; + *_len = len; +} // utf8fromcodepoint + +#define UTF8FROMTYPE(typ, src, dst, len) \ + len--; \ + while (len) \ + { \ + const uint32 cp = (uint32) *(src++); \ + if (cp == 0) break; \ + utf8fromcodepoint(cp, &dst, &len); \ + } \ + *dst = '\0'; \ + +void utf8FromUcs2(const uint16 *src, char *dst, uint64 len) +{ + UTF8FROMTYPE(uint64, src, dst, len); +} // utf8FromUcs4 + +#define UTF8_TO_UNICODE_STACK_MACRO(w_assignto, str) { \ + if (str == NULL) \ + w_assignto = NULL; \ + else { \ + const uint32 len = (uint32) ((strlen(str) * 4) + 1); \ + w_assignto = (WCHAR *) smallAlloc(len); \ + if (w_assignto != NULL) \ + utf8ToUcs2(str, (uint16 *) w_assignto, len); \ + } \ +} \ + +static uint32 wStrLen(const WCHAR *wstr) +{ + uint32 len = 0; + while (*(wstr++)) + len++; + return len; +} // wStrLen + + +static char *unicodeToUtf8Heap(const WCHAR *w_str) +{ + char *retval = NULL; + if (w_str != NULL) + { + void *ptr = NULL; + const uint32 len = (wStrLen(w_str) * 4) + 1; + retval = (char *) xmalloc(len); + utf8FromUcs2((const uint16 *) w_str, retval, len); + retval = xrealloc(retval, strlen(retval) + 1); // shrink. + } // if + return retval; +} // unicodeToUtf8Heap + + +static char *codepageToUtf8Heap(const char *cpstr) +{ + char *retval = NULL; + if (cpstr != NULL) + { + const int len = (int) (strlen(cpstr) + 1); + WCHAR *wbuf = (WCHAR *) smallAlloc(len * sizeof (WCHAR)); + BAIL_IF_MACRO(wbuf == NULL, ERR_OUT_OF_MEMORY, NULL); + MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, cpstr, len, wbuf, len); + retval = (char *) xmalloc(len * 4); + utf8FromUcs2(wbuf, retval, len * 4); + smallFree(wbuf); + } // if + return retval; +} // codepageToUtf8Heap + + +// pointers for APIs that may not exist on some Windows versions... +static HANDLE libKernel32 = NULL; +static HANDLE libUserEnv = NULL; +static HANDLE libAdvApi32 = NULL; +static HANDLE libShell32 = NULL; +static DWORD (WINAPI *pGetModuleFileNameW)(HMODULE, LPWCH, DWORD); +static BOOL (WINAPI *pGetUserProfileDirectoryW)(HANDLE, LPWSTR, LPDWORD); +static BOOL (WINAPI *pGetUserNameW)(LPWSTR, LPDWORD); +static DWORD (WINAPI *pGetFileAttributesW)(LPCWSTR); +static HANDLE (WINAPI *pFindFirstFileW)(LPCWSTR, LPWIN32_FIND_DATAW); +static BOOL (WINAPI *pFindNextFileW)(HANDLE, LPWIN32_FIND_DATAW); +static DWORD (WINAPI *pGetCurrentDirectoryW)(DWORD, LPWSTR); +static BOOL (WINAPI *pDeleteFileW)(LPCWSTR); +static BOOL (WINAPI *pRemoveDirectoryW)(LPCWSTR); +static BOOL (WINAPI *pCreateDirectoryW)(LPCWSTR, LPSECURITY_ATTRIBUTES); +static BOOL (WINAPI *pGetFileAttributesExA) + (LPCSTR, GET_FILEEX_INFO_LEVELS, LPVOID); +static BOOL (WINAPI *pGetFileAttributesExW) + (LPCWSTR, GET_FILEEX_INFO_LEVELS, LPVOID); +static DWORD (WINAPI *pFormatMessageW) + (DWORD, LPCVOID, DWORD, DWORD, LPWSTR, DWORD, va_list *); +static HANDLE (WINAPI *pCreateFileW) + (LPCWSTR, DWORD, DWORD, LPSECURITY_ATTRIBUTES, DWORD, DWORD, HANDLE); +static HRESULT (WINAPI *pSHGetFolderPathA)(HWND, int, HANDLE, DWORD, LPTSTR); +static BOOL (WINAPI *pMoveFileW)(LPCWSTR, LPCWSTR); +static void (WINAPI *pOutputDebugStringW)(LPCWSTR); + + +// Fallbacks for missing Unicode functions on Win95/98/ME. These are filled +// into the function pointers if looking up the real Unicode entry points +// in the system DLLs fails, so they're never used on WinNT/XP/Vista/etc. +// They make an earnest effort to convert to/from UTF-8 and UCS-2 to +// the user's current codepage. + +static BOOL WINAPI fallbackGetUserNameW(LPWSTR buf, LPDWORD len) +{ + const DWORD cplen = *len; + char *cpstr = smallAlloc(cplen); + BOOL retval = GetUserNameA(cpstr, len); + if (buf != NULL) + MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, cpstr, cplen, buf, *len); + smallFree(cpstr); + return retval; +} // fallbackGetUserNameW + +static DWORD WINAPI fallbackFormatMessageW(DWORD dwFlags, LPCVOID lpSource, + DWORD dwMessageId, DWORD dwLangId, + LPWSTR lpBuf, DWORD nSize, + va_list *Arguments) +{ + char *cpbuf = (char *) smallAlloc(nSize); + DWORD retval = FormatMessageA(dwFlags, lpSource, dwMessageId, dwLangId, + cpbuf, nSize, Arguments); + if (retval > 0) + MultiByteToWideChar(CP_ACP,MB_PRECOMPOSED,cpbuf,retval,lpBuf,nSize); + smallFree(cpbuf); + return retval; +} // fallbackFormatMessageW + +static DWORD WINAPI fallbackGetModuleFileNameW(HMODULE hMod, LPWCH lpBuf, + DWORD nSize) +{ + char *cpbuf = (char *) smallAlloc(nSize); + DWORD retval = GetModuleFileNameA(hMod, cpbuf, nSize); + if (retval > 0) + MultiByteToWideChar(CP_ACP,MB_PRECOMPOSED,cpbuf,retval,lpBuf,nSize); + smallFree(cpbuf); + return retval; +} // fallbackGetModuleFileNameW + +static DWORD WINAPI fallbackGetFileAttributesW(LPCWSTR fname) +{ + DWORD retval = 0; + const int buflen = (int) (wStrLen(fname) + 1); + char *cpstr = (char *) smallAlloc(buflen); + WideCharToMultiByte(CP_ACP, 0, fname, buflen, cpstr, buflen, NULL, NULL); + retval = GetFileAttributesA(cpstr); + smallFree(cpstr); + return retval; +} // fallbackGetFileAttributesW + +static DWORD WINAPI fallbackGetCurrentDirectoryW(DWORD buflen, LPWSTR buf) +{ + DWORD retval = 0; + char *cpbuf = NULL; + if (buf != NULL) + cpbuf = (char *) smallAlloc(buflen); + retval = GetCurrentDirectoryA(buflen, cpbuf); + if (cpbuf != NULL) + { + MultiByteToWideChar(CP_ACP,MB_PRECOMPOSED,cpbuf,retval,buf,buflen); + smallFree(cpbuf); + } // if + return retval; +} // fallbackGetCurrentDirectoryW + +static BOOL WINAPI fallbackRemoveDirectoryW(LPCWSTR dname) +{ + BOOL retval = 0; + const int buflen = (int) (wStrLen(dname) + 1); + char *cpstr = (char *) smallAlloc(buflen); + WideCharToMultiByte(CP_ACP, 0, dname, buflen, cpstr, buflen, NULL, NULL); + retval = RemoveDirectoryA(cpstr); + smallFree(cpstr); + return retval; +} // fallbackRemoveDirectoryW + +static BOOL WINAPI fallbackCreateDirectoryW(LPCWSTR dname, + LPSECURITY_ATTRIBUTES attr) +{ + BOOL retval = 0; + const int buflen = (int) (wStrLen(dname) + 1); + char *cpstr = (char *) smallAlloc(buflen); + WideCharToMultiByte(CP_ACP, 0, dname, buflen, cpstr, buflen, NULL, NULL); + retval = CreateDirectoryA(cpstr, attr); + smallFree(cpstr); + return retval; +} // fallbackCreateDirectoryW + +static BOOL WINAPI fallbackDeleteFileW(LPCWSTR fname) +{ + BOOL retval = 0; + const int buflen = (int) (wStrLen(fname) + 1); + char *cpstr = (char *) smallAlloc(buflen); + WideCharToMultiByte(CP_ACP, 0, fname, buflen, cpstr, buflen, NULL, NULL); + retval = DeleteFileA(cpstr); + smallFree(cpstr); + return retval; +} // fallbackDeleteFileW + +static HANDLE WINAPI fallbackCreateFileW(LPCWSTR fname, + DWORD dwDesiredAccess, DWORD dwShareMode, + LPSECURITY_ATTRIBUTES lpSecurityAttrs, + DWORD dwCreationDisposition, + DWORD dwFlagsAndAttrs, HANDLE hTemplFile) +{ + HANDLE retval; + const int buflen = (int) (wStrLen(fname) + 1); + char *cpstr = (char *) smallAlloc(buflen); + WideCharToMultiByte(CP_ACP, 0, fname, buflen, cpstr, buflen, NULL, NULL); + retval = CreateFileA(cpstr, dwDesiredAccess, dwShareMode, lpSecurityAttrs, + dwCreationDisposition, dwFlagsAndAttrs, hTemplFile); + smallFree(cpstr); + return retval; +} // fallbackCreateFileW + +static BOOL WINAPI fallbackMoveFileW(LPCWSTR src, LPCWSTR dst) +{ + BOOL retval; + const int srcbuflen = (int) (wStrLen(src) + 1); + char *srccpstr = (char *) smallAlloc(srcbuflen); + const int dstbuflen = (int) (wStrLen(dst) + 1); + char *dstcpstr = (char *) smallAlloc(dstbuflen); + WideCharToMultiByte(CP_ACP,0,src,srcbuflen,srccpstr,srcbuflen,NULL,NULL); + WideCharToMultiByte(CP_ACP,0,dst,dstbuflen,dstcpstr,dstbuflen,NULL,NULL); + retval = MoveFileA(srccpstr, dstcpstr); + smallFree(srccpstr); + smallFree(dstcpstr); + return retval; +} // fallbackMoveFileW + +static void WINAPI fallbackOutputDebugStringW(LPCWSTR str) +{ + const int buflen = (int) (wStrLen(str) + 1); + char *cpstr = (char *) smallAlloc(buflen); + WideCharToMultiByte(CP_ACP, 0, str, buflen, cpstr, buflen, NULL, NULL); + OutputDebugStringA(cpstr); + smallFree(cpstr); +} // fallbackOutputDebugStringW + + +// A blatant abuse of pointer casting... +static int symLookup(HMODULE dll, void **addr, const char *sym) +{ + return ((*addr = GetProcAddress(dll, sym)) != NULL); +} // symLookup + + +static boolean findApiSymbols(void) +{ + const boolean osHasUnicode = !osIsWin9x; + HMODULE dll = NULL; + + #define LOOKUP_NOFALLBACK(x, reallyLook) { \ + if (reallyLook) \ + symLookup(dll, (void **) &p##x, #x); \ + else \ + p##x = NULL; \ + } + + #define LOOKUP(x, reallyLook) { \ + if ((!reallyLook) || (!symLookup(dll, (void **) &p##x, #x))) \ + p##x = fallback##x; \ + } + + // Apparently Win9x HAS the Unicode entry points, they just don't WORK. + // ...so don't look them up unless we're on NT+. (see osHasUnicode.) + + dll = libUserEnv = LoadLibraryA("userenv.dll"); + if (dll != NULL) + LOOKUP_NOFALLBACK(GetUserProfileDirectoryW, osHasUnicode); + + // !!! FIXME: what do they call advapi32.dll on Win64? + dll = libAdvApi32 = LoadLibraryA("advapi32.dll"); + if (dll != NULL) + LOOKUP(GetUserNameW, osHasUnicode); + + // !!! FIXME: what do they call kernel32.dll on Win64? + dll = libKernel32 = LoadLibraryA("kernel32.dll"); + if (dll != NULL) + { + LOOKUP_NOFALLBACK(GetFileAttributesExA, 1); + LOOKUP_NOFALLBACK(GetFileAttributesExW, osHasUnicode); + LOOKUP_NOFALLBACK(FindFirstFileW, osHasUnicode); + LOOKUP_NOFALLBACK(FindNextFileW, osHasUnicode); + LOOKUP(GetModuleFileNameW, osHasUnicode); + LOOKUP(FormatMessageW, osHasUnicode); + LOOKUP(GetFileAttributesW, osHasUnicode); + LOOKUP(GetCurrentDirectoryW, osHasUnicode); + LOOKUP(CreateDirectoryW, osHasUnicode); + LOOKUP(RemoveDirectoryW, osHasUnicode); + LOOKUP(CreateFileW, osHasUnicode); + LOOKUP(DeleteFileW, osHasUnicode); + LOOKUP(MoveFileW, osHasUnicode); + LOOKUP(OutputDebugStringW, osHasUnicode); + } // if + + // !!! FIXME: what do they call shell32.dll on Win64? + dll = libShell32 = LoadLibraryA("shell32.dll"); + if (dll != NULL) + LOOKUP_NOFALLBACK(SHGetFolderPathA, 1); + + #undef LOOKUP_NOFALLBACK + #undef LOOKUP + + return true; +} // findApiSymbols + + + +// ok, now the actual platform layer implementation... + +boolean MojoPlatform_istty(void) +{ + return (GetConsoleWindow() != 0); +} // MojoPlatform_istty + + +boolean MojoPlatform_launchBrowser(const char *url) +{ + // msdn says: + // "Returns a value greater than 32 if successful, or an error value that + // is less than or equal to 32 otherwise." + return (((int) ShellExecuteA(NULL, "open", url, NULL, NULL, SW_SHOWNORMAL)) > 32); +} // MojoPlatform_launchBrowser + + +boolean MojoPlatform_installDesktopMenuItem(const char *data) +{ + // !!! FIXME: write me. + STUBBED("desktop menu support"); + return false; +} // MojoPlatform_installDesktopMenuItem + + +boolean MojoPlatform_uninstallDesktopMenuItem(const char *data) +{ + // !!! FIXME: write me. + STUBBED("desktop menu support"); + return false; +} // MojoPlatform_uninstallDesktopMenuItem + + +boolean MojoPlatform_spawnTerminal(void) +{ + assert(!MojoPlatform_istty()); + + if (AllocConsole()) + { + int hCrt; + FILE *hf; + hCrt = _open_osfhandle((long) GetStdHandle(STD_OUTPUT_HANDLE), _O_TEXT); + hf = _fdopen( hCrt, "w" ); + *stdout = *hf; + setvbuf( stdout, NULL, _IONBF, 0 ); + + hCrt = _open_osfhandle((long) GetStdHandle(STD_ERROR_HANDLE), _O_TEXT); + hf = _fdopen( hCrt, "w" ); + *stderr = *hf; + setvbuf( stderr, NULL, _IONBF, 0 ); + + hCrt = _open_osfhandle((long) GetStdHandle(STD_INPUT_HANDLE), _O_TEXT); + hf = _fdopen( hCrt, "r" ); + *stdin = *hf; + setvbuf( stdin, NULL, _IONBF, 0 ); + + return true; + } // if + + return false; +} // MojoPlatform_spawnTerminal + + +uint8 *MojoPlatform_decodeImage(const uint8 *data, uint32 size, + uint32 *w, uint32 *h) +{ + return NULL; // !!! FIXME: try IPicture? +} // MojoPlatform_decodeImage + + +char *MojoPlatform_currentWorkingDir(void) +{ + char *retval = NULL; + WCHAR *wbuf = NULL; + DWORD buflen = 0; + + buflen = pGetCurrentDirectoryW(buflen, NULL); + wbuf = (WCHAR *) smallAlloc((buflen + 2) * sizeof (WCHAR)); + BAIL_IF_MACRO(wbuf == NULL, ERR_OUT_OF_MEMORY, NULL); + pGetCurrentDirectoryW(buflen, wbuf); + + if (wbuf[buflen - 2] == '\\') + wbuf[buflen - 1] = '\0'; // just in case... + else + { + wbuf[buflen - 1] = '\\'; + wbuf[buflen] = '\0'; + } // else + + retval = unicodeToUtf8Heap(wbuf); + smallFree(wbuf); + return retval; +} // MojoPlatform_currentWorkingDir + + +char *MojoPlatform_readlink(const char *linkname) +{ + STUBBED("should use symlinks (reparse points) on Vista"); + return NULL; +} // MojoPlatform_readlink + + +// !!! FIXME: this code sort of sucks. +char *MojoPlatform_realpath(const char *path) +{ + // !!! FIXME: this should return NULL if (path) doesn't exist? + // !!! FIXME: Need to handle symlinks in Vista... + // !!! FIXME: try GetFullPathName() instead? + + // this function should be UTF-8 clean. + char *retval = NULL; + char *p = NULL; + + if ((path == NULL) || (*path == '\0')) + return NULL; + + retval = (char *) xmalloc(MAX_PATH); + + // If in \\server\path format, it's already an absolute path. + // We'll need to check for "." and ".." dirs, though, just in case. + if ((path[0] == '\\') && (path[1] == '\\')) + strcpy(retval, path); + + else + { + char *currentDir = MojoPlatform_currentWorkingDir(); + if (currentDir == NULL) + { + free(retval); + return NULL; + } // if + + if (path[1] == ':') // drive letter specified? + { + // Apparently, "D:mypath" is the same as "D:\\mypath" if + // D: is not the current drive. However, if D: is the + // current drive, then "D:mypath" is a relative path. Ugh. + + if (path[2] == '\\') // maybe an absolute path? + strcpy(retval, path); + else // definitely an absolute path. + { + if (path[0] == currentDir[0]) // current drive; relative. + { + strcpy(retval, currentDir); + strcat(retval, path + 2); + } // if + + else // not current drive; absolute. + { + retval[0] = path[0]; + retval[1] = ':'; + retval[2] = '\\'; + strcpy(retval + 3, path + 2); + } // else + } // else + } // if + + else // no drive letter specified. + { + if (path[0] == '\\') // absolute path. + { + retval[0] = currentDir[0]; + retval[1] = ':'; + strcpy(retval + 2, path); + } // if + else + { + strcpy(retval, currentDir); + strcat(retval, path); + } // else + } // else + + free(currentDir); + } // else + + // (whew.) Ok, now take out "." and ".." path entries... + + p = retval; + while ( (p = strstr(p, "\\.")) != NULL) + { + // it's a "." entry that doesn't end the string. + if (p[2] == '\\') + memmove(p + 1, p + 3, strlen(p + 3) + 1); + + // it's a "." entry that ends the string. + else if (p[2] == '\0') + p[0] = '\0'; + + // it's a ".." entry. + else if (p[2] == '.') + { + char *prevEntry = p - 1; + while ((prevEntry != retval) && (*prevEntry != '\\')) + prevEntry--; + + if (prevEntry == retval) // make it look like a "." entry. + memmove(p + 1, p + 2, strlen(p + 2) + 1); + else + { + if (p[3] != '\0') // doesn't end string. + *prevEntry = '\0'; + else // ends string. + memmove(prevEntry + 1, p + 4, strlen(p + 4) + 1); + + p = prevEntry; + } // else + } // else if + + else + { + p++; // look past current char. + } // else + } // while + + // shrink the retval's memory block if possible... + return (char *) xrealloc(retval, strlen(retval) + 1); +} // MojoPlatform_realpath + + +char *MojoPlatform_appBinaryPath(void) +{ + DWORD buflen = 64; + LPWSTR modpath = NULL; + char *retval = NULL; + DWORD rc = 0; + + while (true) + { + void *ptr = xrealloc(modpath, buflen * sizeof(WCHAR)); + + modpath = (LPWSTR) ptr; + + rc = pGetModuleFileNameW(NULL, modpath, buflen); + if (rc == 0) + { + free(modpath); + return NULL; + } // if + + if (rc < buflen) + { + buflen = rc; + break; + } // if + + buflen *= 2; + } // while + + if (buflen > 0) // just in case... + { + WCHAR *ptr = (modpath + buflen) - 1; + while (ptr != modpath) + { + if (*ptr == '\\') + break; + ptr--; + } // while + + if ((ptr != modpath) || (*ptr == '\\')) // should always be true... + { + *(ptr + 1) = '\0'; // chop off filename. + retval = unicodeToUtf8Heap(modpath); + } // else + } // else + + free(modpath); + return retval; +} // MojoPlatform_appBinaryPath + + +// Try to make use of GetUserProfileDirectoryW(), which isn't available on +// some common variants of Win32. If we can't use this, we just punt and +// use the binary path for the user dir, too. +// +// On success, module-scope variable (userDir) will have a pointer to +// a malloc()'d string of the user's profile dir, and a non-zero value is +// returned. If we can't determine the profile dir, (userDir) will +// be NULL, and zero is returned. + +char *MojoPlatform_homedir(void) +{ + char *userDir = NULL; + + // GetUserProfileDirectoryW() is only available on NT 4.0 and later. + // This means Win95/98/ME (and CE?) users have to do without, so for + // them, we'll default to the base directory when we can't get the + // function pointer. Since this is originally an NT API, we don't + // offer a non-Unicode fallback. + + if (pGetUserProfileDirectoryW != NULL) + { + HANDLE accessToken = NULL; // Security handle to process + HANDLE processHandle = GetCurrentProcess(); + if (OpenProcessToken(processHandle, TOKEN_QUERY, &accessToken)) + { + DWORD psize = 0; + WCHAR dummy = 0; + LPWSTR wstr = NULL; + BOOL rc = 0; + + // Should fail. Will write the size of the profile path in + // psize. Also note that the second parameter can't be + // NULL or the function fails. + rc = pGetUserProfileDirectoryW(accessToken, &dummy, &psize); + if (rc == 0) // this should always be true! + { + // Allocate memory for the profile directory + wstr = (LPWSTR) smallAlloc(psize * sizeof (WCHAR)); + if (wstr != NULL) + { + if (pGetUserProfileDirectoryW(accessToken, wstr, &psize)) + userDir = unicodeToUtf8Heap(wstr); + smallFree(wstr); + } // else + } // if + + CloseHandle(accessToken); + } // if + } // if + + if (userDir == NULL) // couldn't get profile for some reason. + { + // Might just be a non-NT system; try SHGetFolderPathA()... + if (pSHGetFolderPathA != NULL) // can be NULL if IE5+ isn't installed! + { + char shellPath[MAX_PATH]; + HRESULT status = pSHGetFolderPathA(NULL, CSIDL_PERSONAL, NULL, + SHGFP_TYPE_CURRENT, shellPath); + if (SUCCEEDED(status)) + userDir = codepageToUtf8Heap(shellPath); + } // if + } // if + + if (userDir == NULL) // Still nothing?! + { + // this either means we had a catastrophic failure, or we're on a + // Win95 system without at least Internet Explorer 5.0. Bleh! + userDir = xstrdup("C:\\My Documents"); // good luck with that. + } // if + + return userDir; +} // MojoPlatform_homedir + + +// This implementation is a bit naive. +char *MojoPlatform_locale(void) +{ + char lang[16]; + char country[16]; + + const int langrc = GetLocaleInfoA(LOCALE_USER_DEFAULT, + LOCALE_SISO639LANGNAME, + lang, sizeof (lang)); + + const int ctryrc = GetLocaleInfoA(LOCALE_USER_DEFAULT, + LOCALE_SISO3166CTRYNAME, + country, sizeof (country)); + + // Win95 systems will fail, because they don't have LOCALE_SISO*NAME ... + if ((langrc != 0) && (ctryrc != 0)) + return format("%0_%1", lang, country); + + return NULL; +} // MojoPlatform_locale + + +char *MojoPlatform_osType(void) +{ + if (osIsWin9x) + return xstrdup("win9x"); + else + return xstrdup("winnt"); + + return NULL; +} // MojoPlatform_ostype + + +char *MojoPlatform_osVersion(void) +{ + return format("%0.%1.%2", + numstr(osMajorVer), + numstr(osMinorVer), + numstr(osBuildVer)); +} // MojoPlatform_osversion + + +void MojoPlatform_sleep(uint32 ticks) +{ + Sleep(ticks); +} // MojoPlatform_sleep + + +uint32 MojoPlatform_ticks(void) +{ + return GetTickCount() - startupTime; +} // MojoPlatform_ticks + + +void MojoPlatform_die(void) +{ + STUBBED("Win32 equivalent of _exit()?"); + _exit(86); +} // MojoPlatform_die + + +boolean MojoPlatform_unlink(const char *fname) +{ + int retval = 0; + LPWSTR wpath; + UTF8_TO_UNICODE_STACK_MACRO(wpath, fname); + if (pGetFileAttributesW(wpath) == FILE_ATTRIBUTE_DIRECTORY) + retval = (pRemoveDirectoryW(wpath) != 0); + else + retval = (pDeleteFileW(wpath) != 0); + smallFree(wpath); + return retval; +} // MojoPlatform_unlink + + +boolean MojoPlatform_symlink(const char *src, const char *dst) +{ + STUBBED("Vista has symlink support"); + return false; +} // MojoPlatform_symlink + + +boolean MojoPlatform_mkdir(const char *path, uint16 perms) +{ + // !!! FIXME: error if already exists? + // !!! FIXME: perms? + WCHAR *wpath; + DWORD rc; + UTF8_TO_UNICODE_STACK_MACRO(wpath, path); + rc = pCreateDirectoryW(wpath, NULL); + smallFree(wpath); + return (rc != 0); +} // MojoPlatform_mkdir + + +boolean MojoPlatform_rename(const char *src, const char *dst) +{ + WCHAR *srcwpath; + WCHAR *dstwpath; + BOOL rc; + MojoPlatform_unlink(dst); // to match Unix rename()... + UTF8_TO_UNICODE_STACK_MACRO(srcwpath, src); + UTF8_TO_UNICODE_STACK_MACRO(dstwpath, dst); + rc = pMoveFileW(srcwpath, dstwpath); + smallFree(srcwpath); + smallFree(dstwpath); + return (rc != 0); +} // MojoPlatform_rename + + +boolean MojoPlatform_exists(const char *dir, const char *fname) +{ + WCHAR *wpath; + char *fullpath = NULL; + boolean retval = false; + + if (fname == NULL) + fullpath = xstrdup(dir); + else + { + const size_t len = strlen(dir) + strlen(fname) + 1; + fullpath = (char *) xmalloc(len); + snprintf(fullpath, len, "%s\\%s", dir, fname); + } // else + + UTF8_TO_UNICODE_STACK_MACRO(wpath, fullpath); + retval = (pGetFileAttributesW(wpath) != INVALID_FILE_ATTRIBUTES); + smallFree(wpath); + free(fullpath); + + return retval; +} // MojoPlatform_exists + + +boolean MojoPlatform_writable(const char *fname) +{ + boolean retval = false; + DWORD attr = 0; + WCHAR *wpath; + UTF8_TO_UNICODE_STACK_MACRO(wpath, fname); + attr = pGetFileAttributesW(wpath); + smallFree(wpath); + if (attr != INVALID_FILE_ATTRIBUTES) + retval = ((attr & FILE_ATTRIBUTE_READONLY) == 0); + return retval; +} // MojoPlatform_writable + + +boolean MojoPlatform_isdir(const char *dir) +{ + boolean retval = false; + LPWSTR wpath; + UTF8_TO_UNICODE_STACK_MACRO(wpath, dir); + retval = ((pGetFileAttributesW(wpath) & FILE_ATTRIBUTE_DIRECTORY) != 0); + smallFree(wpath); + return retval; +} // MojoPlatform_isdir + + +static boolean isSymlinkAttrs(const DWORD attr, const DWORD tag) +{ + return ( (attr & FILE_ATTRIBUTE_REPARSE_POINT) && + (tag == IO_REPARSE_TAG_SYMLINK) ); +} // isSymlinkAttrs + + +boolean MojoPlatform_issymlink(const char *fname) +{ + // !!! FIXME: + // Windows Vista can have NTFS symlinks. Can older Windows releases have + // them when talking to a network file server? What happens when you + // mount a NTFS partition on XP that was plugged into a Vista install + // that made a symlink? + + boolean retval = false; + LPWSTR wpath; + HANDLE dir; + WIN32_FIND_DATAW entw; + + // no unicode entry points? Probably no symlinks. + if (pFindFirstFileW == NULL) + return false; + + // !!! FIXME: filter wildcard chars? + UTF8_TO_UNICODE_STACK_MACRO(wpath, fname); + dir = pFindFirstFileW(wpath, &entw); + smallFree(wpath); + + if (dir != INVALID_HANDLE_VALUE) + { + retval = isSymlinkAttrs(entw.dwFileAttributes, entw.dwReserved0); + FindClose(dir); + } // if + + return retval; +} // MojoPlatform_issymlink + + +boolean MojoPlatform_isfile(const char *dir) +{ + return ((!MojoPlatform_isdir(dir)) && (!MojoPlatform_issymlink(dir))); +} // MojoPlatform_isfile + + +void *MojoPlatform_stdout(void) +{ + return NULL; // unsupported on Windows. +} // MojoPlatform_stdout + + +void *MojoPlatform_open(const char *fname, uint32 flags, uint16 mode) +{ + HANDLE *retval = NULL; + DWORD accessMode = 0; + DWORD createMode = 0; + DWORD shareMode = FILE_SHARE_DELETE | FILE_SHARE_READ | FILE_SHARE_WRITE; + WCHAR *wpath = NULL; + HANDLE fd = 0; + + if (flags & MOJOFILE_READ) + accessMode |= GENERIC_READ; + if (flags & MOJOFILE_WRITE) + accessMode |= GENERIC_WRITE; + if (accessMode == 0) + return NULL; // have to specify SOMETHING. + +// if (flags & MOJOFILE_APPEND) +// unixflags |= O_APPEND; + + if ((flags & MOJOFILE_CREATE) && (flags & MOJOFILE_EXCLUSIVE)) + createMode = CREATE_NEW; + else if ((flags & MOJOFILE_CREATE) && (flags & MOJOFILE_TRUNCATE)) + createMode = CREATE_ALWAYS; + else if (flags & MOJOFILE_CREATE) + createMode = OPEN_ALWAYS; + else if (flags & MOJOFILE_TRUNCATE) + createMode = TRUNCATE_EXISTING; + else + createMode = OPEN_EXISTING; + + // !!! FIXME + STUBBED("file permissions"); + + UTF8_TO_UNICODE_STACK_MACRO(wpath, fname); + fd = pCreateFileW(wpath, accessMode, shareMode, NULL, createMode, + FILE_ATTRIBUTE_NORMAL, NULL); + smallFree(wpath); + + if (fd != INVALID_HANDLE_VALUE) + { + retval = (HANDLE *) xmalloc(sizeof (HANDLE)); + *retval = fd; + } // if + + return retval; +} // MojoPlatform_open + + +int64 MojoPlatform_read(void *fd, void *buf, uint32 bytes) +{ + HANDLE handle = *((HANDLE *) fd); + DWORD br = 0; + + // Read data from the file + // !!! FIXME: uint32 might be a greater # than DWORD + if(!ReadFile(handle, buf, bytes, &br, NULL)) + return -1; + + return (int64) br; +} // MojoPlatform_read + + +int64 MojoPlatform_write(void *fd, const void *buf, uint32 bytes) +{ + HANDLE handle = *((HANDLE *) fd); + DWORD bw = 0; + + // Read data from the file + // !!! FIXME: uint32 might be a greater # than DWORD + if(!WriteFile(handle, buf, bytes, &bw, NULL)) + return -1; + + return (int64) bw; +} // MojoPlatform_write + + +int64 MojoPlatform_tell(void *fd) +{ + return MojoPlatform_seek(fd, 0, MOJOSEEK_CURRENT); +} // MojoPlatform_tell + + +int64 MojoPlatform_seek(void *fd, int64 pos, MojoFileSeek whence) +{ + HANDLE handle = *((HANDLE *) fd); + DWORD highpos = HIGHORDER_UINT64(pos); + const DWORD lowpos = LOWORDER_UINT64(pos); + DWORD winwhence = 0; + DWORD rc = 0; + + switch (whence) + { + case MOJOSEEK_SET: winwhence = FILE_BEGIN; break; + case MOJOSEEK_CURRENT: winwhence = FILE_CURRENT; break; + case MOJOSEEK_END: winwhence = FILE_END; break; + default: return -1; // !!! FIXME: maybe just abort? + } // switch + + rc = SetFilePointer(handle, lowpos, &highpos, winwhence); + if ( (rc == INVALID_SET_FILE_POINTER) && (GetLastError() != NO_ERROR) ) + return -1; + + return (int64) ((((uint64) highpos) << 32) | ((uint64) rc)); +} // MojoPlatform_seek + + +int64 MojoPlatform_flen(void *fd) +{ + HANDLE handle = *((HANDLE *) fd); + int64 retval = 0; + DWORD SizeHigh = 0; + DWORD SizeLow = GetFileSize(handle, &SizeHigh); + + if ((SizeLow == INVALID_SET_FILE_POINTER) && (GetLastError() != NO_ERROR)) + return -1; + else + { + // Combine the high/low order to create the 64-bit position value + retval = (int64) ((((uint64) SizeHigh) << 32) | ((uint64) SizeLow)); + assert(retval >= 0); + } // else + + return retval; +} // MojoPlatform_flen + + +boolean MojoPlatform_flush(void *fd) +{ + HANDLE handle = *((HANDLE *) fd); + return (FlushFileBuffers(handle) != 0); +} // MojoPlatform_flush + + +boolean MojoPlatform_close(void *fd) +{ + HANDLE handle = *((HANDLE *) fd); + boolean retval = (CloseHandle(handle) != 0); + if (retval) + free(fd); + return retval; +} // MojoPlatform_close + + +typedef struct +{ + HANDLE dir; + boolean done; + WIN32_FIND_DATA ent; + WIN32_FIND_DATAW entw; +} WinApiDir; + +void *MojoPlatform_opendir(const char *dirname) +{ + const int unicode = (pFindFirstFileW != NULL) && (pFindNextFileW != NULL); + size_t len = strlen(dirname); + char *searchPath = NULL; + WCHAR *wSearchPath = NULL; + WinApiDir *retval = (WinApiDir *) xmalloc(sizeof (WinApiDir)); + + retval->dir = INVALID_HANDLE_VALUE; + retval->done = false; + + // Allocate a new string for path, maybe '\\', "*", and NULL terminator + searchPath = (char *) smallAlloc(len + 3); + + // Copy current dirname + strcpy(searchPath, dirname); + + // if there's no '\\' at the end of the path, stick one in there. + if (searchPath[len - 1] != '\\') + { + searchPath[len++] = '\\'; + searchPath[len] = '\0'; + } // if + + // Append the "*" to the end of the string + strcat(searchPath, "*"); + + UTF8_TO_UNICODE_STACK_MACRO(wSearchPath, searchPath); + + if (unicode) + retval->dir = pFindFirstFileW(wSearchPath, &retval->entw); + else + { + const int len = (int) (wStrLen(wSearchPath) + 1); + char *cp = (char *) smallAlloc(len); + WideCharToMultiByte(CP_ACP, 0, wSearchPath, len, cp, len, 0, 0); + retval->dir = FindFirstFileA(cp, &retval->ent); + smallFree(cp); + } // else + + smallFree(wSearchPath); + smallFree(searchPath); + if (retval->dir == INVALID_HANDLE_VALUE) + { + free(retval); + return NULL; + } // if + + return retval; +} // MojoPlatform_opendir + + +char *MojoPlatform_readdir(void *_dirhandle) +{ + const int unicode = (pFindFirstFileW != NULL) && (pFindNextFileW != NULL); + WinApiDir *dir = (WinApiDir *) _dirhandle; + char *utf8 = NULL; + + if (dir->done) + return NULL; + + if (unicode) + { + do + { + const DWORD attr = dir->entw.dwFileAttributes; + const DWORD tag = dir->entw.dwReserved0; + const WCHAR *fn = dir->entw.cFileName; + if ((fn[0] == '.') && (fn[1] == '\0')) + continue; + if ((fn[0] == '.') && (fn[1] == '.') && (fn[2] == '\0')) + continue; + + utf8 = unicodeToUtf8Heap(fn); + dir->done = (pFindNextFileW(dir->dir, &dir->entw) == 0); + return utf8; + } while (pFindNextFileW(dir->dir, &dir->entw) != 0); + } // if + + else // ANSI fallback. + { + do + { + const DWORD attr = dir->ent.dwFileAttributes; + const DWORD tag = dir->ent.dwReserved0; + const char *fn = dir->ent.cFileName; + if ((fn[0] == '.') && (fn[1] == '\0')) + continue; + if ((fn[0] == '.') && (fn[1] == '.') && (fn[2] == '\0')) + continue; + + utf8 = codepageToUtf8Heap(fn); + dir->done = (FindNextFileA(dir->dir, &dir->ent) == 0); + return utf8; + } while (FindNextFileA(dir->dir, &dir->ent) != 0); + } // else + + dir->done = true; + return NULL; +} // MojoPlatform_readdir + + +void MojoPlatform_closedir(void *dirhandle) +{ + WinApiDir *dir = (WinApiDir *) dirhandle; + if (dir) + { + FindClose(dir->dir); + free(dir); + } // if +} // MojoPlatform_closedir + + +int64 MojoPlatform_filesize(const char *fname) +{ + // !!! FIXME: this is lame. + int64 retval = -1; + void *fd = MojoPlatform_open(fname, MOJOFILE_READ, 0); + STUBBED("use a stat()-like thing instead"); + if (fd != NULL) + { + retval = MojoPlatform_seek(fd, 0, MOJOSEEK_END); + MojoPlatform_close(fd); + } // if + + return retval; +} // MojoPlatform_filesize + + +boolean MojoPlatform_perms(const char *fname, uint16 *p) +{ + STUBBED("Windows permissions"); + *p = 0; + return true; +} // MojoPlatform_perms + + +uint16 MojoPlatform_defaultFilePerms(void) +{ + STUBBED("Windows permissions"); + return 0644; +} // MojoPlatform_defaultFilePerms + + +uint16 MojoPlatform_defaultDirPerms(void) +{ + STUBBED("Windows permissions"); + return 0755; +} // MojoPlatform_defaultDirPerms + + +uint16 MojoPlatform_makePermissions(const char *str, boolean *_valid) +{ + STUBBED("Windows permissions"); + *_valid = true; + return 0; +} // MojoPlatform_makePermissions + + +boolean MojoPlatform_chmod(const char *fname, uint16 p) +{ + STUBBED("Windows permissions"); + return true; + //return (chmod(fname, p) != -1); +} // MojoPlatform_chmod + + +static BOOL mediaInDrive(const char *drive) +{ + // Prevent windows warning message appearing when checking media size + UINT oldErrorMode = SetErrorMode(SEM_FAILCRITICALERRORS); + DWORD tmp = 0; + // If the function succeeds, there's media in the drive + BOOL retval = GetVolumeInformationA(drive,NULL,0,NULL,NULL,&tmp,NULL,0); + + // Revert back to old windows error handler + SetErrorMode(oldErrorMode); + return retval; +} // mediaInDrive + + +char *MojoPlatform_findMedia(const char *uniquefile) +{ + // !!! FIXME: Probably shouldn't just check drive letters... + + char drive_str[4] = { 'x', ':', '\\', '\0' }; + char ch; + UINT rc; + boolean found = false; + + for (ch = 'A'; ch <= 'Z'; ch++) + { + drive_str[0] = ch; + rc = GetDriveTypeA(drive_str); + if ((rc != DRIVE_UNKNOWN) && (rc != DRIVE_NO_ROOT_DIR)) + { + if (mediaInDrive(drive_str)) + { + drive_str[2] = '\0'; + found = (MojoPlatform_exists(drive_str, uniquefile)); + drive_str[2] = '\\'; + if (found) + return xstrdup(drive_str); + } // if + } // if + } // for + + return NULL; +} // MojoPlatform_findMedia + + +void MojoPlatform_log(const char *str) +{ + if (pOutputDebugStringW != NULL) // in case this gets called before init... + { + static const WCHAR endl[3] = { '\r', '\n', '\0' }; + WCHAR *wstr; + UTF8_TO_UNICODE_STACK_MACRO(wstr, str); + STUBBED("OutputDebugString() is probably not best here"); + pOutputDebugStringW(wstr); + pOutputDebugStringW(endl); + smallFree(wstr); + } // if +} // MojoPlatform_log + + +typedef struct +{ + HINSTANCE dll; + HANDLE file; +} WinApiDll; + +void *MojoPlatform_dlopen(const uint8 *img, size_t len) +{ + WinApiDll *retval = NULL; + char path[MAX_PATH]; + char fname[MAX_PATH]; + DWORD bw = 0; + HANDLE handle; + HINSTANCE dll; + + GetTempPath(sizeof (path), path); + GetTempFileName(path, "mojosetup-plugin-", 0, fname); + + handle = CreateFileA(fname, GENERIC_WRITE, 0, NULL, OPEN_EXISTING, 0, NULL); + if (handle == INVALID_HANDLE_VALUE) + return NULL; + + WriteFile(handle, img, len, &bw, NULL); // dump it to the temp file. + + CloseHandle(handle); + if (bw != len) + { + DeleteFile(fname); + return NULL; + } // if + + // The DELETE_ON_CLOSE will cause the kernel to remove the file when + // we're done with it, including manually closing or the process + // terminating (including crashing). We hold this handle until we close + // the library. + handle = CreateFileA(fname, GENERIC_READ, FILE_SHARE_READ, NULL, + OPEN_EXISTING, FILE_FLAG_DELETE_ON_CLOSE, NULL); + if (handle == INVALID_HANDLE_VALUE) + { + DeleteFile(fname); + return NULL; + } // if + + dll = LoadLibraryA(fname); + if (dll == NULL) + { + CloseHandle(handle); // (also deletes temp file.) + return NULL; + } // if + + retval = (WinApiDll *) xmalloc(sizeof (WinApiDll)); + retval->dll = dll; + retval->file = handle; + return retval; +} // MojoPlatform_dlopen + + +void *MojoPlatform_dlsym(void *_lib, const char *sym) +{ + const WinApiDll *lib = (const WinApiDll *) _lib; + return ((lib) ? GetProcAddress(lib->dll, sym) : NULL); +} // MojoPlatform_dlsym + + +void MojoPlatform_dlclose(void *_lib) +{ + WinApiDll *lib = (WinApiDll *) _lib; + if (lib) + { + FreeLibrary(lib->dll); + CloseHandle(lib->file); // this also deletes the temp file. + free(lib); + } // if +} // MojoPlatform_dlclose + + +uint64 MojoPlatform_getuid(void) +{ + return 0; // !!! FIXME +} // MojoPlatform_getuid + + +uint64 MojoPlatform_geteuid(void) +{ + return 0; // !!! FIXME +} // MojoPlatform_geteuid + + +uint64 MojoPlatform_getgid(void) +{ + return 0; // !!! FIXME +} // MojoPlatform_getgid + + + +// Get OS info and save the important parts. +// Returns non-zero if successful, otherwise it returns zero on failure. +static boolean getOSInfo(void) +{ + OSVERSIONINFO osVerInfo; + osVerInfo.dwOSVersionInfoSize = sizeof(osVerInfo); + if (!GetVersionEx(&osVerInfo)) + return false; + + osIsWin9x = (osVerInfo.dwPlatformId == VER_PLATFORM_WIN32_WINDOWS); + osMajorVer = (uint32) osVerInfo.dwMajorVersion; + osMinorVer = (uint32) osVerInfo.dwMinorVersion; + osBuildVer = (uint32) osVerInfo.dwBuildNumber; + + return true; +} // getOSInfo + + +static boolean platformInit(void) +{ + startupTime = GetTickCount(); + + if (!getOSInfo()) + return false; + + if (!findApiSymbols()) + return false; + + return true; +} // platformInit + + +static void platformDeinit(void) +{ + HANDLE *libs[] = { &libKernel32, &libUserEnv, &libAdvApi32, &libShell32 }; + int i; + + for (i = 0; i < (sizeof (libs) / sizeof (libs[0])); i++) + { + const HANDLE lib = *(libs[i]); + if (lib) + { + FreeLibrary(lib); + *(libs[i]) = NULL; + } // if + } // for +} // platformDeinit + + +static void buildCommandlineArray(LPSTR szCmd, int *_argc, char ***_argv) +{ + int argc = 0; + char **argv = NULL; + + // !!! FIXME: STUBBED("parse command line string into array"); + + *_argc = argc; + *_argv = argv; +} // buildCommandlineArray + + +static void freeCommandlineArray(int argc, char **argv) +{ + while (argc--) + free(argv[argc]); + free(argv); +} // freeCommandlineArray + + +int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrev, LPSTR szCmd, int nCmdShow) +{ + int retval = 0; + int argc = 0; + char **argv = NULL; + + if (!platformInit()) + retval = 1; + else + { + buildCommandlineArray(szCmd, &argc, &argv); + //openlog("mojosetup", LOG_PID, LOG_USER); + //atexit(closelog); + STUBBED("signal handlers"); + //install_signals(); + retval = MojoSetup_main(argc, argv); + freeCommandlineArray(argc, argv); + + platformDeinit(); + } // else + + return retval; +} // main + +#endif // PLATFORM_WINDOWS + +// end of windows.c ... + diff --git a/mk/linux/mojosetup/scripts/app_localization.lua b/mk/linux/mojosetup/scripts/app_localization.lua new file mode 100644 index 00000000..812c80cb --- /dev/null +++ b/mk/linux/mojosetup/scripts/app_localization.lua @@ -0,0 +1,67 @@ +-- MojoSetup; a portable, flexible installation application. +-- +-- Please see the file LICENSE.txt in the source's root directory. +-- +-- This file written by Ryan C. Gordon. +-- +-- Lines starting with "--" are comments in this file. +-- +-- You should add your installer's strings to this file; localization.lua is +-- for strings used internally by MojoSetup itself. Your app can override any +-- individual string in that file, though. +-- +-- NOTE: If you care about Unicode or ASCII chars above 127, this file _MUST_ +-- be UTF-8 encoded! If you think you're using a certain high-ASCII codepage, +-- you're wrong! +-- +-- Most of the MojoSetup table isn't set up when this code is run, so you +-- shouldn't rely on any of it. For most purposes, you should treat this +-- file more like a data description language and less like a turing-complete +-- scripting language. +-- +-- The format of an entry looks like this: +-- +-- ["Hello"] = { +-- es = "Hola", +-- de = "Hallo", +-- fr = "Bonjour", +-- }; +-- +-- So you just fill in the translation of the English for your language code. +-- Note that locales work, too: +-- +-- ["Color"] = { +-- en_GB = "Colour", +-- }; +-- +-- Specific locales are favored, falling back to specific languages, eventually +-- ending up on the untranslated version (which is technically en_US). +-- +-- Whenever you see a %x sequence, that is replaced with a string at runtime. +-- So if you see, ["Hello, %0, my name is %1."], then this might become +-- "Hello, Alice, my name is Bob." at runtime. If your culture would find +-- introducing yourself second to be rude, you might translate this to: +-- "My name is %1, hello %0." If you need a literal '%' char, write "%%": +-- "Operation is %0%% complete" might give "Operation is 3% complete." +-- All strings, from your locale or otherwise, are checked for formatter +-- correctness at startup. This is to prevent the installer working fine +-- in all reasonable tests, then finding out that one guy in Ghana has a +-- crashing installer because his localization forgot to add a %1 somewhere. +-- +-- Occasionally you might see a "\n" ... that's a newline character. "\t" is +-- a tab character, and "\\" turns into a single "\" character. +-- +-- The table you create here goes away shortly after creation, as the relevant +-- parts of it get moved somewhere else. You should call MojoSetup.translate() +-- to get the proper translation for a given string. +-- +-- Questions about the intent of a specific string can go to Ryan C. Gordon +-- (icculus@icculus.org). + +MojoSetup.applocalization = { +}; + +-- end of app_localization.lua ... + + + diff --git a/mk/linux/mojosetup/scripts/config.lua b/mk/linux/mojosetup/scripts/config.lua new file mode 100644 index 00000000..9d200669 --- /dev/null +++ b/mk/linux/mojosetup/scripts/config.lua @@ -0,0 +1,235 @@ +-- MojoSetup; a portable, flexible installation application. +-- +-- Please see the file LICENSE.txt in the source's root directory. +-- +-- This file written by Ryan C. Gordon. + + +-- This is a setup file. Lines that start with "--" are comments. +-- This config file is actually just Lua code. Even though you'll only +-- need a small subset of the language, there's a lot of flexibility +-- available to you if you need it. http://www.lua.org/ +-- +-- All functionality supplied by the installer is encapsulated in either the +-- "Setup" or "MojoSetup" table, so you can use any other symbol name without +-- namespace clashes, assuming it's not a Lua keyword or a symbol supplied +-- by the standard lua libraries. +-- +-- So here's the actual configuration...we used loki_setup's xml schema +-- as a rough guideline. + +-- You can define functions like in any other Lua script. For example, here's +-- a function that figures out how many bytes are in a megabyte, so you don't +-- have to list exact values in Setup.Option's "bytes" attribute. +local function megabytes(num) + return num * 1024 * 1024 +end + +-- And naturally, functions can build on others. It's a programming language, +-- after all! But if you don't want to screw with programming, you can treat +-- this strictly as a config file. This just gives you flexibility if you +-- need it. +local function gigabytes(num) + return megabytes(num) * 1024 +end + +Setup.Package +{ + vendor = "com.mycompany", + id = "mygame", + description = "My Game", + version = "1.0", + splash = "splash.jpg", + superuser = false, + destination = "/usr/local/bin", + recommended_destinations = { "/opt/games", "/usr/local/games" }, + updateurl = "http://localhost/updates/", + write_manifest = true, + support_uninstall = true, + + -- Things named Setup.Something are internal functions we supply. + -- Generally these return the table you pass to them, but they + -- may sanitize the values, add defaults, and verify the data. + + -- End User License Agreement(s). You can specify multiple + -- Setup.Eula sections here. + -- Also, Note the "translate" call. + -- This shows up as the first thing the user sees, and must + -- agree to before anything goes forward. You could put this + -- in the base Setup.Option and they won't be shown it until + -- installation is about to start, if you would rather + -- defer this until necessary and/or show the README first. + Setup.Eula + { + description = "My Game License", + source = MojoSetup.translate("MyGame_EULA.html") + }, + + -- README file(s) to show and install. + Setup.Readme + { + description = "My Game README", + source = MojoSetup.translate("README.html"), + }, + + -- Specify media (discs) we may need for this install and how to find them. + Setup.Media + { + id = "cd1", + description = "MyGame CD 1", + uniquefile = "Sound/blip.wav" + }, + + Setup.Media + { + id = "cd2", + description = "MyGame CD 2", + uniquefile = "Maps/town.map" + }, + + -- Specify chunks to install...optional or otherwise. + Setup.Option + { + value = true, + required = true, + disabled = false, + bytes = megabytes(600), + description = "Base Install", + + -- Install a desktop menu item with the base install. + Setup.DesktopMenuItem + { + disabled = false, + name = "My Game", + genericname = "Shoot-em up", + tooltip = "A game of alien hunting.", + builtin_icon = false, + icon = "icon.png", -- relative to the dest; you must install it! + commandline = "command-line", + category = "Game", + mimetype = { 'application/x-mygame-map', 'application/x-mygame-url' }, + }, + + -- File(s) to install with this option. + Setup.File + { + -- source can be a directory, an archive, or a supported URL. + -- You can use "media://" to get data from a disc that the user + -- will be prompted to insert. Everything in the source will + -- be installed, but the "wildcards" and "filter" attributes + -- can be used to cull the archive's contents. + source = "media://cd1/Maps/m.zip", + + -- This is a directory where files will be installed from this + -- source. If this isn't specified, the directory tree structure + -- in the source will be recreated for the installation. + -- You can change the destination on a per-file basis using + -- the filter attribute instead. It overrides this attribute, + -- but the parameter passed to the filter will use this value + -- if it exists. + destination = "MyGame/MyGame.app", + + -- Files in here need to match at least one wildcard to be + -- installed. If they pass here, they go to the filter function. + -- This can be a single string or a table of strings. + wildcards = { "Single/*/*.map", "Multi/*/*.map" }, + + -- You can optionally assign a lua function...we'll call this for + -- each file to see if we should avoid installing it. It returns + -- nil to drop the file from the install list, or a string of + -- the new install destination...you can return the original + -- string to just pass it through for installation, or + -- use this opportunity to rename a file on the fly. + filter = function(fn) + if fn == "Single/x/dontinstall.map" then return nil end + return fn + end + }, + + -- Here's a suboption that has it's own EULA. + Setup.Option + { + value = true, + required = false, + disabled = false, + bytes = megabytes(1), + description = "PunkBuster support", + + Setup.Eula + { + description = "Punkbuster License", + source = MojoSetup.translate("PunkBuster_EULA.html"), + }, + + Setup.File + { + source = "media://cd1/pb.zip", + }, + }, + + -- Radio buttons. + Setup.OptionGroup + { + disabled = false, + description = "Language", + Setup.Option + { + value = string.match(MojoSetup.info.locale, "^en_") ~= nil, + bytes = megabytes(10), + description = "English", + Setup.File { source = "base:///Lang/English.zip" }, + }, + Setup.Option + { + value = string.match(MojoSetup.info.locale, "^fr_") ~= nil, + bytes = 0, + description = "French", + Setup.OptionGroup + { + disabled = false, + description = "French locale", + Setup.Option + { + value = (MojoSetup.info.locale == fr_CA), + bytes = megabytes(10), + description = "French Canadian", + Setup.File { source = "base:///Lang/FrenchCA.zip" }, + }, + Setup.Option + { + value = (MojoSetup.info.locale ~= fr_CA), + bytes = megabytes(10), + description = "Generic French", + Setup.File { source = "base:///Lang/French.zip" }, + }, + }, + }, + Setup.Option + { + value = string.match(MojoSetup.info.locale, "^de_") ~= nil, + bytes = megabytes(10), + description = "German", + Setup.File { source = "base:///Lang/German.zip" }, + }, + }, + }, + + Setup.Option + { + value = true, + required = false, + disabled = false, + bytes = 19384292, + description = "Downloadable extras", + + -- File(s) to install. + Setup.File + { + destination = "MyGame/MyGame.app", + source = "http://hostname.dom/extras/extras.zip", + }, + }, +} + +-- end of config.lua ... + diff --git a/mk/linux/mojosetup/scripts/localization.lua b/mk/linux/mojosetup/scripts/localization.lua new file mode 100644 index 00000000..c53f2745 --- /dev/null +++ b/mk/linux/mojosetup/scripts/localization.lua @@ -0,0 +1,4661 @@ +-- MojoSetup; a portable, flexible installation application. +-- +-- Please see the file LICENSE.txt in the source's root directory. +-- +-- DO NOT EDIT BY HAND. +-- This file was generated with po2localization.pl, version hg-731:d431888dc3f3 ... +-- on 2009-12-14 03:16:00-0500 +-- +-- Your own installer's localizations go into app_localization.lua instead. +-- If you want to add strings to be translated to this file, contact Ryan +-- (icculus@icculus.org). If you want to add or change a translation for +-- existing strings, please use our nice web interface here for your work: +-- +-- https://translations.launchpad.net/mojosetup/ +-- +-- ...and that work eventually ends up in this file. +-- +-- X-Launchpad-Export-Date: 2009-12-14 08:00+0000 +-- X-Generator: Launchpad (build Unknown) + +MojoSetup.languages = { + en_US = "English (United States)", + af = "Afrikaans", + ar = "Arabic", + cs = "Czech", + da = "Danish", + de = "German", + el = "Greek", + en_AU = "English (Australia)", + en_CA = "English (Canada)", + en_GB = "English (United Kingdom)", + es = "Spanish", + et = "Estonian", + fa = "Persian", + fi = "Finnish", + fr = "French", + he = "Hebrew", + hu = "Hungarian", + id = "Indonesian", + it = "Italian", + ja = "Japanese", + lb = "Luxembourgish", + nb = "Norwegian Bokmal", + nds = "German, Low", + nl = "Dutch", + nn = "Norwegian Nynorsk", + pl = "Polish", + pt = "Portuguese", + pt_BR = "Brazilian Portuguese", + ro = "Romanian", + ru = "Russian", + sk = "Slovak", + sl = "Slovenian", + sv = "Swedish", + te = "Telugu", + tr = "Turkish", + uk = "Ukrainian", + zh_TW = "Traditional Chinese" +}; + +MojoSetup.localization = { + -- This may be shown to the end-user if the application gets extremely + -- confused. It may be shown in desperate sitations when we know + -- something has gone wrong, but not what exactly. + ["unknown error"] = { + af = "onbekende fout", + ar = "خطأ مجهول", + cs = "neznámá chyba", + da = "ukendt fejl", + de = "Unbekannter Fehler", + el = "άγνωστο σφάλμα", + en_AU = "unknown error", + en_CA = "unknown error", + en_GB = "unknown error", + es = "error desconocido", + et = "tundmatu viga", + fa = "خطای نامعلوم", + fi = "Tuntematon virhe", + fr = "Erreur inconnue", + he = "שגי××” ×œ× ×™×“×•×¢×”", + hu = "ismeretlen hiba", + id = "galat tidak dikenal", + it = "errore sconosciuto", + ja = "ä¸æ˜Žãªã‚¨ãƒ©ãƒ¼", + lb = "Onbekannten Fehler", + nb = "ukjent feil", + nds = "unbekannter Fehler", + nl = "onbekende fout", + nn = "ukjent feil", + pl = "nieznany bÅ‚Ä…d", + pt = "erro desconhecido", + pt_BR = "erro desconhecido", + ro = "eroare necunoscută", + ru = "неизвеÑÑ‚Ð½Ð°Ñ Ð¾ÑˆÐ¸Ð±ÐºÐ°", + sk = "neznáma chyba", + sl = "neznana napaka", + sv = "okänt fel", + tr = "bilinmeyen hata", + uk = "невідома помилка", + zh_TW = "未知的錯誤" + }; + + -- stdio UI plugin says this for "OK"-only msgboxes. "%0" is the message + -- box's text content. "[hit enter]" should be translated, too! It's + -- trying to tell the application's user that they should press the + -- key that is normally used to complete a line of text at a terminal's + -- prompt. + ["NOTICE: %0\n[hit enter]"] = { + af = "KENNIS: %0", + ar = "ملحوظة:%0\n[اضغط enter]", + cs = "UPOZORNÄšNÃ: %0\n[stisknÄ›te enter]", + da = "NB: %0\n[tryk enter]", + de = "HINWEIS: %0\n[Drücken Sie Enter]", + el = "ΠΡΟΣΟΧΗ: %0\n[πατήστε ENTER]", + en_AU = "NOTICE: %0\n[hit enter]", + en_CA = "NOTICE: %0\n[hit enter]", + en_GB = "NOTICE: %0\n[hit enter]", + es = "AVISO: %0\n[presiona Intro]", + fi = "HUOMAUTUS: %0\n[paina enter]", + fr = "INFORMATION : %0\n[pressez entrée]", + he = "התר××”: %0\n[לחץ enter]", + hu = "FIGYELEM: %0\n[üss entert]", + id = "CATATAN: %0\n[tekan enter]", + it = "ATTENZIONE: %0", + nb = "Notis: %0\n[trykk enter]", + nds = "HINWEIS: %0", + nl = "OPMERKING: %0\n[Toets enter]", + nn = "Notis: %0\n[trykk enter]", + pt = "AVISO: %0\n[pressione enter]", + pt_BR = "AVISO: %0", + ro = "ATENÅ¢IE: %0\n[apasă enter]", + ru = "Ð’ÐИМÐÐИЕ: %0\n[нажмите enter]", + sk = "Správa: %0", + sl = "OPOZORILO: %0\n[pritisnite enter]", + sv = "NOTERA: %0\n[tryck enter]", + tr = "UYARI: %0\n[giriÅŸ tuÅŸuna basınız]", + uk = "ДО УВÐГИ: %0", + zh_TW = "æ醒:%0" + }; + + -- stdio UI plugin says this for yes/no prompts that default to yes. + -- "%0" is the question the user is being asked to respond to. + -- "[Y/n]" are two options that the user will have to type in response. + -- Please pick reasonable abbreviations for YES and NO that can be + -- typed easily by the user. Case of the "Y" and "n" are not important, + -- although we are using the capital letter to show the default option + -- if the user just presses enter. Be sure to translate the strings "Y" + -- and "N", elsewhere, to match what you enter here! At runtime, the + -- user's response is compared to those strings without case sensitivity. + ["%0 [Y/n]: "] = { + af = "%0 [Y/n]: ", + ar = "%0 [نعم/لا]: ", + cs = "%0 [A/n]: ", + da = "%0 [J/n]: ", + de = "%0 [J/n]: ", + el = "%0 [Î/ο]: ", + en_AU = "%0 [Y/n]: ", + en_CA = "%0 [Y/n]: ", + en_GB = "%0 [Y/n] ", + es = "%0 [S/n]: ", + fi = "%0 [K/e]: ", + fr = "%0 [O/n]: ", + he = "%0 [\"×›\"/ל]: ", + hu = "%0 [I/n]: ", + id = "%0 [Y/t]: ", + it = "%0 [S/n]: ", + ja = "%0 [Y/n]: ", + lb = "%0 [J/n] ", + nb = "%0 [J/n]: ", + nds = "%0 [J/n] ", + nl = "%0 [J/n]: ", + nn = "%0 [J/n]: ", + pt = "%0 [S/n] ", + pt_BR = "%0 [S/n]: ", + ro = "%0 [D/n]: ", + ru = "%0 [Y/n]: ", + sk = "%0 [A/n]: ", + sl = "%0 [D/n]: ", + sv = "%0 [J/n]: ", + tr = "%0 [E/h]]: ", + uk = "%0 [ТÐК/ні] ", + zh_TW = "%0 [Y/n]: " + }; + + -- stdio UI plugin says this for yes/no prompts that default to no. + -- "%0" is the question the user is being asked to respond to. + -- "[y/N]" are two options that the user will have to type in response. + -- Please pick reasonable abbreviations for YES and NO that can be + -- typed easily by the user. Case of the "Y" and "n" are not important, + -- although we are using the capital letter to show the default option + -- if the user just presses enter. Be sure to translate the strings "Y" + -- and "N", elsewhere, to match what you enter here! At runtime, the + -- user's response is compared to those strings without case sensitivity. + ["%0 [y/N]: "] = { + af = "%0 [y/N]: ", + ar = "%0 [نعم/لا]: ", + cs = "%0 [a/N] ", + da = "%0 [j/N]: ", + de = "%0 [j/N]: ", + el = "%0 [ν/Ο]: ", + en_AU = "%0 [y/N]: ", + en_CA = "%0 [y/N]: ", + en_GB = "%0 [y/N]: ", + es = "%0 [s/N]: ", + fi = "%0 [k/E]: ", + fr = "%0 [o/N]: ", + he = "%0 [×›/\"ל\"]: ", + hu = "%0 [i/N]: ", + id = "%0 [y/T]: ", + it = "%0 [s/N]: ", + ja = "%0 [y/N]: ", + lb = "%0 [j/N] ", + nb = "%0 [j/N]: ", + nds = "%0 [j/N] ", + nl = "%0 [j/N]: ", + nn = "%0 [j/N]: ", + pl = "%0 [t/N]: ", + pt = "%0 [s/N] ", + pt_BR = "%0 [s/N]: ", + ro = "%0 [d/N]: ", + ru = "%0 [y/N]: ", + sk = "%0 [a/N]: ", + sl = "%0 [d/N]: ", + sv = "%0 [j/N]: ", + tr = "%0 [e/H]: ", + uk = "%0 [так/ÐІ] ", + zh_TW = "%0 [y/N]: " + }; + + -- stdio UI plugin says this for yes/no/always/never prompts. + -- "%0" is the question the user is being asked to respond to. + -- "[Y/n/Always/Never]" are options that the user will have to type in + -- response. Please pick reasonable abbreviations for YES and NO (and + -- full words for ALWAYS and NEVER) that can be typed easily by the user. + -- Case of the "Y" and "n" are not important; there is no default option + -- chosen here, so the user will have to fully type out one of these four + -- options in response. Be sure to translate the strings "Y", "N", + -- "Always", and "Never", elsewhere, to match what you enter here! At + -- runtime, the user's response is compared to those strings without + -- case sensitivity. + ["%0 [y/n/Always/Never]: "] = { + af = "%0 [y / n / Altyd / Nooit]: ", + ar = "%0 [نعم/لا/دائماً/ابداً]: ", + cs = "%0 [a/n/Vždy/niKdy] ", + da = "%0 [j/n/Alltid/Aldrig]: ", + de = "%0 [j/n/Immer/Niemals]: ", + el = "%0 [ν/ο/Πάντα/Ποτέ]: ", + en_AU = "%0 [y/n/Always/Never]: ", + en_CA = "%0 [y/n/Always/Never]: ", + en_GB = "%0 [y/n/Always/Never]: ", + es = "%0 [s/n/Siempre/Nunca]: ", + fi = "%0 [k/e/Aina/ei Koskaan]: ", + fr = "%0 [o/n/Toujours/Jamais]: ", + he = "%0 [×›/ל/תמיד/××£ פע×]: ", + hu = "%0 [i/n/Mindig/Soha]: ", + id = "%0 [y/t/Selalu/Tidak Pernah]: ", + it = "%0 [s/n/Sempre/Mai]: ", + lb = "%0 [j/n/Emmer/Nie] ", + nb = "%0 [j/n/Alltid/Aldri]: ", + nds = "%0 [j/n/Immer/Niemals] ", + nl = "%0 [j/n/Altijd/Nooit]: ", + nn = "%0 [j/n/Alltid/Aldri]: ", + pl = "%0 [t/n/Zawsze/Nigdy]: ", + pt = "%0 [s/n/Sempre/Nunca] ", + pt_BR = "%0 [s/n/Sempre/Nunca]: ", + ro = "%0 [d/n/Mereu/Niciodată]: ", + ru = "%0 [y/n/Ð’Ñегда(A)/Ðикогда(N)]: ", + sk = "%0 [a/n/Vzdy/Nikdy]: ", + sl = "%0 [d/n/Vedno/Nikoli]: ", + sv = "%0 [j/n/Alltid/Aldrig]: ", + tr = "%0 [e/h/Daima/Asla]: ", + uk = "%0 [так/ні/Завжди/Ðіколи]: ", + zh_TW = "%0[y/n/æ°¸é (A)/æ°¸ä¸(N)]: " + }; + + -- This is used for "yes" in stdio UI's yes/no prompts (case insensitive). + -- Make sure this matches the string you chose for the "[y/n]" and + -- the "y/n/always/never" prompt, above! This should be reasonable for + -- the end user to enter at a terminal prompt. + ["Y"] = { + af = "Y", + ar = "Ù†", + cs = "A", + da = "J", + de = "J", + el = "Î", + en_AU = "Y", + en_CA = "Y", + en_GB = "Y", + es = "S", + fa = "Y", + fi = "K", + fr = "O", + he = "×›", + hu = "I", + id = "Y", + it = "S", + ja = "Y", + lb = "J", + nb = "J", + nds = "J", + nl = "J", + nn = "J", + pl = "T", + pt = "S", + pt_BR = "S", + ro = "D", + ru = "Y", + sk = "A", + sl = "D", + sv = "J", + tr = "E", + uk = "Т", + zh_TW = "是" + }; + + -- This is used for "no" in stdio UI's yes/no prompts (case insensitive). + -- Make sure this matches the string you chose for the "[y/n]" and + -- the "y/n/always/never" prompt, above! This should be reasonable for + -- the end user to enter at a terminal prompt. + ["N"] = { + af = "N", + ar = "Ù„", + cs = "N", + da = "N", + de = "N", + el = "Ο", + en_AU = "N", + en_CA = "N", + en_GB = "N", + es = "N", + fa = "N", + fi = "E", + fr = "N", + he = "ל", + hu = "N", + id = "T", + it = "N", + ja = "N", + lb = "N", + nb = "N", + nds = "N", + nl = "N", + nn = "N", + pl = "N", + pt = "N", + pt_BR = "N", + ro = "N", + ru = "N", + sk = "N", + sl = "N", + sv = "N", + tr = "H", + uk = "Ð", + zh_TW = "å¦" + }; + + -- This is used for "always" in stdio UI's yes/no/always/never prompts + -- (case insensitive). Make sure this matches the string you chose for + -- the "y/n/always/never" prompt, above! This should be reasonable for + -- the end user to enter at a terminal prompt. + ["Always"] = { + af = "Altyd", + ar = "دائماً", + cs = "Vždy", + da = "Altid", + de = "Immer", + el = "Πάντα", + en_AU = "Always", + en_CA = "Always", + en_GB = "Always", + es = "Siempre", + et = "Alati", + fa = "Always", + fi = "Aina", + fr = "Toujours", + he = "תמיד", + hu = "Mindig", + id = "Selalu", + it = "Sempre", + lb = "Emmer", + nb = "Alltid", + nds = "Immer", + nl = "Altijd", + nn = "Alltid", + pl = "Zawsze", + pt = "Sempre", + pt_BR = "Sempre", + ro = "Mereu", + ru = "Ð’Ñегда", + sk = "Vždy", + sl = "Vedno", + sv = "Alltid", + te = "à°Žà°²à±à°²à°ªà±à°ªà±à°¡à±‚", + tr = "Daima", + uk = "Завжди", + zh_TW = "總是" + }; + + -- This is used for "never" in stdio UI's yes/no/always/never prompts + -- (case insensitive). Make sure this matches the string you chose for + -- the "y/n/always/never" prompt, above! This should be reasonable for + -- the end user to enter at a terminal prompt. + ["Never"] = { + af = "Nooit", + ar = "أبداً", + cs = "niKdy", + da = "Aldrig", + de = "Niemals", + el = "Ποτέ", + en_AU = "Never", + en_CA = "Never", + en_GB = "Never", + es = "Nunca", + et = "Mitte kunagi", + fa = "Never", + fi = "Ei koskaan", + fr = "Jamais", + he = "××£ פע×", + hu = "Soha", + id = "Tidak Pernah", + it = "Mai", + lb = "Nie", + nb = "Aldri", + nds = "Niemals", + nl = "Nooit", + nn = "Aldri", + pl = "Nigdy", + pt = "Nunca", + pt_BR = "Nunca", + ro = "Niciodată", + ru = "Ðикогда", + sk = "Nikdy", + sl = "Nikoli", + sv = "Aldrig", + tr = "Asla", + uk = "Ðіколи", + zh_TW = "æ°¸ä¸" + }; + + -- This is shown when using stdio UI's built-in README pager, to + -- show what range of lines of text are being displayed (%0 is first + -- line, %1 is last line, %2 is the total number of lines of text). + ["(%0-%1 of %2 lines, see more?)"] = { + af = "(%0-%1 van %2 lyne, sien meer?)", + ar = "(%0-%1 من %2 سطور، المزيد؟)", + cs = "(%0-%1 z %2 řádků, zobrazit více?)", + da = "(%0-%1 af %2 linie, vis flere?)", + de = "(%0-%1 von %2 Zeilen, weitere betrachten?)", + el = "(%0-%1 από %2 γÏαμμές, θέλετε να δείτε πεÏισσότεÏες?)", + en_AU = "(%0-%1 of %2 lines, see more?)", + en_CA = "(%0-%1 of %2 lines, see more?)", + en_GB = "(%0-%1 of %2 lines, see more?)", + es = "(%0-%1 de %2 líneas, ¿ver más?)", + fi = "(%0-%1 %2:sta rivistä, lue lisää?)", + fr = "(lignes %0 à %1 sur %2, en voir plus ?)", + he = "(%0-%1 מתוך %2 שורות, להציג עוד?)", + hu = "%0-%1 a %2 sorból, tovább?", + id = "(%0-%1 dari %2 baris, lihat lagi?)", + it = "%0-%1 di %2 linee, desideri visualizzare le successive?", + nb = "(%0-%1 av %2 linjer, se mer?)", + nds = "%0-%1 von %2 Zeilen, mehr sehen?", + nl = "(%0-%1 van %2 regels, meer zien?)", + nn = "(%0-%1 av %2 linjer, sjÃ¥ meir?)", + pl = "(%0-%1 z %2 linii, pokazać wiÄ™cej?", + pt = "(%0-%1 de %2 linhas, ver mais?)", + pt_BR = "(%0-%1 de %2 linhas, ver mais?)", + ro = "(%0-%1 din %2 linii, vizualizează mai mult?)", + ru = "(%0-%1 из %2 Ñтрок, дальше?)", + sk = "(%0-%1 of %2 riadkov, zobraziÅ¥ ÄalÅ¡ie?)", + sl = "(%0-%1 od %2 vrstic, pokaži veÄ?)", + sv = "(%0-%1 av %2 rader, visa fler?)", + tr = "(%2 satırın %0-%1 aralığı, daha fazlası gösterilsin mi?)", + uk = "(%0-%1 з %2 Ñ€Ñдків, показати більше?)", + zh_TW = "(%2 總行數中的第 %0-%1 行,ç€è¦½æ›´å¤šï¼Ÿï¼‰" + }; + + -- The stdio UI uses this sentence in the prompt if the user is able + -- to return to a previous stage of installation (from the options + -- section to the "choose installation destination" section, etc). + ["Type '%0' to go back."] = { + af = "Tik '%0' om terug to gaan.", + ar = "اكتب '%0' للرجوع خطوة", + cs = "NapiÅ¡te '%0' pro návrat zpÄ›t.", + da = "Skriv '%0' for at gÃ¥ tillbage.", + de = "Drücken Sie '%0' um zurückzugehen.", + el = "Πατήστε '%0' για να πάτε πίσω.", + en_AU = "Type '%0' to go back.", + en_CA = "Type '%0' to go back.", + en_GB = "Type '%0' to go back.", + es = "Presiona %0 para volver.", + fi = "Kirjoita '%0' palataksesi edelliseen osioon.", + fr = "Tapez '%0' pour revenir en arrière.", + he = "הקלד '%0' כדי לחזור חזרה.", + hu = "Ãœss '%0'-t a visszalépéshez", + id = "Ketik '%0' untuk kembali.", + it = "Digita %0 per tornare indietro.", + lb = "Tippt '%0' an fir zereck", + nb = "Skriv '%0' for Ã¥ gÃ¥ tilbake.", + nds = "Drücken Sie '%0' um zurückzukehren", + nl = "Typ '%0' om terug te gaan.", + nn = "Skriv '%0' for Ã¥ gÃ¥ tilbake.", + pl = "Wpisz '%0' aby powrócić.", + pt = "Tecle '%0' para voltar.", + pt_BR = "Digite '%0' para voltar.", + ro = "Tastează '%0' pentru a revenii.", + ru = "Ðажмите '%0' чтобы вернутьÑÑ.", + sk = "Zadajte '%0' pre návrat späť.", + sl = "Pritisnite '%0' za korak nazaj.", + sv = "Skriv '%0' för att gÃ¥ tillbaka.", + tr = "Geri dönmek için '%0' yazın.", + uk = "Ðаберіть '%0' Ð´Ð»Ñ Ð¿Ð¾Ð²ÐµÑ€Ð½ÐµÐ½Ð½Ñ", + zh_TW = "輸入 '%0' 以返回" + }; + + -- This is the string used for the '%0' in the above string. + -- This is only for the stdio UI, so choose something easy and + -- reasonable for the user to manually type. The graphical UIs use a + -- different string for their button ("Back" vs "back" specifically). + ["back"] = { + af = "terug", + ar = "رجوع", + cs = "zpÄ›t", + da = "tilbage", + de = "zurück", + el = "πίσω", + en_AU = "back", + en_CA = "back", + en_GB = "back", + es = "Atrás", + et = "tagasi", + fi = "takaisin", + fr = "retour", + he = "חזרה", + hu = "vissza", + id = "kembali", + it = "indietro", + ja = "戻る", + nb = "tilbake", + nds = "Zurück", + nl = "terug", + nn = "tilbake", + pl = "tyÅ‚", + pt = "voltar", + pt_BR = "voltar", + ro = "înapoi", + ru = "назад", + sk = "späť", + sl = "nazaj", + sv = "tillbaka", + te = "వెనకà±à°•à°¿", + tr = "geri", + uk = "назад", + zh_TW = "返回" + }; + + -- This is the prompt in the stdio driver when user input is expected. + ["> "] = { + af = "> ", + ar = "> ", + cs = "> ", + da = "> ", + de = "> ", + el = "> ", + en_AU = "> ", + en_CA = "> ", + en_GB = "> ", + es = "> ", + fi = "> ", + fr = "> ", + he = "> ", + hu = "> ", + id = "> ", + it = "> ", + ja = "> ", + nb = "> ", + nds = "> ", + nl = "> ", + nn = "> ", + pl = "> ", + pt = "> ", + pt_BR = "> ", + ro = "> ", + ru = "> ", + sk = "> ", + sl = "> ", + sv = "> ", + te = "> ", + tr = "> ", + uk = "> ", + zh_TW = "> " + }; + + -- That's meant to be the name of an item (%0) and the percent done (%1). + ["%0: %1%%"] = { + af = "%0: %1%%", + ar = "â€%0: %1%%", + cs = "%0: %1%%", + da = "%0: %1%%", + de = "%0: %1%%", + el = "%0: %1%%", + en_AU = "%0: %1%%", + en_CA = "%0: %1%%", + en_GB = "%0: %1%%", + es = "%0: %1%%", + fi = "%0: %1%%", + fr = "%0 : %1%%", + he = "%0: %1%%", + hu = "%0: %1%%", + id = "%0: %1%%", + it = "%0: %1%%", + ja = "%0: %1%%", + nb = "%0: %1%%", + nds = "%0: %1%%", + nl = "%0: %1%%", + nn = "%0: %1%%", + pl = "%0: %1%%", + pt = "%0: %1%%", + pt_BR = "%0: %1%%", + ro = "%0: %1%%", + ru = "%0: %1%%", + sk = "%0: %1%%", + sl = "%0: %1%%", + sv = "%0: %1%%", + tr = "%0: %%%1", + uk = "%0: %1%%", + zh_TW = "%0: %1%%" + }; + + -- The stdio UI uses this to show current status (%0), + -- and overall progress as percentage of work complete (%1). + ["%0 (total progress: %1%%)"] = { + af = "%0 (totale bevordering: %1%%)", + ar = "â€%0 (باقي للانتهاء: %1%%)", + cs = "%0 (celkový průbÄ›h: %1%%)", + da = "%0 (totalt: %1%%)", + de = "%0 (Gesamtfortschritt: %1%%)", + el = "%0 (συνολική Ï€Ïόοδος: %1%%)", + en_AU = "%0 (total progress: %1%%)", + en_CA = "%0 (total progress: %1%%)", + en_GB = "%0 (total progress: %1%%)", + es = "%0 (Progreso total: %1%%)", + fi = "%0 (kokonaisedistyminen: %1%%)", + fr = "%0 (progression totale : %1%%)", + he = "%0 (תהליך כללי: %1%%)", + hu = "%0 (%1%% kész)", + id = "%0 (jumlah kemajuan: %1%%)", + it = "%0 (progresso: %1%%))", + ja = "%0 (全体ã®é€²æ—: %1%%)", + nb = "%0 (total fremgang: %1%%)", + nds = "%0 (Fortschritt insgesamt: %1%%)", + nl = "%0 (totale voortgang: %1%%)", + nn = "%0 (total framgang: %1%%)", + pl = "%0 (caÅ‚kowity postÄ™p: %1%%)", + pt = "%0 (progresso total: %1%%)", + pt_BR = "%0 (progresso total: %1%%)", + ro = "%0 (total completat: %1%%)", + ru = "%0 (вÑего: %1%%)", + sk = "%0 (celkovo priebeh: %1%%)", + sl = "%0 (celoten napredek: %1%%)", + sv = "%0 (totalt: %1%%)", + tr = "%0 (toplam ilerleme: %%%1)", + uk = "%0 (загальний прогреÑ: %1%%)", + zh_TW = "%0(所有進度:%1%%)" + }; + + -- This prompt is shown to the end-user after an End User License Agreement + -- has been displayed, asking them if the license text is acceptable to + -- them. It's a yes/no question. + ["Accept this license?"] = { + af = "Anvaar die lisensie?", + ar = "هل تقبل بتلك الرخصة؟", + cs = "PÅ™ijímáte podmínky licence?", + da = "Accepter denne licens?", + de = "Lizenz akzeptieren?", + el = "Δέχεστε αυτή την άδεια χÏήσης?", + en_AU = "Accept this license?", + en_CA = "Accept this licence?", + en_GB = "Accept this licence?", + es = "¿Acepta esta licencia?", + fi = "Hyväksy lisenssi?", + fr = "Accepter cette licence ?", + he = "לקבל רשיון ×–×”?", + hu = "Elfogadja a liszenszt?", + id = "Terima lisensi ini?", + it = "Accetti questa licenza?", + ja = "ライセンスã«åŒæ„ã—ã¾ã™ã‹ï¼Ÿ", + nb = "Aksepterer du denne lisensen?", + nds = "Diese Lizenz akzeptieren?", + nl = "Accepteert u deze licentie?", + nn = "Aksepterar du denne lisensen?", + pl = "Akceptujesz licencjÄ™?", + pt = "Aceita esta licença?", + pt_BR = "Aceitar esta licença?", + ro = "AcceptaÅ£i această licenţă?", + ru = "Ð’Ñ‹ ÑоглашаетеÑÑŒ?", + sk = "Súhlasíte s licenciou?", + sl = "Sprejmete to licenco?", + sv = "Godkänn licensavtalet?", + tr = "Bu lisansı kabul et?", + uk = "ПогодитиÑÑ Ð· цими умовами?", + zh_TW = "åŒæ„此許å¯è­‰ï¼Ÿ" + }; + + -- This is a GTK+ button label for yes/no/always/never questions. + -- The '_' comes before the hotkey character. + ["_Always"] = { + af = "_Altyd", + ar = "دا_ئمًا", + cs = "_Vždy", + da = "_Altid", + de = "_Immer", + el = "_Πάντα", + en_AU = "_Always", + en_CA = "_Always", + en_GB = "_Always", + es = "_Siempre", + fi = "_Aina", + fr = "_Toujours", + he = "_תמיד", + hu = "_Mindig", + id = "Sel_alu", + it = "_Sempre", + nb = "_Alltid", + nds = "_Immer", + nl = "_Altijd", + nn = "_Alltid", + pl = "_Zawsze", + pt = "_Sempre", + pt_BR = "_Sempre", + ro = "_Mereu", + ru = "_Ð’Ñегда", + sk = "_Vždy", + sl = "_Vedno", + sv = "_Alltid", + tr = "_Daima", + uk = "Зав_жди", + zh_TW = "總是(_A)" + }; + + -- This is an error message reported when a .zip file (or whatever) that + -- we need can't be located. + ["Archive not found"] = { + af = "Argief nie gevind", + ar = "الأرشي٠غير موجود", + cs = "Archiv nenalezen", + da = "Arkiv ikke fundet", + de = "Archiv nicht gefunden", + el = "Το αÏχείο δεν βÏέθηκε.", + en_AU = "Archive not found", + en_CA = "Archive not found", + en_GB = "Archive not found", + es = "Archivo no encontrado", + fi = "Pakettia ei löydy", + fr = "Archive introuvable", + he = "×”×רכיון ×œ× × ×ž×¦×", + hu = "Arhív nem található", + id = "Arsip tidak ditemukan", + it = "Archivio non presente", + ja = "アーカイブãŒè¦‹ã¤ã‹ã‚Šã¾ã›ã‚“", + nb = "Fant ikke arkiv", + nds = "Archiv nicht gefunden", + nl = "Archief niet gevonden", + nn = "Fant ikkje arkiv", + pl = "Archiwum nie znalezione", + pt = "Arquivo não encontrado", + pt_BR = "Arquivo não encontrado", + ro = "Arhiva nu a fost găsită", + ru = "Ðрхив не найден", + sk = "Archív nenájdený", + sl = "Arhiva ni možno najti", + sv = "Hittade inte arkivet", + tr = "ArÅŸiv bulunamadı", + uk = "Ðрхів не знайдено", + zh_TW = "找ä¸åˆ°æª”案包" + }; + + -- This prompt is shown to the user when they click the "Cancel" button, + -- to confirm they really want to stop. It's a yes/no question. + ["Are you sure you want to cancel installation?"] = { + af = "Is jy seker jy will die installasie kanseleer?", + ar = "أألغي التنثبيت؟", + cs = "Opravdu chcete zruÅ¡it instalaci?", + da = "Vil du afbryde installationen?", + de = "Sind Sie sicher, dass Sie die Installation abbrechen wollen?", + el = "Είστε σίγουÏοι ότι θέλετε να ακυÏώσετε την εγκατάσταση?", + en_AU = "Are you sure you want to cancel installation?", + en_CA = "Are you sure you want to cancel installation?", + en_GB = "Are you sure you want to cancel installation?", + es = "¿Está seguro de que quiere cancelar la instalación?", + fi = "Haluatko varmasti keskeyttää asennuksen?", + fr = "Êtes-vous sûr de vouloir annuler l'installation ?", + he = "×”×× ×תה בטוח שברצונך לבטל ×ת ההתקנה?", + hu = "Tényleg megszakítja a telepítést?", + id = "Apakah Anda yakin ingin membatalkan isntalasii?", + it = "Sei sicuro di voler annullare l'installazione?", + ja = "本当ã«ã‚¤ãƒ³ã‚¹ãƒˆãƒ¼ãƒ«ã‚’中止ã—ã¾ã™ã‹ï¼Ÿ", + nb = "Er du sikker pÃ¥ at du vil avbryte installasjonen?", + nds = "Sind Sie sicher, dass Sie die Installation abbrechen wollen?", + nl = "Weet u zeker dat u de installatie wilt afbreken?", + nn = "Er du sikker pÃ¥ at du vil avbryta installasjonen?", + pl = "Czy na pewno chcesz anulować instalacjÄ™?", + pt = "Tem a certeza que quer cancelar a instalação?", + pt_BR = "Você tem certeza que deseja cancelar a instalação?", + ro = "SunteÅ£i sigur că doriÅ£i anularea instalării?", + ru = "Ð’Ñ‹ дейÑтвительно хотите отменить уÑтановку?", + sk = "Ste si istí, že chcete preruÅ¡iÅ¥ inÅ¡taláciu?", + sl = "Ste prepriÄani da želite prekiniti namestitev?", + sv = "Är du säker pÃ¥ att du vill avbryta installationen?", + tr = "Kurulumu iptal etmek istediÄŸinizden emin misiniz?", + uk = "Ви впевнені що хочете відмінити вÑтановленнÑ?", + zh_TW = "確定å–消安è£ç¨‹åºï¼Ÿ" + }; + + -- The opposite of "next", used as a UI button label. + ["Back"] = { + af = "Terug", + ar = "ارجع", + cs = "ZpÄ›t", + da = "Tilbage", + de = "Zurück", + el = "ΠÏοηγοÏμενο", + en_AU = "Back", + en_CA = "Back", + en_GB = "Back", + es = "Atrás", + fi = "Takaisin", + fr = "Retour", + he = "הקוד×", + hu = "Vissza", + id = "Kembali", + it = "Indietro", + ja = "戻る", + nb = "Tilbake", + nds = "Zurück", + nl = "Vorige", + nn = "Tilbake", + pl = "Wstecz", + pt = "Anterior", + pt_BR = "Voltar", + ro = "Precedentul", + ru = "Ðазад", + sk = "Späť", + sl = "Nazaj", + sv = "Tillbaka", + tr = "Geri", + uk = "Ðазад", + zh_TW = "返回" + }; + + -- This is a GTK+ button label. The '_' comes before the hotkey character. + -- "Back" might be using 'B' in English. This button brings up a file + -- dialog where the end-user can navigate to and select files. + ["B_rowse..."] = { + af = "T_erug", + ar = "ت_صÙØ­", + cs = "_Procházet...", + da = "_Gennemse...", + de = "Du_rchsuchen", + el = "_Αναζήτηση...", + en_AU = "B_rowse...", + en_CA = "B_rowse...", + en_GB = "B_rowse...", + es = "_Navegar...", + fi = "_Selaa", + fr = "_Choisir...", + he = "_עיון...", + hu = "_Tallózás...", + it = "_Sfoglia...", + nb = "_Bla gjennom…", + nds = "Du_rchsuchen", + nl = "Bl_aderen...", + nn = "_Bla gjennom…", + pl = "P_rzeglÄ…daj...", + pt = "_Procurar...", + pt_BR = "_Procurar...", + ro = "Na_vigare...", + ru = "Открыть...", + sk = "P_rehliadaÅ¥...", + sl = "B_rskaj ...", + sv = "B_läddra", + tr = "G_özat...", + uk = "_ОглÑд...", + zh_TW = "ç€è¦½(_B)" + }; + + -- All the "BUG:" strings are generally meant to be seen by developers, + -- not end users. They represent programming errors and configuration + -- file problems. + -- This is shown if the configuration file has specified two cd-roms (or + -- whatever) with the same media id, which is a bug the developer must + -- fix before shipping her installer. + -- "media id" refers to Setup.Media.id in the config file. It's not meant + -- to be a proper name, in this case. + ["BUG: duplicate media id"] = { + af = "Kewer: gedupliseerde media id", + ar = "بقة: media id مكرر", + cs = "CHYBA: duplicitní id média", + da = "FEJL: dobbelt forekomst af 'media id'", + de = "FEHLER: Doppelte Medien-ID", + el = "ΣΦΑΛΜΑ: διπλή αναφοÏά στο ίδιο media id", + en_AU = "BUG: duplicate media id", + en_CA = "BUG: duplicate media id", + en_GB = "BUG: duplicate media id", + es = "FALLO: id de medio duplicada", + fi = "BUGI: kaksi identtistä media id:tä", + fr = "BUG: Identifiant du media déjà utilisé", + he = "ב××’: מזהה מדיה כפול", + hu = "BUG: duplikált média azonosító (media id)", + id = "KUTU: id media salinan", + it = "BUG: media id duplicato", + nb = "Programfeil: duplisert media-id", + nds = "FEHLER: Doppelte Medien-ID", + nl = "BUG: dubbele media id", + nn = "Programfeil: duplisert media-id", + pl = "BÅÄ„D: zduplikowany identyfikator media", + pt = "BUG: id de mídia duplicado", + pt_BR = "BUG: ID da mídia duplicado", + ro = "EROARE: media id duplicat", + ru = "Ошибка: дублирование media_id", + sk = "CHYBA: duplicitné médiá id", + sl = "NAPAKA: podvojen media id", + sv = "FEL: dubblett av media id", + tr = "HATA: tekrarlanan ortam kimliÄŸi", + zh_TW = "臭蟲:é‡è¤‡çš„媒體åºè™Ÿ" + }; + + -- This is shown if the configuration file has no installable options, + -- either because none are listed or they've all become disabled, which + -- is a bug the developer must fix before shipping her installer. + ["BUG: no options"] = { + af = "Kewer: geen opsies", + ar = "بقة: لا يوجد options", + cs = "CHYBA: nejsou dostupné žádné volby", + da = "FEJL: ingen muligheder", + de = "FEHLER: Keine Optionen", + el = "ΣΦΑΛΜΑ: δεν υπάÏχουν Ïυθμίσεις εγκατάστασης", + en_AU = "BUG: no options", + en_CA = "BUG: no options", + en_GB = "BUG: no options", + es = "FALLO: sin opciones", + fi = "OHJELMOINTIVIRHE: Ei valittavia kohtia saatavilla", + fr = "BUG: Pas d'options", + he = "ב××’: ×ין ×פשרויות", + hu = "BUG: nincsenek opciók", + id = "KUTU: tidak ada pilihan", + it = "BUG: nessuna opzione disponibile", + lb = "FEHLER : Keng Optiounen", + nb = "Programfeil: ingen valg", + nds = "FEHLER: keine Option", + nl = "BUG: geen opties", + nn = "Programfeil: ingen val", + pl = "BÅÄ„D: brak opcji", + pt = "BUG: sem opções", + pt_BR = "BUG: Sem opções", + ro = "EROARE: nici o opÅ£iune", + ru = "Ошибка: отÑутÑтвуют опции", + sk = "CHYBA: žiadne inÅ¡talaÄné možnosti", + sl = "NAPAKA: ni izbir", + sv = "FEL: inget alternativ", + tr = "HATA: seçenek yok", + zh_TW = "臭蟲:沒有é¸é …" + }; + + -- This is shown if the config file wants us to include the uninstaller + -- program with the rest of the files we write to disk, but didn't enable + -- the manifest support the installer needs. This is a bug the developer + -- must fix before shipping her installer. + ["BUG: support_uninstall requires write_manifest"] = { + af = "Kewer: support_uninstall vereis write_manifest", + ar = "بقة: support_uninstall يحتاج write_manifest", + cs = "CHYBA: support_uninstall vyžaduje write_manifest", + de = "FEHLER: support_uninstall benötigt write_manifest", + el = "ΣΦΑΛΜΑ: το \"support_uninstall\" απαιτεί το \"write_manifest\"", + en_AU = "BUG: support_uninstall requires write_manifest", + en_CA = "BUG: support_uninstall requires write_manifest", + en_GB = "BUG: support_uninstall requires write_manifest", + es = "ERROR: La desintalacion requiere write_manifest", + fi = "BUGI: support_uninstall vaatii write_manifest:n", + fr = "BOGUE: 'support_uninstall' exige 'write_manifest'", + he = "ב××’: support_uninstall דורש ×ת write_manifest", + hu = "BUG: support_uninstall igényli a write_manifest -et", + it = "BUG: support_uninstall richiede write_manifest", + nb = "Programfeil: support_uninstall krever write_manifest", + nds = "FEHLER: support_uninstall benötigt write_manifest", + nl = "BUG: support_uninstall heeft write_manifest nodig", + nn = "Programfeil: support_uninstall krevar write_manifest", + pl = "BÅÄ„D: support_uninstall wymaga write_manifest", + pt = "BUG: support_uninstall requer write_manifest", + pt_BR = "BUG: support_uninstall necessita de write_manifest", + ro = "EROARE: support_uninstall necesită write_manifest", + ru = "Ошибка: support_uninstall нуждаетÑÑ Ð² write_manifest", + sk = "CHYBA: support_uninstall potrebuje write_manifest", + sl = "NAPAKA: support_uninstall potrebuje write_manifest", + sv = "FEL: support_uninstall kräver write_manifest", + tr = "HATA: support_uninstall write_manifest gerektirir", + zh_TW = "臭蟲:support_uninstall éœ€è¦ write_manifest" + }; + + -- This is shown if the config file wants us to install a manifest (a list + -- of everything we wrote to disk) but didn't enable Lua parser support + -- in the binary, which they need to handle Lua source code without + -- compiling it first (as it needs to be "parsed")...the manifest is + -- ultimately just an uncompiled Lua program that the installer generates. + -- This is a bug the developer must fix before shipping her installer. + ["BUG: write_manifest requires Lua parser support"] = { + af = "Kewer: write_manifest vereis Lua omskakelaar ondersteuning", + ar = "بقة: write_manifest يحتاج دعم معالج Lua", + cs = "CHYBA: write_manifest vyžaduje podporu Lua parseru", + de = "FEHLER: write_manifest benötigt Lua Parser Unterstützung", + el = "ΣΦΑΛΜΑ: το \"write_manifest\" απαιτεί να υπάÏχει υποστήÏιξη από \"Lua parser\"", + en_AU = "BUG: write_manifest requires Lua parser support", + en_CA = "BUG: write_manifest requires Lua parser support", + en_GB = "BUG: write_manifest requires Lua parser support", + es = "ERROR: write_manifest requiere un intérprete Lua", + fr = "BOGUE: 'write_manifest' exige le support du parser Lua", + he = "ב××’: write_manifest דורש ×ת התמיכה במפענח Lua", + hu = "BUG: write_manifest igényli a Lua értelmezÅ‘ támogatást", + it = "BUG: write_manifest richiede Lua parser support", + nb = "Programfeil: write_manifest krever støtte for Lua-parser", + nds = "FEHLER: write_manifest benötigt Lua Parser Unterstützung", + nl = "BUG: write_manifest heeft Lua parser ondersteuning nodig", + nn = "Programfeil: write_manifest krevar støtte for Lua-parser", + pl = "BÅÄ„D: write_manifest wymaga obsÅ‚ugi parsera Lua", + pt = "BUG: write_manifest requer suporte do analisador da linguagem Lua", + pt_BR = "BUG: write_manifest necessita do suporte ao parser de Lua", + ro = "EROARE: write_manifest necesită suport Lua", + ru = "Ошибка: write_manifest требует поддержки Lua parser", + sk = "CHYBA: write_manifest potrebuje zapnutú podporu Lua parsera (Lua parser support)", + sl = "NAPAKA: write_manifest potrebuje podporo Lua parserja", + sv = "FEL: write_manifest kräver Lua parser stöd", + tr = "HATA: write_manifest Lua derleyicisi desteÄŸi gerektirir", + zh_TW = "臭蟲:write_manifest éœ€è¦ Lua 語法分æžæ”¯æ´" + }; + + -- This is shown if the config file wants us to add desktop menu items + -- but uninstaller support isn't enabled. It is considered bad taste + -- to add system menu items without a way to remove them. This is + -- a bug the developer must fix before shipping her installer. + ["BUG: Setup.DesktopMenuItem requires support_uninstall"] = { + af = "Kewer: Setup.DesktopMenuItem vereis support_uninstall", + ar = "بقة: Setup.DesktopMenuItem يحتاج support_uninstall", + cs = "CHYBA: Setup.DesktopMenuItem vyžaduje support_uninstall", + de = "FEHLER: Setup.DesktopMenuItem benötigt support_uninstall", + el = "ΣΦΑΛΜΑ: το Setup.DesktopMenuItem απαιτεί το \"support_uninstall\"", + en_AU = "BUG: Setup.DesktopMenuItem requires support_uninstall", + en_CA = "BUG: Setup.DesktopMenuItem requires support_uninstall", + en_GB = "BUG: Setup.DesktopMenuItem requires support_uninstall", + es = "FALLO: Setup.DesktopMenuItem requiere support_uninstall", + fi = "BUGI: Setup.DesktopMenuItem vaatii support_uninstall:n", + fr = "BOGUE: 'Setup.DesktopMenuItem' exige 'support_uninstall'", + he = "ב××’: Setup.DesktopMenuItem דורש ×ת support_uninstall", + hu = "BUG: Setup.DesktopMenuItem igényli a support_uninstall-t", + it = "BUG: Setup.DesktopMenuItem richiede support_uninstall", + nb = "Programfeil: Setup.DesktopMenuItem krever support_uninstall", + nds = "FEHLER: Setup.DesktopMenuItem benötigt support_uninstall", + nl = "BUG: Setup.DesktopMenuItem heeft support_uninstall nodig", + nn = "Programfeil: Setup.DesktopMenuItem krevar support_uninstall", + pl = "BÅÄ„D: Setup.DesktopMenuItem wymaga support_uninstall", + pt = "BUG: Setup.DesktopMenuItem requer support_uninstall", + pt_BR = "BUG: Setup.DesktopMenuItem necessita do support_uninstall", + ro = "EROARE: Setup.DesktopMenuItem necesită support_uninstall", + ru = "Ошибка: Setup.DesktopMenuItem нуждаетÑÑ Ð² support_uninstall", + sk = "CHYBA: Setup.DesktopMenuItem potrebuje support_uninstall", + sl = "NAPAKA: Setup.DesktopMenuItem potrebuje support_uninstall", + sv = "FEL: Setup.DesktopMenuItem kräver support_uninstall", + tr = "HATA: Setup.DesktopMenuItem support_uninstall gerektirir", + zh_TW = "臭蟲:Setup.DesktopMenuItem éœ€è¦ support_uninstall" + }; + + -- This is a file's permissions. Programmers give these as strings, and + -- if one isn't valid, the program will report this. So, on Unix, they + -- might specify "0600" as a valid string, but "sdfksjdfk" wouldn't be + -- valid and would cause this error. + ["BUG: '%0' is not a valid permission string"] = { + af = "Kewer: '%0' is nie 'n geldige toestemming string nie", + ar = "بقة: '%0' تعري٠إذن غير صحيح", + cs = "CHYBA: '%0' není platným Å™etÄ›zcem vyjadÅ™ujícím oprávnÄ›ní", + da = "FEJL: '%0' er ikke en korrekt rettigheds syntaks", + de = "FEHLER: '%0' ist keine zulässige Berechtigungszeichenkette", + el = "ΣΦΑΛΜΑ: '%0' δεν είναι έγγυÏο αλφαÏιθμητικό πεÏιγÏαφής δικαιωμάτων", + en_AU = "BUG: '%0' is not a valid permission string", + en_CA = "BUG: '%0' is not a valid permission string", + en_GB = "BUG: '%0' is not a valid permission string", + es = "FALLO: '%0' no es una cadena de permisos válida", + fi = "OHJELMOINTIVIRHE: \"%0\" ei ole kelvollinen oikeuksia määrittävä merkkijono", + fr = "BUG \"%0\" n'est pas une chaîne de permission valide", + he = "ב××’: '%0' ×ינו מחרוזת הרש××” תקנית", + hu = "BUG: '%0' nem érvényes jogosultság sztring", + it = "BUG: '%0' non è una stringa valida di permessi", + nb = "Programfeil: '%0' er ikke en gyldig rettighetsstreng", + nds = "FEHLER: '%0' ist kein gültiger Zugriffsberechtigungs String", + nl = "BUG: '%0' is geen geldige permissie string", + nn = "Programfeil: '%0' er ikkje ein gyldig rettighetsstreng", + pl = "BÅÄ„D: '%0' nie jest poprawnÄ… wartoÅ›ciÄ… dostÄ™pu", + pt = "BUG: '%0' não é uma expressão de permissões válida", + pt_BR = "BUG: '%0' não é um texto de permissão válido", + ro = "EROARE: '%0' nu este un ÅŸir de caractere ce desemnează permisiuni valide", + ru = "Ошибка: '%0' неправильное значение Ð´Ð»Ñ Ð¿Ñ€Ð°Ð².", + sk = "CHYBA: '%0' nie je správny spôsob zápisu práv", + sl = "NAPAKA: '%0' ni velaven niz za dovoljenja", + sv = "FEL: '%0' är inte en giltig rättighetssträng", + tr = "HATA: '%0' geçerli bir izin dizgisi deÄŸil", + zh_TW = "臭蟲:'%0' 並ä¸æ˜¯æœ‰æ•ˆçš„檔案權é™è¨­å®š" + }; + + -- If there's a string in the program that needs be formatted with + -- %0, %1, etc, and it specifies an invalid sequence like "%z", this + -- error pops up to inform the programmer/translator. + -- "format()" is a proper name in this case (program function name) + ["BUG: Invalid format() string"] = { + af = "Kewer: Ongeldige format() string", + ar = "بقة: format() غير صحيحة", + cs = "CHYBA: Neplatný Å™etÄ›zec pro format()", + de = "FEHLER: Unzulässige format() Zeichenkette", + el = "ΣΦΑΛΜΑ: Λάθος format() αλφαÏιθμητικό", + en_AU = "BUG: Invalid format() string", + en_CA = "BUG: Invalid format() string", + en_GB = "BUG: Invalid format() string", + es = "FALLO: Cadena format() no válida", + fi = "BUGI: Epäkelpo format()-merkkijono", + fr = "BUG: Chaîne format() invalide", + he = "ב××’: מחרוזת format() שגויה", + hu = "BUG: Helytelen format() sztring", + id = "KUTU: Format() strik tidak cocok", + it = "BUG: stringa format() non valida", + nb = "Programfeil: Ugyldig format()-streng", + nds = "FEHLER: Ungültiger format() string", + nl = "BUG: Ongeldige format() string", + nn = "Programfeil: Ugyldig format()-streng", + pl = "BÅÄ„D: NieprawidÅ‚owy ciÄ…g format()", + pt = "BUG: Expressão format() inválida", + pt_BR = "BUG: Texto format() inválido", + ro = "EROARE: Åžir de caractere format() invalid", + ru = "Ошибка: ÐÐµÐºÐ¾Ñ€Ñ€ÐµÐºÑ‚Ð½Ð°Ñ Ñтрока format()", + sk = "CHYBA: nesprávny format() reÅ¥azec", + sl = "NAPAKA: Neveljaven niz format()", + sv = "FEL: Ogiltig format() sträng", + tr = "HATA: Geçersiz format() dizgisi", + zh_TW = "臭蟲:無效的 format() 字串" + }; + + -- The program runs in "stages" and as it transitions from one stage to + -- another, it has to report some data about what happened during the + -- stage. A programming bug may cause unexpected type of data to be + -- reported, causing this error to pop up. + ["BUG: stage returned wrong type"] = { + af = "Kewer: stage het 'n verkeerde tipe terug gevoer", + ar = "بقة: المرحلة انهت بنوع خاطئ", + cs = "CHYBA: instalaÄní krok vrátil chybný datový typ", + de = "FEHLER: Abschnitt gab falschen Typ zurück", + el = "ΣΦΑΛΜΑ: η φάση εγκατάστασης επέστÏεψε λάθος Ï„Ïπο δεδομένων", + en_AU = "BUG: stage returned wrong type", + en_CA = "BUG: stage returned wrong type", + en_GB = "BUG: stage returned wrong type", + es = "FALLO: la etapa ha devuelto tipo erróneo", + fr = "BUG: L'étape renvoie un mauvais type de données", + he = "ב××’: השלב החזיר סוג שגוי", + hu = "BUG: az állomás rossz típussal tért vissza", + it = "BUG: la fase attuale (stage) ha restituito un tipo non valido", + nb = "Programfeil: nivÃ¥ returnerte feil type", + nds = "FEHLER: Arbeitsabschnitts Rückgabewert ist vom falschen Typ", + nl = "BUG: programma-fase leverde een verkeerd datatype", + nn = "Programfeil: nivÃ¥ returnerte feil type", + pl = "BÅÄ„D: kolejna faza zwróciÅ‚a zÅ‚y typ", + pt = "BUG: A etapa retornou um tipo errado", + pt_BR = "BUG: a etapa retornou o tipo errado", + ro = "EROARE: stadiul a returnat un tip de date eronat", + ru = "Ошибка: Ñтап выдал неожиданный тип", + sk = "CHYBA: fáza vrátila nesprávny typ", + sl = "NAPAKA: faza vraÄa napaÄen tip", + sv = "FEL: nivÃ¥ returnerade fel typ", + tr = "HATA: aÅŸama yanlış tip döndürdü", + zh_TW = "臭蟲:此階段傳回錯誤類別" + }; + + -- The program runs in "stages" and as it transitions from one stage to + -- another, it has to report some data about what happened during the + -- stage. A programming bug may cause unexpected information to be + -- reported, causing this error to pop up. + ["BUG: stage returned wrong value"] = { + af = "Kewer: Fase het 'n verkeerde waarde terug gevoer", + ar = "بقة: المرحلة انهت بقيمة خاطئة", + cs = "CHYBA: instalaÄní krok vrátil chybnou hodnotu", + de = "FEHLER: Abschnitt gab falschen Wert zurück", + el = "ΣΦΑΛΜΑ: η φάση εγκατάστασης επέστÏεψε λάθος τιμή", + en_AU = "BUG: stage returned wrong value", + en_CA = "BUG: stage returned wrong value", + en_GB = "BUG: stage returned wrong value", + es = "FALLO: la etapa ha devuelto valor erróneo", + fr = "BUG: L'étape renvoie une mauvaise valeur", + he = "ב××’: השלב החזיר ערך שגוי", + hu = "BUG: az állomás rossz értékkel tért vissza", + it = "BUG: la fase attuale (stage) ha restituito un valore non valido", + nb = "Programfeil: nivÃ¥ returnerte feil verdi", + nds = "FEHLER: Arbeitsabschnitt gab falschen Wert zurück", + nl = "BUG: programma-fase leverde een verkeerde waarde", + nn = "Programfeil: nivÃ¥ returnerte feil verdi", + pl = "BÅÄ„D: kolejna faza zwróciÅ‚a zÅ‚Ä… wartość", + pt = "BUG: A etapa retornou um valor errado", + pt_BR = "BUG: a etapa retornou o valor errado", + ro = "EROARE: stadiul a returnat o valoare invalidă", + ru = "Ошибка: Ñтап выдал неожиданный результат", + sk = "CHYBA: fáza vrátila nesprávnu hodnotu", + sl = "NAPAKA: faza vraÄa napÄno vrednost", + sv = "FEL: nivÃ¥ returnerade fel värde", + tr = "HATA: aÅŸama yanlış deÄŸer döndürdü", + zh_TW = "臭蟲:此階段傳回錯誤值" + }; + + -- The program runs in "stages", which can in many cases be revisited + -- by the user clicking the "Back" button. If the program has a bug + -- that allows the user to click "Back" on the initial stage, this + -- error pops up. + ["BUG: stepped back over start of stages"] = { + af = "Kewer: terug gestap verby die begin van die fases", + ar = "بقة: عودة للوراء ÙÙŠ اول خطوة", + cs = "CHYBA: pokus o krok zpÄ›t pÅ™ed zaÄátek instalace", + de = "FEHLER: Ãœber den Startabschnitt hinaus zurückgegangen", + el = "ΣΦΑΛΜΑ: ζητήθηκε η επιστÏοφή σε Ï€ÏοηγοÏμενη φάση που δεν υπάÏχει", + en_AU = "BUG: stepped back over start of stages", + en_CA = "BUG: stepped back over start of stages", + en_GB = "BUG: stepped back over start of stages", + es = "FALLO: retroceso más atrás del inicio de las etapas", + fr = "BUG: Revenu au début des étapes", + he = "ב××’: צעד ×חורה ×ל מעבר לשלבי ההתחלה", + hu = "BUG: visszalépés a kezdÅ‘ állomás után", + it = "BUG: ritornato all'inizio della fase (stage)", + nb = "Programfeil: Gikk tilbake forbi startnivÃ¥", + nds = "FEHLER: Vor den ersten Arbeitsabschnitt zurückgegangen", + nl = "BUG: teruggegaan naar voor eerste stadium.", + nn = "Programfeil: Gjekk tilbake forbi startnivÃ¥", + pl = "BÅÄ„D: Krok wstecz podczas poczÄ…tkowej fazy", + pt = "BUG: Retrocedeu na primeira etapa", + pt_BR = "BUG: voltar na primeira etapa", + ro = "EROARE: s-a făcut întoarcere înainte de începerea stadiilor", + ru = "БÐГ: переход назад Ñ Ð½Ð°Ñ‡Ð°Ð»ÑŒÐ½Ð¾Ð³Ð¾ Ñтапа", + sk = "CHYBA: vrátili ste sa pred zaÄiatok poÄiatoÄnej fázy", + sl = "NAPAKA: prestop nazaj preko zaÄetka faz", + sv = "FEL: Gick tillbaka förbi startnivÃ¥", + tr = "HATA: baÅŸlangıç aÅŸamasından geri dönüldü", + zh_TW = "臭蟲:在起始階段進行返回" + }; + + -- This happens if there's an unusual case when writing out Lua scripts + -- to disk. This should never be seen by an end-user. + ["BUG: Unhandled data type"] = { + af = "BUG: Ongehanteerde data tipe", + ar = "بقة: نوع بيانات لا يمكن التعامل معه", + cs = "CHYBA: Datový typ není obsluhován", + de = "FEHLER: Unbehandelter Datentyp", + el = "ΣΦΑΛΜΑ: Άγνωστος Ï„Ïπος δεδομένων", + en_AU = "BUG: Unhandled data type", + en_CA = "BUG: Unhandled data type", + en_GB = "BUG: Unhandled data type", + es = "FALLO: Tipo de datos sin manipular", + fr = "BUG: Type de fichier inconnu", + he = "ב××’: סוג ×”× ×ª×•× ×™× ×‘×œ×ª×™ מטופל", + hu = "BUG: Lekezeletlen adattípus", + id = "KUTU: Jenis data yang tidak ditangani", + it = "BUG: tipo di dato non gestito", + nb = "Programfeil: UhÃ¥ndtert datatype", + nds = "FEHLER: Unbehandelter Datentyp", + nl = "BUG: onbekend data type", + nn = "Programfeil: UhÃ¥ndtert datatype", + pl = "BÅÄ„D: NieobsÅ‚ugiwany typ danych", + pt = "BUG: Tipo sem tratamento", + pt_BR = "BUG: tipo de dado não suportado", + ro = "EROARE: Tip de date invalid", + ru = "Ошибка: неподдерживаемый тип данных", + sk = "CHYBA: Nespracovateľný typ dát", + sl = "NAPAKA: Neuporaben tip podatkov", + sv = "FEL: Ohanterad datatyp", + tr = "HATA: Tanıtılmamış veri tipi", + zh_TW = "臭蟲:未處ç†çš„資料類別" + }; + + -- This is triggered by a logic bug in the i/o subsystem. + -- This should never be seen by an end-user. + -- "tar" is a proper name in this case (it's a file format). + ["BUG: Can't duplicate tar inputs"] = { + af = "Kewer: Kan nie tar toevoere dupliseer nie", + ar = "بقة: لا يمكن تكرار مدخلات tar", + cs = "CHYBA: Nemohu zduplikovat vstupy z taru", + de = "FEHLER: Tar-Eingaben können nicht dupliziert werden", + el = "ΣΦΑΛΜΑ: Δεν είναι δυναταή αντιγÏαφή των δεδομένων εισόδου του \"tar\"", + en_AU = "BUG: Can't duplicate tar inputs", + en_CA = "BUG: Can't duplicate tar inputs", + en_GB = "BUG: Can't duplicate tar inputs", + es = "FALLO: No se pueden duplicar las entradas tar", + fr = "BUG: Impossible de dupliquer les entrées tar", + he = "ב××’: ×œ× × ×™×ª×Ÿ לשכפל פלט מסוג tar", + hu = "BUG: tar bemenet nem duplikálható", + id = "KUTU: Tidak dapat menyalin masukan tar", + it = "BUG: impossibile duplicare il .tar di input", + nb = "Programfeil: Kan ikke duplisere innfiler for tar", + nds = "FEHLER: Kann tar-Eingaben nicht duplizieren", + nl = "BUG: kan tar input kan niet gedupliceerd woorden.", + nn = "Programfeil: Kan ikke duplisere innfiler for tar", + pl = "BÅÄ„D: Nie można zduplikować wejść tar", + pt = "BUG: Impossível duplicar as entradas do tar", + pt_BR = "BUG: Não é possível duplicar as entradas do tar", + ro = "EROARE: Nu se pot dubla datele de intrare tar", + ru = "Ошибка: Ð½ÐµÐ»ÑŒÐ·Ñ Ð´ÑƒÐ±Ð»Ð¸Ñ€Ð¾Ð²Ð°Ñ‚ÑŒ иÑходные данные Ð´Ð»Ñ tar", + sk = "CHYBA: Nemôžete duplikovaÅ¥ tar vstupy", + sl = "NAPAKA: Podvajanje vnosov v tar ni možno", + sv = "FEL: Kan inte duplicera infiler för tar", + tr = "HATA: Tar giriÅŸleri çoklanamıyor", + zh_TW = "臭蟲:無法é‡è¤‡ tar 的輸入" + }; + + -- This is a generic error message when a programming bug produced a + -- result we weren't expecting (a negative number when we expected + -- positive, etc...) + ["BUG: Unexpected value"] = { + af = "Kewer: Onverwagte waarde", + ar = "بقة: قيمة غير متوقعة", + cs = "CHYBA: NeoÄekávaná hodnota", + de = "FEHLER: Unerwarteter Wert", + el = "ΣΦΑΛΜΑ: Μη αναμενόμενη τιμή", + en_AU = "BUG: Unexpected value", + en_CA = "BUG: Unexpected value", + en_GB = "BUG: Unexpected value", + es = "FALLO: Valor inesperado", + fi = "BUGI: Odottamaton arvo", + fr = "BUG: Valeur inattendue", + he = "ב××’: ערך בלתי צפוי", + hu = "BUG: váratlan érték", + id = "KUTU: Nilai yang tidak diharapkan", + it = "BUG: Valore inatteso", + lb = "FEHLER : Onerwaart Werter", + nb = "Programfeil: Uventet verdi", + nds = "FEHLER: Unerwarteter Wert", + nl = "BUG: Onverwachte waarde", + nn = "Programfeil: Uventa verdi", + pl = "BÅÄ„D: Niespodziewana wartość", + pt = "BUG: Valor inexperado", + pt_BR = "BUG: valor inesperado", + ro = "EROARE: Valoare neaÅŸteptată", + ru = "Ошибка: Ðеожиданное значение", + sk = "CHYBA: NeoÄakávaná hodnota", + sl = "NAPAKA: NepriÄakovana vrednost", + sv = "FEL: Oväntat värde", + tr = "HATA: Beklenmeyen deÄŸer", + zh_TW = "臭蟲:æ„外的值" + }; + + -- Buggy config elements: + -- This is supposed to be a config element (%0) and something that's wrong + -- with it (%1), such as "BUG: Config Package::description not a string" + -- The grammar can be imperfect here; this is a developer error, not an + -- end-user error, so we haven't made this very flexible. + ["BUG: Config %0 %1"] = { + af = "Kewer: Konfigurasie %0 %1", + ar = "بقة: الإعداد %0 %1", + cs = "CHYBA: KonfiguraÄní hodnota %0 %1", + da = "FEJL: Konfiguration %0 %1", + de = "FEHLER: Konfiguration %0 %1", + el = "ΣΦΑΛΜΑ: ΠαÏάμετÏος %0 %1", + en_AU = "BUG: Config %0 %1", + en_CA = "BUG: Config %0 %1", + en_GB = "BUG: Config %0 %1", + es = "FALLO: Configuración %0 %1", + fi = "OHJELMOINTIVIRHE: Asetus %0 %1", + fr = "BUG: Config %0 %1", + he = "ב××’: תצורה %0 %1", + hu = "BUG: Beállítás %0 %1", + id = "KUTU: Atur %0 %1", + it = "BUG: Config %0 %1", + nb = "Programfeil: Konfigurasjon %0 %1", + nds = "FEHLER: Konfiguration %0 %1", + nl = "BUG: configuratie %0 %1", + nn = "Programfeil: Konfigurasjon %0 %1", + pl = "BÅÄ„D: Konfiguracja %0 $1", + pt = "BUG: Configuração %0 %1", + pt_BR = "BUG: Configuração %0 %1", + ro = "EROARE: ConfiguraÅ£ie %0 %1", + ru = "Ошибка: ÐžÐ¿Ñ†Ð¸Ñ %0 %1", + sk = "CHYBA: Config %0 %1", + sl = "NAPAKA: Nastavitev %0 %1", + sv = "FEL: Konfiguration %0 %1", + tr = "HATA: Yapılandırma %0 için sorun %1", + zh_TW = "臭蟲:設定 %0 %1" + }; + + -- This is an error string for a buggy config element. See notes above. + ["invalid string"] = { + cs = "není platným Å™etÄ›zcem", + de = "ungültige Zeichenkette", + en_AU = "invalid string", + en_GB = "invalid string", + es = "cadena de texto inválida", + fr = "chaîne invalide", + he = "מחרוזת ×œ× ×ª×§×™× ×”", + it = "Stringa non valida", + nds = "ungültige Zeichenkette", + nl = "foute string", + pt = "expressão inválida", + ro = "ÅŸir de caractere invalid", + sk = "neplatný reÅ¥azec", + sv = "Felaktig sträng", + tr = "geçersiz dizgi", + zh_TW = "無效的字串" + }; + + -- This is an error string for a buggy config element. See notes above. + ["must be explicitly specified"] = { + af = "moet uitdruklik gespesifiseer word", + ar = "يجب تحديده", + cs = "musí být explicitnÄ› urÄena", + de = "muss explizit angegeben werden", + el = "Ï€Ïέπει να οÏιστεί Ïητά", + en_AU = "must be explicitly specified", + en_CA = "must be explicitly specified", + en_GB = "must be explicitly specified", + es = "debe ser especificado explícitamente", + fi = "pitää tarkkaan määritellä", + fr = "doit être spécifié explicitement", + he = "עליו להיות מצויין במפורש", + hu = "ezt explicit módon kell meghatározni", + id = "harus ditetapkan secara ekplisit", + it = "deve essere esplicitato", + nb = "mÃ¥ spesifiseres eksplisitt", + nds = "muss ausdrücklich spezifiziert werden", + nl = "moet expliciet gespecifieerd worden", + nn = "mÃ¥ spesifiserast eksplisitt", + pl = "musi być jasno podany", + pt = "deve ser especificado explicitamente", + pt_BR = "precisa ser especificado explicitamente", + ro = "trebuie specific explicit", + ru = "должна быть указана Ñвно", + sk = "musí byÅ¥ explicitne Å¡pecifikovaný", + sl = "mora biti explicitno doloÄena", + sv = "mÃ¥ste vara ett specificerat uttryck", + tr = "açıkça belirtilmeli", + uk = "повинно бути чітко вказано", + zh_TW = "必須明確指定" + }; + + -- This is an error string for a buggy config element. See notes above. + ["must be string or table of strings"] = { + af = "moet 'n string of tabel van stringe wees", + ar = "يجب ان يكون سلسلة حرÙية او جدول من السلاسل الحرÙية", + cs = "musí být Å™etÄ›zcem nebo tabulkou Å™etÄ›zců", + de = "muss eine Zeichenkette oder eine Tabelle mit Zeichenketten sein", + el = "Ï€Ïέπει να είναι ένα αλφαÏιθμητικό ή πίνακας απο αλφαÏιθμητικά", + en_AU = "must be string or table of strings", + en_CA = "must be string or table of strings", + en_GB = "must be string or table of strings", + es = "debe ser una cadena o tabla de cadenas", + fi = "täytyy olla merkkijono tai merkkijonotaulukko", + fr = "doit être une chaîne de caractères ou un tableau de chaînes de caractères", + he = "עליו להיות מחרוזת ×ו טבלת מחרוזות", + hu = "sztring vagy sztringtáblának kell lennie", + id = "harus string atau daftar string", + it = "deve essere una stringa o una tabella di stringhe", + nb = "mÃ¥ være streng eller tabell av strenger", + nds = "muss String oder Tabelle von Strings sein", + nl = "moet een string of een tabel met strings zijn", + nn = "mÃ¥ væra streng eller tabell av strengar", + pl = "musi być ciÄ…giem lub tabelÄ… ciÄ…gów", + pt = "deve ser uma expressão ou uma tabela de expressões", + pt_BR = "precisa ser um texto ou uma tabela de textos", + ro = "trebuie să fie un ÅŸir de caractere sau un tabel de ÅŸiruri de caractere", + ru = "должна быть Ñтрокой или таблицей Ñтрок", + sk = "musí byÅ¥ reÅ¥azec alebo tabuľka reÅ¥azcov", + sl = "mora biti niz ali tabela nizov", + sv = "mÃ¥ste vara en sträng eller en tabell av strängar", + tr = "bir dizgi ya da dizgi tablosu olmalı", + uk = "повинно бути Ñ€Ñдком або таблицею Ñ€Ñдків", + zh_TW = "必須是字串或字串表格" + }; + + -- This is an error string for a buggy config element. See notes above. + ["must be a string or number"] = { + af = "moet 'n string of 'n nommer wees", + ar = "يجب ان يكون سلسلة حرÙية او رقم", + cs = "musí být Å™etÄ›zcem nebo Äíslem", + de = "muss eine Zeichenkette oder Zahl sein", + el = "Ï€Ïέπει να είναι αλφαÏιθμητικό ή αÏιθμός", + en_AU = "must be a string or number", + en_CA = "must be a string or number", + en_GB = "must be a string or number", + es = "debe ser una cadena o un número", + fi = "täytyy olla merkkijono tai luku", + fr = "doit être une chaîne de caractères ou un nombre", + he = "עליו להיות מחרוזת ×ו מספר", + hu = "sztringnek vagy számnak kell lennie", + id = "harus string atau angka", + it = "deve essere una stringa oppure un numero", + nb = "mÃ¥ være en streng eller et nummer", + nds = "muss String oder Nummer sein", + nl = "moet een string of een nummer zijn", + nn = "mÃ¥ væra ein streng eller eit nummer", + pl = "musi być ciÄ…giem lub liczbÄ…", + pt = "deve ser uma expressão ou número", + pt_BR = "precisa ser um texto ou um número", + ro = "trebuie să fie un ÅŸir de caractere sau un număr", + ru = "должна быть Ñтрокой или чиÑлом", + sk = "musí byÅ¥ reÅ¥azec alebo Äíslo", + sl = "mora biti niz ali Å¡tevilo", + sv = "mÃ¥ste vara en sträng eller ett nummer", + tr = "bir dizgi ya da sayı olmalı", + uk = "повинно бути Ñ€Ñдком або чиÑлом", + zh_TW = "必須是字串或數字" + }; + + -- This is an error string for a buggy config element. See notes above. + ["can't be empty string"] = { + af = "kan nie 'n lee string wees nie", + ar = "لا يمكن ان يكون سلسلة حرÙية خالية", + cs = "nemůže být prázdným Å™etÄ›zcem", + de = "darf keine leere Zeichenkette sein", + el = "δεν μποÏεί να είναι άδειο αλφαÏιθμητικό", + en_AU = "can't be empty string", + en_CA = "can't be empty string", + en_GB = "can't be empty string", + es = "no puede ser una cadena vacía", + fi = "ei saa olla tyhjä merkkijono", + fr = "ne peut être une chaîne de caractères vide", + he = "×œ× × ×™×ª×Ÿ להותיר מחרוזת ריקה", + hu = "nem lehet üres sztring", + id = "tidak boleh string kosong", + it = "non può essere una stringa vuota", + nb = "kan ikke være en tom streng", + nds = "kann String nicht leeren", + nl = "kan geen lege string zijn", + nn = "kan ikkje væra ein tom streng", + pl = "nie może być pustym ciÄ…giem", + pt = "não pode ser uma expressão vazia", + pt_BR = "não pode ser uma string vazia", + ro = "nu poate fi un ÅŸir de caractere gol", + ru = "не может быть пуÑтой Ñтрокой", + sk = "nemôže byÅ¥ reÅ¥azec", + sl = "ne mora biti prazen niz", + sv = "kan inte vara en tom sträng", + tr = "boÅŸ bir dizgi olamaz", + uk = "не може бути порожнім Ñ€Ñдком", + zh_TW = "ä¸èƒ½æ˜¯ç©ºå­—串" + }; + + -- This is an error string for a buggy config element. See notes above. + ["URL doesn't have protocol"] = { + af = "URL het nie 'n protokol gespesifiseer nie", + ar = "العنوان لم يحدد البروتوكول", + cs = "URL nemá urÄený protokol", + da = "URL har ikke en protekol", + de = "URL hat kein Protokoll", + el = "το URL δεν πεÏιέχει πεÏιγÏαφή Ï€Ïοτοκόλου", + en_AU = "URL doesn't have protocol", + en_CA = "URL doesn't have protocol", + en_GB = "URL doesn't have protocol", + es = "URL sin protocolo", + fr = "L'URL manque un protocole", + he = "לכתובת ×ין פרוטוקול", + hu = "URL-nek nincs protokollja", + id = "URL tidak memiliki protokol", + it = "URL malformato (senza protocollo)", + nb = "URL har ikke protokoll", + nds = "URL hat kein Protokoll", + nl = "URL heeft geen protocol", + nn = "URL har ikkje protokoll", + pl = "URL nie ma protokoÅ‚u", + pt = "O URL não contém o protocolo", + pt_BR = "Não existe protocolo na URL", + ro = "calea URL nu are protocol", + ru = "URL не Ñодержит протокол", + sk = "URL neurÄuje protokol", + sl = "URL nima protokola", + sv = "URL saknar protokoll", + tr = "URL'nin protokolü yok", + uk = "Ð’ URL не вказано протокол", + zh_TW = "URL 沒有通訊å”定" + }; + + -- This is an error string for a buggy config element. See notes above. + ["URL doesn't have host"] = { + af = "URL het nie 'n masjien naam gespesifiseer nie", + ar = "العنوان لم يحدد الخادم", + cs = "URL neobsahuje hostitele", + da = "URL mangler vært", + de = "URL hat keinen Host", + el = "το URL δεν πεÏιέχει πεÏιγÏαφή διακομιστή", + en_AU = "URL doesn't have host", + en_CA = "URL doesn't have host", + en_GB = "URL doesn't have host", + es = "No se encuentra el servidor", + fr = "L'URL manque un nom d'hôte", + he = "לכתובת ×ין מ×רח", + hu = "URL-nek nincs hosztja", + id = "URL tidak memiliki host", + it = "URL malformato (senza host)", + nb = "URL har ikke vert", + nds = "URL hat keinen Host", + nl = "URL heeft geen host", + nn = "URL har ikke vert", + pl = "URL nie ma hosta", + pt = "O URL não contém o servidor", + pt_BR = "Não existe host na URL", + ro = "calea URL nu are gazdă", + ru = "URL не Ñодержит хоÑÑ‚", + sk = "URL neobsahuje hostiteľa", + sl = "URL nima gostitelja", + sv = "URL saknar värd", + tr = "URL'de makine adı yok", + uk = "Ð’ URL не вказано хоÑÑ‚", + zh_TW = "URL 沒有主機" + }; + + -- This is an error string for a buggy config element. See notes above. + ["URL doesn't have path"] = { + af = "URL het nie 'n destinasie nie", + ar = "العنوان لا يحدد المسار", + cs = "URL neobsahuje cestu", + da = "URL mangler sti", + de = "URL hat keinen Pfad", + el = "το URL δεν πεÏιέχει το μονοπάτι", + en_AU = "URL doesn't have path", + en_CA = "URL doesn't have path", + en_GB = "URL doesn't have path", + es = "URL sin ruta de acceso", + fr = "L'URL manque un chemin", + he = "לכתובת ×ין נתיב", + hu = "URL-nek nincs útvonala", + id = "URL tidak memiliki path", + it = "URL malformato (senza percorso)", + nb = "URL har ikke sti", + nds = "URL hat keinen Pfad", + nl = "URL heeft geen pad", + nn = "URL har ikkje sti", + pl = "URL nie ma Å›cieżki", + pt = "O URL não contém o caminho", + pt_BR = "Não existe caminho na URL", + ro = "URL nu are cale", + ru = "URL не Ñодержит путь", + sk = "URL neobsahuje cestu", + sl = "URL nima poti", + sv = "URL saknar sökväg", + tr = "URL'nin yolu yok", + uk = "Ð’ URL не вказано шлÑÑ…", + zh_TW = "URL 沒有路徑" + }; + + -- This is an error string for a buggy config element. See notes above. + ["URL protocol is unsupported"] = { + af = "URL se protokol is nie ondersteun nie", + ar = "بروتوكول العنوان غير مدعوم", + cs = "Protokol v URL není podporován", + de = "URL Protokoll wird nicht unterstützt", + el = "το Ï€Ïοτόκολο που πεÏιέχει το URL δεν υποστηÏίζεται", + en_AU = "URL protocol is unsupported", + en_CA = "URL protocol is unsupported", + en_GB = "URL protocol is unsupported", + es = "Protocolo de URL no soportado", + fr = "Le protocole de l'URL n'est pas supporté", + he = "פרוטוקול הכתובת ×ינו נתמך", + hu = "URL protokoll nem támogatott", + id = "Protokol URL tidak didukung", + it = "URL malformato (protocollo non supportato)", + nb = "URL-protokollen er ikke støttet", + nds = "URL Protokoll wird nicht unterstützt", + nl = "protocol van URL wordt niet ondersteund", + nn = "URL-protokollen er ikkje støtta", + pl = "protokół URL nie obsÅ‚ugiwany", + pt = "O protocolo do URL não é suportado", + pt_BR = "O protocolo da URL não é suportado", + ro = "protocolul URL nu este suportat", + ru = "Протокол URL не поддерживаетÑÑ", + sk = "URL protokol nie je podporovaný", + sl = "URL protokol ni podprt", + sv = "URL-protokollet har inget stöd", + tr = "URL protokolü desteklenmiyor", + uk = "Протокол, вказаний в URL , не підтримуєтьÑÑ", + zh_TW = "URL 通訊å”定ä¸æ”¯æ´" + }; + + -- This is an error string for a buggy config element. See notes above. + -- "Permission string" is text representing a file's permissions, + -- such as "0644" on Unix. + ["Permission string is invalid"] = { + af = "Toestemming string is ongeldig", + ar = "تعري٠إذن غير صحيح", + cs = "ŘetÄ›zec s oprávnÄ›ními je neplatný", + da = "Rettigheds syntaks er ikke korrekt", + de = "Berechtigungszeichenkette ist ungültig", + el = "Το αλφαÏιθμητικό που πεÏιγÏάφει τα δικαιώματα είναι λάθος.", + en_AU = "Permission string is invalid", + en_CA = "Permission string is invalid", + en_GB = "Permission string is invalid", + es = "Cadena de permisos no válida", + fr = "Chaine de permissions invalide", + he = "מחרוזת ההרש××” ×”×™× ×” שגויה", + hu = "Helytelen engedélysztring", + id = "String perizinan tidak cocok", + it = "Stringa dei permessi non valida", + nb = "Rettighetsstrengen er ugyldig", + nds = "Zugriffsberechtigungs String ist ungültig", + nl = "Permissie string is niet geldig", + nn = "Rettighetsstrengen er ugyldig", + pl = "CiÄ…g uprawnieÅ„ jest niepoprawny", + pt = "A expressão de permissão não é válida", + pt_BR = "A string de permissão é inválida", + ro = "Åžirul de caractere nu desemnează permisiuni valide", + ru = "Строка прав доÑтупа некорректна", + sk = "ReÅ¥azec práv je neplatný", + sl = "Dovoljenje ni veljavne oblike", + sv = "Rättighetssträngen är ogiltig", + tr = "Ä°zin dizgisi geçersiz", + uk = "РÑдок із правами не Ñ” коректним", + zh_TW = "無效的檔案權é™è¨­å®š" + }; + + -- This is an error string for a buggy config element. See notes above. + -- "property" means attribute, not something owned, in this case. + ["is not a valid property"] = { + af = "is nie 'n geldige waarde", + ar = "خاصية غير صحيحة", + cs = "není platnou vlastností", + de = "ist keine gültige Eigenschaft", + el = "δεν είναι έγγυÏη ιδιότητα", + en_AU = "is not a valid property", + en_CA = "is not a valid property", + en_GB = "is not a valid property", + es = "no es un atributo válido", + fr = "n'est pas une propriété valide", + he = "××™× ×” בעלת ערך תקני", + hu = "érvénytelen tulajdonság", + id = "bukan properti yang cocok", + it = "non è una proprietà valida", + nb = "er ikke en gyldig egenskap", + nds = "ist keine gültige Eigenschaft", + nl = "is geen geldige eigenschap", + nn = "er ikkje ein gyldig egenskap", + pl = "nie jest poprawym atrybutem", + pt = "não é uma propriedade válida", + pt_BR = "não é uma propriedade válida", + ro = "nu este un atribut valid", + ru = "недопуÑтимое значение", + sk = "nie je správnym atribútom", + sl = "ni veljavna nastavitev", + sv = "är inte ett giltigt attribut", + tr = "geçerli bir özellik deÄŸil", + uk = "не Ñ” коректним атрибутом", + zh_TW = "並ä¸æ˜¯æœ‰æ•ˆè¨­å®š" + }; + + -- This is an error string for a buggy config element. See notes above. + -- %0 is a data type name (string, number, table, etc). + ["must be %0"] = { + af = "moet %0 wees", + ar = "يجب أن يكون %0", + cs = "musí být %0", + da = "skal være %0", + de = "muss vom Typ %0 sein", + el = "Ï€Ïέπει να είναι %0", + en_AU = "must be %0", + en_CA = "must be %0", + en_GB = "must be %0", + es = "debe ser %0", + fi = "täytyy olla %0", + fr = "doit être de type %0", + he = "עליה להיות %0", + hu = "%0 -nak kell lennie", + id = "harus %0", + it = "deve essere %0", + nb = "mÃ¥ være %0", + nds = "muss %0 sein", + nl = "moet %0 zijn", + nn = "mÃ¥ væra %0", + pl = "musi być %0", + pt = "tem que ser %0", + pt_BR = "precisa ser %0", + ro = "trebuie să fie %0", + ru = "должна быть %0", + sk = "musí byÅ¥ %0", + sl = "mora biti %0", + sv = "mÃ¥ste vara %0", + tr = "%0 tipinde olmalı", + uk = "повинно бути %0", + zh_TW = "必須是 %0" + }; + + -- Data type for "must be %0" above... + ["string"] = { + af = "string", + ar = "سلسلة حرÙية", + cs = "Å™etÄ›zec", + da = "streng", + de = "Zeichenkette", + el = "αλφαÏιθμητικό", + en_AU = "string", + en_CA = "string", + en_GB = "string", + es = "cadena", + fi = "merkkijono", + fr = "chaîne de caractères", + he = "מחרוזת", + hu = "szöveg", + id = "string", + it = "stringa", + nb = "streng", + nds = "String", + nl = "string", + nn = "streng", + pl = "ciÄ…giem", + pt = "expressão", + pt_BR = "string", + ro = "ÅŸir de caractere", + ru = "Ñтрокой", + sk = "reÅ¥azec", + sl = "niz", + sv = "sträng", + tr = "dizgi", + uk = "Ñ€Ñдок", + zh_TW = "字串" + }; + + -- Data type for "must be %0" above... + ["boolean"] = { + af = "bool", + ar = "منطقي", + cs = "booleovská hodnota", + da = "boolsk", + de = "Bool", + el = "boolean", + en_AU = "boolean", + en_CA = "boolean", + en_GB = "boolean", + es = "booleano", + fi = "totuusarvo", + fr = "booléen", + he = "בולי×× ×™", + hu = "logikai", + id = "boolean", + it = "booleano", + nb = "boolsk verdi", + nds = "Boolean", + nl = "boolean", + nn = "boolsk verdi", + pl = "wartoÅ›ciÄ… logicznÄ…", + pt = "boleano", + pt_BR = "booleano", + ro = "tip logic", + ru = "булевым", + sk = "booleovská hodnota", + sl = "boolova vrednost", + sv = "boolskt värde", + tr = "mantıksal deÄŸer", + uk = "булеве", + zh_TW = "布林值" + }; + + -- Data type for "must be %0" above... + ["number"] = { + af = "numeries", + ar = "عدد", + cs = "Äíslo", + da = "nummer", + de = "Zahl", + el = "αÏιθμός", + en_AU = "number", + en_CA = "number", + en_GB = "number", + es = "número", + fi = "luku", + fr = "nombre", + he = "מספר", + hu = "szám", + id = "angka", + it = "numero", + nb = "tall", + nds = "Nummer", + nl = "nummer", + nn = "tal", + pl = "liczbÄ…", + pt = "número", + pt_BR = "número", + ro = "număr", + ru = "чиÑлом", + sk = "Äíslo", + sl = "Å¡tevilo", + sv = "nummer", + tr = "sayı", + uk = "чиÑло", + zh_TW = "數字" + }; + + -- Data type for "must be %0" above... + ["function"] = { + af = "funksie", + ar = "دالة", + cs = "funkce", + da = "funktion", + de = "Funktion", + el = "function", + en_AU = "function", + en_CA = "function", + en_GB = "function", + es = "función", + fi = "funktio", + fr = "fonction", + he = "פונקציה", + hu = "függvény", + id = "fungsi", + it = "funzione", + nb = "funksjon", + nds = "Funktion", + nl = "functie", + nn = "funksjon", + pl = "funkcjÄ…", + pt = "função", + pt_BR = "função", + ro = "funcÅ£ie", + ru = "функцией", + sk = "funkcia", + sl = "funkcija", + sv = "funktion", + tr = "fonksiyon", + uk = "функціÑ", + zh_TW = "函å¼" + }; + + -- Data type for "must be %0" above... + ["table"] = { + af = "tabel", + ar = "جدول", + cs = "tabulka", + da = "tabel", + de = "Tabelle", + el = "πίνακας", + en_AU = "table", + en_CA = "table", + en_GB = "table", + es = "tabla", + fi = "taulukko", + fr = "tableau", + he = "טבלה", + hu = "táblázat", + id = "tabel", + it = "tabella", + nb = "tabell", + nds = "Tabelle", + nl = "tabel", + nn = "tabell", + pl = "tabelÄ…", + pt = "tabela", + pt_BR = "tabela", + ro = "tabelă", + ru = "таблицей", + sk = "tabuľka", + sl = "tabela", + sv = "tabell", + tr = "tablo", + uk = "таблицÑ", + zh_TW = "表格" + }; + + -- bzlib is a proper name. The error message (%0) may not be localized, + -- it's meant to be a developer error and not an end-user message. + ["bzlib triggered an internal error: %0"] = { + af = "bzlib het 'n interne fout ge-initieer", + ar = "bzlib تسبب ÙÙŠ خطأ: %0", + cs = "bzlib vyvolala vnitÅ™ní chybu: %0", + da = "bzlib forÃ¥rsagede en intern fejl:", + de = "bzlib hat einen internen Fehler ausgelöst: %0", + el = "το bzlib παÏουσίασε εσωτεÏικό σφάλμα: %0", + en_AU = "bzlib triggered an internal error: %0", + en_CA = "bzlib triggered an internal error: %0", + en_GB = "bzlib triggered an internal error: %0", + es = "bzlib ha provocado un error interno: %0", + fr = "bzlib a causé une erreur interne: %0", + he = "bzlib העלה שגי××” פנימית: %0", + hu = "bzlib belsÅ‘ hibát észlelt: %0", + id = "bzlib memicu galat di bagian dalam", + it = "bzlib ha causato un errore interno: %0", + nb = "bzlib forÃ¥rsaket en intern feil: %0", + nds = "bzlib löste eine internen Fehler aus: %0", + nl = "bzlib heeft een interne fout veroorzaakt: %0", + nn = "bzlib forÃ¥rsaka ein intern feil: %0", + pl = "bzlib wywoÅ‚aÅ‚ bÅ‚Ä…d wewnÄ™trzny: %0", + pt = "A bzlib despoletou um erro interno: %0", + pt_BR = "bzlib disparou um erro interno: %0", + ro = "bzlib a raportat o eroare internă: %0", + ru = "произошла ошибка в bzlib: %0", + sk = "bzlib spôsobilo vnútornú chybu: %0", + sl = "bzlib je sprožil napako: %0", + sv = "bzlib orsakade ett internt fel: %0", + tr = "bzlib içsel bir hata tetikledi: %0", + zh_TW = "bzlib é­é‡ä¸€å€‹å…§éƒ¨éŒ¯èª¤ï¼š %0" + }; + + -- This is a UI button label, usually paired with "OK", but also usually + -- present as a generic "stop the program" button. + ["Cancel"] = { + af = "Staak", + ar = "ألغÙ", + cs = "ZruÅ¡it", + da = "Annuller", + de = "Abbrechen", + el = "ΆκυÏο", + en_AU = "Cancel", + en_CA = "Cancel", + en_GB = "Cancel", + es = "Cancelar", + fi = "Peru", + fr = "Annuler", + he = "ביטול", + hu = "Mégsem", + id = "Batal", + it = "Annulla", + nb = "Avbryt", + nds = "Abbrechen", + nl = "Annuleren", + nn = "Avbryt", + pl = "Anuluj", + pt = "Cancelar", + pt_BR = "Cancelar", + ro = "Renunță", + ru = "Отмена", + sk = "ZruÅ¡iÅ¥", + sl = "PrekliÄi", + sv = "Avbryt", + tr = "Ä°ptal", + uk = "СкаÑувати", + zh_TW = "å–消" + }; + + -- This is a message box title when prompting for confirmation when the + -- the user clicks the Cancel button. + ["Cancel installation"] = { + af = "Staak die installasie", + ar = "ألغ التثبيت", + cs = "ZruÅ¡it instalaci", + da = "Afbryd installation", + de = "Installation abbrechen", + el = "ΑκÏÏωση εγκατάστασης", + en_AU = "Cancel Installation", + en_CA = "Cancel installation", + en_GB = "Cancel installation", + es = "Cancelar instalación", + fi = "Peru asennus", + fr = "Annuler l'installation", + he = "בטל התקנה", + hu = "Telepítés megszakítása", + id = "Batal instalasi", + it = "Annulla l'installazione", + nb = "Avbryt installasjonen", + nds = "Installation abbrechen", + nl = "Installatie afbreken?", + nn = "Avbryt installasjonen", + pl = "Anuluj InstalacjÄ™", + pt = "Cancelar instalação", + pt_BR = "Cancelar instalação", + ro = "Anulează instalarea", + ru = "Отменить уÑтановку", + sk = "ZruÅ¡iÅ¥ inÅ¡taláciu", + sl = "PrekliÄi namestitev", + sv = "Avbryt installationen", + tr = "Kurulumu iptal et", + uk = "СкаÑувати вÑтановленнÑ", + zh_TW = "å–消安è£" + }; + + -- This error is reported for i/o failures while listing files contained + -- in a .zip (or whatever) file. + ["Couldn't enumerate archive"] = { + af = "Kon nie die argief se inhoud lys nie", + ar = "لا يمكن ترقيم ملÙات الأرشيÙ", + cs = "Nemohu projít archiv", + de = "Archiv kann nicht aufgelistet werden", + el = "Δεν είναι δυνατή η απαÏίθμηση του πακέτου αÏχείων", + en_AU = "Couldn't enumerate archive", + en_CA = "Couldn't enumerate archive", + en_GB = "Couldn't enumerate archive", + es = "No se puede enumerar el archivo", + fi = "Paketin tiedostojen listaus epäonnistui", + fr = "Ne peux pas énumérer les fichiers de l'archive", + he = "×œ× × ×™×ª×Ÿ למנות ×רכיון", + hu = "Az archívum nem csomagolható ki", + id = "Tidak dapat menghitung arsip", + it = "Impossibile enumerare l'archivio", + nb = "Kunne ikke liste filer i arkivet", + nds = "Konnte Archiv nicht enumerieren", + nl = "Kan het archief niet weergeven", + nn = "Kunne ikkje lista filer i arkivet", + pl = "nie można przetworzyć archiwum", + pt = "Foi impossível enumerar o arquivo", + pt_BR = "Não é possível enumerar o arquivo", + ro = "Nu se poate citi arhiva", + ru = "Ðе могу прочитать архив", + sk = "Nemôžem prelistovaÅ¥ archív", + sl = "Branje arhiva ni uspelo", + sv = "Kunde inte lista filen", + tr = "ArÅŸiv numaralandırılamadı", + uk = "Ðеможливо отримати ÑпиÑок файлів з архіву", + zh_TW = "無法列出檔案包的內容" + }; + + -- This error is reported for i/o failures while opening a .zip + -- (or whatever) file. + ["Couldn't open archive"] = { + af = "Kon nie argief oopmaak nie", + ar = "لا يمكن Ùتح الأرشيÙ", + cs = "Nemohu otevřít archiv", + da = "Kunne ikke Ã¥bne arkiv", + de = "Archiv kann nicht geöffnet werden", + el = "Δεν μπόÏεσε να ανοίξει το αÏχείο", + en_AU = "Couldn't open archive", + en_CA = "Couldn't open archive", + en_GB = "Couldn't open archive", + es = "No se puede abrir el archivo", + fr = "Impossible d'ouvrir l'archive.", + he = "×œ× × ×™×ª×Ÿ לפתוח ×רכיון", + hu = "Archív megnyitása sikertelen", + id = "Tidak dapat membuka arsip", + it = "Impossibile aprire l'archivio", + nb = "Kunne ikke Ã¥pne arkivet", + nds = "Kann Archiv nicht öffnen", + nl = "Kon archief niet openen", + nn = "Kunne ikkje opna arkivet", + pl = "Nie można otworzyć archiwum", + pt = "Foi impossível abrir o arquivo", + pt_BR = "Não é possível abrir o arquivo", + ro = "Nu s-a putut deschide arhiva", + ru = "Ðе могу открыть архив", + sk = "Nemôžem otvoriÅ¥ archív", + sl = "Arhiva ni bilo možno odpreti", + sv = "Kunde inte öppna filen", + tr = "ArÅŸiv açılamadı", + uk = "Ðеможливо відкрити архів", + zh_TW = "無法開啟檔案包" + }; + + -- This is used by the stdio UI to choose a location to write files. + -- A numbered list of options is printed, and the user may choose one by + -- its number (default is number one), or enter their own text instead of + -- choosing a default. This string is the instructions printed for the + -- user before the prompt. + ["Choose install destination by number (hit enter for #1), or enter your own."] = { + af = "Kies installasie destinasie by nommer (druk enter vir #1), of kies U eie.", + ar = "اختر رقم مكان التثبيت (اضغط Enter لأختيار #1) او أدخل المكان اللذي تريده.", + cs = "Zvolte cíl instalace Äíslem (stisknÄ›te enter pro #1) nebo zadejte vlastní cíl.", + de = "Wählen Sie eine Nummer für das Installationsziel (drücken Sie Enter für #1), oder geben Sie ein eigenes an.", + el = "Διαλέξτε Ï€ÏοοÏισμό εγκατάστασης βάση αÏÎ¹Î¸Î¼Î¿Ï (πατήστε ENTER για #1), ή γÏαψτε τον δικό σας.", + en_AU = "Choose install destination by number (hit enter for #1), or enter your own.", + en_CA = "Choose install destination by number (hit enter for #1), or enter your own.", + en_GB = "Choose install destination by number (hit enter for #1), or enter your own.", + es = "Elige el lugar de instalación con números (pulsa Intro para #1), o especifícalo", + fr = "Choisissez la destination d'installation par un nombre (Appuyez sur Entrée pour le n°1), ou entrez votre propre choix.", + he = "בחר ×ת יעד ההתקנה על ידי מספר (לחיצה על enter עבור מס' 1), ×ו הזן בעצמך.", + hu = "Válassz telepítési célt szám szerint (üss entert az elsÅ‘höz), vagy adj meg egyet.", + id = "Pilih tujuan instal dengan nomor (tekan enter untuk #1), atau masukkan angka.", + it = "Seleziona la destinazione dell'installazione tramite il numero corrispondente (invio per la #1), oppure digita il percorso desiderato.", + nb = "Velg installasjonssti etter nummer (trykk enter for #1), eller skriv inn din egen.", + nds = "Wählen Sie das Installationsverzeichnis durch Drücken einer Nummer (enter für #1), oder geben Sie selber einen ein.", + nl = "Kies installatiemap met het bijbehorende nummer, of voer u eigen keuze in.", + nn = "Vel installasjonssti etter tal (trykk enter for #1), eller skriv inn din eigen.", + pl = "Wybierz miejsce instalacji wybierajÄ…c numer (naciÅ›nij enter dla #1), lub wpisz wÅ‚asnÄ….", + pt = "Escolha o destino da instalação pelo seu número (pressione enter para o primeiro destino), ou introduza um outro destino.", + pt_BR = "Escolha um destino de instalação pelo número (pressione enter para 1), ou informe o seu própio.", + ro = "Alege destinaÅ£ia de instalare printr-un număr (apasă enter pentru 1), sau introdu-o pe cea dorită.", + ru = "Выберите путь уÑтановки (нажмите Enter Ð´Ð»Ñ Ð½Ð¾Ð¼ÐµÑ€Ð° 1), или введите Ñвой.", + sk = "Vyberte cieľ inÅ¡talácie pomocou Äísla zo zoznamu (stlaÄte enter pre prvú možnosÅ¥), alebo zadajte svoju vlastnú možnosÅ¥.", + sl = "Izberite mapo namestitve s Å¡tevilko (pritisnite enter za #1), ali vnesite lasten izbor.", + sv = "Välj sökväg för installationen efter nummer (tryck enter för #1), eller skriv in din egen.", + tr = "Kurulum yerini sayı yardımıyla seçiniz (#1 için giriÅŸe basınız), ya da kendiniz belirtiniz", + uk = "Оберіть Ð¿Ñ€Ð¸Ð·Ð½Ð°Ñ‡ÐµÐ½Ð½Ñ Ð·Ð° номером (натиÑніть enter Ð´Ð»Ñ Ð²Ð¸Ð±Ð¾Ñ€Ñƒ â„–1), або введіть влаÑне.", + zh_TW = "è«‹ä¾æ•¸å­—é¸æ“‡æ¬²å®‰è£çš„目標ä½ç½®ï¼ˆæŒ‰ [Enter] éµå¯ç›´æŽ¥é¸å–é è¨­é¸é …),或者自行輸入ä½ç½®ã€‚" + }; + + -- This is used by the stdio UI to toggle options. A numbered list is + -- printed, and the user can enter one of those numbers to toggle that + -- option on or off. This string is the instructions printed for the + -- user before the prompt. + ["Choose number to change."] = { + af = "Kies nommer om te verander", + ar = "اختر الرقم للتغيير", + cs = "Zadejte Äíslo pro zmÄ›nu.", + da = "Vælg nummer som skal ændres.", + de = "Wählen Sie eine Nummer zum Ändern.", + el = "Διάλεξτε τον αÏιθμό που θέλετε να αλλάξετε.", + en_AU = "Choose number to change.", + en_CA = "Choose number to change.", + en_GB = "Choose number to change.", + es = "Elegir número para cambiar", + fr = "Entrez le numéro de l'option à modifier.", + he = "בחר מספר לשינוי.", + hu = "Adj meg egy számot a változtatáshoz.", + id = "Pilih angka untuk mengubah.", + it = "Seleziona il numero corrispondente per cambiare.", + nb = "Velg tall som skal endres.", + nds = "Wähle eine Nummer zum ändern", + nl = "Kies een nummer om te veranderen", + nn = "Velg tal som skal endrast.", + pl = "Wybierz numer, aby zmienić.", + pt = "Escolha um número para alterar", + pt_BR = "Escolha o número para alterar", + ro = "Alege numărul ce se va schimba.", + ru = "Выберите чиÑло Ð´Ð»Ñ Ð¸Ð·Ð¼ÐµÐ½ÐµÐ½Ð¸Ñ", + sk = "Vyberte pomocou Äísla, ak chcete zmeniÅ¥ nastavenie", + sl = "Izberite Å¡tevilko za spremembo.", + sv = "Välj nummer som skall ändras.", + tr = "DeÄŸiÅŸtirmek için bir sayı seçiniz", + uk = "Оберіть номер Ð´Ð»Ñ Ð·Ð¼Ñ–Ð½Ð¸", + zh_TW = "é¸æ“‡æ•¸å­—以更改" + }; + + -- As in "two different files want to use the same name." This is a title + -- on a message box. + ["Conflict!"] = { + af = "Konflik!", + ar = "تعارض!", + cs = "Konflikt!", + da = "Konflikt!", + de = "Konflikt!", + el = "Διένεξη!", + en_AU = "Conflict!", + en_CA = "Conflict!", + en_GB = "Conflict!", + es = "¡Conflicto!", + fi = "Ristiriita!", + fr = "Conflit !", + he = "התנגשות!", + hu = "Ãœtközés!", + id = "Bertentangan!", + it = "Conflitto!", + nb = "Konflikt!", + nds = "Konflikt!", + nl = "Conflict!", + nn = "Konflikt!", + pl = "Konflikt!", + pt = "Conflito!", + pt_BR = "Conflito!", + ro = "Conflict!", + ru = "Конфликт!", + sk = "Konflikt!", + sl = "Spor!", + sv = "Konflikt!", + tr = "Çakışma!", + uk = "Конфлікт!", + zh_TW = "è¡çªï¼" + }; + + -- This is an error message shown to the user. When a file is to be + -- overwritten, we move it out of the way instead, so we can restore it + -- ("roll the file back") in case of problems, with the goal of having + -- an installation that fails halfway through reverse any changes it made. + -- This error is shown if we can't move a file out of the way. + ["Couldn't backup file for rollback"] = { + af = "Konnie leer rugsteen vir terugrol nie", + ar = "لم نستطع Ø­Ùظ نسخة احتياطية", + cs = "Nemohu zazálohovat soubor pro obnovu", + de = "Konnte Datei nicht zur Wiederherstellung sichern", + el = "Δεν είναι δυνατή η αντιγÏαφή ασφαλείας για χÏήση σε πεÏίπτωση επαναφοÏάς", + en_AU = "Couldn't backup file for rollback", + en_CA = "Couldn't backup file for rollback", + en_GB = "Couldn't backup file for rollback", + es = "No se puede guardar el archivo para revertir", + fr = "Impossible de faire une copie de secours du fichier", + he = "×œ× × ×™×ª×Ÿ לגבות ×ת הקובץ למטרות שיחזור", + hu = "Fájllista biztonsági mentése nem lehetséges", + it = "Impossibile eseguire il backup del file per un successivo ripristino", + nb = "Kunne ikke sikkerhetskopiere fil for tilbakerulling", + nds = "Datei konnte für die Wiederherstellung nicht gesichert werden", + nl = "Kon bestand niet backupen om de installatie terug te kunnen draaien", + nn = "Kunne ikkje sikkerhetskopiera fil for tilbakerulling", + pl = "Nie można zaarchiwizować pliku do odtworzenia", + pt = "Foi impossível salvaguardar o ficheiro para refazer as acções", + pt_BR = "Não foi possível criar um backup ou restaurar o arquivo", + ro = "Nu s-a putut salva fiÅŸierul pentru opÅ£iunea de revenire", + ru = "Ðе могу Ñохранить копию файла Ð´Ð»Ñ Ð²Ð¾ÑÑтановлениÑ", + sk = "Nemôžem zálohovaÅ¥ súbor pre obnovu", + sl = "Varnostna kopija za razveljavitev ni uspela", + sv = "Kunde inte säkerhetskopiera filen för Ã¥terställning", + tr = "Dosya geri yükleme için yedeklenemedi", + uk = "Ðеможливо зарезервувати файл Ð´Ð»Ñ Ð²Ñ–Ð´ÐºÐ°Ñ‚Ñƒ", + zh_TW = "無法備份檔案以復原" + }; + + -- This error is shown if we aren't able to write the list of files + -- that were installed (the "manifest") to disk. Apparently some languages + -- don't have a convenient translation of "manifest" ... it is not + -- important that this word maps directly for end-users, as long as the + -- general concept is explained. + ["Couldn't create manifest"] = { + af = "Kon nie manifesto skep nie", + ar = "لم يمكن كتابة قائمة ملÙات التثبيت", + cs = "Nemohu vytvoÅ™it manifest", + de = "Konnte Manifest nicht erstellen", + el = "Δεν μπόÏεσε να δημιουÏγήσει το \"manifest\"", + en_AU = "Couldn't create manifest", + en_CA = "Couldn't create manifest", + en_GB = "Couldn't create manifest", + es = "No se puede crear manifiesto", + fr = "Echec de création du fichier manifest", + he = "×œ× × ×™×ª×Ÿ ליצור מניפסט", + hu = "TelepítendÅ‘ fájlok listájának létrehozása sikertelen", + id = "Tidak dapat membuat manifesto", + it = "Impossibile creare la lista dei file installati su disco.", + nb = "Kunne ikke lage manifest", + nds = "Erstellen des Manifests schlug fehl.", + nl = "Kon het installatiemanifest niet maken", + nn = "Kunne ikkje laga manifest", + pl = "Nie można utworzyć manifestu", + pt = "Foi impossível criar o manifesto", + pt_BR = "Não é possível criar o manifest", + ro = "Nu s-a putut creea lista de fiÅŸiere instalate", + ru = "Ðевозможно Ñоздать ÑпиÑок уÑтановленных файлов", + sk = "Nemôžem vytvoriÅ¥ manifest", + sl = "Ustvarjanje manifesta ni uspelo", + sv = "Kunde inte skapa en fillista", + tr = "Kurulum kaydı oluÅŸturulamadı", + uk = "Ðеможливо Ñтворити файл manifest", + zh_TW = "無法建立檔案清單" + }; + + -- This is an error message. It speaks for itself. :) + ["Couldn't restore some files. Your existing installation is likely damaged."] = { + af = "Kon nie alle lêers herstel nie. Jou huidege installasie is waarskynlik beskadig.", + ar = "لم بمكن استرجاع بعض الملÙات، التثبيت السابق يحتوي على أخطاء", + cs = "NepodaÅ™ilo se obnovit nÄ›které soubory. VaÅ¡e existující instalace je pravdÄ›podobnÄ› poÅ¡kozená.", + de = "Konnte einige Dateien nicht wiederherstellen. Ihre Installation ist wahrscheinlich beschädigt.", + el = "Δεν μπόÏεσε να ανακτήση κάποια αÏχεία. Είναι πιθανόν η εγκατάσταση να είναι κατεστÏαμένη.", + en_AU = "Couldn't restore some files. Your existing installation is likely damaged.", + en_CA = "Couldn't restore some files. Your existing installation is likely damaged.", + en_GB = "Couldn't restore some files. Your existing installation is likely to be damaged.", + es = "No se pudieron restaurar algunos archivos. Tu instalación posiblemente esté dañada", + fr = "Impossible de restaurer certains fichiers. Votre installation existante est certainement endommagée.", + he = "×œ× × ×™×ª×Ÿ לשחזר כמה מהקבצי×. ייתכן וההתקנה הנוכחית שלך פגומה.", + hu = "Néhány fájlt nem lehet visszaállítani. A meglévÅ‘ telepítés valószínűleg megsérült.", + id = "Tidak dapat mengembalikan beberapa berkas. Instalasi yang ada sepertinya rusak.", + it = "Non è stato possibile ripristinare alcuni files. L'installazione corrente probabilmente è danneggiata.", + nb = "Noen filer kunne ikke tilbakestilles. Den eksisterende installasjonen er sannsynligvis skadet.", + nds = "Konnte einige Dateien nicht wiederherstellen. Ihre bestehende Installation ist möglicherweise beschädigt.", + nl = "Kon sommige bestanden niet terugzetten. Uw bestaande installatie is waarschijnlijk beschadigd.", + nn = "Nokon av filene kunne ikkje tilbakestillast. Den eksisterande installasjonen er sannsynlegvis skada.", + pl = "Nie można odtworzyć niektórych plików. Twoja aktualna instalacja jest prawdopodobnie uszkodzona.", + pt = "Foi impossível recuperar alguns ficheiros. Provavelmente, a sua instalação está danificada.", + pt_BR = "Não foi possível restaurar alguns arquivos. Sua instalação provavelmente está danificada.", + ro = "Nu s-au putut restaura anumite fiÅŸiere. Cel mai probabil instalarea actuală este stricată.", + ru = "Ðе могу воÑÑтановить некоторые файлы. Ваша уÑтановка наверно повреждена.", + sk = "Nemôžem obnoviÅ¥ niektoré súbory. VaÅ¡a aktuálna inÅ¡talácia je zrejme poÅ¡kodená.", + sl = "Obnovitev nekaterih datotek ni uspela. ObstojeÄa namestitev je verjetno poÅ¡kodovana.", + sv = "NÃ¥gra filer kunde inte Ã¥terskapas. Den existerande installationen är troligtvis skadad.", + tr = "Bazı dosyalar onarılamadı. Varolan kurulumunuz büyük olasılıkla zarar görmüş", + uk = "Ðеможливо відновити деÑкі файли. Вашу Ñ–Ñнуючу копію Ñкоріш за вÑе пошкоджено.", + zh_TW = "一些檔案無法復原,ç¾æœ‰çš„安è£å…§å®¹ä¼¼ä¹Žå·²æ毀。" + }; + + -- Error message when deleting a file fails. + ["Deletion failed!"] = { + af = "Uitvee het misluk!", + ar = "المسح Ùشل!", + cs = "OdstranÄ›ní selhalo!", + da = "Kunne ikke slette!", + de = "Löschen fehlgeschlagen!", + el = "Απέτυχε η διαγÏαφή!", + en_AU = "Deletion failed!", + en_CA = "Deletion failed!", + en_GB = "Deletion failed!", + es = "¡Borrado fallido!", + fr = "Suppression de fichier échouée!", + he = "המחיקה נכשלה!", + hu = "Törlés sikertelen!", + id = "Penghapusan gagal!", + it = "Eliminazione del file fallita!", + nb = "Kunne ikke slette!", + nds = "Löschen fehlgeschlagen!", + nl = "Verwijderen mislukt!", + nn = "Klarte ikkje Ã¥ sletta!", + pl = "Kasowanie nieudane!", + pt = "A remoção falhou!", + pt_BR = "Falha ao apagar o arquivo!", + ro = "Nu s-a putut ÅŸterge!", + ru = "Ðе могу удалить!", + sk = "Odstraňovanie súboru zlyhalo!", + sl = "Brisanje ni uspelo!", + sv = "Radering misslyckades!", + tr = "Silme iÅŸlemi baÅŸarılamadı!", + uk = "Ð’Ð¸Ð´Ð°Ð»ÐµÐ½Ð½Ñ Ð½ÐµÐ¼Ð¾Ð¶Ð»Ð¸Ð²Ð¾!", + zh_TW = "刪除失敗" + }; + + -- This is a label displayed next to the text entry in the GTK+ UI where + -- the user specifies the installation destination (folder/directory) in + -- the filesystem. + ["Folder:"] = { + af = "Lêer", + ar = "مجلد:", + cs = "Složka:", + da = "Mappe:", + de = "Verzeichnis:", + el = "Φάκελος:", + en_AU = "Folder:", + en_CA = "Folder:", + en_GB = "Folder:", + es = "Carpeta:", + fi = "Kansio:", + fr = "Dossier :", + he = "תיקיה:", + hu = "Mappa:", + id = "Folder:", + it = "Cartella:", + nb = "Katalog:", + nds = "Ordner:", + nl = "Map:", + nn = "Mappe:", + pl = "Folder:", + pt = "Directorio", + pt_BR = "Diretório:", + ro = "Dosar:", + ru = "Папка:", + sk = "Adresár:", + sl = "Mapa:", + sv = "Katalog:", + tr = "Klasör:", + uk = "Тека:", + zh_TW = "資料夾:" + }; + + -- This is a window title when user is selecting a path to install files. + ["Destination"] = { + af = "Bestemming", + ar = "الوÙجهة", + cs = "Cíl", + da = "Destination", + de = "Ziel", + el = "ΠÏοοÏισμός", + en_AU = "Destination", + en_CA = "Destination", + en_GB = "Destination", + es = "Destino", + fi = "Kohde", + fr = "Destination", + he = "יעד", + hu = "Cél", + id = "Tujuan", + it = "Destinazione", + nb = "MÃ¥l", + nds = "Ziel", + nl = "Bestemming", + nn = "MÃ¥l", + pl = "Miejsce docelowe", + pt = "Destino", + pt_BR = "Destino", + ro = "DestinaÅ£ie", + ru = "Ðазначение", + sk = "Cieľ", + sl = "Cilj", + sv = "MÃ¥l", + tr = "Hedef", + uk = "ПризначеннÑ", + zh_TW = "目的地" + }; + + -- This is a window title while the program is downloading external files + -- it needs from the network. + ["Downloading"] = { + af = "Besig om af te laai", + ar = "يجري التنزيل", + cs = "Stahuji", + da = "Henter", + de = "Lade herunter", + el = "Γίνεται λήψη", + en_AU = "Downloading", + en_CA = "Downloading", + en_GB = "Downloading", + es = "Descargando", + fi = "Noudetaan", + fr = "Téléchargement en cours", + he = "מוריד", + hu = "Letöltés", + id = "Mengunduh", + it = "Download in corso", + nb = "Laster ned", + nds = "Lade herunter", + nl = "Bezig met downloaden", + nn = "Lastar ned", + pl = "Pobieranie", + pt = "A descarregar", + pt_BR = "Baixando", + ro = "Descărcare", + ru = "Скачиваем", + sk = "SÅ¥ahujem", + sl = "PrenaÅ¡anje", + sv = "Laddar ned", + tr = "Ä°ndiriliyor", + uk = "ЗавантаженнÑ", + zh_TW = "下載中" + }; + + -- Several UIs use this string as a prompt to the end-user when selecting + -- a destination for newly-installed files. + ["Enter path where files will be installed."] = { + af = "Verskaf die pad waar die lêers na toe sal geinstaleer word", + ar = "أدخل مكان تثبيت البرنامج", + cs = "Zadejte cestu, kam mají být soubory nainstalovány.", + de = "Geben Sie den Pfad an, wohin die Dateien installiert werden sollen.", + el = "Δώστε το μονοπάτι που θα εγκατασταθοÏν τα αÏχεία.", + en_AU = "Enter path where files will be installed.", + en_CA = "Enter path where files will be installed.", + en_GB = "Enter path where files will be installed.", + es = "Introduce una ruta de instalacion.", + fi = "Syötä polku, johon tiedostot asennetaan.", + fr = "Entrez le chemin d'installation souhaité pour vos fichiers.", + he = "הזן ×ת הנתיב ×ליו ×”×§×‘×¦×™× ×™×•×ª×§× ×•.", + hu = "Add meg az útvonalat, ahova a fájlokat telepíthetem.", + id = "Masukkan path ke mana berkas akan diinstal.", + it = "Inserisci il percorso di installazione.", + nb = "Skriv inn mÃ¥lsti for installasjonen.", + nds = "Pfad eingeben, in den installiert werden soll.", + nl = "Geef de map op waar de bestanden geinstalleerd zullen worden", + nn = "Skriv inn sti for installasjonen.", + pl = "Podaj Å›cieżkÄ™ gdzie pliki bÄ™dÄ… zainstalowane.", + pt = "Introduza o caminho para os ficheiros que serão instalados.", + pt_BR = "Entre o caminho onde os arquivos serão instalados.", + ro = "Introdu calea unde vor fi instalate fiÅŸierele.", + ru = "Введите путь куда будет произведена уÑтановка.", + sk = "Zadajte cestu, kam chcete súbory inÅ¡talovaÅ¥.", + sl = "Vnesite pot kamor bodo datoteke nameÅ¡Äene.", + sv = "Välj sökväg för installationen", + tr = "Dosyaların kurulacağı yolu giriniz.", + uk = "Введіть шлÑÑ… Ð´Ð»Ñ Ð²ÑÑ‚Ð°Ð½Ð¾Ð²Ð»ÐµÐ½Ð½Ñ Ñ„Ð°Ð¹Ð»Ñ–Ð².", + zh_TW = "輸入欲安è£æª”案的路徑" + }; + + -- Error message when a file we expect to load can't be read from disk. + ["failed to load file '%0'"] = { + af = "misluk om lêer '%0' te laai", + ar = "Ùشل ÙÙŠ تحميل المل٠'%0'", + cs = "nepodaÅ™ilo se naÄíst soubor '%0'", + da = "Kunne ikke indlæse fil '%0'", + de = "Laden von Datei '%0' fehlgeschlagen", + el = "απέτυχε το φόÏτωμα του αÏχείου '%0'", + en_AU = "failed to load file '%0'", + en_CA = "failed to load file '%0'", + en_GB = "failed to load file '%0'", + es = "no se pudo leer el archivo '%0'", + fi = "tiedoston \"%0\" lukeminen epäonnistui", + fr = "Echec du chargement du fichier '%0'", + he = "שגי××” בטעינת הקובץ '%0'", + hu = "fájl betöltése sikertelen '%0'", + id = "gagal memuat berkas '%0'", + it = "Caricamento del file '%0' fallito", + nb = "kunne ikke laste filen '%0'", + nds = "Fehler beim Laden von '%0'", + nl = "laden van bestand \"%0\" mislukt", + nn = "kunne ikkje lasta fila '%0'", + pl = "Nie można zaÅ‚adować pliku '%0'", + pt = "falhou a carregar o ficheiro '%0'", + pt_BR = "falha ao carregar o arquivo '%0'", + ro = "nu s-a putut citi fiÅŸierul '%0'", + ru = "не могу загрузить файл '%0'", + sk = "nemôžem nahraÅ¥ súbor '%0'", + sl = "neuspeÅ¡no nalaganje datoteke '%0'", + sv = "Misslyckades med att läsa filen '%0'", + tr = "'%0' dosyası yüklenemedi", + uk = "неможливо відкрити файл '%0'", + zh_TW = "無法讀å–檔案 '%0'" + }; + + -- This is a window title when something goes very wrong. + ["Fatal error"] = { + af = "Noodlottige fout", + ar = "خطأ Ùادح", + cs = "Kritická chyba", + da = "Alvorlig fejl", + de = "Schwerer Fehler", + el = "ΜοιÏαίο σφάλμα", + en_AU = "Fatal error", + en_CA = "Fatal error", + en_GB = "Fatal error", + es = "Error grave", + fr = "Erreur fatale", + he = "תקלה משמעותית", + hu = "Végzetes hiba", + id = "Galat yang mematikan", + it = "Errore critico", + nb = "Kritisk feil", + nds = "Fataler Fehler", + nl = "Fatale fout", + nn = "Kritisk feil", + pl = "Poważny bÅ‚Ä…d", + pt = "Erro fatal", + pt_BR = "Erro fatal", + ro = "Eroare terminală", + ru = "Ð¤Ð°Ñ‚Ð°Ð»ÑŒÐ½Ð°Ñ Ð¾ÑˆÐ¸Ð±ÐºÐ°", + sk = "ZÃVAŽNà CHYBA", + sl = "Neodpravljiva napaka", + sv = "Allvarligt fel", + tr = "Önemli hata", + uk = "Фатальна помилка", + zh_TW = "åš´é‡éŒ¯èª¤" + }; + + -- This is an error message when failing to write a file to disk. + ["File creation failed!"] = { + af = "Lêer skepping het misluk!", + ar = "كتابة المل٠Ùشلت!", + cs = "NepodaÅ™ilo se vytvoÅ™it soubor!", + de = "Dateierstellung fehlgeschlagen!", + el = "Η δημιουÏγεία αÏχείου απέτυχε!", + en_AU = "File creation failed!", + en_CA = "File creation failed!", + en_GB = "File creation failed!", + es = "¡Escritura de archivo ha fallado!", + fi = "Tiedoston luominen epäonnistui!", + fr = "Création de fichier échouée!", + he = "יצירת הקובץ נכשלה!", + hu = "Fájl létrehozása sikertelen!", + id = "Pembuatan berkas gagal!", + it = "Creazione del file fallita!", + nb = "Kunne ikke opprette fil!", + nds = "Datei Erstellung ist fehlgeschlagen!", + nl = "aanmaken bestand mislukt!", + nn = "Kunne ikkje oppretta fil!", + pl = "Nie można utworzyć pliku!", + pt = "Falhou a criação do ficheiro!", + pt_BR = "Erro na criação do arquivo!", + ro = "Nu s-a putut creea fiÅŸierul!", + ru = "Ðе могу Ñоздать файл!", + sk = "Nemôžem vytvoriÅ¥ súbor!", + sl = "Ustvarjanje datoteke ni uspelo!", + sv = "Misslyckades med att skapa fil!", + tr = "Dosya oluÅŸturulamadı!", + uk = "Ðеможливо Ñтворити файл!", + zh_TW = "無法建立檔案ï¼" + }; + + -- This is an error message when failing to get a file from the network. + ["File download failed!"] = { + af = "Aflaai van die lêer het misluk", + ar = "تنزيل المل٠Ùشل!", + cs = "NepodaÅ™ilo se stáhnout soubor!", + da = "Download af fil mislykkedes!", + de = "Dateidownload fehlgeschlagen!", + el = "Η λήψη αÏχείου απέτυχε!", + en_AU = "File download failed!", + en_CA = "File download failed!", + en_GB = "File download failed!", + es = "¡Descarga de archivo ha fallado!", + fi = "Tiedoston noutaminen epäonnistui!", + fr = "Téléchargement échoué!", + he = "הורדת הקובץ נכשלה!", + hu = "Fájl letöltése sikertelen!", + id = "Gagal mengunduh berkas!", + it = "Download del file fallito!", + nb = "Kunne ikke laste ned fil!", + nds = "Dateidownload fehlgeschlagen!", + nl = "downloaden van bestand mislukt!", + nn = "Kunne ikkje lasta ned fil!", + pl = "Nie można pobrać pliku!", + pt = "Falhou a descarregar!", + pt_BR = "Erro ao baixar o arquivo!", + ro = "Nu s-a putut descărca fiÅŸierul!", + ru = "Ошибка ÑÐºÐ°Ñ‡Ð¸Ð²Ð°Ð½Ð¸Ñ Ñ„Ð°Ð¹Ð»Ð°!", + sk = "SÅ¥ahovanie zlyhalo!", + sl = "Prenos datoteke ni uspel!", + sv = "Nedladdning av fil misslyckades!", + tr = "Dosya indirilemedi!", + uk = "Ðеможливо завантажити файл!", + zh_TW = "檔案下載失敗" + }; + + -- This prompt is shown to users when we may overwrite an existing file. + -- "%0" is the filename. + ["File '%0' already exists! Replace?"] = { + af = "Lêer '%0' bestaan al! Vervang?", + ar = "المل٠'%0' موجود من قبل! أأستبدل؟", + cs = "Soubor '%0' již existuje! PÅ™epsat?", + de = "Datei '%0' existiert bereits! Ersetzen?", + el = "Το αÏχείο '%0' υπάÏχει ήδη! Αντικατάσταση?", + en_AU = "File '%0' already exists! Replace?", + en_CA = "File '%0' already exists! Replace?", + en_GB = "File '%0' already exists! Replace?", + es = "¡El archivo '%0' ya existe! ¿Sustituirlo?", + fi = "Tiedosto \"%0\" on jo olemassa! Korvaa?", + fr = "Le fichier '%0' existe déjà! Le remplacer?", + he = "הקובץ '%0' כבר קיי×! להחליפו?", + hu = "'%0' már létezik! Felülírjam?", + id = "Berkas '%0' sudah ada! Ganti?", + it = "Il file %0 esiste già! Sostituire?", + nb = "Filen '%0' eksisterer allerede! Skrive over?", + nds = "Datei '%0' existiert bereits! Ãœberschreiben?", + nl = "Bestand \"%0\" bestaat al! Vervangen?", + nn = "Fila '%0' eksisterar! Vil du skriva over ho?", + pl = "Plik '%0' już istnieje! Nadpisać?", + pt = "O ficheiro '%0' já existe! Substituir?", + pt_BR = "Arquivo '%0' já existe! Substituir?", + ro = "FiÅŸierul '%0' exista! V-a fi înlocuit?", + ru = "Файл '%0' уже ÑущеÑтвует! Заменить?", + sk = "Súbor '%0' už existuje! PrepísaÅ¥?", + sl = "Datoteka '%0' že obstaja! Zamenjam?", + sv = "Filen '%0' existerar redan! Vill du ersätta den?", + tr = "'%0' dosyası zaten var! DeÄŸiÅŸtirilsin mi?", + uk = "Файл '%0' вже Ñ–Ñнує! Замінити?", + zh_TW = "檔案 '%0' 已經存在,是å¦å–代?" + }; + + -- This is a button in the UI. It replaces "Next" when there are no more + -- stages to move forward to. + ["Finish"] = { + af = "Voltooi", + ar = "أنهÙ", + cs = "DokonÄit", + da = "Udfør", + de = "Fertig stellen", + el = "Τέλος", + en_AU = "Finish", + en_CA = "Finish", + en_GB = "Finish", + es = "Terminar", + fi = "Valmis", + fr = "Terminer", + he = "סיו×", + hu = "Kész", + id = "Selesai", + it = "Fine", + nb = "Ferdig", + nds = "Fertig", + nl = "Voltooien", + nn = "Fullfør", + pl = "ZakoÅ„cz", + pt = "Finalizar", + pt_BR = "Concluir", + ro = "Finalizează", + ru = "Завершение", + sk = "DokonÄiÅ¥", + sl = "KonÄaj", + sv = "Slutför", + tr = "Bitir", + uk = "Завершити", + zh_TW = "完æˆ" + }; + + -- This error message is (hopefully) shown to the user if the UI + -- subsystem can't create the main application window. + ["GUI failed to start"] = { + af = "GUI het misluk om te laai", + ar = "الواجهة الرسومية Ùشلت ÙÙŠ البدء", + cs = "NepodaÅ™ilo se spustit GUI", + da = "Grafisk brugerflade kunne ikke startes", + de = "GUI konnte nicht gestartet werden", + el = "Το γÏαφικό πεÏιβάλλον απέτυχε να ξεκινήσει", + en_AU = "GUI failed to start", + en_CA = "GUI failed to start", + en_GB = "GUI failed to start", + es = "El interfaz gráfico de usuario ha fallado al arrancar", + fr = "Echec du démarrage de l'interface", + he = "שגי××” בהפעלת ממשק המשתמש", + hu = "Grafikus felület indítása sikertelen", + id = "Gagal memulai GUI!", + it = "Inizializzazione della GUI fallita", + nb = "Kunne ikke starte grafisk grensesnitt", + nds = "Fehler beim starten der GUI", + nl = "Opstarten GUI mislukt", + nn = "Kunne ikkje starta det grafiske grensesnittet", + pl = "GUI nie mógÅ‚ siÄ™ uruchomić", + pt = "O GUI falhou a iniciar", + pt_BR = "Falha ao iniciar a GUI", + ro = "InterfaÅ£a grafică nu a putut porni", + ru = "Ошибка запуÑка графичеÑкого интерфейÑа", + sk = "Nie je možné spustiÅ¥ GUI", + sl = "GUI se ni uspel zagnati", + sv = "Kunde inte starta grafisk gränssnitt", + tr = "Grafik arabirimi baÅŸlatılamadı", + uk = "Ðеможливо запуÑтити графічний інтерфейÑ", + zh_TW = "無法啟動圖形使用者介é¢" + }; + + -- This message is shown to the user if an installation encounters a fatal + -- problem (or the user clicked "cancel"), telling them that we'll try + -- to put everything back how it was before we started. + ["Incomplete installation. We will revert any changes we made."] = { + af = "Onvoltooide installasie. Ons sal enige veranderinge terugrol.", + ar = "لم يكتمل التثبيت. سيتم إزالة اي تغييرات.", + cs = "Instalace nebyla dokonÄena. VÅ¡e bude uvedeno do původního stavu.", + da = "Installation kunne ikke fuldendes. Ændringer tilbageføres.", + de = "Unvollständige Installation. Änderungen werden rückgängig gemacht.", + el = "Μισοτελειωμένη εγκατάσταση. Θα διαγÏάψουμε όσες αλλαγές κάναμε.", + en_AU = "Incomplete installation. We will revert any changes we made.", + en_CA = "Incomplete installation. We will revert any changes we made.", + en_GB = "Incomplete installation. We will revert any changes we made.", + es = "Instalación incompleta. Desharemos cualquier cambio que hayamos hecho.", + fr = "Installation incomplète. Tous les changements effectués seront annulés.", + he = "ההתקנה ×œ× ×”×•×©×œ×ž×”. ×נו נשיב ×ת ×”×©×™× ×•×™×™× ×©×‘×™×¦×¢× ×•.", + hu = "Telepítés befejezetlen. Eredeti helyzet visszaállítása.", + id = "Instalasi yang tidak lengkap. Kami akan mengembalikan perubahab yang dibuat.", + it = "Installazione incompleta. Ripristino delle modifiche effettuate in corso.", + nb = "Installasjonen ble ikke ferdig. Vi vil tilbakestille alle endringer som ble gjort.", + nds = "Unvollständige Installation. Alle Veränderungen werden rückgängig gemacht.", + nl = "Incomplete installatie. De veranderingen zullen ongedaan gemaakt worden.", + nn = "Installasjonen vart ikkje ferdig. Alle endringar vert tilbakestillt.", + pl = "Niekompletna instalacja. Cofniemy dokonane zmiany.", + pt = "Instalação incompleta. Todas as alterações serão desfeitas.", + pt_BR = "Instalação incompleta. As alterações feitas serão revertidas.", + ro = "Proces de instalare incomplet. Se vor restaura toate modificările făcute.", + ru = "Ошибка уÑтановки. Ð’Ñе Ð¸Ð·Ð¼ÐµÐ½ÐµÐ½Ð¸Ñ Ð±ÑƒÐ´ÑƒÑ‚ отменены.", + sk = "Neúplná inÅ¡talácia. Vraciam späť vykonané zmeny.", + sl = "Namestitev ni uspela. Vse spremembe bodo razveljavljene.", + sv = "Ofullständig installation. Ã…terställning av alla gjorda ändringar utförs.", + tr = "Eksik kurulum. Yaptığımız tüm deÄŸiÅŸiklikleri geri alacağız.", + uk = "Ðезавершене вÑтановленнÑ. УÑÑ– зміни буде відкачено.", + zh_TW = "安è£ç¨‹åºæœªå®Œæˆï¼Œä»»ä½•æ›´å‹•å°‡æœƒè¢«å¾©åŽŸ" + }; + + -- Reported to the user if everything worked out. + ["Installation was successful."] = { + af = "Installasie was suksesvol.", + ar = "نجح التثبيت", + cs = "Instalace byla úspěšná.", + da = "Installationen var succesfuld.", + de = "Installation war erfolgreich.", + el = "Η εγκατάσταση πέτυχε.", + en_AU = "Installation was successful.", + en_CA = "Installation was successful.", + en_GB = "Installation was successful.", + es = "La instalación fue un éxito.", + fi = "Asentaminen onnistui.", + fr = "Installation réussie.", + he = "ההתקנה הושלמה.", + hu = "Sikeres telepítés.", + id = "Instalasi berhasil.", + it = "Installazione riuscita.", + nb = "Installasjonen var en suksess.", + nds = "Die Installation war erfolgreich", + nl = "De installatie is succesvol verlopen.", + nn = "Installasjonen er ferdig.", + pl = "Instalacja zakoÅ„czona poprawnie.", + pt = "A instalação foi bem sucedida.", + pt_BR = "Instalação concluída com sucesso.", + ro = "Instalarea s-a terminat cu succes.", + ru = "УÑтановка была уÑпешна.", + sk = "InÅ¡talácia je hotová.", + sl = "Namestitev je uspela.", + sv = "Installationen lyckades.", + tr = "Kurulum baÅŸarılı oldu.", + uk = "Ð’ÑÑ‚Ð°Ð½Ð¾Ð²Ð»ÐµÐ½Ð½Ñ ÑƒÑпішне.", + zh_TW = "安è£ç¨‹åºå®Œæˆã€‚" + }; + + -- This is a window title, shown while the actual installation to disk + -- is in process and a progress meter is being shown. + ["Installing"] = { + af = "Besig om te installeer", + ar = "عملية التثبيت", + cs = "Instaluji", + da = "Installerer", + de = "Installiere", + el = "Γίνεται εγκατάσταση", + en_AU = "Installing", + en_CA = "Installing", + en_GB = "Installing", + es = "Instalando", + fi = "Asennetaan", + fr = "Installation en cours", + he = "מתקין", + hu = "Telepítés", + id = "Menginstal", + it = "Installazione in corso", + nb = "Installerer", + nds = "Installiere ...", + nl = "Installeren", + nn = "Installerar", + pl = "Instalacja", + pt = "A instalar", + pt_BR = "Instalando", + ro = "Instalare", + ru = "УÑтановка", + sk = "InÅ¡talujem", + sl = "nameÅ¡Äanje", + sv = "Installerar", + tr = "Kuruluyor", + uk = "Ð’ÑтановленнÑ", + zh_TW = "正在安è£" + }; + + -- This is a window title, shown while the user is choosing + -- installation-specific options. + ["Options"] = { + af = "Opsies", + ar = "الخيارات", + cs = "Volby", + da = "Indstillinger", + de = "Optionen", + el = "Επιλογές", + en_AU = "Options", + en_CA = "Options", + en_GB = "Options", + es = "Opciones", + fi = "Valinnat", + fr = "Options", + he = "×פשרויות", + hu = "Beállítások", + id = "Pilihan", + it = "Opzioni", + nb = "Valg", + nds = "Optionen", + nl = "Opties", + nn = "Val", + pl = "Opcje", + pt = "Opções", + pt_BR = "Opções", + ro = "OpÈ›iuni", + ru = "ÐаÑтройки", + sk = "Možnosti", + sl = "Možnosti", + sv = "Alternativ", + tr = "Seçenekler", + uk = "Параметри", + zh_TW = "é¸é …" + }; + + -- Shown as an option in the ncurses UI as the final element in a list of + -- default filesystem paths where a user may install files. They can + -- choose this to enter a filesystem path manually. + ["(I want to specify a path.)"] = { + af = "(Ek wil 'n pad aanwys)", + ar = "(أنا أريد اختيار المسار)", + cs = "(Chci urÄit cestu.)", + de = "(Ich möchte einen Pfad angeben.)", + el = "(Θέλω να οÏίσω μονοπάτι.)", + en_AU = "(I want to specify a path.)", + en_CA = "(I want to specify a path.)", + en_GB = "(I want to specify a path.)", + es = "(Quiero especificar una ruta.)", + fi = "(Haluan syöttää polun.)", + fr = "(Je veux spécifier une destination.)", + he = "(×× ×™ מעוניין לציין נתיב.)", + hu = "(egy útvonalat szeretnék)", + id = "(Saya akan menentukan path.)", + it = "(Voglio specificare un percorso)", + nb = "(Jeg vil skrive inn min egen sti.)", + nds = "(Ich möchte einen Pfad angeben.)", + nl = "(Ik wil een pad specificeren.)", + nn = "(Eg vil skriva inn min eigen sti.)", + pl = "(ChcÄ™ podać Å›cieżkÄ™.)", + pt = "(Eu quero especificar o caminho.)", + pt_BR = "(Eu quero especificar um caminho.)", + ro = "(Doresc să specific o cale.)", + ru = "(указать путь.)", + sk = "(Chcem zadaÅ¥ cestu ruÄne.)", + sl = "(Želim doloÄiti pot)", + sv = "(Jag vill skriva in en egen sökväg.)", + tr = "(Bir yol belirtmek istiyorum.)", + uk = "(Я хочу вказати шлÑÑ….)", + zh_TW = "(我想è¦æŒ‡å®šè·¯å¾‘)" + }; + + -- "kilobytes per second" ... download rate. + ["KB/s"] = { + af = "KB/s", + ar = "Ùƒ.بايت/Ø«", + cs = "KB/s", + da = "KB/s", + de = "KB/s", + el = "KB/δευτ.", + en_AU = "KB/s", + en_CA = "KB/s", + en_GB = "KB/s", + es = "KB/s", + fi = "kt/s", + fr = "Ko/s", + he = "ק\"ב/ש", + hu = "KB/mp", + id = "KB/detik", + it = "KB/s", + nb = "KB/s", + nds = "kB/s", + nl = "KB/s", + nn = "KB/s", + pl = "KB/s", + pt = "KB/s", + pt_BR = "KB/s", + ro = "KB/s", + ru = "КБ/Ñ", + sk = "KB/s", + sl = "KB/s", + sv = "KB/s", + tr = "KB/s", + uk = "КБ/c", + zh_TW = "KB/秒" + }; + + -- "bytes per second" ... download rate. + ["B/s"] = { + af = "B/s", + ar = "بايت/ثانية", + cs = "B/s", + da = "B/s", + de = "B/s", + el = "B/δευτ", + en_AU = "B/s", + en_CA = "B/s", + en_GB = "B/s", + es = "B/s", + fi = "t/s", + fr = "octets/s", + he = "ב'/ש", + hu = "B/mp", + id = "B/detik", + it = "B/s", + nb = "B/s", + nds = "B/s", + nl = "B/s", + nn = "B/s", + pl = "B/s", + pt = "B/s", + pt_BR = "B/s", + ro = "B/s", + ru = "Б/Ñ", + sk = "B/s", + sl = "B/s", + sv = "B/s", + tr = "B/s", + uk = "Б/Ñ", + zh_TW = "ä½å…ƒçµ„/秒" + }; + + -- Download rate when we don't know the goal (can't report time left). + -- This is a number (%0) followed by the localized "KB/s" or "B/s" (%1). + ["%0 %1"] = { + af = "%0 %1", + ar = "â€%0 %1", + cs = "%0 %1", + da = "%0 %1", + de = "%0 %1", + el = "%0 %1", + en_AU = "%0 %1", + en_CA = "%0 %1", + en_GB = "%0 %1", + es = "%0 %1", + fi = "%0 %1", + fr = "%0 %1", + he = "%0 %1", + hu = "%0 %1", + id = "%0 %1", + it = "%0 %1", + nb = "%0 %1", + nds = "%0 %1", + nl = "%0 %1", + nn = "%0 %1", + pl = "%0 %1", + pt = "%0 %1", + pt_BR = "%0 %1", + ro = "%0 %1", + ru = "%0 %1", + sk = "%0 %1", + sl = "%0 %1", + sv = "%0 %1", + tr = "%0 %1", + zh_TW = "%0 %1" + }; + + -- Download rate when we know the goal (can report time left). + -- This is a number (%0) followed by the localized "KB/s" or "B/s" (%1), + -- then the hours (%2), minutes (%3), and seconds (%4) remaining + ["%0 %1, %2:%3:%4 remaining"] = { + af = "%0 %1, %2:%3:%4 oorblywend", + ar = "â€%0 %1, %2:%3:%4 متبقية", + cs = "%0 %1, %2:%3:%4 zbývá", + da = "%0 %1, %2:%3:%4 tilbage", + de = "%0 %1, %2:%3:%4 verbleibend", + el = "%0 %1, απομένουν %2:%3:%4", + en_AU = "%0 %1, %2:%3:%4 remaining", + en_CA = "%0 %1, %2:%3:%4 remaining", + en_GB = "%0 %1, %2:%3:%4 remaining", + es = "%0 %1, %2:%3:%4 restantes", + fi = "%0 %1, %2:%3:%4 jäljellä", + fr = "%0 %1, %2:%3:%4 restantes", + he = "%0 %1, נותרו %2:%3:%4", + hu = "%0 %1, %2:%3:%4 van még hátra", + id = "%0 %1, %2:%3:%4 tersisa", + it = "%0 %1, %2:%3:%4 rimanenti", + nb = "%0 %1, %2:%3:%4 igjen", + nds = "%0 %1, %2:%3:%4 verbleiben", + nl = "%0 %1, %2:%3:%4 resterend", + nn = "%0 %1, %2:%3:%4 gjenstÃ¥r", + pl = "%0 %1, %2:%3:%4 do koÅ„ca", + pt = "restam %0 %1, %2:%3:%4", + pt_BR = "%0 %1, faltam %2:%3:%4", + ro = "%0 %1, %2:%3:%4 rămas", + ru = "%0 %1, оÑталоÑÑŒ %2:%3:%4", + sk = "%0 %1, %2:%3:%4 zostáva", + sl = "%0 %1, %2:%3:%4 preostanka", + sv = "%0 %1, %2:%3:%4 Ã¥terstÃ¥r", + tr = "%0 %1, %2:%3:%4 kaldı", + uk = "%0 %1, залишилоÑÑ %2:%3:%4", + zh_TW = "剩餘 %0 %1, %2:%3:%4" + }; + + -- download rate when download isn't progressing at all. + ["stalled"] = { + af = "hang", + ar = "توقÙ", + cs = "zaseknuté", + de = "wartend", + el = "σταματημένο", + en_AU = "stalled", + en_CA = "stalled", + en_GB = "stalled", + es = "parado", + fr = "bloqué", + he = "נדחה", + hu = "beragadt", + it = "in stallo", + nb = "stanset", + nds = "Angehalten", + nl = "staat stil", + nn = "stanset", + pl = "wstrzymano", + pt = "Parado", + pt_BR = "parado", + ro = "întârziat", + ru = "заÑÑ‚Ñ€Ñло", + sk = "zastavené", + sl = "prekinjeno", + sv = "avstannad", + tr = "duraksadı", + zh_TW = "已延é²" + }; + + -- Download progress string: filename (%0), percent downloaded (%1), + -- download rate determined in one of the above strings (%2). + ["%0: %1%% (%2)"] = { + af = "%0: %1%% (%2)", + ar = "â€%0: %1%% (%2)", + cs = "%0: %1%% (%2)", + da = "%0: %1%% (%2)", + de = "%0: %1%% (%2)", + el = "%0: %1%% (%2)", + en_AU = "%0: %1%% (%2)", + en_CA = "%0: %1%% (%2)", + en_GB = "%0: %1%% (%2)", + es = "%0: %1%% (%2)", + fi = "%0: %1%% (%2)", + fr = "%0: %1%% (%2)", + he = "%0: %1%% (%2)", + hu = "%0: %1%% (%2)", + id = "%0: %1%% (%2)", + it = "%0: %1%% (%2)", + nb = "%0: %1%% (%2)", + nds = "%0: %1%% (%2)", + nl = "%0: %1%% (%2)", + nn = "%0: %1%% (%2)", + pl = "%0: %1%% (%2)", + pt = "%0: %1%% (%2)", + pt_BR = "%0: %1%% (%2)", + ro = "%0: %1%% (%2)", + ru = "%0: %1%% (%2)", + sk = "%0: %1%% (%2)", + sl = "%0: %1%% (%2)", + sv = "%0: %1%% (%2)", + tr = "%0: %%%1 (%2)", + zh_TW = "%0: %1%% (%2)" + }; + + -- This is a window title when prompting the user to insert a new disc. + ["Media change"] = { + af = "Media verander", + ar = "تغيير القرص", + cs = "VýmÄ›na média", + da = "Skift medie", + de = "Medienwechsel", + el = "Αλάξτε μέσο αποθήκευσης", + en_AU = "Media change", + en_CA = "Media change", + en_GB = "Media change", + es = "Cambio de disco", + fr = "Changement de média", + he = "שינוי מדיה", + hu = "KövetkezÅ‘ média", + id = "Ganti media", + it = "Inserire il prossimo disco", + nb = "Mediaendring", + nds = "Medien Wechsel", + nl = "Medium wisselen", + nn = "Mediaendring", + pl = "Zmiana noÅ›nika", + pt = "Mudança de media", + pt_BR = "Mídia alterada", + ro = "Schimbare mediu stocare", + ru = "Смена диÑка", + sk = "Výmena média", + sl = "Manjava medija", + sv = "Mediabyte", + tr = "Medya deÄŸiÅŸimi", + uk = "Зміна ноÑÑ–Ñ", + zh_TW = "媒體更改" + }; + + -- This error message is shown to the end-user when we can't make a new + -- folder/directory in the filesystem. + ["Directory creation failed"] = { + af = "Lêer skepping het misluk", + ar = "Ùشل ÙÙŠ إنشاء المجلد", + cs = "Selhalo vytváření adresáře", + da = "Kunne ikke oprette katalog", + de = "Erstellung eines Verzeichnisses fehlgeschlagen", + el = "Η δημιουÏγεία φακέλου απέτυχε", + en_AU = "Directory creation failed", + en_CA = "Directory creation failed", + en_GB = "Directory creation failed", + es = "Fallo en la creación de directorio", + fi = "Hakemiston luominen epäonnistui", + fr = "Création de répertoire échouée", + he = "יצירת התיקיה נכשלה", + hu = "Mappa létrehozása sikertelen", + id = "Pembuatan direktori gagal", + it = "Creazione directory fallita", + nb = "Kunne ikke lage katalog", + nds = "Ordner erstellen schlug fehl!", + nl = "Aanmaken folder mislukt", + nn = "Kunne ikkje laga katalog", + pl = "Tworzenie katalogu nie powiodÅ‚o siÄ™", + pt = "A criação da directoria falhou", + pt_BR = "Falha na criação do diretório", + ro = "Eroare la crearea directorului", + ru = "Ошибка ÑÐ¾Ð·Ð´Ð°Ð½Ð¸Ñ ÐºÐ°Ñ‚Ð°Ð»Ð¾Ð³Ð°", + sk = "Nemôžem vytvoriÅ¥ adresár", + sl = "Ustvarjanje mape ni uspelo", + sv = "Kunde inte skapa katalog", + tr = "Dizin oluÅŸturulamadı", + uk = "Ðеможливо Ñтворити теку", + zh_TW = "無法建立目錄" + }; + + -- This is a GTK+ button label. The '_' comes before the hotkey character. + -- "No" would take the 'N' hotkey in English. + ["N_ever"] = { + af = "N_ooit", + ar = "أب_داً", + cs = "Ni_kdy", + da = "Al_drig", + de = "Ni_emals", + el = "_Ποτέ", + en_AU = "N_ever", + en_CA = "N_ever", + en_GB = "N_ever", + es = "N_unca", + fi = "Ei _koskaan", + fr = "_Jamais", + he = "×_×£ פע×", + hu = "_Soha", + id = "Tidak per_nah", + it = "_Mai", + nb = "Al_dri", + nds = "N_ie", + nl = "No_oit", + nn = "_Aldri", + pl = "N_igdy", + pt = "N_unca", + pt_BR = "N_unca", + ro = "N_iciodată", + ru = "Ð_икогда", + sk = "N_ikdy", + sl = "N_ikoli", + sv = "Al_drig", + tr = "A_sla", + uk = "Ð_іколи", + zh_TW = "æ°¸ä¸(_N)" + }; + + -- This is a GUI button label, to move forward to the next stage of + -- installation. It's opposite is "Back" in this case. + ["Next"] = { + af = "Volgende", + ar = "التالي", + cs = "Další", + da = "Næste", + de = "Weiter", + el = "Επόμενο", + en_AU = "Next", + en_CA = "Next", + en_GB = "Next", + es = "Siguiente", + fi = "Seuraava", + fr = "Suivant", + he = "הב×", + hu = "KövetkezÅ‘", + id = "Berikutnya", + it = "Avanti", + nb = "Neste", + nds = "Weiter", + nl = "Volgende", + nn = "Neste", + pl = "Dalej", + pt = "Seguinte", + pt_BR = "Avançar", + ro = "Următorul", + ru = "Далее", + sk = "ÄŽalej", + sl = "Naprej", + sv = "Nästa", + tr = "Ä°leri", + uk = "Далі", + zh_TW = "下一個" + }; + + -- This is a GUI button label, indicating a negative response. + ["No"] = { + af = "Nee", + ar = "لا", + cs = "Ne", + da = "Nej", + de = "Nein", + el = "Όχι", + en_AU = "No", + en_CA = "No", + en_GB = "No", + es = "No", + fi = "Ei", + fr = "Non", + he = "ל×", + hu = "Nem", + id = "Tidak", + it = "No", + nb = "Nei", + nds = "Nein", + nl = "Nee", + nn = "Nei", + pl = "Nie", + pt = "Não", + pt_BR = "Não", + ro = "Nu", + ru = "Ðет", + sk = "Nie", + sl = "Ne", + sv = "Nej", + tr = "Hayır", + uk = "ÐÑ–", + zh_TW = "å¦" + }; + + -- This is a GUI button label, indicating a positive response. + ["Yes"] = { + af = "Ja", + ar = "نعم", + cs = "Ano", + da = "Ja", + de = "Ja", + el = "Îαί", + en_AU = "Yes", + en_CA = "Yes", + en_GB = "Yes", + es = "Sí", + fi = "Kyllä", + fr = "Oui", + he = "כן", + hu = "Igen", + id = "Ya", + it = "Si", + nb = "Ja", + nds = "Ja", + nl = "Ja", + nn = "Ja", + pl = "Tak", + pt = "Sim", + pt_BR = "Sim", + ro = "Da", + ru = "Да", + sk = "Ãno", + sl = "Da", + sv = "Ja", + tr = "Evet", + uk = "Так", + zh_TW = "是" + }; + + -- HTTP error message in the www UI, as in "404 Not Found" ... requested + -- file is missing. + ["Not Found"] = { + af = "Nie gevind nie", + ar = "لا يوجد", + cs = "Nenalezeno", + da = "Ikke fundet", + de = "Nicht gefunden", + el = "Δεν βÏέθηκε", + en_AU = "Not Found", + en_CA = "Not Found", + en_GB = "Not Found", + es = "No encontrado", + fi = "Ei löytynyt", + fr = "Introuvable", + he = "×œ× × ×ž×¦×", + hu = "Nem található", + id = "Tidak Ditemukan", + it = "Non Trovato", + nb = "Ikke funnet", + nds = "Nicht gefunden", + nl = "Niet Gevonden", + nn = "Ikkje funne", + pl = "Nie znaleziono", + pt = "Inexistente", + pt_BR = "Não Encontrado", + ro = "Nu a fost găsit", + ru = "Ðе найдено", + sk = "Nemôžem nájsÅ¥", + sl = "Ni najdeno", + sv = "Hittades inte", + tr = "Bulunamadı", + uk = "Ðе знайдено", + zh_TW = "找ä¸åˆ°" + }; + + -- This is reported to the user when there are no files to install, and + -- thus no installation to go forward. + ["Nothing to do!"] = { + af = "Niks om te doen nie!", + ar = "لا يوجد شيء لنÙعله", + cs = "Není co instalovat!", + da = "Ingen aktivitet mulig!", + de = "Nichts zu tun!", + el = "Δεν υπάÏχει τίποτα για να γίνει!", + en_AU = "Nothing to do!", + en_CA = "Nothing to do!", + en_GB = "Nothing to do!", + es = "¡Nada que hacer!", + fi = "Ei tehtävää!", + fr = "Rien à faire!", + he = "×ין מה לעשות!", + hu = "Nincs mit telepítenem!", + id = "Tidak ada yang akan dilakukan!", + it = "Impossible procedere!", + nb = "Ingenting Ã¥ gjøre!", + nds = "Nichts zu tun!", + nl = "Niets te doen!", + nn = "Ingenting Ã¥ gjera!", + pl = "Nic do zrobienia!", + pt = "Nada por fazer!", + pt_BR = "Nada para fazer!", + ro = "Nu este nimic de făcut!", + ru = "Ðечего делать!", + sk = "Nemám Äo robiÅ¥", + sl = "NiÄesar ni možno namestiti!", + sv = "Ingenting att göra!", + tr = "Yapılacak bir iÅŸ yok!", + uk = "Ðема чого робити!", + zh_TW = "沒有需è¦åŸ·è¡Œçš„程åº" + }; + + -- This is a GUI button label, sometimes paired with "Cancel" + ["OK"] = { + af = "Regso", + ar = "مواÙÙ‚", + cs = "OK", + da = "OK", + de = "OK", + el = "Εντάξει", + en_AU = "OK", + en_CA = "OK", + en_GB = "OK", + es = "Aceptar", + fr = "OK", + he = "×ישור", + hu = "OK", + id = "OK", + it = "OK", + nb = "OK", + nds = "OK", + nl = "OK", + nn = "OK", + pl = "OK", + pt = "Aceitar", + pt_BR = "OK", + ro = "Bine", + ru = "Да", + sk = "OK", + sl = "V redu", + sv = "OK", + tr = "Tamam", + uk = "Гаразд", + zh_TW = "確定" + }; + + -- This is displayed when the application has a serious problem, such as + -- crashing again in the crash handler, or being unable to find basic + -- files it needs to get started. It may be a window title, or written + -- to stdout, or whatever, but it's basically meant to be a title or + -- header, with more information to follow later. + ["PANIC"] = { + af = "PANIEK", + ar = "خطأ مهم", + cs = "SELHÃNÃ", + da = "PANIK", + de = "PANIK", + el = "ΠΑÎΙΚΟΣ", + en_AU = "PANIC", + en_CA = "PANIC", + en_GB = "PANIC", + es = "PÃNICO", + fr = "PANIC", + he = "בהלה", + hu = "PÃNIK", + id = "GEGER", + it = "PANICO", + nb = "PANIKK", + nds = "PANIK", + nl = "PROBLEEM", + nn = "Panikk", + pl = "PANIKA", + pt = "PÂNICO", + pt_BR = "PÂNICO", + ro = "PANICAT", + ru = "СЕРЬЕЗÐÐЯ ОШИБКÐ", + sk = "PANIKA", + sl = "PANIKA", + sv = "PANIK", + tr = "PANÄ°K", + uk = "ПÐÐІКÐ!!!", + zh_TW = "åš´é‡éŒ¯èª¤" + }; + + -- Prompt shown to user when we need her to insert a new disc. + ["Please insert '%0'"] = { + af = "Verskaf asseblief '%0'", + ar = "من Ùضلك أدخÙÙ„ '%0'", + cs = "Prosím vložte '%0'", + de = "Bitte legen Sie '%0' ein", + el = "ΠαÏακαλώ εισάγεται '%0'", + en_AU = "Please insert '%0'", + en_CA = "Please insert '%0'", + en_GB = "Please insert '%0'", + es = "Por favor introduce '%0'", + fi = "Syötä \"%0\"", + fr = "Veuillez insérer '%0'", + he = "×× × ×”×›× ×¡ '%0'", + hu = "Helyezze be '%0'-t", + id = "Silakan sisipkan '%0'", + it = "Per favore inserire '%0'", + nb = "Sett inn '%0'", + nds = "Bitte '%0' in das Laufwerk einlegen.", + nl = "Laadt '%0' a.u.b.", + nn = "Sett inn '%0'", + pl = "ProszÄ™ wÅ‚ożyć '%0'", + pt = "Por favor insira '%0'", + pt_BR = "Por favor, insira '%0'", + ro = "IntroduceÅ£i '%0'", + ru = "Ð’Ñтавьте, пожалуйÑта, '%0'", + sk = "Prosím vložte '%0'", + sl = "Prosim vstavite '%0'", + sv = "Sätt in '%0'", + tr = "Lütfen '%0' adlı diski takınız", + uk = "Будьте лаÑкаві, вÑтавте '%0'", + zh_TW = "è«‹æ’å…¥ '%0'" + }; + + -- Prompt shown to user in the stdio UI when we need to pause before + -- continuing, usually to let them read the outputted text that is + -- scrolling by. + ["Press enter to continue."] = { + af = "Druk enter sleutel om voort te gaan.", + ar = "اضغط Ù…Ùتاح الإدخال للاستمرار.", + cs = "Pro pokraÄování stisknÄ›te enter.", + da = "Tryk retur for at fortsætte.", + de = "Drücken Sie Enter um fortzufahren", + el = "Πατήστε ENTER για συνέχεια.", + en_AU = "Press enter to continue.", + en_CA = "Press enter to continue.", + en_GB = "Press enter to continue.", + es = "Presione Intro para continuar.", + fi = "Jatka painamalla enter.", + fr = "Veuillez appuyer sur Entrée pour continuer.", + he = "לחץ enter להמשך.", + hu = "Ãœss egy entert a folytatáshoz.", + id = "Untuk melanjtukan tekan enter.", + it = "Premere invio per continuare.", + nb = "Trykk enter for Ã¥ fortsette.", + nds = "Enter drücken, um fortzufahren.", + nl = "Toets enter om door te gaan.", + nn = "Trykk Enter for Ã¥ halda fram.", + pl = "ProszÄ™ nacisnąć enter, aby kontynuować.", + pt = "Pressione enter para continuar.", + pt_BR = "Pressione enter para continuar.", + ro = "ApăsaÅ£i Enter pentru a continua.", + ru = "Ðажмите Enter Ð´Ð»Ñ Ð¿Ñ€Ð¾Ð´Ð¾Ð»Ð¶ÐµÐ½Ð¸Ñ", + sk = "StlaÄte Enter pre pokraÄovanie.", + sl = "Za nadaljevanje pritisnite enter.", + sv = "Tryck enter för att fortsätta.", + tr = "Devam etmek için giriÅŸ tuÅŸuna basınız.", + uk = "Ð”Ð»Ñ Ð¿Ñ€Ð¾Ð´Ð¾Ð²Ð¶ÐµÐ½Ð½Ñ Ð½Ð°Ñ‚Ð¸Ñніть Enter.", + zh_TW = "請按 [Enter] éµç¹¼çºŒã€‚" + }; + + -- This is a window title when informing the user that something + -- important has gone wrong (such as being unable to revert changes + -- during a rollback). + ["Serious problem"] = { + af = "Ernstige probleem", + ar = "مشكلة كبيرة", + cs = "Závažný problém", + da = "Seriøst problem", + de = "Ernstes Problem", + el = "ΣοβαÏÏŒ Ï€Ïόβλημα", + en_AU = "Serious problem", + en_CA = "Serious problem", + en_GB = "Serious problem", + es = "Problema grave", + fi = "Vakava ongelma", + fr = "Problème grave", + he = "תקלה רצינית", + hu = "Komoly probléma", + id = "Masalah berat", + it = "Problema critico", + nb = "Alvorlig problem", + nds = "Ernstzunehmender Fehler", + nl = "Serieus probleem", + nn = "Alvorleg problem", + pl = "Poważny bÅ‚Ä…d", + pt = "Problema sério", + pt_BR = "Problema sério", + ro = "Problemă serioasă", + ru = "Ð¡ÐµÑ€ÑŒÐµÐ·Ð½Ð°Ñ Ð¾ÑˆÐ¸Ð±ÐºÐ°", + sk = "Vážny problém", + sl = "Pomembna napaka", + sv = "Allvarligt problem", + tr = "Ciddi problem", + uk = "Серйозна проблема", + zh_TW = "åš´é‡å•é¡Œ" + }; + + -- The www UI uses this as a page title when the program is terminating. + ["Shutting down..."] = { + af = "Besig om af te skakel...", + ar = "يجري الإغلاق...", + cs = "UkonÄuji se...", + da = "Lukker ned...", + de = "Schließe...", + el = "Γίνεται τεÏματισμός...", + en_AU = "Shutting down...", + en_CA = "Shutting down...", + en_GB = "Shutting down...", + es = "Cerrando ...", + fr = "Fermeture en cours...", + he = "מכבה...", + hu = "Leállítás...", + id = "Mematikan...", + it = "Uscita in corso...", + nb = "Avslutter...", + nds = "Schließe...", + nl = "Afsluiten...", + nn = "Avsluttar...", + pl = "Zamykanie...", + pt = "A terminar...", + pt_BR = "Desligando...", + ro = "Oprire...", + ru = "Завершение", + sk = "Vypínam sa...", + sl = "Izklaplanje...", + sv = "Avslutar...", + tr = "Kapatılıyor...", + uk = "Ð—Ð°Ð²ÐµÑ€ÑˆÐµÐ½Ð½Ñ Ñ€Ð¾Ð±Ð¾Ñ‚Ð¸...", + zh_TW = "關閉……" + }; + + -- The www UI uses this as page text when the program is terminating. + ["You can close this browser now."] = { + af = "U kan die blaaier nou toemaak.", + ar = "يمكنك إغلاق هذا المتصÙØ­", + cs = "Nyní můžete ukonÄit tento prohlížeÄ.", + da = "Du kan lukke browseren nu.", + de = "Sie können diesen Browser nun schließen.", + el = "ΜποÏείτε να κλείσετε αυτόν τον πεÏιηγητή Ï„ÏŽÏα.", + en_AU = "You can close this browser now.", + en_CA = "You can close this browser now.", + en_GB = "You can close this browser now.", + es = "Ya puedes cerrar el navegador.", + fr = "Vous pouvez maintenant fermer ce navigateur", + he = "תוכל לסגור דפדפן ×–×” כעת.", + hu = "Most már bezárhatod ezt az ablakot.", + id = "Anda dapat menutup browser ini sekarang.", + it = "Puoi chiudere il browser adesso.", + nb = "Du kan lukke denne nettleseren nÃ¥.", + nds = "Sie können den Browser nun schließen.", + nl = "U kunt dit scherm nu sluiten.", + nn = "Du kan stenga denne nettlesaren no.", + pl = "Możesz zamknąć już przeglÄ…darkÄ™.", + pt = "Já pode fechar este browser.", + pt_BR = "Você não pode fechar esse navegador agora.", + ro = "Se poate închide navigatorul web acum.", + ru = "Можете закрыть браузер.", + sk = "Tento prehliadaÄ môžete zavrieÅ¥.", + sl = "Sedaj lahko zaprete brskalnik.", + sv = "Du kan stänga denna webbläsare nu.", + tr = "Bu tarayıcı penceresini ÅŸimdi kapatabilirsiniz.", + uk = "Тепер можна зачинити цей оглÑдач.", + zh_TW = "ä½ ç¾åœ¨å·²å¯ä»¥é—œé–‰ç€è¦½å™¨" + }; + + -- Error message shown to end-user when we can't write a symbolic link + -- to the filesystem. + ["Symlink creation failed!"] = { + af = "Simboliese skakel skepping het misluk!", + ar = "Ùشل ÙÙŠ إنشاء الوصلة الرمزية", + cs = "Selhalo vytváření symbolického odkazu!", + de = "Erzeugung einer Verknüpfung fehlgeschlagen!", + el = "Απέτυχε η δημιουÏγεία ενός symlink!", + en_AU = "Symlink creation failed!", + en_CA = "Symlink creation failed!", + en_GB = "Symlink creation failed!", + es = "¡Error al crear enlace simbólico!", + fi = "Symbolisen linkin luominen epäonnistui!", + fr = "Création de lien symbolique échouée!", + he = "יצירת הקישורית נכשלה!", + hu = "Symlink készítés sikertelen!", + id = "Pembuatan symlink gagal!", + it = "Creazione del collegamento (symlink) fallita!", + nb = "Kunne ikke lage symbolsk lenke!", + nds = "Fehler beim Erstellen einer symbolischen Verknüpfung!", + nl = "Maken van symbolische link mislukt!", + nn = "Kunne ikkje laga symbolsk lenke!", + pl = "Nie udaÅ‚o siÄ™ utworzyć odnoÅ›nika symbolicznego!", + pt = "A criação de uma ligação simbólica falhou!", + pt_BR = "Falha na criação do link simbólico!", + ro = "Nu s-au putut creea legături!", + ru = "Ошибка ÑÐ¾Ð·Ð´Ð°Ð½Ð¸Ñ ÑÑылки!", + sk = "Nemôžem vytvoriÅ¥ symlink", + sl = "Ustvarjanje symlinka ni uspelo!", + sv = "Kunde inte skapa symbolisk länk!", + tr = "Sembolik baÄŸ oluÅŸturulamadı!", + uk = "Ðеможливо Ñтворити Ñимвольне поÑиланнÑ!", + zh_TW = "無法建立連çµ" + }; + + -- Error message shown to the end-user when the OS has requested + -- termination of the program (SIGINT/ctrl-c on Unix, etc). + ["The installer has been stopped by the system."] = { + af = "Die instaleerder is gestop deur die stelsel.", + ar = "أوق٠نظام التشغيل التثبيت", + cs = "Instalátor byl zastaven signálem ze systému.", + da = "Installation stoppes af operativsystemet.", + de = "Das Installationsprogramm wurde vom System gestoppt.", + el = "Το Ï€ÏόγÏαμμα εγκατάστασης διακόπηκε από το σÏστημα.", + en_AU = "The installer has been stopped by the system.", + en_CA = "The installer has been stopped by the system.", + en_GB = "The installer has been stopped by the system.", + es = "El instalador ha sido interrumpido por el sistema.", + fi = "Järjestelmä pysäytti asennusohjelman.", + fr = "L'installeur a été interrompu par le système.", + he = "ההתקנה נעצרה על ידי המערכת.", + hu = "A telepítÅ‘ megszakítva a rendszer által.", + id = "Installer telah dihentikan oleh sistem.", + it = "L'installazione è stata terminata dal sistema operativo.", + nb = "Installasjonsprogrammet ble stoppet av systemet.", + nds = "Der Installer wurde vom System gestoppt.", + nl = "Het installatieprogramma is door het systeem gestopt.", + nn = "Installasjonsprogrammet vart stoppa av systemet.", + pl = "Instalator zostaÅ‚ zatrzymany przez system.", + pt = "O instalador foi parado pelo sistema.", + pt_BR = "O instalador foi parado pelo sistema.", + ro = "Programul de instalare a fost oprit de către sistem.", + ru = "Программа уÑтановки была оÑтановлена ÑиÑтемой.", + sk = "InÅ¡talátor bol zastavený systémom.", + sl = "Namestitveni program je bil zaustavljen od operacijskega sistema.", + sv = "Installationsprogrammet blev stoppat av systemet.", + tr = "Kurulum programı sistem tarafından durduruldu.", + uk = "ІнÑталÑтор зупинено ÑиÑтемою.", + zh_TW = "安è£ç¨‹å¼å·²è¢«ç³»çµ±çµ‚æ­¢" + }; + + -- Error message shown to the end-user when the program crashes with a + -- bad memory access (segfault on Unix, GPF on Windows, etc). + ["The installer has crashed due to a bug."] = { + af = "Die instaleerder het gefou asgevolg van 'n kewer.", + ar = "Ùشل التركيب بسبب بقة", + cs = "Instalátor zhavaroval vinou vlastní chyby.", + de = "Das Installationsprogramm ist aufgrund eines Fehlers abgestürzt.", + el = "Το Ï€ÏόγÏαμμα εγκατάστασης έσκασε λόγω κάποιου σφάλματος.", + en_AU = "The installer has crashed due to a bug.", + en_CA = "The installer has crashed due to a bug.", + en_GB = "The installer has crashed due to a bug.", + es = "El instalador se ha bloqueado por un fallo.", + fi = "Bugi kaatoi asennusohjelman.", + fr = "L'installateur a quitté inopinément à cause d'un bogue.", + he = "תוכנית ההתקנה קרה עקב שגי×ת תוכנה.", + hu = "A telepítÅ‘ egy bug miatt összeomlott.", + id = "Installer telah bertabrakan karena kutu.", + it = "L'installer è crashato a causa di un bug.", + nb = "Installasjonsprogrammet kræsjet pga. en feil.", + nds = "Der Installer ist Aufgrund eines Fehlers abgestürzt.", + nl = "Het installatieprogramma is door een bug gecrasht.", + nn = "Installasjonsprogrammet kræsja pÃ¥ grunn av ein programfeil.", + pl = "Instalator przerwaÅ‚ dziaÅ‚anie z powodu bÅ‚Ä™du.", + pt = "O instalador terminou acidentalmente devido a um erro.", + pt_BR = "O instalador travou devido a um bug.", + ro = "Programul de instalare s-a oprit din cauza unei erori.", + ru = "Программа уÑтановки завершилаÑÑŒ из-за ошибки.", + sk = "InÅ¡talátor havaroval kvôli chybe.", + sl = "Namestitveni program se je zruÅ¡il zaradi napake.", + sv = "Installationsprogrammet kraschade pga. ett fel.", + tr = "Kurulum bir hata yüzünden çöktü.", + uk = "ІнÑталÑтор завершив роботу через помилку.", + zh_TW = "安è£ç¨‹å¼å› è‡­èŸ²è€Œçµ‚æ­¢" + }; + + -- This is a button label in the ncurses ui to flip an option on/off. + ["Toggle"] = { + af = "Wisselaar", + ar = "بدّل", + cs = "PÅ™epnout", + da = "Skift", + de = "Umschalten", + el = "Εναλλαγή", + en_AU = "Toggle", + en_CA = "Toggle", + en_GB = "Toggle", + es = "Alternar", + fi = "Vaihda", + fr = "Basculer", + he = "הפוך מצב", + hu = "Kapcsoló", + id = "Toggle", + it = "Attiva/Disattiva", + nb = "Velg", + nds = "Umschalten", + nl = "Aan/Uit", + nn = "SlÃ¥ av/pÃ¥", + pl = "PrzeÅ‚Ä…cz", + pt = "Alternar", + pt_BR = "Alternar", + ro = "Comută", + ru = "Переключить", + sk = "Výber", + sl = "Preklopi", + sv = "Växla", + tr = "DeÄŸiÅŸtir", + uk = "Переключити", + zh_TW = "切æ›" + }; + + -- This is an error message shown to the end-user when there is an + -- unexpected entry in a .zip (or whatever) file that we didn't know + -- how to handle. + ["Unknown file type in archive"] = { + af = "Onbekende lêer tipe in argief", + ar = "نوع ملÙات غير معرو٠ÙÙŠ الأرشيÙ", + cs = "Neznámý typ souboru v archivu.", + da = "Ukendt filtype i arkiv", + de = "Unbekannter Dateityp im Archiv", + el = "Άγνωστος Ï„Ïπος αÏχείου μέσα στο πακέτο αÏχείων.", + en_AU = "Unknown file type in archive", + en_CA = "Unknown file type in archive", + en_GB = "Unknown file type in archive", + es = "Tipo de archivo desconocido", + fi = "Paketissa on tiedosto, jonka tyyppiä ei tunneta.", + fr = "Type de fichier inconnu dans cette archive.", + he = "סוג קובץ ×œ× ×™×“×•×¢ ב×רכיון", + hu = "Ismeretlen fájl típus az archívumban", + id = "Jenis berkas dalam arsip tidak dikenal", + it = "Non è stato possibile riconoscere un file presente nell'archivio", + nb = "Ukjent filtype i arkivet", + nds = "Unbekannter Dateityp im Archiv", + nl = "Onbekend bestandstype in archief", + nn = "Ukjent filtype i arkivet", + pl = "Nie znany typ pliku w archiwum.", + pt = "Tipo de ficheiro desconhecido no arquivo", + pt_BR = "Tipo de arquivo desconhecido no arquivo", + ro = "Tip de fiÅŸier necunoscut în arhivă", + ru = "ÐеизвеÑтный тип файла в архиве", + sk = "Neznámy typ súboru v archíve", + sl = "Naznana vrsta datoteke v arhivu", + sv = "Okänd filtyp pÃ¥träffad i arkivet", + tr = "ArÅŸivde bilinmeyen dosya tipi", + uk = "Ðевідомий тип файлу в архіві", + zh_TW = "檔案包中有未知的檔案類別" + }; + + -- This is an error message shown to the end-user if they refuse to + -- agree to the license of the software they are try to install. + ["You must accept the license before you may install"] = { + af = "U moet die lisensie aanvaar voor U mag installeer", + ar = "يجب أن تواÙÙ‚ على الرخصة قبل التثبيت", + cs = "PÅ™ed instalací je nutné odsouhlasit licenci", + de = "Sie müssen den Lizenzbedingungen zustimmen, bevor sie installieren können", + el = "ΠÏέπει να συμφωνήσετε με την άδεια χÏήσης Ï€Ïιν συνεχίσετε με την εγκατάσταση", + en_AU = "You must accept the license before you may install", + en_CA = "You must accept the licence before you may install", + en_GB = "You must accept the licence before you may install", + es = "Tienes que aceptar la licencia antes de que puedas instalar", + fi = "Asennusta ei suoriteta, ellet hyväksy lisenssiä.", + fr = "Vous devez accepter la licence avant de pouvoir installer", + he = "עליך לקבל ×ת הרשיון לפני שתוכל להתקין", + hu = "El kell fogadnod a liszenszt a telepítés elÅ‘tt", + id = "Anda harus menerima lisensi sebelum Anda dapat menginstal", + it = "E' necessario accettare la licenza prima di procedere con l'installazione.", + nb = "Lisensen mÃ¥ godkjennes før du kan installere", + nds = "Sie müssen der Lizenzbedingung zustimmen, um die Installation fortzusetzen", + nl = "U moet akkoord gaan met de licentie om te kunnen installeren", + nn = "Du mÃ¥ godkjenna lisensen før du fÃ¥r installera", + pl = "Musisz zaakceptować licencjÄ™ przed instalacjÄ…", + pt = "Tem que aceitar a licença antes de prosseguir com a instalação", + pt_BR = "Você precisa aceitar esta licença antes de poder instalar", + ro = "Trebuie să acceptaÅ£i licenÅ£a înainte de a instala", + ru = "Ð”Ð»Ñ ÑƒÑтановки вы должны принÑÑ‚ÑŒ лицензионное Ñоглашение", + sk = "Pokiaľ chcete pokraÄovaÅ¥ v inÅ¡talácii, musíte súhlasiÅ¥ s licenciou", + sl = "Za namestitev se morate strinjati z licenco", + sv = "Du mÃ¥ste acceptera licensavtalet innan du kan fortsätta med installationen", + tr = "Kuruluma baÅŸlamadan önce lisansı kabul etmelisiniz", + uk = "Ви маєте погодитиÑÑ Ð· умовами викориÑÑ‚Ð°Ð½Ð½Ñ Ð´Ð»Ñ Ð¿Ð¾Ñ‡Ð°Ñ‚ÐºÑƒ вÑтановленнÑ", + zh_TW = "ä½ å¿…é ˆåŒæ„該許å¯è­‰ä»¥ç¹¼çºŒå®‰è£ç¨‹åº" + }; + + -- Installations display the currently-installing component, such as + -- "Base game" or "Bonus pack content" or whatnot. The installer lists + -- the current component as "Metadata" when writing out its own + -- information, such as the final list of installed files, the uninstall + -- support application, etc. It's a catch-all category: data about the + -- actual data, basically. + ["Metadata"] = { + af = "Metadata", + ar = "البيانات الإضاÙية", + cs = "Metadata", + da = "Metadata", + de = "Metadaten", + el = "Μεταδεδομένα", + en_AU = "Metadata", + en_CA = "Metadata", + en_GB = "Metadata", + es = "Metadatos", + fi = "Metadata", + fr = "Métadonnées", + he = "נתוני מט×", + hu = "Metaadat", + id = "Metadata", + it = "Metadati", + nb = "Metadata", + nds = "Metadaten", + nl = "Metadata", + nn = "Metadata", + pl = "Metadane", + pt = "Meta-Informação", + pt_BR = "Metadado", + ro = "Metadata", + ru = "Метаданные", + sk = "Metadáta", + sl = "Metapodatki", + sv = "Metadata", + tr = "Bilgi", + uk = "Метадані", + zh_TW = "中繼資料" + }; + + -- This error is shown if incorrect command line arguments are used. + ["Invalid command line"] = { + af = "Ongeldige bevel argumente", + ar = "أمر غير صحيح", + cs = "Neplatné argumenty", + de = "Ungültige Kommandozeile", + el = "Λάθος γÏαμμή εντολών", + en_AU = "Invalid command line", + en_CA = "Invalid command line", + en_GB = "Invalid command line", + es = "Orden incorrecta", + fi = "Virheellinen komentorivi", + fr = "Ligne de commande invalide", + he = "פקודת שורה שגויה", + hu = "Helytelen parancssor", + id = "Perintah baris tidak cocok", + it = "Parametri nella riga di comando non validi", + nb = "Ugyldig kommandolinje", + nds = "Ungültige Befehlszeile", + nl = "Ongeldige opdrachtregel", + nn = "Ugyldig kommandolinje", + pl = "Niepoprawny parametr", + pt = "Argumento da linha de comandos inválido", + pt_BR = "Linha de comando inválida", + ro = "Linie de comandă invalidă", + ru = "ÐÐµÐ²ÐµÑ€Ð½Ð°Ñ ÐºÐ¾Ð¼Ð°Ð½Ð´Ð½Ð°Ñ Ñтрока", + sk = "Chybné parametre", + sl = "Neveljaven ukaz", + sv = "Ogiltigt kommando", + tr = "Geçersiz komut satırı", + uk = "Ðекоректні параметри у командному Ñ€Ñдку", + zh_TW = "無效的命令" + }; + + -- This error is shown when updating the manifest (the list of files that + -- we installed), if it can't load the file for some reason. '%0' is the + -- manifest's package name. + ["Couldn't load manifest file for '%0'"] = { + af = "Kon nie die manifesto lêer laai vir '%0' nie.", + ar = "لم يمكن تحميل قائمة الملÙات لـ'%0'", + cs = "Nemohu naÄíst soubor s manifestem pro '%0'", + de = "Konnte Manifestdatei für '%0' nicht laden", + el = "Δεν μπόÏεσε να φοÏτώσει το αÏχείο \"manifest\" για '%0'", + en_AU = "Couldn't load manifest file for '%0'", + en_CA = "Couldn't load manifest file for '%0'", + en_GB = "Couldn't load manifest file for '%0'", + es = "No pudo cargar el archivo manifest de '%0'", + fi = "Asennusluetteloa paketille \"%0\" ei kyetty lukemaan.", + fr = "Impossible de charger le fichier manifeste de '%0'", + he = "×œ× × ×™×ª×Ÿ לטעון ×ת קובץ המניפסט עבור '%0'", + hu = "'%0' fájllista betöltése sikertelen", + id = "Tidak dapat memuat manifesto untuk '%0'", + it = "Impossibile caricare il manifest file per '%0'", + nb = "Kunne ikke laste manifestfil for '%0'", + nds = "Konnte Manifest für '%0' nicht laden.", + nl = "Kan manifest bestand for '%0' niet laden", + nn = "Kunne ikkje lasta manifestfil for '%0'", + pl = "Nie można zaÅ‚adować manifestu dla pliku '%0'", + pt = "Foi impossível carregar o ficheiro de manifesto para '%0'", + pt_BR = "Não é possível carregar o arquivo manifest de '%0'", + ro = "Nu s-a putut încărca lista de fiÅŸiere de instalat pentru '%0'", + ru = "Ðевозможно загрузить ÑпиÑок уÑтановленных файлов Ð´Ð»Ñ '%0'", + sk = "Nemôžem nahraÅ¥ manifest súbor pre '%0'", + sl = "NeuspeÅ¡no nalaganje datoteke manifesta za '%0'", + sv = "Kunde inte ladda fillistan för '%0'", + tr = "'%0' için kurulum kaydı yüklenemedi", + uk = "Ðеможливо відкрити файл маніфеÑту Ð´Ð»Ñ '%0'", + zh_TW = "無法讀å–來自 '%0' 的檔案清單" + }; + + -- This error is shown when the user prompted the app to read a filename + -- (%0) that doesn't exist. + ["File %0 not found"] = { + af = "Lêer %0 nie gevind nie", + ar = "المل٠%0 غير موجود", + cs = "Soubor '%0' nebyl nalezen", + da = "Filen '%0' ikke fundet", + de = "Datei %0 nicht gefunden.", + el = "Το αÏχείο %0 δεν βÏέθηκε", + en_AU = "File %0 not found", + en_CA = "File %0 not found", + en_GB = "File %0 not found", + es = "Archivo %0 no encontrado", + fi = "Tiedostoa \"%0\" ei ole.", + fr = "Fichier %0 introuvable", + he = "הקובץ %0 ×œ× × ×ž×¦×", + hu = "%0 nem található", + id = "Berkas %0 tidak ditemukan", + it = "Impossibile trovare il File %0", + nb = "Filen '%0' ble ikke funnet", + nds = "Datei %0 wurde nicht gefunden", + nl = "Bestand %0 niet gevonden", + nn = "Kunne ikkje finne fila '%0'", + pl = "Plik %0 nie znaleziony", + pt = "O ficheiro %0 não foi encontrado", + pt_BR = "Arquivo %0 não encontrado", + ro = "FiÅŸierul %0 nu a fost găsit", + ru = "Файл %0 не найден", + sk = "NenaÅ¡iel som súbor %0", + sl = "Datoteke %0 ni možno najti", + sv = "Filen '%0' hittades inte", + tr = "%0 dosyası bulunamadı", + uk = "Ðеможливо знаÑти файл %0", + zh_TW = "找ä¸åˆ°æª”案 %0" + }; + + -- This is a window title on the message box when asking if user is sure + -- they want to uninstall a package. + ["Uninstall"] = { + af = "Verwyder", + ar = "إزالة التثبيت", + cs = "Odinstalovat", + da = "Afinstallér", + de = "Deinstallieren", + el = "Απεγκατάσταση", + en_AU = "Uninstall", + en_CA = "Uninstall", + en_GB = "Uninstall", + es = "Desinstalar", + et = "Eemalda", + fi = "Asennuksen poisto", + fr = "Désinstaller", + he = "הסרה", + hu = "Eltávolítás", + id = "Uninstall", + it = "Disinstalla", + nb = "Avinstallasjon", + nds = "Deinstalleren", + nl = "Deïnstalleren", + nn = "Avinstaller", + pl = "Odinstaluj", + pt = "Desinstalar", + pt_BR = "Desinstalar", + ro = "Dezinstalare", + ru = "Удалить", + sk = "OdinÅ¡talovaÅ¥", + sl = "Odstrani", + sv = "Avinstallera", + tr = "Kaldır", + uk = "ДеінÑталювати", + zh_TW = "移除" + }; + + -- This is the text when asking the user if they want to uninstall + -- the package named '%0'. + ["Are you sure you want to uninstall '%0'?"] = { + af = "Is U seker U wil '%0' verwyder?", + ar = "هل تريد Ùعلاً إزالة '%0' ØŸ", + cs = "Opravdu chcete odinstalovat '%0'?", + da = "Er du sikker pÃ¥ at du vil afinstallere '%0'?", + de = "Sind Sie sicher, dass Sie '%0' deinstallieren wollen?", + el = "Είστε σίγουÏοι θέλετε να απεγκαταστήσετε το '%0'?", + en_AU = "Are you sure you want to uninstall '%0'?", + en_CA = "Are you sure you want to uninstall '%0'?", + en_GB = "Are you sure you want to uninstall '%0'?", + es = "¿Está seguro de que quiere desinstalar '%0'?", + fi = "Haluatko varmasti poistaa asennuksen \"%0\"?", + fr = "Êtes-vous sûr de vouloir désinstaller '%0' ?", + he = "×”×× ×תה בטוח שברצונך להסיר ×ת '%0'?", + hu = "Biztosan eltávolítod: '%0' ?", + id = "Apakah Anda yakin ingin meng-uninstal '%0'?", + it = "Se veramente sicuro di voler disinstallare '%0'?", + nb = "Er du sikker pÃ¥ at du vil avinstallere '%0'?", + nds = "Sind sie sicher, dass sie '%0' deinstallieren wollen?", + nl = "Bent u er zeker van dat u '%0' wilt deïnstalleren?", + nn = "Er du sikker pÃ¥ at du vil avinstallera '%0'?", + pl = "Czy na pewno chcesz odinsalować '%0'?", + pt = "Tem a certeza que quer desinstalar '%0'?", + pt_BR = "Você tem certeza que deseja desinstalar '%0'?", + ro = "SunteÅ£i sigur că doriÅ£i dezinstalarea '%0'?", + ru = "Ð’Ñ‹ уверены, что хотите удалить '%0'?", + sk = "Ste si istí, že chcete odinÅ¡talovaÅ¥ '%0'?", + sl = "Ali ste prepriÄani, da želite odstraniti '%0'?", + sv = "Är du säker pÃ¥ att du vill avinstallera '%0'?", + tr = "'%0' paketini kaldırmak istediÄŸinizden emin misiniz?", + uk = "Ви впевнені що хочете деінÑталювати '%0'?", + zh_TW = "你確定è¦ç§»é™¤ '%0'" + }; + + -- This is a window title, shown while the actual uninstall is in process + -- and a progress meter is being shown. + ["Uninstalling"] = { + af = "In die proses van verwydering", + ar = "يجري الإزالة", + cs = "Odinstalovávám", + da = "Afinstallerer", + de = "Deinstalliere", + el = "Γίνεται απεγκατάσταση", + en_AU = "Uninstalling", + en_CA = "Uninstalling", + en_GB = "Uninstalling", + es = "Desinstalando", + fi = "Poistetaan asennusta", + fr = "Désinstallation en cours", + he = "מסיר", + hu = "Eltávolítás", + id = "Meng-uninstal", + it = "Disinstallazione in corso", + nb = "Avinstallerer", + nds = "Deinstallation", + nl = "Deïnstallatie", + nn = "Avinstallerar", + pl = "Odinstalowywanie", + pt = "A desinstalar", + pt_BR = "Desinstalando", + ro = "Se dezinstalează", + ru = "Удаление", + sk = "OdinÅ¡talovávam", + sl = "Odstranjevanje", + sv = "Avinstallerar", + tr = "Kaldırılıyor", + uk = "ПрибираннÑ", + zh_TW = "正在移除" + }; + + -- This is shown to the user in a message box when uninstallation is done. + ["Uninstall complete"] = { + af = "Verwydering voltooi", + ar = "انتهت الإزالة", + cs = "Odinstalace dokonÄena", + da = "Afinstallation er gennemført", + de = "Deinstallation abgeschlossen", + el = "Η απεγκατάσταση ολοκληÏώθηκε", + en_AU = "Uninstall complete", + en_CA = "Uninstall complete", + en_GB = "Uninstall complete", + es = "Desinstalación terminada", + fi = "Asennus poistettu", + fr = "Désinstallation complète", + he = "ההסרה הושלמה", + hu = "Eltávolítás kész", + id = "Uninstal selesai", + it = "Disinstallazione completata", + nb = "Avinstallasjonen er ferdig", + nds = "Deinstallation abgeschlossen", + nl = "Deïnstallatie voltooid", + nn = "Avinstallasjonen er ferdig", + pl = "Odinstalowanie zakoÅ„czone", + pt = "A desinstalação foi bem sucedida", + pt_BR = "Desinstalação completada", + ro = "Dezinstalare completă", + ru = "Удаление завершено", + sk = "OdinÅ¡talácia dokonÄená", + sl = "Odstranitev konÄana", + sv = "Avinstallation slutförd", + tr = "Kaldırma tamamlandı", + uk = "ÐŸÑ€Ð¸Ð±Ð¸Ñ€Ð°Ð½Ð½Ñ Ð·Ð°Ð²ÐµÑ€ÑˆÐµÐ½Ð¾", + zh_TW = "移除完æˆ" + }; + + -- This is written to the terminal in the ncurses UI when the window is + -- too thin to be usable; it's asking the user to resize the terminal + -- window horizontally. Since space may be extremely tight, try to be as + -- terse as possible (but we can wrap the text if possible, so don't be + -- cryptic). The '[' and ']' characters are just decoration to imply this + -- is a system problem outside the scope of the application, but they + -- aren't required. + ["[Make the window wider!]"] = { + af = "[Maak die venster weier!]", + ar = "[كبّر الناÙذة!]", + cs = "[ZvÄ›tÅ¡it šířku okna!]", + da = "[Gør vinduet bredere!]", + de = "[Fenster breiter machen!]", + el = "[Μεγαλώστε το παÏάθυÏο κατά πλάτος!]", + en_AU = "[Make the window wider!]", + en_CA = "[Make the window wider!]", + en_GB = "[Make the window wider!]", + es = "[¡Ensanchar la ventana!]", + fi = "[Levennä ikkunaa!]", + fr = "[Élargissez la fenêtre!]", + he = "[הרחב ×ת החלון!]", + hu = "[Húzd az ablakot szélesebbre!]", + id = "[Buat jendela lebih lebar!]", + it = "[Allarga la finestra!]", + nb = "[Gjør vinduet bredere!]", + nds = "[Mach das Fenster breiter!]", + nl = "[Maak het scherm breder!]", + nn = "[Gjer vindauget breiare!]", + pl = "[Zrób szersze okno!]", + pt = "[Torne a janela mais larga!]", + pt_BR = "[Aumente a largura da janela!]", + ro = "[MăreÅŸte lăţimea ferestrei]", + ru = "Сделайте окно шире!", + sk = "[Roztiahnite okno do šírky!]", + sl = "[RazÅ¡iri to okno!]", + sv = "[Gör fönstret bredare!]", + tr = "[Pencereyi geniÅŸlet!]", + uk = "[Зробіть вікно ширше!]", + zh_TW = "[使視窗更寬]" + }; + + -- This is written to the terminal in the ncurses UI when the window is + -- too short to be usable; it's asking the user to resize the terminal + -- window vertically. Since space may be extremely tight, try to be as + -- terse as possible (but we can wrap the text if possible, so don't be + -- cryptic). The '[' and ']' characters are just decoration to imply this + -- is a system problem outside the scope of the application, but they + -- aren't required. + ["[Make the window taller!]"] = { + af = "[Maak die venster langer!]", + ar = "[اجعل الناÙذة أطول!]", + cs = "[ZvÄ›tÅ¡it výšku okna!]", + da = "[Gør vinduet højere!]", + de = "[Fenster höher machen!]", + el = "[Μεγαλώστε το παÏάθυÏο κατα Ïψος]", + en_AU = "[Make the window taller!]", + en_CA = "[Make the window taller!]", + en_GB = "[Make the window taller!]", + es = "[¡Hacer la ventana más alta!]", + fi = "[Tee ikkunasta korkeampi!]", + fr = "[Agrandissez la fenêtre!]", + he = "[הגבה ×ת החלון!]", + hu = "[Húzd az ablakot magasabbra!]", + id = "[Buat jendela lebih tinggi!]", + it = "[Allunga la finestra!]", + nb = "[Gjør vinduet høyere!]", + nds = "[Mach das Fenster höher!]", + nl = "[Maak het scherm langer!]", + nn = "[Gjer vindauget høgare!]", + pl = "[Zrób wyższe okno!]", + pt = "[Torne a janela mais alta!]", + pt_BR = "[Aumente a altura da janela!]", + ro = "[MăreÅŸte înălÅ£imea ferestrei!]", + ru = "Сделайте окно выше!", + sk = "[Roztiahnite okno do výšky!]", + sl = "[PoviÅ¡aj to okno!]", + sv = "[Gör fönstret högre!]", + tr = "[Pencereyi uzat!]", + uk = "[Зробіть вікно вище!]", + zh_TW = "[使視窗更長]" + }; + + -- This is written out if we failed to add an item to the desktop + -- application menu (or "Start" bar on Windows, or maybe the Dock on + -- Mac OS X, etc). + ["Failed to install desktop menu item"] = { + af = "Mislukking tydens die installasie van die werkskerm kieslys item", + ar = "Ùشل ÙÙŠ التثبيت لقائمة سطح المكتب", + cs = "NepodaÅ™ilo se nainstalovat položku do menu", + da = "Kunne ikke oprette menupunkt i skrivebordets menu", + de = "Konnte Verknüpfung für Desktop-Menü nicht installieren", + el = "Σφάλμα κατα την εγκατάσταση της συντόμευσης εκκίνησης του Ï€ÏογÏάμματος", + en_AU = "Failed to install desktop menu item", + en_CA = "Failed to install desktop menu item", + en_GB = "Failed to install desktop menu item", + es = "Fallo al añadir un elemento al menú de escritorio", + fi = "Kohdan lisääminen työpöytävalikkoon epäonnistui.", + fr = "Echec de l'installation des éléments du bureau", + he = "שגי××” בהתקנת פריט בתפריט היישומי×", + hu = "Asztali ikon létrehozása sikertelen", + it = "L'installazione di un oggetto nel menu delle applicazioni è fallita", + nb = "Klarte ikke Ã¥ installere snarvei", + nds = "Desktop Menu-Eintrag konnte nicht erstellt werden.", + nl = "Installatie van het bureaublad menu item is mislukt", + nn = "Klarte ikkje Ã¥ installera snarveg", + pl = "Nie udaÅ‚o siÄ™ utworzyć elementu menu", + pt = "A instalação do menu no desktop falhou", + pt_BR = "Falha ao instalar o item no menu", + ro = "Nu s-a putut instala itemul din meniu", + ru = "Ðе удалоÑÑŒ уÑтановить Ñлемент меню", + sk = "Nepodarilo sa mi nainÅ¡talovaÅ¥ odkaz na plochu", + sl = "Namestitev menija na namizju ni uspela", + sv = "Misslycklades med att lägga till genväg i programmenyn", + tr = "Masaüstü menü öğesi kurulamadı", + uk = "Ðеможливо Ñтворити Ð·Ð°Ð¿Ð¸Ñ Ñƒ меню", + zh_TW = "安è£æ¡Œé¢é¸å–®é …目失敗" + }; + + -- This is written out if we failed to remove an item from the desktop + -- application menu (or "Start" bar on Windows, or maybe the Dock on + -- Mac OS X, etc). + ["Failed to uninstall desktop menu item"] = { + af = "Mislukking tydens die verwydering van die werkskerm kieslys item", + ar = "Ùشل ÙÙŠ الإزالة من قائمة سطح المكتب", + cs = "NepodaÅ™ilo se odstranit položku z menu", + da = "Kunne ikke fjerne menupunkt i skrivebordets menu", + de = "Konnte Verknüpfung für Desktop-Menü nicht deinstallieren", + el = "Σφάλμα κατά την απεγκατάσταση της συντόμευσης εκκίνησης του Ï€ÏογÏάμματος", + en_AU = "Failed to uninstall desktop menu item", + en_CA = "Failed to uninstall desktop menu item", + en_GB = "Failed to uninstall desktop menu item", + es = "Fallo al quitar un elemento del menú de escritorio", + fi = "Kohdan poistaminen työpöytävalikkosta epäonnistui.", + fr = "Echec de la désinstallation des éléments du bureau", + he = "שגי××” בהסרת פריט מתפריט היישומי×", + hu = "Asztali ikon eltávolítása sikertelen", + it = "La disinstallazione di un oggetto del menu è fallita", + nb = "Klarte ikke Ã¥ fjerne snarvei", + nds = "Desktop Menu-Eintrag konnte nicht entfernt werden.", + nl = "Deïnstallatie van het bureaublad menu item is mislukt", + nn = "Klarte ikkje Ã¥ fjerna snarveg", + pl = "Nie udaÅ‚o siÄ™ odinstalować elementu menu", + pt = "A desinstalação do menu no desktop falhou", + pt_BR = "Falha ao remover o item do menu", + ro = "Nu s-a putut dezinstala itemul din meniu", + ru = "Ðе удалоÑÑŒ удалить Ñлемент меню", + sk = "Nepodarilo sa mi odinÅ¡talovaÅ¥ odkaz z plochy", + sl = "Odstranitev menija na namizju ni uspela", + sv = "Misslyckades med att ta bort genväg i programmenyn", + tr = "Masaüstü menü öğesi kaldırılamadı", + uk = "Ðеможливо прибрати Ð·Ð°Ð¿Ð¸Ñ Ñƒ меню", + zh_TW = "移除桌é¢é¸å–®é …目失敗" + }; + + -- This is a prompt to the user to type in their product key (CD key, + -- authorization code, etc). + ["Please enter your product key"] = { + cs = "Prosím, zadejte klÃ­Ä produktu", + de = "Bitte geben Sie Ihren Produktschlüssel ein", + en_AU = "Please enter your product key", + en_GB = "Please enter your product key", + es = "Por favor, introduzca su código de producto", + fr = "Veuillez entrer la clé du produit", + he = "יש להכניס ×ת המספר הסידורי שלך", + hu = "Kérem adja meg a termékkódot", + it = "Inserisci la CD Key", + nb = "Skriv inn din produkt nøkkel", + nds = "Bitte geben Sie den Produktschlüssel ein", + nl = "Voer uw productsleutel in", + pt = "Entre com a chave do produto", + ro = "IntroduceÅ£i cheia produsului", + sk = "Prosím vložte váš klÃºÄ produktu", + sv = "Skriv in din produktnyckel", + tr = "Lütfen ürün anahtarını giriniz", + zh_TW = "請輸入你的產å“åºè™Ÿ" + }; + + -- The stdio GUI uses this string when we have a default value that can + -- be chosen instead of the user pressing a potentially-lengthy string + -- of keys. "%0" is the default string that will be used if they just + -- press the enter key on their keyboard. This is a parenthetical phrase, + -- as it won't be shown if there's no default available. + ["(just press enter to use '%0')"] = { + cs = "(stisknÄ›te enter pro použití hodnoty '%0')", + de = "(drücken Sie Enter, um '%0' zu verwenden)", + en_AU = "just press enter to use '%0'", + en_GB = "(just press enter to use '%0')", + es = "(simplemente presione enter para usar '%0')", + fr = "(faites \"entrée\" pour effectuer les opérations suivantes: '%0')", + he = "(רק הקש על Enter בכדי להשתמש ב־'%0')", + it = "Premere invio per utilizzare '%0'", + nb = "(trykk enter for Ã¥ bruke '%0')", + nl = "(druk op enter om '%0' te kiezen)", + pt = "(pressione enter para usar '%0')", + ro = "(apăsaÅ£i enter pentru a folosi '%0')", + sk = "(stlaÄte enter pre '%0')", + sv = "(tryck enter för att använda '%0')", + tr = "('%0' yi kullanmak için giriÅŸe basınız)", + zh_TW = "(請按下 Enter éµä»¥ä½¿ç”¨ '%0')" + }; + + -- This is a message box title when informing the user that their product + -- key (CD key, authorization code, etc) is incorrect, mistyped, or + -- invalid in some way. + ["Invalid product key"] = { + cs = "Neplatný klÃ­Ä produktu", + de = "Ungültiger Produktschlüssel", + en_AU = "Invalid product key", + en_GB = "Invalid product key", + es = "Código de producto inválido", + fr = "La clé du produit est invalide", + he = "המספר סידורי ×ינו תקין", + hu = "Valótan termékkód", + it = "CD key non valida", + nb = "Ugyldig produkt nøkkel", + nds = "Ungültiger Produktschlüssel", + nl = "Foute productsleutel", + pt = "Chave do produto inválida", + ro = "Cheia produsului nu este valida", + sk = "Neplatný kÄ¾ÃºÄ produktu", + sv = "Felaktig produktnyckel", + tr = "Geçersiz ürün anahtarı", + zh_TW = "無效的產å“åºè™Ÿ" + }; + + -- This is the text of a message box informing the user that their product + -- key (CD key, authorization code, etc) is incorrect, mistyped, or + -- invalid in some way, and they should try to type the key again. + ["That key appears to be invalid. Please try again."] = { + cs = "Zadaný klÃ­Ä nevypadá platnÄ›. Zkuste jej prosím zadat znovu.", + de = "Dieser Produktschlüssel scheint ungültig zu sein. Versuchen Sie es bitte noch einmal.", + en_AU = "That key appears to be invalid. Please try again.", + en_GB = "That key appears to be invalid. Please try again.", + es = "El código parece inválido. Por favor, inténtelo de nuevo", + fr = "La clé du produit est invalide, veuillez la ressaisir", + he = "מפתח ×–×” ככל הנר××” שגוי, ×× × × ×¡×” שוב.", + it = "La CD key non sembra valida. Sei pregato di riprovare.", + nb = "Produkt nøkkelen ser ut til Ã¥ være ugylidig. Prøv igjen.", + nds = "Dieser Schlüssel ist ungültig. Bitte versuchen Sie es nochmals.", + nl = "Deze produktsleutel lijkt niet te kloppen. Probeer a.u.b. opnieuw.", + pt = "Esta chave do produto parece ser inválida. Por favor tente novamente.", + ro = "Acea cheie nu este validă. Vă rugăm încercaÅ£i iarăşi.", + sk = "KÄ¾ÃºÄ produktu je neplatný, prosím zadajte nový.", + sv = "Denna produktnyckel verkar felaktig. Försök gärna igen.", + tr = "Ãœrün anahtarı geçersiz görünüyor. Lütfen tekrar deneyin.", + zh_TW = "這組åºè™Ÿä¼¼ä¹Žæ˜¯ç„¡æ•ˆçš„,請å†è¼¸å…¥ä¸€æ¬¡ã€‚" + }; + + -- This is the text of the "Window" menu item, on Mac OS X. + -- This is a standard top-level menu item that contains subitems like + -- "Minimize," "Zoom," and "Bring All to Front." + ["Window"] = { + cs = "Okno", + de = "Fenster", + en_AU = "Window", + en_GB = "Window", + es = "Ventana", + fr = "Fenêtre", + he = "חלון", + hu = "Ablak", + it = "Finestra", + nb = "Vindu", + nl = "Venster", + pt = "Janela", + ro = "Fereastră", + sv = "Fönster", + tr = "Pencere", + zh_TW = "視窗" + }; + + -- This is the text of the "About" menu item, on Mac OS X. + -- This menu item creates a window with basic application information. + -- "%0" is the name of the application ("MyGame Installer" or whatnot), + -- which will be replaced at runtime. + ["About %0"] = { + cs = "O %0", + de = "Ãœber %0", + en_AU = "About %0", + en_GB = "About %0", + es = "Acerca de %0", + fr = "À propos de %0", + he = "×ודות %0", + it = "Informazioni su %0", + nl = "Over %0", + pt = "Sobre o %0", + ro = "Despre %0", + sv = "Om %0", + tr = "%0 Hakkında", + zh_TW = "關於 %0" + }; + + -- This is the text of the "Hide" menu item, on Mac OS X. + -- This menu item makes MojoSetup's windows disappear. + -- "%0" is the name of the application ("MyGame Installer" or whatnot), + -- which will be replaced at runtime. + ["Hide %0"] = { + cs = "Skrýt %0", + de = "Blende %0 aus", + en_AU = "Hide %0", + en_GB = "Hide %0", + es = "Ocultar %0", + fr = "Masquer %0", + he = "הסתרת %0", + it = "Nascondi %0", + nb = "Gjem %0", + nl = "Verberg %0", + pt = "Esconder %0", + ro = "Ascunde %0", + sv = "Dölj %0", + tr = "%0 Gizlensin", + zh_TW = "éš±è— %0" + }; + + -- This is the text of the "Hide Others" menu item, on Mac OS X. + -- This menu item makes every application window except MojoSetup's + -- disappear. + ["Hide Others"] = { + cs = "Skrýt ostatní", + de = "Andere ausblenden", + en_AU = "Hide Others", + en_GB = "Hide Others", + es = "Ocultar Otros", + fr = "Masquer les autres", + he = "הסתרת ×חרי×", + it = "Nascondi le altre", + nb = "Skjul andre", + nl = "Verberg Anderen", + pt = "Ocultar os Outros", + ro = "Ascunde-le pe celelalte", + sv = "Dölj övriga", + tr = "DiÄŸerlerini Gizle", + zh_TW = "éš±è—其它" + }; + + -- This is the text of the "Quit" menu item, on Mac OS X. + -- This menu item requests that the MojoSetup application terminate. + -- "%0" is the name of the application ("MyGame Installer" or whatnot), + -- which will be replaced at runtime. + ["Quit %0"] = { + cs = "UkonÄit %0", + de = "Beende %0", + en_AU = "Quit %0", + en_GB = "Quit %0", + es = "Cerrar %0", + fr = "Quitter %0", + he = "יצי××” מ־Quit", + hu = "Kilépés %0", + it = "Esci da %0", + nb = "Avslutt %0", + nl = "Sluit %0", + pt = "Sair do %0", + ro = "IeÅŸire %0", + sv = "Avsluta %0", + tr = "%0 Çıkış", + zh_TW = "çµæŸ %0" + }; + + -- This is the text of the "Show All" menu item, on Mac OS X. + -- This is a standard menu item that means "redisplay all previously + -- hidden windows". + ["Show All"] = { + cs = "Zobrazit vÅ¡e", + de = "Alle einblenden", + en_AU = "Show All", + en_GB = "Show All", + es = "Mostrar Todos", + fr = "Afficher tout", + he = "הצג הכל", + it = "Mostra Tutto", + nb = "Vis alle", + nl = "Alles weergeven", + pt = "Mostrar Todos", + ro = "Arată tot", + sv = "Visa alla", + tr = "Hepsini Göster", + zh_TW = "顯示全部" + }; + + -- This is the text of the "Services" menu item, on Mac OS X. + -- This is a standard menu item that has submenus for other applications + -- to hook into the current app (for example, Mail.app might appear under + -- this menu item with a means to add a email address, copied to the + -- clipboard, to the user's address book). + ["Services"] = { + cs = "Služby", + de = "Dienste", + en_AU = "Services", + en_GB = "Services", + es = "Servicios", + fr = "Services", + he = "שירותי×", + hu = "Szolgáltatások", + it = "Servizi", + nb = "Tjenester", + nl = "Voorzieningen", + pt = "Serviços", + ro = "Servicii", + sv = "Tjänster", + tr = "Hizmetler", + zh_TW = "æœå‹™" + }; + + -- This is the text of the "Minimize" menu item, on Mac OS X. + -- This is a standard menu item that shrinks the current window so it's + -- not on the desktop any more. + ["Minimize"] = { + cs = "Minimalizovat", + de = "Minimieren", + en_AU = "Minimize", + en_GB = "Minimise", + es = "Minimizar", + fr = "Minimiser", + he = "מיזעור", + hu = "Minimalizálás", + it = "Riduci a icona", + nb = "Minimer", + nl = "Minimaliseren", + pt = "Minimizar", + ro = "Minimizează", + sv = "Minimera", + tr = "Küçült", + zh_TW = "最å°åŒ–" + }; + + -- This is the text of the "Zoom" menu item, on Mac OS X. + -- This is a standard menu item that means "Maximize" on most platforms; + -- make the application's current window as large as reasonably possible. + ["Zoom"] = { + cs = "Maximalizovat", + de = "Vergrößern", + en_AU = "Zoom", + en_GB = "Zoom", + es = "Zoom", + fr = "Zoom", + he = "תקריב", + hu = "Nagyítás", + it = "Massimizza", + nb = "Forstørr", + nl = "Vergroten", + pt = "Ampliar", + ro = "Mărire", + sv = "Maximera", + tr = "Büyüt", + zh_TW = "縮放" + }; + + -- This is the text of the "Bring All to Front" menu item, on Mac OS X. + -- This is a standard menu item that brings all MojoSetup application + -- windows to the top of the desktop's window stack. + ["Bring All to Front"] = { + cs = "PÅ™enést vÅ¡e do popÅ™edí", + de = "Alle in den Vordergrund", + en_AU = "Bring All to Front", + en_GB = "Bring All to Front", + es = "Traer Todo al Frente", + fr = "Tout ramener au premier plan", + he = "×§×“× ×”×›×œ לחזית", + it = "Porta tutto in primo piano", + nb = "Flytt Alt Fram", + nl = "Alles op Voorgrond", + pt = "Trazer Todos Para a Frente", + ro = "AfiÅŸează toate în primplan", + tr = "Hepsini Öne Getir", + zh_TW = "將所有視窗移至最上層" + }; +}; + +-- end of localization.lua ... + diff --git a/mk/linux/mojosetup/scripts/mojosetup_init.lua b/mk/linux/mojosetup/scripts/mojosetup_init.lua new file mode 100644 index 00000000..4454a02c --- /dev/null +++ b/mk/linux/mojosetup/scripts/mojosetup_init.lua @@ -0,0 +1,586 @@ +-- MojoSetup; a portable, flexible installation application. +-- +-- Please see the file LICENSE.txt in the source's root directory. +-- +-- This file written by Ryan C. Gordon. + + +-- !!! FIXME: go through the schema and ditch loki_setup things we don't want. + +-- These are various things that need to be exposed to Lua, or are just +-- better written in Lua than C. All work will be done in the "MojoSetup" +-- table (for generic functionality) or the "Setup" table (for config file +-- elements), so the rest of the namespace is available to end-user code, +-- minus what the Lua runtime claims for itself. +-- +-- This file is loaded and executed at MojoSetup startup. The Base Archive, +-- GUI, and Lua are initialized, the MojoSetup table is created and has some +-- initial CFunctions and such inserted. The localization script runs, and +-- then this code executes to do the heavy lifting. All Lua state should be +-- sane for the rest of the app once this script successfully completes. + +local _ = MojoSetup.translate + +-- Set up the garbage counter. Things that are done in possibly long-running +-- loops that create a lot of junk can optionally set a threshold and call +-- MojoSetup.incrementgarbagecounter() on each iteration. Whenever you hit +-- the threshold, garbage collection runs and resets the counter. This keeps +-- memory usage from spiraling out of control for pathological cases. +-- Note that the counter resets in MojoSetup.collectgarbage() itself, so you +-- don't have to worry about the counter accumulating and firing off extra +-- unnecessary collections if you happen to hit a loop at the wrong time. +MojoSetup.garbagecounter = 0 +MojoSetup.garbagethreshold = 500 + +function MojoSetup.incrementgarbagecount() + MojoSetup.garbagecounter = MojoSetup.garbagecounter + 1 + if MojoSetup.garbagecounter >= MojoSetup.garbagethreshold then + MojoSetup.collectgarbage() + end +end + +-- Returns three elements: protocol, host, path +function MojoSetup.spliturl(url) + return string.match(url, "^(.+://)(.-)/(.*)") +end + + +-- This is MojoSetup.stringtofile() for string tables. +function MojoSetup.stringtabletofile(t, dest, perms, len, callback) + -- !!! FIXME: We could do this entirely in C to avoid a concatenated + -- !!! FIXME: string on the Lua heap. + return MojoSetup.stringtofile(table.concat(t), dest, perms, len, callback) +end + + +-- This is handy for debugging. +function MojoSetup.dumptable(tabname, tab, depth) + if depth == nil then -- first call, before any recursion? + local loglevel = MojoSetup.info.loglevel + if (loglevel ~= "debug") and (loglevel ~= "everything") then + return -- don't spend time on this if there's no output... + end + depth = 1 + end + + if tabname ~= nil then + if tab == nil then + MojoSetup.logdebug(tabname .. " = nil") + return + else + MojoSetup.logdebug(tabname .. " = {") + end + end + + local depthstr = "" + for i=1,(depth*4) do + depthstr = depthstr .. " " + end + + if tab.MOJOSETUP_DUMPTABLE_ITERATED then + MojoSetup.logdebug(depthstr .. "(...circular reference...)") + else + tab.MOJOSETUP_DUMPTABLE_ITERATED = true + for k,v in pairs(tab) do + if type(v) == "table" then + MojoSetup.logdebug(depthstr .. tostring(k) .. " = {") + MojoSetup.dumptable(nil, v, depth + 1) + MojoSetup.logdebug(depthstr .. "}") + else + if k ~= "MOJOSETUP_DUMPTABLE_ITERATED" then + MojoSetup.logdebug(depthstr .. tostring(k) .. " = " .. tostring(v)) + end + end + end + tab.MOJOSETUP_DUMPTABLE_ITERATED = nil + end + + if tabname ~= nil then + MojoSetup.logdebug("}") + end +end + + +-- Our namespace for config API... +Setup = {} + +local function schema_assert(test, fnname, elem, errstr) + if not test then + local msg = MojoSetup.format(_("BUG: Config %0 %1"), + fnname .. "::" .. elem, errstr) + MojoSetup.fatal(msg) + end +end + +local function mustExist(fnname, elem, val) + schema_assert(val ~= nil, fnname, elem, _("must be explicitly specified")) +end + +local function mustBeSomething(fnname, elem, val, elemtype) + -- Can be nil...please use mustExist if this is a problem! + if val ~= nil then + if type(val) ~= elemtype then + local msg = MojoSetup.format(_("must be %0"), + MojoSetup.translate(elemtype)) + schema_assert(false, fnname, elem, msg) + end + end +end + +local function mustBeString(fnname, elem, val) + mustBeSomething(fnname, elem, val, "string") +end + +local function mustBeBool(fnname, elem, val) + mustBeSomething(fnname, elem, val, "boolean") +end + +local function mustBeNumber(fnname, elem, val) + mustBeSomething(fnname, elem, val, "number") +end + +local function mustBeFunction(fnname, elem, val) + mustBeSomething(fnname, elem, val, "function") +end + +local function mustBeTable(fnname, elem, val) + mustBeSomething(fnname, elem, val, "table") +end + +local function cantBeEmpty(fnname, elem, val) + -- Can be nil...please use mustExist if this is a problem! + if val ~= nil then + schema_assert(val ~= "", fnname, elem, _("can't be empty string")) + end +end + +local function mustBeStringOrTableOfStrings(fnname, elem, val) + -- Can be nil...please use mustExist if this is a problem! + if val ~= nil then + local err = _("must be string or table of strings") + if type(val) == "string" then + val = { val } + end + schema_assert(type(val) == "table", fnname, elem, err) + for k,v in pairs(val) do + schema_assert(type(v) == "string", fnname, elem, err) + end + end +end + +local function mustBeStringOrNumber(fnname, elem, val) + -- Can be nil...please use mustExist if this is a problem! + if val ~= nil then + local t = type(val) + schema_assert((t == "string") or (t == "number"), fnname, elem, + _("must be a string or number")) + end +end + +local function mustBeUrl(fnname, elem, val) + mustBeString(fnname, elem, val) + cantBeEmpty(fnname, elem, val) + if (val ~= nil) then + local prot,host,path = MojoSetup.spliturl(val) + schema_assert(prot ~= nil,fnname,elem,_("URL doesn't have protocol")) + schema_assert(host ~= nil,fnname,elem,_("URL doesn't have host")) + schema_assert(path ~= nil,fnname,elem,_("URL doesn't have path")) + prot = string.gsub(prot, "://$", "") + local supported = MojoSetup.info.supportedurls[prot] + schema_assert(supported,fnname,elem,_("URL protocol is unsupported")) + end +end + +local function mustBeSplashPosition(fnname, elem, val) + mustBeString(fnname, elem, val) + local valid = (val == nil) or (val == "right") or (val == "bottom") or + (val == "left") or (val == "top") or (val == "background"); + schema_assert(valid, fnname, elem, _("Splash position is invalid")) +end + +local function mustBePerms(fnname, elem, val) + mustBeString(fnname, elem, val) + local valid = MojoSetup.isvalidperms(val) + schema_assert(valid, fnname, elem, _("Permission string is invalid")) +end + +local function mustBeValidProductKeyFormat(fnname, elem, val) + -- Can be nil...please use mustExist if this is a problem! + if val ~= nil then + mustBeString(fnname, elem, val) + cantBeEmpty(fnname, elem, val) + local valid = (string.match(val, "^[X#%*%? %-]*$") ~= nil) + schema_assert(valid, fnname, elem, _("invalid string")) + end +end + +local function sanitize(fnname, tab, elems) + mustBeTable(fnname, "", tab) + tab._type_ = string.lower(fnname) .. "s" -- "Eula" becomes "eulas". + for i,elem in ipairs(elems) do + local child = elem[1] + local defval = elem[2] + + if tab[child] == nil and defval ~= nil then + tab[child] = defval + end + local j = 3 + while elem[j] do + elem[j](fnname, child, tab[child]) -- will assert on problem. + j = j + 1 + end + end + + local notvaliderr = _("is not a valid property") + for k,v in pairs(tab) do + local found = false + if k == "_type_" then + found = true + elseif (type(k) == "number") and (type(v) == "table") then + found = true + else + for i,elem in ipairs(elems) do + local child = elem[1] + if (child == k) then + found = true + break + end + end + end + schema_assert(found, fnname, k, notvaliderr) + end + + return tab +end + +local function reform_schema_table(tab) + local killlist = {} + for k,v in pairs(tab) do + local ktype = type(k) + local vtype = type(v) + if (ktype == "number") and (vtype == "table") and (v._type_ ~= nil) then + -- add element to proper named array. + local typestr = v._type_ + v._type_ = nil + MojoSetup.logdebug("schema: reforming '" .. typestr .. "', '" .. k .. "'") + if tab[typestr] == nil then + tab[typestr] = { v } + else + table.insert(tab[typestr], v) + end + -- can't just set tab[k] to nil here, since it screws up pairs()... + killlist[#killlist+1] = k + elseif vtype == "table" then + tab[k] = reform_schema_table(v) + end + end + + for i,v in ipairs(killlist) do + tab[v] = nil + end + + return tab +end + + +-- Actual schema elements are below... + +function Setup.Package(tab) + -- !!! FIXME: allow_uninstall + -- !!! FIXME: write_manifest + -- !!! FIXME: allow_uninstall must check write_manifest, write_manifest + -- !!! FIXME: must check for Lua parser support...or something like that. + + tab = sanitize("Package", tab, + { + { "vendor", nil, mustExist, mustBeString, cantBeEmpty }, + { "id", nil, mustExist, mustBeString, cantBeEmpty }, + { "disabled", nil, mustBeBool }, + { "description", nil, mustExist, mustBeString, cantBeEmpty }, + { "version", nil, mustExist, mustBeString, cantBeEmpty }, + { "destination", nil, mustBeString, cantBeEmpty }, + { "recommended_destinations", nil, mustBeStringOrTableOfStrings }, + { "precheck", nil, mustBeFunction }, + { "preflight", nil, mustBeFunction }, + { "preinstall", nil, mustBeFunction }, + { "postinstall", nil, mustBeFunction }, + { "splash", nil, mustBeString, cantBeEmpty }, + { "splashpos", nil, mustBeSplashPosition }, + { "url", nil, mustBeString, cantBeEmpty }, + { "once", true, mustBeBool }, + { "category", "Games", mustBeString, cantBeEmpty }, + { "promptoverwrite", true, mustBeBool }, + { "binarypath", nil, mustBeString, cantBeEmpty }, + { "updateurl", nil, mustBeUrl }, + { "superuser", false, mustBeBool }, + { "write_manifest", true, mustBeBool }, + { "support_uninstall", true, mustBeBool }, + { "preuninstall", nil, mustBeFunction }, + { "postuninstall", nil, mustBeFunction } + }) + + if MojoSetup.installs == nil then + MojoSetup.installs = {} + end + + tab._type_ = nil + tab = reform_schema_table(tab) + table.insert(MojoSetup.installs, tab) + return tab + +--[[ + promptbinaries When set to "yes", setup will create a checkbox + to allow the user whether or not to create + a symbolic link to the binaries. + + This setting has no effect if nobinaries is "yes". + + meta When this attribute is set to "yes", then setup will act as + a meta-installer, i.e. it will allow the user to select a + product and set-up will respawn itself for the selected + product installation. + See the section "About Meta-Installation" below. + + component When this attribute is present, its value is the name of the component + that will created by this installer. This means that the files will be added + to an existing installation of the product, and that basic configuration parameters + such as the installation path will be used from the previous installation. + Currently setup is not able to update an existing component, thus if the component + is detected as already installed the installation will fail. + Important: This attribute can't be mixed with elements. + + appbundle (CARBON ONLY) If this is "yes", the destination folder does not include the product + name as part of the path. An application bundle is typically installed much like + a single file would be...and so is treated as such. + + The app bundle path usually specified in the "path" attribute of the "files" element, + or it is specified in the archives directly. + + manpages If set to "yes", then the user will be prompted for the install pages installation path. + Should be used when using the MANPAGE element described below. + + appbundleid (CARBON ONLY) This string means that you are installing new files into an existing + Application Bundle. If the bundle isn't found, the installation aborts, otherwise, all + files are added relative to the base of the app bundle. The string specified here is + the app bundle's CFBundleIdentifier entry in its Info.plist file. LaunchServices are + used to find the bundle and the user can be prompted to manually locate the product + if LaunchServices fails to find it. This is all MacOS-specific, and unrelated to the + "component" attribute. + + appbundledesc (CARBON ONLY) This string is used with the "appbundleid" attribute...it's a human + readable text describing the app bundle in question. +]]-- + +end + +function Setup.Eula(tab) + return sanitize("Eula", tab, + { + { "description", nil, mustExist, mustBeString, cantBeEmpty }, + { "source", nil, mustExist, mustBeString, cantBeEmpty }, + }) +end + +function Setup.Readme(tab) + return sanitize("Readme", tab, + { + { "description", nil, mustExist, mustBeString, cantBeEmpty }, + { "source", nil, mustExist, mustBeString, cantBeEmpty }, + }) +end + +function Setup.ProductKey(tab) + return sanitize("ProductKey", tab, + { + { "description", nil, mustExist, mustBeString, cantBeEmpty }, + { "format", nil, mustBeValidProductKeyFormat }, + { "verify", nil, mustBeFunction }, + { "destination", nil, mustBeString, cantBeEmpty }, + }) +end + +function Setup.Media(tab) + return sanitize("Media", tab, + { + { "id", nil, mustExist, mustBeString, cantBeEmpty }, + { "description", nil, mustExist, mustBeString, cantBeEmpty }, + { "uniquefile", nil, mustExist, mustBeString, cantBeEmpty }, + }) +end + +function Setup.File(tab) + return sanitize("File", tab, + { + { "source", nil, mustBeUrl }, + { "destination", nil, mustBeString, cantBeEmpty }, + { "wildcards", nil, mustBeStringOrTableOfStrings }, + { "filter", nil, mustBeFunction }, + { "allowoverwrite", nil, mustBeBool }, + { "permissions", nil, mustBePerms }, + }) +end + +function Setup.Option(tab) + return sanitize("Option", tab, + { + { "value", false, mustBeBool }, + { "required", false, mustBeBool }, + { "disabled", false, mustBeBool }, + { "bytes", nil, mustExist, mustBeNumber }, + { "description", nil, mustExist, mustBeString, cantBeEmpty }, + { "tooltip", nil, mustBeString, cantBeEmpty }, + }) +end + +function Setup.OptionGroup(tab) + return sanitize("OptionGroup", tab, + { + { "disabled", nil, mustBeBool }, + { "description", nil, mustExist, mustBeString, cantBeEmpty }, + { "tooltip", nil, mustBeString, cantBeEmpty }, + }) +end + +function Setup.DesktopMenuItem(tab) + return sanitize("DesktopMenuItem", tab, + { + { "disabled", nil, mustBeBool }, + { "name", nil, mustExist, mustBeString, cantBeEmpty }, + { "genericname", nil, mustExist, mustBeString, cantBeEmpty }, + { "tooltip", nil, mustExist, mustBeString, cantBeEmpty }, + { "builtin_icon", nil, mustBeBool }, + { "icon", nil, mustExist, mustBeString, cantBeEmpty }, + { "commandline", nil, mustExist, mustBeString, cantBeEmpty }, + { "category", nil, mustExist, mustBeStringOrTableOfStrings }, + { "mimetype", nil, mustBeStringOrTableOfStrings }, + }) +end + +local function prepare_localization() + -- Map some legacy language identifiers into updated equivalents. + local lang_remap = + { + no = "nb", -- "Norwegian" split into "Bokmal" (nb) and "Nynorsk" (nn) + } + + local function sanity_check_localization_entry(str, translations) + local maxval = -1; + + for val in string.gmatch(str, "%%.") do + val = string.sub(val, 2) + if string.match(val, "^[^%%0-9]$") ~= nil then + MojoSetup.fatal("BUG: localization key ['" .. str .. "'] has invalid escape sequence.") + end + if val ~= "%" then + local num = tonumber(val) + if num > maxval then + maxval = num + end + end + end + + for k,v in pairs(translations) do + for val in string.gmatch(v, "%%.") do + val = string.sub(val, 2) + if string.match(val, "^[^%%0-9]$") ~= nil then + MojoSetup.fatal("BUG: '" .. k .. "' localization ['" .. v .. "'] has invalid escape sequence for translation of ['" .. str .. "'].") + end + if val ~= "%" then + if tonumber(val) > maxval then + MojoSetup.fatal("BUG: '" .. k .. "' localization ['" .. v .. "'] has escape sequence > max for translation of ['" .. str .. "'].") + end + end + end + end + end + + -- Build the translations table from the localizations table supplied in + -- localizations.lua... + if type(MojoSetup.localization) ~= "table" then + MojoSetup.localization = nil + end + + -- Merge the applocalization table into localization. + if type(MojoSetup.applocalization) == "table" then + if MojoSetup.localization == nil then + MojoSetup.localization = {} + end + for k,v in pairs(MojoSetup.applocalization) do + if MojoSetup.localization[k] == nil then + MojoSetup.localization[k] = v -- just take the whole table as-is. + else + -- This can add or overwrite entries... + for lang,str in pairs(v) do + MojoSetup.localization[k][lang] = str + end + end + end + end + MojoSetup.applocalization = nil -- done with this; garbage collect it. + + if MojoSetup.localization ~= nil then + local at_least_one = false + local locale = MojoSetup.info.locale + local lang = string.gsub(locale, "_%w+", "", 1) -- make "en_US" into "en" + + if lang_remap[lang] ~= nil then + lang = lang_remap[lang] + end + + MojoSetup.translations = {} + for k,v in pairs(MojoSetup.localization) do + if MojoSetup.translations[k] ~= nil then + MojoSetup.fatal("BUG: Duplicate localization key ['" .. k .. "']") + end + if type(v) == "table" then + sanity_check_localization_entry(k, v) + if v[locale] ~= nil then + MojoSetup.translations[k] = v[locale] + at_least_one = true + elseif v[lang] ~= nil then + MojoSetup.translations[k] = v[lang] + at_least_one = true + end + end + end + + -- Delete the table if there's no actual useful translations for this run. + if (not at_least_one) then + MojoSetup.translations = nil + end + + -- This is eligible for garbage collection now. We're done with it. + MojoSetup.localization = nil + end +end + + +-- Mainline... + +MojoSetup.loginfo("MojoSetup Lua initialization at " .. MojoSetup.date()) +MojoSetup.loginfo("buildver: " .. MojoSetup.info.buildver) +MojoSetup.loginfo("locale: " .. MojoSetup.info.locale) +MojoSetup.loginfo("platform: " .. MojoSetup.info.platform) +MojoSetup.loginfo("arch: " .. MojoSetup.info.arch) +MojoSetup.loginfo("ostype: " .. MojoSetup.info.ostype) +MojoSetup.loginfo("osversion: " .. MojoSetup.info.osversion) +MojoSetup.loginfo("ui: " .. MojoSetup.info.ui) +MojoSetup.loginfo("loglevel: " .. MojoSetup.info.loglevel) + +MojoSetup.loginfo("command line:") +for i,v in ipairs(MojoSetup.info.argv) do + MojoSetup.loginfo(" " .. i .. ": " .. v) +end + +--MojoSetup.loginfo(MojoSetup.info.license) +--MojoSetup.loginfo(MojoSetup.info.lualicense) + +-- These scripts are optional, but hopefully exist... +MojoSetup.runfile("localization") +MojoSetup.runfile("app_localization") +prepare_localization() + +-- okay, we're initialized! + +-- end of mojosetup_init.lua ... + diff --git a/mk/linux/mojosetup/scripts/mojosetup_mainline.lua b/mk/linux/mojosetup/scripts/mojosetup_mainline.lua new file mode 100644 index 00000000..28712180 --- /dev/null +++ b/mk/linux/mojosetup/scripts/mojosetup_mainline.lua @@ -0,0 +1,2082 @@ +-- MojoSetup; a portable, flexible installation application. +-- +-- Please see the file LICENSE.txt in the source's root directory. +-- +-- This file written by Ryan C. Gordon. + + +-- This is where most of the magic happens. Everything is initialized, and +-- the user's config script has successfully run. This Lua chunk drives the +-- main application code. + +-- !!! FIXME: add a --dryrun option. + +local _ = MojoSetup.translate + +MojoSetup.metadatakey = ".mojosetup_metadata." +MojoSetup.metadatadesc = _("Metadata") +MojoSetup.metadatadirname = ".mojosetup" + +if MojoSetup.info.platform == "windows" then + MojoSetup.controlappname = "mojosetup.exe" +else + MojoSetup.controlappname = "mojosetup" +end + + +local function badcmdline() + MojoSetup.fatal(_("Invalid command line")) +end + + +-- This currently counts on (base) ending with a single "/", and not having +-- any strange distortions: "/blah/../blah/.//" would not match "/blah/x", +-- although it _should_ if we parsed it out. +local function make_relative(fname, base) + local baselen = string.len(base) + if string.sub(fname, 0, baselen) == base then + fname = string.sub(fname, baselen+2) -- make it relative. + end + return fname +end + + +local function manifest_resync(man, fname, _key) + if fname == nil then return end + + local fullpath = fname + fname = make_relative(fname, MojoSetup.destination) + + if man[fname] == nil then + MojoSetup.logwarning("Tried to resync unknown file '" ..fname.. "' in manifest!") + else + local perms = "0644" -- !!! FIXME MojoSetup.platform.perms(fullpath) + local sums = nil + local lndest = nil + local ftype = nil + + if MojoSetup.platform.issymlink(fullpath) then + ftype = "symlink" + -- !!! FIXME: linkdest? + elseif MojoSetup.platform.isdir(fullpath) then + ftype = "dir" + else -- !!! FIXME: other types? + ftype = "file" + sums = MojoSetup.checksum(fullpath) + end + + man[fname] = + { + key = _key, + type = ftype, + mode = perms, + checksums = sums, + linkdest = lndest + } + + MojoSetup.logwarning("Resync'd file '" ..fname.. "' in manifest") + end +end + + +-- !!! FIXME: I need to go back from managing everything installed through +-- !!! FIXME: the manifest to a separate table of "things written to disk +-- !!! FIXME: on just this run" ... the existing manifest code can stay as-is, +-- !!! FIXME: rollbacks should be done exclusively from that other table. +-- !!! FIXME: Right now we're relying on dumb stuff like sorting the filenames +-- !!! FIXME: to get a safe deletion order on revert, but we should just +-- !!! FIXME: keep a chronological array instead. + +local function manifest_add(man, fname, _key, ftype, mode, sums, lndest) + if (fname ~= nil) and (_key ~= nil) then + local destlen = string.len(MojoSetup.destination) + if string.sub(fname, 0, destlen) == MojoSetup.destination then + fname = string.sub(fname, destlen+2) -- make it relative. + end + + if man[fname] ~= nil then + MojoSetup.logwarning("Overwriting file '" .. fname .. "' in manifest!") + end + + man[fname] = { + key = _key, + type = ftype, + mode = perms, + checksums = sums, + linkdest = lndest + } + end +end + + +local function manifest_delete(man, fname) + if fname ~= nil then + local destlen = string.len(MojoSetup.destination) + if string.sub(fname, 0, destlen) == MojoSetup.destination then + fname = string.sub(fname, destlen+2) -- make it relative. + end + + if man[fname] == nil then + MojoSetup.logwarning("Deleting unknown file '" .. fname .. "' from manifest!") + else + man[fname] = nil + end + end +end + + +local function flatten_list(list) + local retval = list + if type(list) == "table" then + retval = {} + for i,v in ipairs(list) do + if #retval == 0 then + retval[1] = v + else + retval[#retval+1] = ';' + retval[#retval+1] = v + end + end + retval = table.concat(retval) + end + return retval +end + + +local function do_delete(fname) + local retval = false + if fname == nil then + retval = true + else + -- Try to unlink() first, so we'll catch broken symlinks, then try + -- exists(): if it really wasn't there, we'll call it success anyhow. + if MojoSetup.platform.unlink(fname) then + MojoSetup.loginfo("Deleted '" .. fname .. "'") + retval = true + elseif not MojoSetup.platform.exists(fname) then + retval = true + end + end + return retval +end + + +local function delete_files(filelist, callback, error_is_fatal) + if filelist ~= nil then + local max = #filelist + for i = max,1,-1 do + local fname = filelist[i] + if not do_delete(fname) and error_is_fatal then + MojoSetup.fatal(_("Deletion failed!")) + end + + if callback ~= nil then + callback(fname, i, max) + end + end + end +end + +local function delete_rollbacks() + if MojoSetup.rollbacks == nil then + return + end + local fnames = {} + local max = #MojoSetup.rollbacks + for id = 1,max,1 do + fnames[id] = MojoSetup.rollbackdir .. "/" .. id + end + MojoSetup.rollbacks = {} -- just in case this gets called again... + delete_files(fnames) -- !!! FIXME: callback for gui queue pump? +end + +local function delete_scratchdirs() + do_delete(MojoSetup.downloaddir) + do_delete(MojoSetup.rollbackdir) + do_delete(MojoSetup.scratchdir) -- must be after dirs it contains! + do_delete(MojoSetup.metadatadir) -- must be last! (and is okay to fail.) +end + + +local function do_rollbacks() + if MojoSetup.rollbacks == nil then + return + end + + local max = #MojoSetup.rollbacks + for id = max,1,-1 do + local src = MojoSetup.rollbackdir .. "/" .. id + local dest = MojoSetup.rollbacks[id] + if not MojoSetup.movefile(src, dest) then + -- we're already in fatal(), so we can only throw up a msgbox... + MojoSetup.msgbox(_("Serious problem"), + _("Couldn't restore some files. Your existing installation is likely damaged.")) + end + MojoSetup.loginfo("Restored rollback #" .. id .. ": '" .. src .. "' -> '" .. dest .. "'") + end + + MojoSetup.rollbacks = {} -- just in case this gets called again... +end + + +-- get a linear array of filenames in the manifest. +local function flatten_manifest(man, postprocess) + local files = {} + if postprocess == nil then + postprocess = function(x) return x end + end + if man ~= nil then + for fname,items in pairs(man) do + files[#files+1] = postprocess(fname) + end + end + + table.sort(files, function(a,b) return MojoSetup.strcmp(a,b) < 0 end) + return files +end + + +local function prepend_dest_dir(fname) + if fname == "" then + return MojoSetup.destination + end + return MojoSetup.destination .. "/" .. fname +end + + +-- This gets called by fatal()...must be a global function. +function MojoSetup.revertinstall() + -- (The real revertinstall is set later. This is a stub for startup.) +end + + +local function calc_percent(current, total) + if total == 0 then + return 0 + elseif total < 0 then + return -1 + end + + local retval = MojoSetup.truncatenum((current / total) * 100) + if retval > 100 then + retval = 100 + elseif retval < 0 then + retval = 0 + end + return retval +end + + +local function make_rate_string(rate, bw, total) + local retval = nil + + if rate <= 0 then + retval = _("stalled") + else + local ratetype = _("B/s") + if rate > 1024 then + rate = MojoSetup.truncatenum(rate / 1024) + ratetype = _("KB/s") + end + + if total > 0 then -- can approximate time left if we know the goal. + local bytesleft = total - bw + local secsleft = MojoSetup.truncatenum(bytesleft / rate) + local minsleft = MojoSetup.truncatenum(secsleft / 60) + local hoursleft = MojoSetup.truncatenum(minsleft / 60) + + secsleft = string.sub("00" .. (secsleft - (minsleft * 60)), -2) + minsleft = string.sub("00" .. (minsleft - (hoursleft * 60)), -2) + + if hoursleft < 10 then + hoursleft = "0" .. hoursleft + else + hoursleft = tostring(hoursleft) + end + + retval = MojoSetup.format(_("%0 %1, %2:%3:%4 remaining"), + rate, ratetype, + hoursleft, minsleft, secsleft) + else + retval = MojoSetup.format(_("%0 %1"), rate, ratetype) + end + end + + return retval +end + + +local function split_path(path) + local retval = {} + for item in string.gmatch(path .. "/", "(.-)/") do + if item ~= "" then + retval[#retval+1] = item + end + end + return retval +end + +local function rebuild_path(paths, n) + local retval = paths[n] + n = n + 1 + while paths[n] ~= nil do + retval = retval .. "/" .. paths[n] + n = n + 1 + end + return retval +end + +local function normalize_path(path) + return rebuild_path(split_path(path), 1) +end + + +local function close_archive_list(arclist) + for i = #arclist,1,-1 do + MojoSetup.archive.close(arclist[i]) + arclist[i] = nil + end +end + + +-- This code's a little nasty... +local function drill_for_archive(archive, path, arclist) + if not MojoSetup.archive.enumerate(archive) then + MojoSetup.fatal(_("Couldn't enumerate archive")) + end + + local pathtab = split_path(path) + local ent = MojoSetup.archive.enumnext(archive) + while ent ~= nil do + if ent.type == "file" then + local i = 1 + local enttab = split_path(ent.filename) + while (enttab[i] ~= nil) and (enttab[i] == pathtab[i]) do + i = i + 1 + end + + if enttab[i] == nil then + -- It's a file that makes up some of the specified path. + -- open it as an archive and keep drilling... + local arc = MojoSetup.archive.fromentry(archive) + if arc == nil then + MojoSetup.fatal(_("Couldn't open archive")) + end + arclist[#arclist+1] = arc + if pathtab[i] == nil then + return arc -- this is the end of the path! Done drilling! + end + return drill_for_archive(arc, rebuild_path(pathtab, i), arclist) + end + end + ent = MojoSetup.archive.enumnext(archive) + end + + MojoSetup.fatal(_("Archive not found")) +end + + +local function install_file(dest, perms, writefn, desc, manifestkey) + -- Upvalued so we don't look these up each time... + local fname = string.gsub(dest, "^.*/", "", 1) -- chop the dirs off... + local ptype = _("Installing") + local component = desc + local keepgoing = true + local callback = function(ticks, justwrote, bw, total) + local percent = -1 + local item = fname + if total >= 0 then + MojoSetup.written = MojoSetup.written + justwrote + percent = calc_percent(MojoSetup.written, MojoSetup.totalwrite) + item = MojoSetup.format(_("%0: %1%%"), fname, calc_percent(bw, total)) + end + keepgoing = MojoSetup.gui.progress(ptype, component, percent, item, true) + return keepgoing + end + + -- !!! FIXME: maybe keep a separate list, so we can rollback installs + -- !!! FIXME: that are building on previous installations? + -- Add to manifest first, so we can delete it during rollback if i/o fails. + -- !!! FIXME: perms may be nil...we need a MojoSetup.defaultPermsString()... + manifest_add(MojoSetup.manifest, dest, manifestkey, "file", perms, nil, nil) + + MojoSetup.gui.progressitem() + local written, sums = writefn(callback) + if not written then + if not keepgoing then + MojoSetup.logerror("User cancelled install during file write.") + MojoSetup.fatal() + else + MojoSetup.logerror("Failed to create file '" .. dest .. "'") + MojoSetup.fatal(_("File creation failed!")) + end + end + + -- Readd it to the manifest, now with a checksum! + if manifestkey ~= nil then + manifest_delete(MojoSetup.manifest, dest) + manifest_add(MojoSetup.manifest, dest, manifestkey, "file", perms, sums, nil) + end + + MojoSetup.loginfo("Created file '" .. dest .. "'") + MojoSetup.incrementgarbagecount() +end + + +local function install_file_from_archive(dest, archive, perms, desc, manifestkey) + local fn = function(callback) + return MojoSetup.writefile(archive, dest, perms, nil, callback) + end + return install_file(dest, perms, fn, desc, manifestkey) +end + + +local function install_file_from_stringtable(dest, t, perms, desc, manifestkey) + local fn = function(callback) + return MojoSetup.stringtabletofile(t, dest, perms, nil, callback) + end + return install_file(dest, perms, fn, desc, manifestkey) +end + + +local function install_file_from_string(dest, str, perms, desc, manifestkey) + local fn = function(callback) + return MojoSetup.stringtofile(str, dest, perms, nil, callback) + end + return install_file(dest, perms, fn, desc, manifestkey) +end + + +local function install_file_from_filesystem(dest, src, perms, desc, manifestkey, maxbytes) + local fn = function(callback) + return MojoSetup.copyfile(src, dest, perms, maxbytes, callback) + end + return install_file(dest, perms, fn, desc, manifestkey) +end + + +-- !!! FIXME: we should probably pump the GUI queue here, in case there are +-- !!! FIXME: thousands of symlinks in a row or something. +local function install_symlink(dest, lndest, manifestkey) + if not MojoSetup.platform.symlink(dest, lndest) then + MojoSetup.logerror("Failed to create symlink '" .. dest .. "'") + MojoSetup.fatal(_("Symlink creation failed!")) + end + + manifest_add(MojoSetup.manifest, dest, manifestkey, "symlink", nil, nil, lndest) + MojoSetup.loginfo("Created symlink '" .. dest .. "' -> '" .. lndest .. "'") +end + + +-- !!! FIXME: we should probably pump the GUI queue here, in case there are +-- !!! FIXME: thousands of dirs in a row or something. +local function install_directory(dest, perms, manifestkey) + -- Chop any '/' chars from the end of the string... + dest = string.gsub(dest, "/+$", "") + + if not MojoSetup.platform.mkdir(dest, perms) then + MojoSetup.logerror("Failed to create dir '" .. dest .. "'") + MojoSetup.fatal(_("Directory creation failed")) + end + + manifest_add(MojoSetup.manifest, dest, manifestkey, "directory", perms, nil, nil) + MojoSetup.loginfo("Created directory '" .. dest .. "'") +end + + +local function install_parent_dirs(path, manifestkey) + -- Chop any '/' chars from the end of the string... + path = string.gsub(path, "/+$", "") + + -- Build each piece of final path. The gmatch() skips the last element. + local fullpath = "" + for item in string.gmatch(path, "(.-)/") do + if item ~= "" then + fullpath = fullpath .. "/" .. item + if not MojoSetup.platform.exists(fullpath) then + install_directory(fullpath, nil, manifestkey) + end + end + end +end + + +local function permit_write(dest, entinfo, file) + local allowoverwrite = true + if MojoSetup.platform.exists(dest) then + -- never "permit" existing dirs, so they don't rollback. + if entinfo.type == "dir" then + allowoverwrite = false + else + if MojoSetup.forceoverwrite ~= nil then + allowoverwrite = MojoSetup.forceoverwrite + else + -- !!! FIXME: option/package-wide overwrite? + allowoverwrite = file.allowoverwrite + if not allowoverwrite then + MojoSetup.loginfo("File '" .. dest .. "' already exists.") + local text = MojoSetup.format(_("File '%0' already exists! Replace?"), dest) + local ynan = MojoSetup.promptynan(_("Conflict!"), text, true) + if ynan == "always" then + MojoSetup.forceoverwrite = true + allowoverwrite = true + elseif ynan == "never" then + MojoSetup.forceoverwrite = false + allowoverwrite = false + elseif ynan == "yes" then + allowoverwrite = true + elseif ynan == "no" then + allowoverwrite = false + end + end + end + + -- !!! FIXME: Setup.File.mustoverwrite to override "never"? + + if allowoverwrite then + local id = #MojoSetup.rollbacks + 1 + local f = MojoSetup.rollbackdir .. "/" .. id + install_parent_dirs(f, MojoSetup.metadatakey) + MojoSetup.rollbacks[id] = dest + if not MojoSetup.movefile(dest, f) then + MojoSetup.fatal(_("Couldn't backup file for rollback")) + end + MojoSetup.loginfo("Moved rollback #" .. id .. ": '" .. dest .. "' -> '" .. f .. "'") + + -- Make sure this isn't already in the manifest... + if MojoSetup.manifest[dest] ~= nil then + manifest_delete(MojoSetup.manifest, dest) + end + end + end + end + + return allowoverwrite +end + + +local function install_archive_entity(dest, ent, archive, desc, manifestkey, perms) + install_parent_dirs(dest, manifestkey) + if ent.type == "file" then + install_file_from_archive(dest, archive, perms, desc, manifestkey) + elseif ent.type == "dir" then + install_directory(dest, perms, manifestkey) + elseif ent.type == "symlink" then + install_symlink(dest, ent.linkdest, manifestkey) + else -- !!! FIXME: device nodes, etc... + -- !!! FIXME: should this be fatal? + MojoSetup.fatal(_("Unknown file type in archive")) + end +end + + +local function install_archive_entry(archive, ent, file, option) + local entdest = ent.filename + if entdest == nil then return end -- probably can't happen... + + -- Set destination in native filesystem. May be default or explicit. + local dest = file.destination + if dest == nil then + dest = entdest + else + dest = dest .. "/" .. entdest + end + + local perms = file.permissions -- may be nil + + if file.filter ~= nil then + local filterperms + dest, filterperms = file.filter(dest) + if filterperms ~= nil then + perms = filterperms + end + end + + if dest ~= nil then -- Only install if file wasn't filtered out + dest = MojoSetup.destination .. "/" .. dest + if permit_write(dest, ent, file) then + local desc = option.description + install_archive_entity(dest, ent, archive, desc, desc, perms) + end + end +end + + +local function install_archive(archive, file, option) + if not MojoSetup.archive.enumerate(archive) then + MojoSetup.fatal(_("Couldn't enumerate archive")) + end + + local isbase = (archive == MojoSetup.archive.base) + local single_match = true + local wildcards = file.wildcards + + -- If there's only one explicit file we're looking for, we don't have to + -- iterate the whole archive...we can stop as soon as we find it. + if wildcards == nil then + single_match = false + else + if type(wildcards) == "string" then + wildcards = { wildcards } + end + if #wildcards > 1 then + single_match = false + else + for i,v in ipairs(wildcards) do + if string.find(v, "[*?]") ~= nil then + single_match = false + break -- no reason to keep iterating... + end + end + end + end + + local ent = MojoSetup.archive.enumnext(archive) + while ent ~= nil do + -- If inside GBaseArchive (no URL lead in string), then we + -- want to clip to data/ directory... + if isbase then + local count + ent.filename, count = string.gsub(ent.filename, "^data/", "", 1) + if count == 0 then + ent.filename = nil + end + end + + -- See if we should install this file... + if (ent.filename ~= nil) and (ent.filename ~= "") then + local should_install = false + if wildcards == nil then + should_install = true + else + for i,v in ipairs(wildcards) do + if MojoSetup.wildcardmatch(ent.filename, v) then + should_install = true + break -- no reason to keep iterating... + end + end + end + + if should_install then + install_archive_entry(archive, ent, file, option) + if single_match then + break -- no sense in iterating further if we're done. + end + end + end + + -- and check the next entry in the archive... + ent = MojoSetup.archive.enumnext(archive) + end +end + + +local function install_basepath(basepath, file, option) + -- Obviously, we don't want to enumerate the entire physical filesystem, + -- so we'll dig through each path element with MojoPlatform_exists() + -- until we find one that doesn't, then we'll back up and try to open + -- that as a directory, and then a file archive, and start drilling from + -- there. Fun. + + local function create_basepath_archive(path) + local archive = MojoSetup.archive.fromdir(path) + if archive == nil then + archive = MojoSetup.archive.fromfile(path) + if archive == nil then + MojoSetup.fatal(_("Couldn't open archive")) + end + end + return archive + end + + -- fast path: See if the whole path exists. This is probably the normal + -- case, but it won't work for archives-in-archives. + if MojoSetup.platform.exists(basepath) then + local archive = create_basepath_archive(basepath) + install_archive(archive, file, option) + MojoSetup.archive.close(archive) + else + -- Check for archives-in-archives... + local path = "" + local paths = split_path(basepath) + for i,v in ipairs(paths) do + local knowngood = path + path = path .. "/" .. v + if not MojoSetup.platform.exists(path) then + if knowngood == "" then + MojoSetup.fatal(_("Archive not found")) + end + local archive = create_basepath_archive(knowngood) + local arclist = { archive } + path = rebuild_path(paths, i) + local arc = drill_for_archive(archive, path, arclist) + install_archive(arc, file, option) + close_archive_list(arclist) + return -- we're done here + end + end + + -- wait, the whole thing exists now? Did this just move in? + install_basepath(basepath, file, option) -- try again, I guess... + end +end + + +local function set_destination(dest) + -- Chop any '/' chars from the end of the string... + dest = string.gsub(dest, "/+$", "") + + MojoSetup.loginfo("Install dest: '" .. dest .. "'") + MojoSetup.destination = dest + MojoSetup.metadatadir = MojoSetup.destination .. "/" .. MojoSetup.metadatadirname + MojoSetup.controldir = MojoSetup.metadatadir -- .. "/control" + MojoSetup.manifestdir = MojoSetup.metadatadir .. "/manifest" + MojoSetup.scratchdir = MojoSetup.metadatadir .. "/tmp" + MojoSetup.rollbackdir = MojoSetup.scratchdir .. "/rollbacks" + MojoSetup.downloaddir = MojoSetup.scratchdir .. "/downloads" +end + + +local function run_config_defined_hook(func, pkg) + if func ~= nil then + local errstr = func(pkg) + if errstr ~= nil then + MojoSetup.fatal(errstr) + end + end +end + + +-- The XML manifest is compatible with the loki_setup manifest schema, since +-- it has a reasonable set of data, and allows you to use loki_update or +-- loki_patch with a MojoSetup installation. Please note that we never ever +-- look at this data! You are responsible for updating the other files if +-- you think it'll be important. The Unix MojoSetup uninstaller uses the +-- lua manifest, for example (but loki_uninstall can use the xml one, +-- so if you want, you can just drop in MojoSetup to replace loki_setup and +-- use the Loki tools for everything else. +local function build_xml_manifest(package) + local retval = {}; + + local function addstr(str) + retval[#retval+1] = str + end + + addstr('\n') + addstr('\n') + addstr('\t\n') + + -- Need to group these by options. + local grouped = {} + for fname,entity in pairs(package.manifest) do + local key = entity.key + if grouped[key] == nil then + grouped[key] = {} + end + entity.path = fname + local list = grouped[key] + list[#list+1] = entity + end + + for desc,items in pairs(grouped) do + addstr('\t\t\n'); + end + + addstr('\t\n\n\n') + + return retval +end + + +local function serialize(obj, prefix, postfix) + local retval = {} + local function addstr(str) + retval[#retval+1] = str + end + + if prefix ~= nil then + addstr(prefix) + end + + local function _serialize(obj, indent) + local objtype = type(obj) + if objtype == "nil" then + addstr("nil") + elseif (objtype == "number") or (objtype == "boolean") then + addstr(tostring(obj)) + elseif objtype == "string" then + addstr(string.format("%q", obj)) + elseif objtype == "function" then + addstr("loadstring(") + addstr(string.format("%q", string.dump(obj))) + addstr(")") + elseif objtype == "table" then + addstr("{\n") + local tab = string.rep("\t", indent) + for k,v in pairs(obj) do + local key = k + addstr(tab) + if type(key) == "number" then + addstr('[') + addstr(key) + addstr(']') + elseif not string.match(key, "^[_a-zA-Z][_a-zA-Z0-9]*$") then + addstr('[') + addstr(string.format("%q", key)) + addstr(']') + else + addstr(key) + end + addstr(" = ") + _serialize(v, indent+1) + addstr(",\n") + end + addstr(string.rep("\t", indent-1)) + addstr("}") + else + MojoSetup.logerror("unexpected object to serialize (" .. + objtype .. "): '" .. tostring(obj) .. "'") + MojoSetup.fatal(_("BUG: Unhandled data type")) + end + end + + _serialize(obj, 1) + + if postfix ~= nil then + addstr(postfix) + end + + return retval +end + + +local function build_lua_manifest(package) + return serialize(package, 'MojoSetup.package = ', '\n\n') +end + + +local function build_txt_manifest(package) + local flat = flatten_manifest(package.manifest) + local retval = {} + for i,v in pairs(flat) do + retval[#retval+1] = v + retval[#retval+1] = "\n" + end + return retval +end + + +local function install_control_app(desc, key) + local dst, src + + -- We copy the installer binary itself, and any auxillary files it needs, + -- like this Lua script, to a metadata directory in the installation. + -- Unfortunately, the binary might be a self-extracting installer that + -- has gigabytes of now-unnecessary data appended to it, so we need to + -- decide if that's the case and, if so, extract just the program itself + -- from the start of the file. + local maxbytes = -1 -- copy whole thing by default. + local base = MojoSetup.archive.base + + dst = MojoSetup.controldir .. "/" .. MojoSetup.controlappname + src = MojoSetup.info.binarypath + if src == MojoSetup.info.basearchivepath then + maxbytes = MojoSetup.archive.offsetofstart(base) + if maxbytes <= 0 then + MojoSetup.fatal(_("BUG: Unexpected value")) + end + end + + local perms = "0755" -- !!! FIXME + install_parent_dirs(dst, key) + install_file_from_filesystem(dst, src, perms, desc, key, maxbytes) + + -- Okay, now we need all the support files. + if not MojoSetup.archive.enumerate(base) then + MojoSetup.fatal(_("Couldn't enumerate archive")) + end + + local needdirs = { "scripts", "guis", "meta" } + + local ent = MojoSetup.archive.enumnext(base) + while ent ~= nil do + -- Make sure this is in a directory we want to write out... + local should_write = false + + if (ent.filename ~= nil) and (ent.filename ~= "") then + for i,dir in ipairs(needdirs) do + local clipdir = "^" .. dir .. "/" + if string.find(ent.filename, clipdir) ~= nil then + should_write = true + break + end + end + end + + if should_write then + dst = MojoSetup.controldir .. "/" .. ent.filename + -- don't overwrite preexisting stuff. + if not MojoSetup.platform.exists(dst) then + install_archive_entity(dst, ent, base, desc, key, perms) + end + end + + -- and check the next entry in the archive... + ent = MojoSetup.archive.enumnext(base) + end + + -- okay, we're written out. +end + + +local function install_unix_uninstaller(desc, key) + -- Write a script out that calls the uninstaller. + local fname = MojoSetup.destination .. "/" .. + "uninstall-" .. MojoSetup.install.id .. ".sh" + + -- Man, I hate escaping shell strings... + local bin = "\"`dirname \"$0\"`\"'/" .. MojoSetup.metadatadirname .. "/" .. + MojoSetup.controlappname .. "'" + string.gsub(bin, "'", "'\\''") -- !!! FIXME: no-op!-- Escape single quotes for shell. + + local id = MojoSetup.install.id + string.gsub(id, "'", "'\\''") -- !!! FIXME: no-op! + + local script = + "#!/bin/sh\n" .. + "exec " .. bin .. " uninstall '" .. id .. "' \"$@\"\n\n" + + install_parent_dirs(fname, key) + install_file_from_string(fname, script, "0755", desc, key) +end + + +local function install_product_keys(productkeys) + for desc,prodkey in pairs(productkeys) do + local dest = MojoSetup.destination .. "/" .. prodkey.destination + local productkey = prodkey.productkey + local component = prodkey.component + -- !!! FIXME: Windows registry support. + -- !!! FIXME: file permissions for product keys? + install_parent_dirs(dest, component) + install_file_from_string(dest, productkey, "0644", desc, component) + end +end + + +local function install_manifests(desc, key) + -- We write out a Lua script as a data definition language, a + -- loki_setup-compatible XML manifest, and a straight text file of + -- all the filenames. Take your pick. + + local perms = "0644" -- !!! FIXME + local basefname = MojoSetup.manifestdir .. "/" .. MojoSetup.install.id + local lua_fname = basefname .. ".lua" + local xml_fname = basefname .. ".xml" + local txt_fname = basefname .. ".txt" + + -- We have to cheat and just plug these into the manifest directly, since + -- they won't show up until after we write them out, otherwise. + -- Obviously, we don't have checksums for them, either, as we haven't + -- assembled the data yet! + + manifest_add(MojoSetup.manifest, lua_fname, key, "file", perms, nil, nil) + manifest_add(MojoSetup.manifest, xml_fname, key, "file", perms, nil, nil) + manifest_add(MojoSetup.manifest, txt_fname, key, "file", perms, nil, nil) + + -- build the "package" table that we serialize, etc. + local package = + { + id = MojoSetup.install.id, + vendor = MojoSetup.install.vendor, + description = MojoSetup.install.description, + root = MojoSetup.destination, + update_url = MojoSetup.install.updateurl, + version = MojoSetup.install.version, + manifest = MojoSetup.manifest, + splash = MojoSetup.install.splash, + splashpos = MojoSetup.install.splashpos, + desktopmenuitems = MojoSetup.install.desktopmenuitems, + preuninstall = MojoSetup.install.preuninstall, + postuninstall = MojoSetup.install.postuninstall + } + + -- now build these things... + install_parent_dirs(lua_fname, key) + install_file_from_stringtable(lua_fname, build_lua_manifest(package), perms, desc, nil) + install_file_from_stringtable(xml_fname, build_xml_manifest(package), perms, desc, nil) + install_file_from_stringtable(txt_fname, build_txt_manifest(package), perms, desc, nil) +end + + +local function freedesktop_menuitem_filename(pkg, idx) -- only for Unix. + local vendor = string.gsub(pkg.vendor, "%.", "_") + local fname = vendor .. "-" .. pkg.id .. "_" .. idx .. ".desktop" + return MojoSetup.metadatadir .. "/" .. fname +end + + +local function uninstall_desktop_menu_items(pkg) + -- !!! FIXME: GUI progress? + if pkg.desktopmenuitems ~= nil then + for i,v in ipairs(pkg.desktopmenuitems) do + if MojoSetup.info.platform == "windows" then + MojoSetup.fatal(_("Unimplemented")) -- !!! FIXME: write me. + elseif MojoSetup.info.platform == "macosx" then + MojoSetup.fatal(_("Unimplemented")) -- !!! FIXME: write me. + elseif MojoSetup.info.platform == "beos" then + MojoSetup.fatal(_("Unimplemented")) -- !!! FIXME: write me. + else -- freedesktop, we hope. + local fname = freedesktop_menuitem_filename(pkg, i) + if not MojoSetup.platform.uninstalldesktopmenuitem(fname) then + MojoSetup.fatal(_("Failed to uninstall desktop menu item")) + end + end + end + end +end + + +local function install_freedesktop_menuitem(pkg, idx, item) -- only for Unix. + local icon + local dest = MojoSetup.destination + if item.builtin_icon then + icon = item.icon + else + icon = dest .. "/" .. item.icon + end + + local cmdline = MojoSetup.format(item.commandline, dest) + + -- Try to escape some characters... + cmdline = '"' .. string.gsub(string.gsub(cmdline, "\"","\\\""), "%%", "%%%%") .. '"' + + local t = { "[Desktop Entry]\n" } + local function addpair(key, val) + t[#t+1] = key + t[#t+1] = '=' + t[#t+1] = val + t[#t+1] = '\n' + end + + addpair("Encoding", "UTF-8") + addpair("Value", "1.0") + addpair("Type", "Application") + addpair("Name", item.name) + addpair("GenericName", item.genericname) + addpair("Comment", item.tooltip) + addpair("Icon", icon) + addpair("Exec", cmdline) + addpair("Categories", flatten_list(item.category)) + + if item.mimetype ~= nil then + addpair("MimeType", flatten_list(item.mimetype)) + end + + t[#t+1] = '\n' + + local fname = freedesktop_menuitem_filename(pkg, idx) + local perms = "0644" -- !!! FIXME + local key = MojoSetup.metadatakey + local desc = MojoSetup.metadatadesc + + --MojoSetup.logdebug("Install FreeDesktop file") + --MojoSetup.logdebug(fname) + --MojoSetup.logdebug(str) + install_parent_dirs(fname, key) + install_file_from_stringtable(fname, t, perms, desc, key) + if not MojoSetup.platform.installdesktopmenuitem(fname) then + MojoSetup.fatal(_("Failed to install desktop menu item")) + end +end + + +local function install_desktop_menu_items(pkg) + -- !!! FIXME: GUI progress? + if pkg.desktopmenuitems ~= nil then + for i,item in ipairs(pkg.desktopmenuitems) do + if not item.disabled then + if MojoSetup.info.platform == "windows" then + MojoSetup.fatal(_("Unimplemented")) -- !!! FIXME: write me. + elseif MojoSetup.info.platform == "macosx" then + MojoSetup.fatal(_("Unimplemented")) -- !!! FIXME: write me. + elseif MojoSetup.info.platform == "beos" then + MojoSetup.fatal(_("Unimplemented")) -- !!! FIXME: write me. + else -- freedesktop, we hope. + install_freedesktop_menuitem(pkg, i, item) + end + end + end + end +end + + +local function get_productkey(thisstage, maxstage, desc, fmt, verify, dest, manifestkey) + local key = nil + local userkey = nil + local retval = nil + + -- Retrieve the previous entry, in case we're stepping back over a stage. + -- This lets the user edit it or jsut move forward without typing the + -- whole thing again. + if MojoSetup.productkeys[desc] ~= nil then + userkey = MojoSetup.productkeys[desc].user_productkey + end + + while key == nil do + retval, userkey = MojoSetup.gui.productkey(desc, fmt, userkey, thisstage, maxstage) + if retval ~= 1 then + return retval -- user hit back or cancel. + end + + key = userkey + if verify ~= nil then + local ok, newkey = verify(userkey) + if not ok then + MojoSetup.msgbox( + _("Invalid product key"), + _("That key appears to be invalid. Please try again.")) + key = nil + elseif newkey ~= nil then + key = newkey + end + end + end + + for desckey,prodkey in pairs(MojoSetup.productkeys) do + if (prodkey.destination == dest) and (desckey ~= desc) then + MojoSetup.logwarning("More than one product key with same destination!") + break + end + end + + MojoSetup.productkeys[desc] = { + destination = dest, + productkey = key, + user_productkey = userkey, + component = manifestkey + } + + return 1 +end + + +local function start_gui(desc, splashfname, splashpos) + if splashfname ~= nil then + splashfname = 'meta/' .. splashfname + end + + if not MojoSetup.gui.start(desc, splashfname, splashpos) then + MojoSetup.fatal(_("GUI failed to start")) + end + + MojoSetup.gui_started = true +end + + +local function stop_gui() + MojoSetup.gui.stop() + MojoSetup.gui_started = nil +end + + +local function do_install(install) + MojoSetup.forceoverwrite = nil + MojoSetup.written = 0 + MojoSetup.totalwrite = 0 + MojoSetup.downloaded = 0 + MojoSetup.totaldownload = 0 + MojoSetup.install = install + MojoSetup.installed_menu_items = false + + -- !!! FIXME: need a cmdline to automate cdkey entry? + local skipeulas = MojoSetup.cmdline("i-agree-to-all-licenses") + local skipreadmes = MojoSetup.cmdline("noreadme") + local skipoptions = MojoSetup.cmdline("nooptions") + + -- !!! FIXME: try to sanity check everything we can here + -- !!! FIXME: (unsupported URLs, bogus media IDs, etc.) + -- !!! FIXME: I would like everything possible to fail here instead of + -- !!! FIXME: when a user happens to pick an option no one tested... + + if (install.options == nil) and (install.optiongroups == nil) then + MojoSetup.fatal(_("BUG: no options")) + end + + -- The uninstaller support needs a manifest to know what to do. Force it on. + if (install.support_uninstall) and (not install.write_manifest) then + MojoSetup.fatal(_("BUG: support_uninstall requires write_manifest")) + end + + -- Desktop icons should probably require uninstall so we don't clutter + -- the system with no option for reversal later. + -- !!! FIXME: will miss menu items that are Setup.Option children... + if (install.desktopmenuitems ~= nil) and (not install.support_uninstall) then + MojoSetup.fatal(_("BUG: Setup.DesktopMenuItem requires support_uninstall")) + end + + -- Manifest support requires the Lua parser. + if (install.write_manifest) and (not MojoSetup.info.luaparser) then + MojoSetup.fatal(_("BUG: write_manifest requires Lua parser support")) + end + + -- This is to save us the trouble of a loop every time we have to + -- find media by id... + MojoSetup.media = {} + if install.medias ~= nil then + for k,v in pairs(install.medias) do + if MojoSetup.media[v.id] ~= nil then + MojoSetup.fatal(_("BUG: duplicate media id")) + end + MojoSetup.media[v.id] = v + end + end + + -- Build a bunch of functions into a linear array...this lets us move + -- back and forth between stages of the install with customized functions + -- for each bit that have their own unique params embedded as upvalues. + -- So if there are three EULAs to accept, we'll call three variations of + -- the EULA function with three different tables that appear as local + -- variables, and the driver that calls this function will be able to + -- skip back and forth based on user input. This is a cool Lua thing. + local stages = {} + + -- First stage: Make sure installer can run. Always fails or steps forward. + -- !!! FIXME: you can step back onto this...need a way to run some stages + -- !!! FIXME: only once... + if install.precheck ~= nil then + stages[#stages+1] = function () + run_config_defined_hook(install.precheck, install) + return 1 + end + end + + -- Next stage: accept all global EULAs. Rejection of any EULA is considered + -- fatal. These are global EULAs for the install, per-option EULAs come + -- later. + if (install.eulas ~= nil) and (not skipeulas) then + for k,eula in pairs(install.eulas) do + local desc = eula.description + local fname = "data/" .. eula.source + + -- (desc) and (fname) become upvalues in this function. + stages[#stages+1] = function (thisstage, maxstage) + local retval = MojoSetup.gui.readme(desc,fname,thisstage,maxstage) + if retval == 1 then + if not MojoSetup.promptyn(desc, _("Accept this license?"), false) then + MojoSetup.fatal(_("You must accept the license before you may install")) + end + end + return retval + end + end + end + + -- Next stage: enter all global products keys. These are global keys + -- for the install, per-option keys come later. + MojoSetup.productkeys = {} + if install.productkeys ~= nil then + for k,prodkey in pairs(install.productkeys) do + -- (prodkey) becomes an upvalue in this function. + stages[#stages+1] = function(thisstage, maxstage) + return get_productkey(thisstage, maxstage, prodkey.description, + prodkey.format, prodkey.verify, + prodkey.destination, + MojoSetup.metadatakey) + end + end + end + + -- Next stage: show any READMEs. + if (install.readmes ~= nil) and (not skipreadmes) then + for k,readme in pairs(install.readmes) do + local desc = readme.description + -- !!! FIXME: pull from archive? + local fname = "data/" .. readme.source + -- (desc) and (fname) become upvalues in this function. + stages[#stages+1] = function(thisstage, maxstage) + return MojoSetup.gui.readme(desc, fname, thisstage, maxstage) + end + end + end + + -- Next stage: let user choose install destination. + -- The config file can force a destination if it has a really good reason + -- (system drivers that have to go in a specific place, for example), + -- but really really shouldn't in 99% of the cases. + local destcmdline = MojoSetup.cmdlinestr("destination") + if install.destination ~= nil then + set_destination(install.destination) + elseif destcmdline ~= nil then + set_destination(destcmdline) + else + local recommend = nil + local recommended_cfg = install.recommended_destinations + if recommended_cfg ~= nil then + if type(recommended_cfg) == "string" then + recommended_cfg = { recommended_cfg } + end + + recommend = {} + for i,v in ipairs(recommended_cfg) do + if MojoSetup.platform.isdir(v) then + if MojoSetup.platform.writable(v) then + recommend[#recommend+1] = v .. "/" .. install.id + end + end + end + + if #recommend == 0 then + recommend = nil + end + end + + -- (recommend) becomes an upvalue in this function. + stages[#stages+1] = function(thisstage, maxstage) + local rc, dst + rc, dst = MojoSetup.gui.destination(recommend, thisstage, maxstage) + if rc == 1 then + set_destination(dst) + end + return rc + end + end + + -- Next stage: let user choose install options. + -- This may not produce a GUI stage if it decides that all options + -- are either required or disabled. + if not skipoptions then -- (just take the defaults...) + -- (install) becomes an upvalue in this function. + stages[#stages+1] = function(thisstage, maxstage) + -- This does some complex stuff with a hierarchy of tables in C. + return MojoSetup.gui.options(install, thisstage, maxstage) + end + end + + + -- Next stage: accept all option-specific EULAs. + -- Rejection of any EULA will put you back one stage (usually to the + -- install options), but if there is no previous stage, this becomes + -- fatal. + -- This may not produce a GUI stage if there are no selected options with + -- EULAs to accept. + if not skipeulas then + stages[#stages+1] = function(thisstage, maxstage) + local option_eulas = {} + + local function find_option_eulas(opts) + local options = opts['options'] + if options ~= nil then + for k,v in pairs(options) do + if v.value then + if v.eulas ~= nil then + for ek,ev in pairs(v.eulas) do + option_eulas[#option_eulas+1] = ev + end + end + find_option_eulas(v) + end + end + end + + local optiongroups = opts['optiongroups'] + if optiongroups ~= nil then + for k,v in pairs(optiongroups) do + if not v.disabled then + find_option_eulas(v) + end + end + end + end + + find_option_eulas(install) + + for k,eula in pairs(option_eulas) do + local desc = eula.description + local fname = "data/" .. eula.source + local retval = MojoSetup.gui.readme(desc,fname,thisstage,maxstage) + if retval == 1 then + if not MojoSetup.promptyn(desc, _("Accept this license?"), false) then + -- can't go back? We have to die here instead. + if thisstage == 1 then + MojoSetup.fatal(_("You must accept the license before you may install")) + else + retval = -1 -- just step back a stage. + end + end + end + + if retval ~= 1 then + return retval + end + end + + return 1 -- all licenses were agreed to. Go to the next stage. + end + end + + -- Next stage: enter all option-specific product keys. + -- This may not produce a GUI stage if there are no selected options with + -- product keys. Many installers will use a single global key instead. + stages[#stages+1] = function(thisstage, maxstage) + local options_with_keys = {} + + local function find_options_with_keys(opts) + local options = opts['options'] + if options ~= nil then + for k,v in pairs(options) do + if v.value then + if v.productkeys ~= nil then + options_with_keys[#options_with_keys+1] = v; + end + find_options_with_keys(v) + end + end + end + + local optiongroups = opts['optiongroups'] + if optiongroups ~= nil then + for k,v in pairs(optiongroups) do + if not v.disabled then + find_options_with_keys(v) + end + end + end + end + + find_options_with_keys(install) + + for optk,option in ipairs(options_with_keys) do + for k,prodkey in ipairs(option.productkeys) do + local retval = get_productkey(thisstage, maxstage, + prodkey.description, + prodkey.format, prodkey.verify, + prodkey.destination, + option.description) + if retval ~= 1 then + return retval + end + end + end + + return 1 -- all product keys are entered. Go to the next stage. + end + + -- Next stage: Make sure source list is sane. + -- This is not a GUI stage, it just needs to run between them. + -- This gets a little hairy. + stages[#stages+1] = function(thisstage, maxstage) + -- Make sure we install the destination dir, so it's in the manifest. + if not MojoSetup.platform.exists(MojoSetup.destination) then + install_parent_dirs(MojoSetup.destination, MojoSetup.metadatakey) + install_directory(MojoSetup.destination, nil, MojoSetup.metadatakey) + end + + local function process_file(option, file) + -- !!! FIXME: what happens if a file shows up in multiple options? + local src = file.source + local prot,host,path + if src ~= nil then -- no source, it's in GBaseArchive + prot,host,path = MojoSetup.spliturl(src) + end + if (src == nil) or (prot == "base://") then -- included content? + if MojoSetup.files.included == nil then + MojoSetup.files.included = {} + end + MojoSetup.files.included[file] = option + elseif prot == "media://" then + -- !!! FIXME: make sure media id is valid. + if MojoSetup.files.media == nil then + MojoSetup.files.media = {} + end + if MojoSetup.files.media[host] == nil then + MojoSetup.files.media[host] = {} + end + MojoSetup.files.media[host][file] = option + else + -- !!! FIXME: make sure we can handle this URL... + if MojoSetup.files.downloads == nil then + MojoSetup.files.downloads = {} + end + + if option.bytes > 0 then + MojoSetup.totaldownload = MojoSetup.totaldownload + option.bytes + end + MojoSetup.files.downloads[file] = option + end + end + + -- Sort an option into tables that say what sort of install it is. + -- This lets us batch all the things from one CD together, + -- do all the downloads first, etc. + local function process_option(option) + if option.bytes > 0 then + MojoSetup.totalwrite = MojoSetup.totalwrite + option.bytes + end + if option.files ~= nil then + for k,v in pairs(option.files) do + process_file(option, v) + end + end + + if option.desktopmenuitems ~= nil then + for i,item in ipairs(option.desktopmenuitems) do + if install.desktopmenuitems == nil then + install.desktopmenuitems = {} + end + install.desktopmenuitems[#install.desktopmenuitems+1] = item + end + end + end + + local function build_source_tables(opts) + local options = opts['options'] + if options ~= nil then + for k,v in pairs(options) do + if v.value then + process_option(v) + build_source_tables(v) + end + end + end + + local optiongroups = opts['optiongroups'] + if optiongroups ~= nil then + for k,v in pairs(optiongroups) do + if not v.disabled then + build_source_tables(v) + end + end + end + end + + run_config_defined_hook(install.preflight, install) + + MojoSetup.files = {} + build_source_tables(install) + + -- This dumps the files tables using MojoSetup.logdebug, + -- so it only spits out crap if debug-level logging is enabled. + MojoSetup.dumptable("MojoSetup.files", MojoSetup.files) + + return 1 -- always go forward from non-GUI stage. + end + + -- Next stage: Download external packages. + stages[#stages+1] = function(thisstage, maxstage) + if MojoSetup.files.downloads ~= nil then + -- !!! FIXME: id will cause problems for download resume + -- !!! FIXME: id will chop filename extension + local id = 0 + for file,option in pairs(MojoSetup.files.downloads) do + local f = MojoSetup.downloaddir .. "/" .. id + install_parent_dirs(f, MojoSetup.metadatakey) + id = id + 1 + + -- Upvalued so we don't look these up each time... + local url = file.source + local fname = string.gsub(url, "^.*/", "", 1) -- chop the dirs off... + local ptype = _("Downloading") + local component = option.description + local bps = 0 + local bpsticks = 0 + local ratestr = '' + local item = fname + local percent = -1 + local callback = function(ticks, justwrote, bw, total) + if total < 0 then + -- adjust start point for d/l rate calculation... + bpsticks = ticks + 1000 + else + if ticks >= bpsticks then + ratestr = make_rate_string(bps, bw, total) + bpsticks = ticks + 1000 + bps = 0 + end + bps = bps + justwrote + MojoSetup.downloaded = MojoSetup.downloaded + justwrote + percent = calc_percent(MojoSetup.downloaded, + MojoSetup.totaldownload) + + item = MojoSetup.format(_("%0: %1%% (%2)"), + fname, + calc_percent(bw, total), + ratestr) + end + return MojoSetup.gui.progress(ptype, component, percent, item, true) + end + + MojoSetup.loginfo("Download '" .. url .. "' to '" .. f .. "'") + MojoSetup.gui.progressitem() + local downloaded, sums = MojoSetup.download(url, f, nil, nil, callback) + if not downloaded then + MojoSetup.fatal(_("File download failed!")) + end + MojoSetup.downloads[#MojoSetup.downloads+1] = f + end + end + return 1 + end + + -- Next stage: actual installation. + stages[#stages+1] = function(thisstage, maxstage) + run_config_defined_hook(install.preinstall) + + -- Do stuff on media first, so the user finds out he's missing + -- disc 3 of 57 as soon as possible... + + -- Since we sort all things to install by the media that contains + -- the source data, you should only have to insert each disc + -- once, no matter how they landed in the config file. + + if MojoSetup.files.media ~= nil then + -- Build an array of media ids so we can sort them into a + -- reasonable order...disc 1 before disc 2, etc. + local medialist = {} + for mediaid,mediavalue in pairs(MojoSetup.files.media) do + medialist[#medialist+1] = mediaid + end + table.sort(medialist) + + for mediaidx,mediaid in ipairs(medialist) do + local media = MojoSetup.media[mediaid] + local basepath = MojoSetup.findmedia(media.uniquefile) + while basepath == nil do + if not MojoSetup.gui.insertmedia(media.description) then + return 0 -- user cancelled. + end + basepath = MojoSetup.findmedia(media.uniquefile) + end + + -- Media is ready, install everything from this one... + MojoSetup.loginfo("Found correct media at '" .. basepath .. "'") + local files = MojoSetup.files.media[mediaid] + for file,option in pairs(files) do + local prot,host,path = MojoSetup.spliturl(file.source) + install_basepath(basepath .. "/" .. path, file, option) + end + end + medialist = nil -- done with this. + end + + if MojoSetup.files.downloads ~= nil then + local id = 0 + for file,option in pairs(MojoSetup.files.downloads) do + local f = MojoSetup.downloaddir .. "/" .. id + id = id + 1 + install_basepath(f, file, option) + end + end + + if MojoSetup.files.included ~= nil then + for file,option in pairs(MojoSetup.files.included) do + local arc = MojoSetup.archive.base + if file.source == nil then + install_archive(arc, file, option) + else + local prot,host,path = MojoSetup.spliturl(file.source) + local arclist = {} + arc = drill_for_archive(arc, "data/" .. path, arclist) + install_archive(arc, file, option) + close_archive_list(arclist) + end + end + end + + if install.desktopmenuitems ~= nil then + install_desktop_menu_items(install) + MojoSetup.installed_menu_items = true + end + + if install.support_uninstall then + if MojoSetup.info.platform == "windows" then + MojoSetup.fatal(_("Unimplemented")) -- !!! FIXME: write me. + else -- Unix, Mac OS X, BeOS... + install_unix_uninstaller(MojoSetup.metadatadesc, MojoSetup.metadatakey) + end + end + + install_product_keys(MojoSetup.productkeys) + + run_config_defined_hook(install.postinstall, install) + + if install.write_manifest then + install_control_app(MojoSetup.metadatadesc, MojoSetup.metadatakey) + install_manifests(MojoSetup.metadatadesc, MojoSetup.metadatakey) + end + + return 1 -- go to next stage. + end + + -- Next stage: show results gui + stages[#stages+1] = function(thisstage, maxstage) + MojoSetup.gui.final(_("Installation was successful.")) + return 1 -- go forward. + end + + -- Now make all this happen. + start_gui(install.description, install.splash, install.splashpos) + + -- Make the stages available elsewhere. + MojoSetup.stages = stages + + MojoSetup.manifest = {} + MojoSetup.rollbacks = {} + MojoSetup.downloads = {} + + local i = 1 + while MojoSetup.stages[i] ~= nil do + local stage = MojoSetup.stages[i] + local rc = stage(i, #MojoSetup.stages) + + -- Too many times I forgot to return something. :) + if type(rc) ~= "number" then + MojoSetup.fatal(_("BUG: stage returned wrong type")) + end + + if rc == 1 then + i = i + 1 -- next stage. + elseif rc == -1 then + if i == 1 then + MojoSetup.fatal(_("BUG: stepped back over start of stages")) + else + i = i - 1 + end + elseif rc == 0 then + MojoSetup.fatal() -- user cancelled + else + MojoSetup.fatal(_("BUG: stage returned wrong value")) + end + end + + -- Successful install, so delete conflicts we no longer need to rollback. + delete_rollbacks() + delete_files(MojoSetup.downloads) + delete_scratchdirs() + + -- Don't let future errors delete files from successful installs... + MojoSetup.downloads = nil + MojoSetup.rollbacks = nil + + stop_gui() + + -- Done with these things. Make them eligible for garbage collection. + stages = nil + MojoSetup.manifest = nil + MojoSetup.destination = nil + MojoSetup.manifestdir = nil + MojoSetup.metadatadir = nil + MojoSetup.controldir = nil + MojoSetup.scratchdir = nil + MojoSetup.rollbackdir = nil + MojoSetup.downloaddir = nil + MojoSetup.install = nil + MojoSetup.forceoverwrite = nil + MojoSetup.installed_menu_items = nil + MojoSetup.stages = nil + MojoSetup.files = nil + MojoSetup.productkeys = nil + MojoSetup.media = nil + MojoSetup.written = 0 + MojoSetup.totalwrite = 0 + MojoSetup.downloaded = 0 + MojoSetup.totaldownload = 0 +end + + +local function real_revertinstall() + if MojoSetup.gui_started then + MojoSetup.gui.final(_("Incomplete installation. We will revert any changes we made.")) + end + + MojoSetup.loginfo("Cleaning up half-finished installation...") + + -- !!! FIXME: callbacks here. + if MojoSetup.installed_menu_items then + uninstall_desktop_menu_items(MojoSetup.install) + end + + delete_files(MojoSetup.downloads) + delete_files(flatten_manifest(MojoSetup.manifest, prepend_dest_dir)) + do_rollbacks() + delete_scratchdirs() +end + + +local function installer() + MojoSetup.loginfo("Installer starting") + + MojoSetup.revertinstall = real_revertinstall -- replace the stub. + + -- This dumps the table built from the user's config script using logdebug, + -- so it only spits out crap if debug-level logging is enabled. + MojoSetup.dumptable("MojoSetup.installs", MojoSetup.installs) + + local saw_an_installer = false + for installkey,install in pairs(MojoSetup.installs) do + if not install.disabled then + saw_an_installer = true + do_install(install) + MojoSetup.collectgarbage() -- nuke all the tables we threw around... + end + end + + if not saw_an_installer then + MojoSetup.fatal(_("Nothing to do!")) + end +end + + +local function load_manifest(pkg) + local package = nil + if pkg == nil then + badcmdline() + end + + MojoSetup.package = nil -- just in case. + + -- We need to be in the metadata directory of an install or this fails. + local base = string.gsub(MojoSetup.info.basearchivepath, "/[^/]*$", "", 1) + set_destination(base) -- set up directories + if MojoSetup.metadatadir == MojoSetup.info.basearchivepath then + -- load the existing manifest first... + local ran = MojoSetup.runfilefromdir("manifest", pkg) + if (not ran) or (MojoSetup.package == nil) then + MojoSetup.fatal(MojoSetup.format( + _("Couldn't load manifest file for '%0'"), pkg)) + end + + -- Move this out of the global... + package = MojoSetup.package + MojoSetup.package = nil + end + + -- note that we discard the base directory specified in the manifest, as + -- someone could have moved the installation's folder elsewhere. We'll + -- keep it up to date for loki_update or whatever to use, though. + package.destination = MojoSetup.destination + + return package +end + + +local function manifest_management() + MojoSetup.loginfo("Manifest management starting") + local package = load_manifest(MojoSetup.info.argv[3]) + + local i = 4 + while MojoSetup.info.argv[i] ~= nil do + local cmd = MojoSetup.info.argv[i] + i = i + 1 + + if cmd == "add" then + local key = MojoSetup.info.argv[i] + i = i + 1 + local fname = MojoSetup.info.argv[i] + i = i + 1 + if (key == nil) or (fname == nil) then + badcmdline() + end + + MojoSetup.loginfo("Add '" ..fname.. "', '" ..key.. "' to manifest") + fname = MojoSetup.destination .. "/" .. fname + if not MojoSetup.platform.exists(fname) then + MojoSetup.fatal(MojoSetup.format(_("File %0 not found"), fname)) + end + + manifest_add(package.manifest, fname, key, nil, nil, nil, nil) + manifest_resync(package.manifest, fname, key) + + elseif cmd == "delete" then + local fname = MojoSetup.info.argv[i] + i = i + 1 + if fname == nil then + badcmdline() + end + MojoSetup.loginfo("Delete '" .. fname .. "' from manifest") + fname = MojoSetup.destination .. "/" .. fname + manifest_delete(package.manifest, fname) + + elseif cmd == "resync" then + local fname = MojoSetup.info.argv[i] + i = i + 1 + if fname == nil then + badcmdline() + end + MojoSetup.loginfo("Resync '" .. fname .. "' in manifest") + fname = MojoSetup.destination .. "/" .. fname + if not MojoSetup.platform..exists(fname) then + MojoSetup.fatal(MojoSetup.format(_("File %0 not found"), fname)) + end + manifest_resync(package.manifest, fname) + + elseif string.match(cmd, "^-") == nil then -- skip "-option" strings + MojoSetup.logerror("Unknown command '" .. cmd .. "'") + badcmdline() + end + end + + -- !!! FIXME: duplication with install_manifests() + local perms = "0644" -- !!! FIXME + local basefname = MojoSetup.manifestdir .. "/" .. package.id + local lua_fname = basefname .. ".lua" + local xml_fname = basefname .. ".xml" + local txt_fname = basefname .. ".txt" + + MojoSetup.loginfo("rebuilding manifests...") + + -- !!! FIXME: rollback! + delete_files({lua_fname, xml_fname, txt_fname}, nil, false) + MojoSetup.stringtabletofile(build_lua_manifest(package), lua_fname, perms, nil, nil) + MojoSetup.stringtabletofile(build_xml_manifest(package), xml_fname, perms, nil, nil) + MojoSetup.stringtabletofile(build_txt_manifest(package), txt_fname, perms, nil, nil) + + MojoSetup.loginfo("manifests rebuilt!") +end + + +local function uninstaller() + MojoSetup.loginfo("Uninstaller starting") + local package = load_manifest(MojoSetup.info.argv[3]) + + local title = _("Uninstall") + + local uninstall_permitted = false + if MojoSetup.cmdline("force") then + uninstall_permitted = true + else + local question = _("Are you sure you want to uninstall '%0'?") + question = MojoSetup.format(question, package.description) + uninstall_permitted = MojoSetup.promptyn(title, question, false) + end + + if uninstall_permitted then + start_gui(package.description, package.splash, package.splashpos) + run_config_defined_hook(package.preuninstall, package) + + uninstall_desktop_menu_items(package) + + -- Upvalued in callback so we don't look this up each time... + local ptype = _("Uninstalling") + local callback = function(fname, current, total) + fname = make_relative(fname, MojoSetup.destination) + local percent = 100 - calc_percent(current, total) + local component = package.manifest[fname].key + if component == nil then + component = "" + elseif component == MojoSetup.metadatakey then + component = MojoSetup.metadatadesc + end + + local item = string.gsub(fname, "^.*/", "", 1) -- chop off dirs... + MojoSetup.gui.progressitem() + MojoSetup.gui.progress(ptype, component, percent, item, false) + return true -- !!! FIXME: need to disable cancel button in UI... + end + + local filelist = flatten_manifest(package.manifest, prepend_dest_dir) + delete_files(filelist, callback, true) + run_config_defined_hook(package.postuninstall, package) + MojoSetup.gui.final(_("Uninstall complete")) + stop_gui() + end + + -- !!! FIXME: postuninstall hook? +end + + + +-- Mainline... + +local purpose = nil + +-- Have to check argv instead of using cmdline(), for precision's sake. +-- Remember that unlike main()'s argv in C, Lua starts arrays at 1, +-- so argv[2] would be argv[1] in C. Fun. +local argv2 = MojoSetup.info.argv[2] +if argv2 == "manifest" then + purpose = manifest_management +elseif argv2 == "uninstall" then + purpose = uninstaller +else + purpose = installer + MojoSetup.runfile("config") -- This builds the MojoSetup.installs table. +end + +-- We don't need the "Setup" namespace anymore. Make it eligible +-- for garbage collection. +Setup = nil +MojoSetup.collectgarbage() -- and collect it, etc. + +-- Now do the real work... +purpose() + +-- end of mojosetup_mainline.lua ... + diff --git a/mk/linux/mojosetup/stb_image.c b/mk/linux/mojosetup/stb_image.c new file mode 100644 index 00000000..6602ad20 --- /dev/null +++ b/mk/linux/mojosetup/stb_image.c @@ -0,0 +1,3818 @@ +// (Changes to this code are wrapped in __MOJOSETUP__ sections. --ryan.) +// (Changes to JUST THIS FILE are also public domain. The rest of MojoSetup +// falls under different licensing terms. --ryan.) +#if !__MOJOSETUP__ +#error This file is probably miscompiled. +#endif + +/* stbi-1.08 - public domain JPEG/PNG reader - http://nothings.org/stb_image.c + when you control the images you're loading + + QUICK NOTES: + Primarily of interest to game developers and other people who can + avoid problematic images and only need the trivial interface + + JPEG baseline (no JPEG progressive, no oddball channel decimations) + PNG non-interlaced + BMP non-1bpp, non-RLE + TGA (not sure what subset, if a subset) + PSD (composite view only, no extra channels) + HDR (radiance rgbE format) + writes BMP,TGA (define STBI_NO_WRITE to remove code) + decoded from memory or through stdio FILE (define STBI_NO_STDIO to remove code) + + TODO: + stbi_info_* + + history: + 1.08 Thatcher Ulrich's PSD code integrated by Nicolas Schulz + 1.07 attempt to fix C++ warning/errors again + 1.06 attempt to fix C++ warning/errors again + 1.05 fix TGA loading to return correct *comp and use good luminance calc + 1.04 default float alpha is 1, not 255; use 'void *' for stbi_image_free + 1.03 bugfixes to STBI_NO_STDIO, STBI_NO_HDR + 1.02 support for (subset of) HDR files, float interface for preferred access to them + 1.01 fix bug: possible bug in handling right-side up bmps... not sure + fix bug: the stbi_bmp_load() and stbi_tga_load() functions didn't work at all + 1.00 interface to zlib that skips zlib header + 0.99 correct handling of alpha in palette + 0.98 TGA loader by lonesock; dynamically add loaders (untested) + 0.97 jpeg errors on too large a file; also catch another malloc failure + 0.96 fix detection of invalid v value - particleman@mollyrocket forum + 0.95 during header scan, seek to markers in case of padding + 0.94 STBI_NO_STDIO to disable stdio usage; rename all #defines the same + 0.93 handle jpegtran output; verbose errors + 0.92 read 4,8,16,24,32-bit BMP files of several formats + 0.91 output 24-bit Windows 3.0 BMP files + 0.90 fix a few more warnings; bump version number to approach 1.0 + 0.61 bugfixes due to Marc LeBlanc, Christopher Lloyd + 0.60 fix compiling as c++ + 0.59 fix warnings: merge Dave Moore's -Wall fixes + 0.58 fix bug: zlib uncompressed mode len/nlen was wrong endian + 0.57 fix bug: jpg last huffman symbol before marker was >9 bits but less + than 16 available + 0.56 fix bug: zlib uncompressed mode len vs. nlen + 0.55 fix bug: restart_interval not initialized to 0 + 0.54 allow NULL for 'int *comp' + 0.53 fix bug in png 3->4; speedup png decoding + 0.52 png handles req_comp=3,4 directly; minor cleanup; jpeg comments + 0.51 obey req_comp requests, 1-component jpegs return as 1-component, + on 'test' only check type, not whether we support this variant +*/ + +#if __MOJOSETUP__ +# include "universal.h" // catches xmalloc() defines, etc. +# undef malloc +# define malloc(x) xmalloc(x) +# undef realloc +# define realloc(x, y) xrealloc(x, y) + +# define STBI_NO_WRITE 1 +# define STBI_NO_STDIO 1 +# define STBI_NO_FAILURE_STRINGS 1 +# if !SUPPORT_HDR +# define STBI_NO_HDR 1 +# endif +# if !SUPPORT_TGA +# define STBI_NO_TGA 1 +# endif +# if !SUPPORT_JPG +# define STBI_NO_JPEG 1 +# endif +# if !SUPPORT_BMP +# define STBI_NO_BMP 1 +# endif +# if !SUPPORT_PSD +# define STBI_NO_PSD 1 +# endif +# if !SUPPORT_PNG +# define STBI_NO_PNG 1 +# define STBI_NO_ZLIB 1 +# endif +#endif + +//// begin header file //////////////////////////////////////////////////// +// +// Limitations: +// - no progressive/interlaced support (jpeg, png) +// - 8-bit samples only (jpeg, png) +// - not threadsafe +// - channel subsampling of at most 2 in each dimension (jpeg) +// - no delayed line count (jpeg) -- IJG doesn't support either +// +// Basic usage (see HDR discussion below): +// int x,y,n; +// unsigned char *data = stbi_load(filename, &x, &y, &n, 0); +// // ... process data if not NULL ... +// // ... x = width, y = height, n = # 8-bit components per pixel ... +// // ... replace '0' with '1'..'4' to force that many components per pixel +// stbi_image_free(data) +// +// Standard parameters: +// int *x -- outputs image width in pixels +// int *y -- outputs image height in pixels +// int *comp -- outputs # of image components in image file +// int req_comp -- if non-zero, # of image components requested in result +// +// The return value from an image loader is an 'unsigned char *' which points +// to the pixel data. The pixel data consists of *y scanlines of *x pixels, +// with each pixel consisting of N interleaved 8-bit components; the first +// pixel pointed to is top-left-most in the image. There is no padding between +// image scanlines or between pixels, regardless of format. The number of +// components N is 'req_comp' if req_comp is non-zero, or *comp otherwise. +// If req_comp is non-zero, *comp has the number of components that _would_ +// have been output otherwise. E.g. if you set req_comp to 4, you will always +// get RGBA output, but you can check *comp to easily see if it's opaque. +// +// An output image with N components has the following components interleaved +// in this order in each pixel: +// +// N=#comp components +// 1 grey +// 2 grey, alpha +// 3 red, green, blue +// 4 red, green, blue, alpha +// +// If image loading fails for any reason, the return value will be NULL, +// and *x, *y, *comp will be unchanged. The function stbi_failure_reason() +// can be queried for an extremely brief, end-user unfriendly explanation +// of why the load failed. Define STBI_NO_FAILURE_STRINGS to avoid +// compiling these strings at all, and STBI_FAILURE_USERMSG to get slightly +// more user-friendly ones. +// +// Paletted PNG and BMP images are automatically depalettized. +// +// +// =========================================================================== +// +// HDR image support (disable by defining STBI_NO_HDR) +// +// stb_image now supports loading HDR images in general, and currently +// the Radiance .HDR file format, although the support is provided +// generically. You can still load any file through the existing interface; +// if you attempt to load an HDR file, it will be automatically remapped to +// LDR, assuming gamma 2.2 and an arbitrary scale factor defaulting to 1; +// both of these constants can be reconfigured through this interface: +// +// stbi_hdr_to_ldr_gamma(2.2f); +// stbi_hdr_to_ldr_scale(1.0f); +// +// (note, do not use _inverse_ constants; stbi_image will invert them +// appropriately). +// +// Additionally, there is a new, parallel interface for loading files as +// (linear) floats to preserve the full dynamic range: +// +// float *data = stbi_loadf(filename, &x, &y, &n, 0); +// +// If you load LDR images through this interface, those images will +// be promoted to floating point values, run through the inverse of +// constants corresponding to the above: +// +// stbi_ldr_to_hdr_scale(1.0f); +// stbi_ldr_to_hdr_gamma(2.2f); +// +// Finally, given a filename (or an open file or memory block--see header +// file for details) containing image data, you can query for the "most +// appropriate" interface to use (that is, whether the image is HDR or +// not), using: +// +// stbi_is_hdr(char *filename); + + +#ifndef STBI_NO_STDIO +#include +#endif + +#ifndef STBI_NO_HDR +#include // ldexp +#include // strcmp +#endif + +enum +{ + STBI_default = 0, // only used for req_comp + + STBI_grey = 1, + STBI_grey_alpha = 2, + STBI_rgb = 3, + STBI_rgb_alpha = 4, +}; + +typedef unsigned char stbi_uc; + +#ifdef __cplusplus +extern "C" { +#endif + +// WRITING API + +#if !defined(STBI_NO_WRITE) && !defined(STBI_NO_STDIO) +// write a BMP/TGA file given tightly packed 'comp' channels (no padding, nor bmp-stride-padding) +// (you must include the appropriate extension in the filename). +// returns TRUE on success, FALSE if couldn't open file, error writing file +extern int stbi_write_bmp (char *filename, int x, int y, int comp, void *data); +extern int stbi_write_tga (char *filename, int x, int y, int comp, void *data); +#endif + +// PRIMARY API - works on images of any type + +// load image by filename, open file, or memory buffer +#ifndef STBI_NO_STDIO +extern stbi_uc *stbi_load (char *filename, int *x, int *y, int *comp, int req_comp); +extern stbi_uc *stbi_load_from_file (FILE *f, int *x, int *y, int *comp, int req_comp); +extern int stbi_info_from_file (FILE *f, int *x, int *y, int *comp); +#endif +extern stbi_uc *stbi_load_from_memory(stbi_uc *buffer, int len, int *x, int *y, int *comp, int req_comp); +// for stbi_load_from_file, file pointer is left pointing immediately after image + +#ifndef STBI_NO_HDR +#ifndef STBI_NO_STDIO +extern float *stbi_loadf (char *filename, int *x, int *y, int *comp, int req_comp); +extern float *stbi_loadf_from_file (FILE *f, int *x, int *y, int *comp, int req_comp); +#endif +extern float *stbi_loadf_from_memory(stbi_uc *buffer, int len, int *x, int *y, int *comp, int req_comp); + +extern void stbi_hdr_to_ldr_gamma(float gamma); +extern void stbi_hdr_to_ldr_scale(float scale); + +extern void stbi_ldr_to_hdr_gamma(float gamma); +extern void stbi_ldr_to_hdr_scale(float scale); + +#endif // STBI_NO_HDR + +// get a VERY brief reason for failure +extern char *stbi_failure_reason (void); + +// free the loaded image -- this is just free() +extern void stbi_image_free (void *retval_from_stbi_load); + +// get image dimensions & components without fully decoding +extern int stbi_info_from_memory(stbi_uc *buffer, int len, int *x, int *y, int *comp); +extern int stbi_is_hdr_from_memory(stbi_uc *buffer, int len); +#ifndef STBI_NO_STDIO +extern int stbi_info (char *filename, int *x, int *y, int *comp); +extern int stbi_is_hdr (char *filename); +extern int stbi_is_hdr_from_file(FILE *f); +#endif + +// ZLIB client - used by PNG, available for other purposes + +extern char *stbi_zlib_decode_malloc_guesssize(int initial_size, int *outlen); +extern char *stbi_zlib_decode_malloc(char *buffer, int len, int *outlen); +extern int stbi_zlib_decode_buffer(char *obuffer, int olen, char *ibuffer, int ilen); + +extern char *stbi_zlib_decode_noheader_malloc(char *buffer, int len, int *outlen); +extern int stbi_zlib_decode_noheader_buffer(char *obuffer, int olen, char *ibuffer, int ilen); + + +// TYPE-SPECIFIC ACCESS + +// is it a jpeg? +extern int stbi_jpeg_test_memory (stbi_uc *buffer, int len); +extern stbi_uc *stbi_jpeg_load_from_memory(stbi_uc *buffer, int len, int *x, int *y, int *comp, int req_comp); +extern int stbi_jpeg_info_from_memory(stbi_uc *buffer, int len, int *x, int *y, int *comp); + +#ifndef STBI_NO_STDIO +extern stbi_uc *stbi_jpeg_load (char *filename, int *x, int *y, int *comp, int req_comp); +extern int stbi_jpeg_test_file (FILE *f); +extern stbi_uc *stbi_jpeg_load_from_file (FILE *f, int *x, int *y, int *comp, int req_comp); + +extern int stbi_jpeg_info (char *filename, int *x, int *y, int *comp); +extern int stbi_jpeg_info_from_file (FILE *f, int *x, int *y, int *comp); +#endif + +extern int stbi_jpeg_dc_only; // only decode DC component + +// is it a png? +extern int stbi_png_test_memory (stbi_uc *buffer, int len); +extern stbi_uc *stbi_png_load_from_memory (stbi_uc *buffer, int len, int *x, int *y, int *comp, int req_comp); +extern int stbi_png_info_from_memory (stbi_uc *buffer, int len, int *x, int *y, int *comp); + +#ifndef STBI_NO_STDIO +extern stbi_uc *stbi_png_load (char *filename, int *x, int *y, int *comp, int req_comp); +extern int stbi_png_info (char *filename, int *x, int *y, int *comp); +extern int stbi_png_test_file (FILE *f); +extern stbi_uc *stbi_png_load_from_file (FILE *f, int *x, int *y, int *comp, int req_comp); +extern int stbi_png_info_from_file (FILE *f, int *x, int *y, int *comp); +#endif + +// is it a bmp? +extern int stbi_bmp_test_memory (stbi_uc *buffer, int len); + +extern stbi_uc *stbi_bmp_load (char *filename, int *x, int *y, int *comp, int req_comp); +extern stbi_uc *stbi_bmp_load_from_memory (stbi_uc *buffer, int len, int *x, int *y, int *comp, int req_comp); +#ifndef STBI_NO_STDIO +extern int stbi_bmp_test_file (FILE *f); +extern stbi_uc *stbi_bmp_load_from_file (FILE *f, int *x, int *y, int *comp, int req_comp); +#endif + +// is it a tga? +extern int stbi_tga_test_memory (stbi_uc *buffer, int len); + +extern stbi_uc *stbi_tga_load (char *filename, int *x, int *y, int *comp, int req_comp); +extern stbi_uc *stbi_tga_load_from_memory (stbi_uc *buffer, int len, int *x, int *y, int *comp, int req_comp); +#ifndef STBI_NO_STDIO +extern int stbi_tga_test_file (FILE *f); +extern stbi_uc *stbi_tga_load_from_file (FILE *f, int *x, int *y, int *comp, int req_comp); +#endif + +// is it a psd? +extern int stbi_psd_test_memory (stbi_uc *buffer, int len); + +extern stbi_uc *stbi_psd_load (char *filename, int *x, int *y, int *comp, int req_comp); +extern stbi_uc *stbi_psd_load_from_memory (stbi_uc *buffer, int len, int *x, int *y, int *comp, int req_comp); +#ifndef STBI_NO_STDIO +extern int stbi_psd_test_file (FILE *f); +extern stbi_uc *stbi_psd_load_from_file (FILE *f, int *x, int *y, int *comp, int req_comp); +#endif + +// is it an hdr? +extern int stbi_hdr_test_memory (stbi_uc *buffer, int len); + +extern float * stbi_hdr_load (char *filename, int *x, int *y, int *comp, int req_comp); +extern float * stbi_hdr_load_from_memory (stbi_uc *buffer, int len, int *x, int *y, int *comp, int req_comp); +#ifndef STBI_NO_STDIO +extern int stbi_hdr_test_file (FILE *f); +extern float * stbi_hdr_load_from_file (FILE *f, int *x, int *y, int *comp, int req_comp); +#endif + +// define new loaders +typedef struct +{ + int (*test_memory)(stbi_uc *buffer, int len); + stbi_uc * (*load_from_memory)(stbi_uc *buffer, int len, int *x, int *y, int *comp, int req_comp); + #ifndef STBI_NO_STDIO + int (*test_file)(FILE *f); + stbi_uc * (*load_from_file)(FILE *f, int *x, int *y, int *comp, int req_comp); + #endif +} stbi_loader; + +// register a loader by filling out the above structure (you must defined ALL functions) +// returns 1 if added or already added, 0 if not added (too many loaders) +extern int stbi_register_loader(stbi_loader *loader); + +#ifdef __cplusplus +} +#endif + +// +// +//// end header file ///////////////////////////////////////////////////// + +#ifndef STBI_NO_STDIO +#include +#endif +#include +#include +#include +#include + +#ifndef _MSC_VER +#define __forceinline +#endif + +// implementation: +#if !__MOJOSETUP__ // (we define these in universal.h ...) +typedef unsigned char uint8; +typedef unsigned short uint16; +typedef signed short int16; +typedef unsigned int uint32; +typedef signed int int32; +typedef unsigned int uint; +#endif + +// should produce compiler error if size is wrong +typedef unsigned char validate_uint32[sizeof(uint32)==4]; + +#if defined(STBI_NO_STDIO) && !defined(STBI_NO_WRITE) +#define STBI_NO_WRITE +#endif + +////////////////////////////////////////////////////////////////////////////// +// +// Generic API that works on all image types +// + +static char *failure_reason; + +char *stbi_failure_reason(void) +{ + return failure_reason; +} + +#if __MOJOSETUP__ && !defined(STBI_NO_FAILURE_STRINGS) +static int e(char *str) +{ + failure_reason = str; + return 0; +} +#endif // __MOJOSETUP__ + +#ifdef STBI_NO_FAILURE_STRINGS + #define e(x,y) 0 +#elif defined(STBI_FAILURE_USERMSG) + #define e(x,y) e(y) +#else + #define e(x,y) e(x) +#endif + +#define epf(x,y) ((float *) (e(x,y)?NULL:NULL)) +#define epuc(x,y) ((unsigned char *) (e(x,y)?NULL:NULL)) + +void stbi_image_free(void *retval_from_stbi_load) +{ + free(retval_from_stbi_load); +} + +#define MAX_LOADERS 32 +stbi_loader *loaders[MAX_LOADERS]; +static int max_loaders = 0; + +int stbi_register_loader(stbi_loader *loader) +{ + int i; + for (i=0; i < MAX_LOADERS; ++i) { + // already present? + if (loaders[i] == loader) + return 1; + // end of the list? + if (loaders[i] == NULL) { + loaders[i] = loader; + max_loaders = i+1; + return 1; + } + } + // no room for it + return 0; +} + +#ifndef STBI_NO_HDR +static float *ldr_to_hdr(stbi_uc *data, int x, int y, int comp); +static stbi_uc *hdr_to_ldr(float *data, int x, int y, int comp); +#endif + +#ifndef STBI_NO_STDIO +unsigned char *stbi_load(char *filename, int *x, int *y, int *comp, int req_comp) +{ + FILE *f = fopen(filename, "rb"); + unsigned char *result; + if (!f) return epuc("can't fopen", "Unable to open file"); + result = stbi_load_from_file(f,x,y,comp,req_comp); + fclose(f); + return result; +} + +unsigned char *stbi_load_from_file(FILE *f, int *x, int *y, int *comp, int req_comp) +{ + int i; + + #ifndef STBI_NO_JPEG // __MOJOSETUP__ + if (stbi_jpeg_test_file(f)) + return stbi_jpeg_load_from_file(f,x,y,comp,req_comp); + #endif // __MOJOSETUP__ + + #ifndef STBI_NO_PNG // __MOJOSETUP__ + if (stbi_png_test_file(f)) + return stbi_png_load_from_file(f,x,y,comp,req_comp); + #endif // __MOJOSETUP__ + + #ifndef STBI_NO_BMP // __MOJOSETUP__ + if (stbi_bmp_test_file(f)) + return stbi_bmp_load_from_file(f,x,y,comp,req_comp); + #endif // __MOJOSETUP__ + + #ifndef STBI_NO_PSD // __MOJOSETUP__ + if (stbi_psd_test_file(f)) + return stbi_psd_load_from_file(f,x,y,comp,req_comp); + #endif // __MOJOSETUP__ + + #ifndef STBI_NO_HDR + if (stbi_hdr_test_file(f)) { + float *hdr = stbi_hdr_load_from_file(f, x,y,comp,req_comp); + return hdr_to_ldr(hdr, *x, *y, req_comp ? req_comp : *comp); + } + #endif + + for (i=0; i < max_loaders; ++i) + if (loaders[i]->test_file(f)) + return loaders[i]->load_from_file(f,x,y,comp,req_comp); + + #ifndef STBI_NO_TGA // __MOJOSETUP__ + // test tga last because it's a crappy test! + if (stbi_tga_test_file(f)) + return stbi_tga_load_from_file(f,x,y,comp,req_comp); + #endif // __MOJOSETUP__ + + return epuc("unknown image type", "Image not of any known type, or corrupt"); +} +#endif + +unsigned char *stbi_load_from_memory(stbi_uc *buffer, int len, int *x, int *y, int *comp, int req_comp) +{ + int i; + + #ifndef STBI_NO_JPEG // __MOJOSETUP__ + if (stbi_jpeg_test_memory(buffer,len)) + return stbi_jpeg_load_from_memory(buffer,len,x,y,comp,req_comp); + #endif // __MOJOSETUP__ + + #ifndef STBI_NO_PNG // __MOJOSETUP__ + if (stbi_png_test_memory(buffer,len)) + return stbi_png_load_from_memory(buffer,len,x,y,comp,req_comp); + #endif // __MOJOSETUP__ + + #ifndef STBI_NO_BMP // __MOJOSETUP__ + if (stbi_bmp_test_memory(buffer,len)) + return stbi_bmp_load_from_memory(buffer,len,x,y,comp,req_comp); + #endif // __MOJOSETUP__ + + #ifndef STBI_NO_PSD // __MOJOSETUP__ + if (stbi_psd_test_memory(buffer,len)) + return stbi_psd_load_from_memory(buffer,len,x,y,comp,req_comp); + #endif // __MOJOSETUP__ + + #ifndef STBI_NO_HDR + if (stbi_hdr_test_memory(buffer, len)) { + float *hdr = stbi_hdr_load_from_memory(buffer, len,x,y,comp,req_comp); + return hdr_to_ldr(hdr, *x, *y, req_comp ? req_comp : *comp); + } + #endif + + for (i=0; i < max_loaders; ++i) + if (loaders[i]->test_memory(buffer,len)) + return loaders[i]->load_from_memory(buffer,len,x,y,comp,req_comp); + + #ifndef STBI_NO_TGA // __MOJOSETUP__ + // test tga last because it's a crappy test! + if (stbi_tga_test_memory(buffer,len)) + return stbi_tga_load_from_memory(buffer,len,x,y,comp,req_comp); + #endif // __MOJOSETUP__ + + return epuc("unknown image type", "Image not of any known type, or corrupt"); +} + +#ifndef STBI_NO_HDR + +#ifndef STBI_NO_STDIO +float *stbi_loadf(char *filename, int *x, int *y, int *comp, int req_comp) +{ + FILE *f = fopen(filename, "rb"); + float *result; + if (!f) return epf("can't fopen", "Unable to open file"); + result = stbi_loadf_from_file(f,x,y,comp,req_comp); + fclose(f); + return result; +} + +float *stbi_loadf_from_file(FILE *f, int *x, int *y, int *comp, int req_comp) +{ + unsigned char *data; + #ifndef STBI_NO_HDR + if (stbi_hdr_test_file(f)) + return stbi_hdr_load_from_file(f,x,y,comp,req_comp); + #endif + data = stbi_load_from_file(f, x, y, comp, req_comp); + if (data) + return ldr_to_hdr(data, *x, *y, req_comp ? req_comp : *comp); + return epf("unknown image type", "Image not of any known type, or corrupt"); +} +#endif + +float *stbi_loadf_from_memory(stbi_uc *buffer, int len, int *x, int *y, int *comp, int req_comp) +{ + stbi_uc *data; + #ifndef STBI_NO_HDR + if (stbi_hdr_test_memory(buffer, len)) + return stbi_hdr_load_from_memory(buffer, len,x,y,comp,req_comp); + #endif + data = stbi_load_from_memory(buffer, len, x, y, comp, req_comp); + if (data) + return ldr_to_hdr(data, *x, *y, req_comp ? req_comp : *comp); + return epf("unknown image type", "Image not of any known type, or corrupt"); +} +#endif + +// these is-hdr-or-not is defined independent of whether STBI_NO_HDR is +// defined, for API simplicity; if STBI_NO_HDR is defined, it always +// reports false! + +extern int stbi_is_hdr_from_memory(stbi_uc *buffer, int len) +{ + #ifndef STBI_NO_HDR + return stbi_hdr_test_memory(buffer, len); + #else + return 0; + #endif +} + +#ifndef STBI_NO_STDIO +extern int stbi_is_hdr (char *filename) +{ + FILE *f = fopen(filename, "rb"); + int result=0; + if (f) { + result = stbi_is_hdr_from_file(f); + fclose(f); + } + return result; +} + +extern int stbi_is_hdr_from_file(FILE *f) +{ + #ifndef STBI_NO_HDR + return stbi_hdr_test_file(f); + #else + return 0; + #endif +} + +#endif + +// @TODO: get image dimensions & components without fully decoding +#ifndef STBI_NO_STDIO +extern int stbi_info (char *filename, int *x, int *y, int *comp); +extern int stbi_info_from_file (FILE *f, int *x, int *y, int *comp); +#endif +extern int stbi_info_from_memory(stbi_uc *buffer, int len, int *x, int *y, int *comp); + +#ifndef STBI_NO_HDR +static float h2l_gamma_i=1.0f/2.2f, h2l_scale_i=1.0f; +static float l2h_gamma=2.2f, l2h_scale=1.0f; + +void stbi_hdr_to_ldr_gamma(float gamma) { h2l_gamma_i = 1/gamma; } +void stbi_hdr_to_ldr_scale(float scale) { h2l_scale_i = 1/scale; } + +void stbi_ldr_to_hdr_gamma(float gamma) { l2h_gamma = gamma; } +void stbi_ldr_to_hdr_scale(float scale) { l2h_scale = scale; } +#endif + + +////////////////////////////////////////////////////////////////////////////// +// +// Common code used by all image loaders +// + +// image width, height, # components +static uint32 img_x, img_y; +static int img_n, img_out_n; + +#if __MOJOSETUP__ // moved here from elsewhere for #ifdef safety. +static uint8 *idata, *expanded, *out; +static uint32 code_buffer; // jpeg entropy-coded buffer +#endif + +enum +{ + SCAN_load=0, + SCAN_type, + SCAN_header, +}; + +// An API for reading either from memory or file. +#ifndef STBI_NO_STDIO +static FILE *img_file; +#endif +static uint8 *img_buffer, *img_buffer_end; + +#ifndef STBI_NO_STDIO +static void start_file(FILE *f) +{ + img_file = f; +} +#endif + +static void start_mem(uint8 *buffer, int len) +{ +#ifndef STBI_NO_STDIO + img_file = NULL; +#endif + img_buffer = buffer; + img_buffer_end = buffer+len; +} + +static int get8(void) +{ +#ifndef STBI_NO_STDIO + if (img_file) { + int c = fgetc(img_file); + return c == EOF ? 0 : c; + } +#endif + if (img_buffer < img_buffer_end) + return *img_buffer++; + return 0; +} + +static int at_eof(void) +{ +#ifndef STBI_NO_STDIO + if (img_file) + return feof(img_file); +#endif + return img_buffer >= img_buffer_end; +} + +static uint8 get8u(void) +{ + return (uint8) get8(); +} + +static void skip(int n) +{ +#ifndef STBI_NO_STDIO + if (img_file) + fseek(img_file, n, SEEK_CUR); + else +#endif + img_buffer += n; +} + +static int get16(void) +{ + int z = get8(); + return (z << 8) + get8(); +} + +static uint32 get32(void) +{ + uint32 z = get16(); + return (z << 16) + get16(); +} + +static int get16le(void) +{ + int z = get8(); + return z + (get8() << 8); +} + +static uint32 get32le(void) +{ + uint32 z = get16le(); + return z + (get16le() << 16); +} + +static void getn(stbi_uc *buffer, int n) +{ +#ifndef STBI_NO_STDIO + if (img_file) { + fread(buffer, 1, n, img_file); + return; + } +#endif + memcpy(buffer, img_buffer, n); + img_buffer += n; +} + +////////////////////////////////////////////////////////////////////////////// +// +// generic converter from built-in img_n to req_comp +// individual types do this automatically as much as possible (e.g. jpeg +// does all cases internally since it needs to colorspace convert anyway, +// and it never has alpha, so very few cases ). png can automatically +// interleave an alpha=255 channel, but falls back to this for other cases +// +// assume data buffer is malloced, so malloc a new one and free that one +// only failure mode is malloc failing + +static uint8 compute_y(int r, int g, int b) +{ + return (uint8) (((r*77) + (g*150) + (29*b)) >> 8); +} + +static unsigned char *convert_format(unsigned char *data, int img_n, int req_comp) +{ +#if __MOJOSETUP__ + //uint i,j; + uint32 i,j; +#endif + unsigned char *good; + + if (req_comp == img_n) return data; + assert(req_comp >= 1 && req_comp <= 4); + + good = (unsigned char *) malloc(req_comp * img_x * img_y); + if (good == NULL) { + free(data); + return epuc("outofmem", "Out of memory"); + } + + for (j=0; j < img_y; ++j) { + unsigned char *src = data + j * img_x * img_n ; + unsigned char *dest = good + j * img_x * req_comp; + + #define COMBO(a,b) ((a)*8+(b)) + #define CASE(a,b) case COMBO(a,b): for(i=0; i < img_x; ++i, src += a, dest += b) + + // convert source image with img_n components to one with req_comp components; + // avoid switch per pixel, so use switch per scanline and massive macros + switch(COMBO(img_n, req_comp)) { + CASE(1,2) dest[0]=src[0], dest[1]=255; break; + CASE(1,3) dest[0]=dest[1]=dest[2]=src[0]; break; + CASE(1,4) dest[0]=dest[1]=dest[2]=src[0], dest[3]=255; break; + CASE(2,1) dest[0]=src[0]; break; + CASE(2,3) dest[0]=dest[1]=dest[2]=src[0]; break; + CASE(2,4) dest[0]=dest[1]=dest[2]=src[0], dest[3]=src[1]; break; + CASE(3,4) dest[0]=src[0],dest[1]=src[1],dest[2]=src[2],dest[3]=255; break; + CASE(3,1) dest[0]=compute_y(src[0],src[1],src[2]); break; + CASE(3,2) dest[0]=compute_y(src[0],src[1],src[2]), dest[1] = 255; break; + CASE(4,1) dest[0]=compute_y(src[0],src[1],src[2]); break; + CASE(4,2) dest[0]=compute_y(src[0],src[1],src[2]), dest[1] = src[3]; break; + CASE(4,3) dest[0]=src[0],dest[1]=src[1],dest[2]=src[2]; break; + default: assert(0); + } + #undef CASE + } + + free(data); + img_out_n = req_comp; + return good; +} + +#ifndef STBI_NO_HDR +static float *ldr_to_hdr(stbi_uc *data, int x, int y, int comp) +{ + int i,k,n; + float *output = (float *) malloc(x * y * comp * sizeof(float)); + if (output == NULL) { free(data); return epf("outofmem", "Out of memory"); } + // compute number of non-alpha components + if (comp & 1) n = comp; else n = comp-1; + for (i=0; i < x*y; ++i) { + for (k=0; k < n; ++k) { + output[i*comp + k] = (float) pow(data[i*comp+k]/255.0f, l2h_gamma) * l2h_scale; + } + if (k < comp) output[i*comp + k] = data[i*comp+k]/255.0f; + } + free(data); + return output; +} + +#define float2int(x) ((int) (x)) +static stbi_uc *hdr_to_ldr(float *data, int x, int y, int comp) +{ + int i,k,n; + stbi_uc *output = (stbi_uc *) malloc(x * y * comp); + if (output == NULL) { free(data); return epuc("outofmem", "Out of memory"); } + // compute number of non-alpha components + if (comp & 1) n = comp; else n = comp-1; + for (i=0; i < x*y; ++i) { + for (k=0; k < n; ++k) { + float z = (float) pow(data[i*comp+k]*h2l_scale_i, h2l_gamma_i) * 255 + 0.5f; + if (z < 0) z = 0; + if (z > 255) z = 255; + output[i*comp + k] = float2int(z); + } + if (k < comp) { + float z = data[i*comp+k] * 255 + 0.5f; + if (z < 0) z = 0; + if (z > 255) z = 255; + output[i*comp + k] = float2int(z); + } + } + free(data); + return output; +} +#endif + + +#ifndef STBI_NO_JPEG // __MOJOSETUP__ + +////////////////////////////////////////////////////////////////////////////// +// +// "baseline" JPEG/JFIF decoder (not actually fully baseline implementation) +// +// simple implementation +// - channel subsampling of at most 2 in each dimension +// - doesn't support delayed output of y-dimension +// - simple interface (only one output format: 8-bit interleaved RGB) +// - doesn't try to recover corrupt jpegs +// - doesn't allow partial loading, loading multiple at once +// - still fast on x86 (copying globals into locals doesn't help x86) +// - allocates lots of intermediate memory (full size of all components) +// - non-interleaved case requires this anyway +// - allows good upsampling (see next) +// high-quality +// - upsampled channels are bilinearly interpolated, even across blocks +// - quality integer IDCT derived from IJG's 'slow' +// performance +// - fast huffman; reasonable integer IDCT +// - uses a lot of intermediate memory, could cache poorly +// - load http://nothings.org/remote/anemones.jpg 3 times on 2.8Ghz P4 +// stb_jpeg: 1.34 seconds (MSVC6, default release build) +// stb_jpeg: 1.06 seconds (MSVC6, processor = Pentium Pro) +// IJL11.dll: 1.08 seconds (compiled by intel) +// IJG 1998: 0.98 seconds (MSVC6, makefile provided by IJG) +// IJG 1998: 0.95 seconds (MSVC6, makefile + proc=PPro) + +int stbi_jpeg_dc_only; + +// huffman decoding acceleration +#define FAST_BITS 9 // larger handles more cases; smaller stomps less cache + +typedef struct +{ + uint8 fast[1 << FAST_BITS]; + // weirdly, repacking this into AoS is a 10% speed loss, instead of a win + uint16 code[256]; + uint8 values[256]; + uint8 size[257]; + unsigned int maxcode[18]; + int delta[17]; // old 'firstsymbol' - old 'firstcode' +} huffman; + +static huffman huff_dc[4]; // baseline is 2 tables, extended is 4 +static huffman huff_ac[4]; +static uint8 dequant[4][64]; + +static int build_huffman(huffman *h, int *count) +{ + int i,j,k=0,code; + // build size list for each symbol (from JPEG spec) + for (i=0; i < 16; ++i) + for (j=0; j < count[i]; ++j) + h->size[k++] = (uint8) (i+1); + h->size[k] = 0; + + // compute actual symbols (from jpeg spec) + code = 0; + k = 0; + for(j=1; j <= 16; ++j) { + // compute delta to add to code to compute symbol id + h->delta[j] = k - code; + if (h->size[k] == j) { + while (h->size[k] == j) + h->code[k++] = (uint16) (code++); + if (code-1 >= (1 << j)) return e("bad code lengths","Corrupt JPEG"); + } + // compute largest code + 1 for this size, preshifted as needed later + h->maxcode[j] = code << (16-j); + code <<= 1; + } + h->maxcode[j] = 0xffffffff; + + // build non-spec acceleration table; 255 is flag for not-accelerated + memset(h->fast, 255, 1 << FAST_BITS); + for (i=0; i < k; ++i) { + int s = h->size[i]; + if (s <= FAST_BITS) { + int c = h->code[i] << (FAST_BITS-s); + int m = 1 << (FAST_BITS-s); + for (j=0; j < m; ++j) { + h->fast[c+j] = (uint8) i; + } + } + } + return 1; +} + +// sizes for components, interleaved MCUs +static int img_h_max, img_v_max; +static int img_mcu_x, img_mcu_y; +static int img_mcu_w, img_mcu_h; + +// definition of jpeg image component +static struct +{ + int id; + int h,v; + int tq; + int hd,ha; + int dc_pred; + + int x,y,w2,h2; + uint8 *data; +} img_comp[4]; + +#if !__MOJOSETUP__ // moved elsewhere for #ifdef safety. +static unsigned long code_buffer; // jpeg entropy-coded buffer +#endif +static int code_bits; // number of valid bits +static unsigned char marker; // marker seen while filling entropy buffer +static int nomore; // flag if we saw a marker so must stop + +static void grow_buffer_unsafe(void) +{ + do { + int b = nomore ? 0 : get8(); + if (b == 0xff) { + int c = get8(); + if (c != 0) { + marker = (unsigned char) c; + nomore = 1; + return; + } + } + code_buffer = (code_buffer << 8) | b; + code_bits += 8; + } while (code_bits <= 24); +} + +// (1 << n) - 1 +static unsigned long bmask[17]={0,1,3,7,15,31,63,127,255,511,1023,2047,4095,8191,16383,32767,65535}; + +// decode a jpeg huffman value from the bitstream +__forceinline static int decode(huffman *h) +{ + unsigned int temp; + int c,k; + + if (code_bits < 16) grow_buffer_unsafe(); + + // look at the top FAST_BITS and determine what symbol ID it is, + // if the code is <= FAST_BITS + c = (code_buffer >> (code_bits - FAST_BITS)) & ((1 << FAST_BITS)-1); + k = h->fast[c]; + if (k < 255) { + if (h->size[k] > code_bits) + return -1; + code_bits -= h->size[k]; + return h->values[k]; + } + + // naive test is to shift the code_buffer down so k bits are + // valid, then test against maxcode. To speed this up, we've + // preshifted maxcode left so that it has (16-k) 0s at the + // end; in other words, regardless of the number of bits, it + // wants to be compared against something shifted to have 16; + // that way we don't need to shift inside the loop. + if (code_bits < 16) + temp = (code_buffer << (16 - code_bits)) & 0xffff; + else + temp = (code_buffer >> (code_bits - 16)) & 0xffff; + for (k=FAST_BITS+1 ; ; ++k) + if (temp < h->maxcode[k]) + break; + if (k == 17) { + // error! code not found + code_bits -= 16; + return -1; + } + + if (k > code_bits) + return -1; + + // convert the huffman code to the symbol id + c = ((code_buffer >> (code_bits - k)) & bmask[k]) + h->delta[k]; + assert((((code_buffer) >> (code_bits - h->size[c])) & bmask[h->size[c]]) == h->code[c]); + + // convert the id to a symbol + code_bits -= k; + return h->values[c]; +} + +// combined JPEG 'receive' and JPEG 'extend', since baseline +// always extends everything it receives. +__forceinline static int extend_receive(int n) +{ + unsigned int m = 1 << (n-1); + unsigned int k; + if (code_bits < n) grow_buffer_unsafe(); + k = (code_buffer >> (code_bits - n)) & bmask[n]; + code_bits -= n; + // the following test is probably a random branch that won't + // predict well. I tried to table accelerate it but failed. + // maybe it's compiling as a conditional move? + if (k < m) + return (-1 << n) + k + 1; + else + return k; +} + +// given a value that's at position X in the zigzag stream, +// where does it appear in the 8x8 matrix coded as row-major? +static uint8 dezigzag[64+15] = +{ + 0, 1, 8, 16, 9, 2, 3, 10, + 17, 24, 32, 25, 18, 11, 4, 5, + 12, 19, 26, 33, 40, 48, 41, 34, + 27, 20, 13, 6, 7, 14, 21, 28, + 35, 42, 49, 56, 57, 50, 43, 36, + 29, 22, 15, 23, 30, 37, 44, 51, + 58, 59, 52, 45, 38, 31, 39, 46, + 53, 60, 61, 54, 47, 55, 62, 63, + // let corrupt input sample past end + 63, 63, 63, 63, 63, 63, 63, 63, + 63, 63, 63, 63, 63, 63, 63 +}; + +// decode one 64-entry block-- +static int decode_block(short data[64], huffman *hdc, huffman *hac, int b) +{ + int diff,dc,k; + int t = decode(hdc); + if (t < 0) return e("bad huffman code","Corrupt JPEG"); + + // 0 all the ac values now so we can do it 32-bits at a time + memset(data,0,64*sizeof(data[0])); + + diff = t ? extend_receive(t) : 0; + dc = img_comp[b].dc_pred + diff; + img_comp[b].dc_pred = dc; + data[0] = (short) dc; + + // decode AC components, see JPEG spec + k = 1; + do { + int r,s; + int rs = decode(hac); + if (rs < 0) return e("bad huffman code","Corrupt JPEG"); + s = rs & 15; + r = rs >> 4; + if (s == 0) { + if (rs != 0xf0) break; // end block + k += 16; + } else { + k += r; + // decode into unzigzag'd location + data[dezigzag[k++]] = (short) extend_receive(s); + } + } while (k < 64); + return 1; +} + +// take a -128..127 value and clamp it and convert to 0..255 +__forceinline static uint8 clamp(int x) +{ + x += 128; + // trick to use a single test to catch both cases + if ((unsigned int) x > 255) { + if (x < 0) return 0; + if (x > 255) return 255; + } + return (uint8) x; +} + +#define f2f(x) (int) (((x) * 4096 + 0.5)) +#define fsh(x) ((x) << 12) + +// derived from jidctint -- DCT_ISLOW +#define IDCT_1D(s0,s1,s2,s3,s4,s5,s6,s7) \ + int t0,t1,t2,t3,p1,p2,p3,p4,p5,x0,x1,x2,x3; \ + p2 = s2; \ + p3 = s6; \ + p1 = (p2+p3) * f2f(0.5411961f); \ + t2 = p1 + p3*f2f(-1.847759065f); \ + t3 = p1 + p2*f2f( 0.765366865f); \ + p2 = s0; \ + p3 = s4; \ + t0 = fsh(p2+p3); \ + t1 = fsh(p2-p3); \ + x0 = t0+t3; \ + x3 = t0-t3; \ + x1 = t1+t2; \ + x2 = t1-t2; \ + t0 = s7; \ + t1 = s5; \ + t2 = s3; \ + t3 = s1; \ + p3 = t0+t2; \ + p4 = t1+t3; \ + p1 = t0+t3; \ + p2 = t1+t2; \ + p5 = (p3+p4)*f2f( 1.175875602f); \ + t0 = t0*f2f( 0.298631336f); \ + t1 = t1*f2f( 2.053119869f); \ + t2 = t2*f2f( 3.072711026f); \ + t3 = t3*f2f( 1.501321110f); \ + p1 = p5 + p1*f2f(-0.899976223f); \ + p2 = p5 + p2*f2f(-2.562915447f); \ + p3 = p3*f2f(-1.961570560f); \ + p4 = p4*f2f(-0.390180644f); \ + t3 += p1+p4; \ + t2 += p2+p3; \ + t1 += p2+p4; \ + t0 += p1+p3; + +// .344 seconds on 3*anemones.jpg +static void idct_block(uint8 *out, int out_stride, short data[64], uint8 *dequantize) +{ + int i,val[64],*v=val; + uint8 *o,*dq = dequantize; + short *d = data; + + if (stbi_jpeg_dc_only) { + // ok, I don't really know why this is right, but it seems to be: + int z = 128 + ((d[0] * dq[0]) >> 3); + for (i=0; i < 8; ++i) { + out[0] = out[1] = out[2] = out[3] = out[4] = out[5] = out[6] = out[7] = z; + out += out_stride; + } + return; + } + + // columns + for (i=0; i < 8; ++i,++d,++dq, ++v) { + // if all zeroes, shortcut -- this avoids dequantizing 0s and IDCTing + if (d[ 8]==0 && d[16]==0 && d[24]==0 && d[32]==0 + && d[40]==0 && d[48]==0 && d[56]==0) { + // no shortcut 0 seconds + // (1|2|3|4|5|6|7)==0 0 seconds + // all separate -0.047 seconds + // 1 && 2|3 && 4|5 && 6|7: -0.047 seconds + int dcterm = d[0] * dq[0] << 2; + v[0] = v[8] = v[16] = v[24] = v[32] = v[40] = v[48] = v[56] = dcterm; + } else { + IDCT_1D(d[ 0]*dq[ 0],d[ 8]*dq[ 8],d[16]*dq[16],d[24]*dq[24], + d[32]*dq[32],d[40]*dq[40],d[48]*dq[48],d[56]*dq[56]) + // constants scaled things up by 1<<12; let's bring them back + // down, but keep 2 extra bits of precision + x0 += 512; x1 += 512; x2 += 512; x3 += 512; + v[ 0] = (x0+t3) >> 10; + v[56] = (x0-t3) >> 10; + v[ 8] = (x1+t2) >> 10; + v[48] = (x1-t2) >> 10; + v[16] = (x2+t1) >> 10; + v[40] = (x2-t1) >> 10; + v[24] = (x3+t0) >> 10; + v[32] = (x3-t0) >> 10; + } + } + + for (i=0, v=val, o=out; i < 8; ++i,v+=8,o+=out_stride) { + // no fast case since the first 1D IDCT spread components out + IDCT_1D(v[0],v[1],v[2],v[3],v[4],v[5],v[6],v[7]) + // constants scaled things up by 1<<12, plus we had 1<<2 from first + // loop, plus horizontal and vertical each scale by sqrt(8) so together + // we've got an extra 1<<3, so 1<<17 total we need to remove. + x0 += 65536; x1 += 65536; x2 += 65536; x3 += 65536; + o[0] = clamp((x0+t3) >> 17); + o[7] = clamp((x0-t3) >> 17); + o[1] = clamp((x1+t2) >> 17); + o[6] = clamp((x1-t2) >> 17); + o[2] = clamp((x2+t1) >> 17); + o[5] = clamp((x2-t1) >> 17); + o[3] = clamp((x3+t0) >> 17); + o[4] = clamp((x3-t0) >> 17); + } +} + +#define MARKER_none 0xff +// if there's a pending marker from the entropy stream, return that +// otherwise, fetch from the stream and get a marker. if there's no +// marker, return 0xff, which is never a valid marker value +static uint8 get_marker(void) +{ + uint8 x; + if (marker != MARKER_none) { x = marker; marker = MARKER_none; return x; } + x = get8u(); + if (x != 0xff) return MARKER_none; + while (x == 0xff) + x = get8u(); + return x; +} + +// in each scan, we'll have scan_n components, and the order +// of the components is specified by order[] +static int scan_n, order[4]; +static int restart_interval, todo; +#define RESTART(x) ((x) >= 0xd0 && (x) <= 0xd7) + +// after a restart interval, reset the entropy decoder and +// the dc prediction +static void reset(void) +{ + code_bits = 0; + code_buffer = 0; + nomore = 0; + img_comp[0].dc_pred = img_comp[1].dc_pred = img_comp[2].dc_pred = 0; + marker = MARKER_none; + todo = restart_interval ? restart_interval : 0x7fffffff; + // no more than 1<<31 MCUs if no restart_interal? that's plenty safe, + // since we don't even allow 1<<30 pixels +} + +static int parse_entropy_coded_data(void) +{ + reset(); + if (scan_n == 1) { + int i,j; + short data[64]; + int n = order[0]; + // non-interleaved data, we just need to process one block at a time, + // in trivial scanline order + // number of blocks to do just depends on how many actual "pixels" this + // component has, independent of interleaved MCU blocking and such + int w = (img_comp[n].x+7) >> 3; + int h = (img_comp[n].y+7) >> 3; + for (j=0; j < h; ++j) { + for (i=0; i < w; ++i) { + if (!decode_block(data, huff_dc+img_comp[n].hd, huff_ac+img_comp[n].ha, n)) return 0; + idct_block(img_comp[n].data+img_comp[n].w2*j*8+i*8, img_comp[n].w2, data, dequant[img_comp[n].tq]); + // every data block is an MCU, so countdown the restart interval + if (--todo <= 0) { + if (code_bits < 24) grow_buffer_unsafe(); + // if it's NOT a restart, then just bail, so we get corrupt data + // rather than no data + if (!RESTART(marker)) return 1; + reset(); + } + } + } + } else { // interleaved! + int i,j,k,x,y; + short data[64]; + for (j=0; j < img_mcu_y; ++j) { + for (i=0; i < img_mcu_x; ++i) { + // scan an interleaved mcu... process scan_n components in order + for (k=0; k < scan_n; ++k) { + int n = order[k]; + // scan out an mcu's worth of this component; that's just determined + // by the basic H and V specified for the component + for (y=0; y < img_comp[n].v; ++y) { + for (x=0; x < img_comp[n].h; ++x) { + int x2 = (i*img_comp[n].h + x)*8; + int y2 = (j*img_comp[n].v + y)*8; + if (!decode_block(data, huff_dc+img_comp[n].hd, huff_ac+img_comp[n].ha, n)) return 0; + idct_block(img_comp[n].data+img_comp[n].w2*y2+x2, img_comp[n].w2, data, dequant[img_comp[n].tq]); + } + } + } + // after all interleaved components, that's an interleaved MCU, + // so now count down the restart interval + if (--todo <= 0) { + if (code_bits < 24) grow_buffer_unsafe(); + // if it's NOT a restart, then just bail, so we get corrupt data + // rather than no data + if (!RESTART(marker)) return 1; + reset(); + } + } + } + } + return 1; +} + +static int process_marker(int m) +{ + int L; + switch (m) { + case MARKER_none: // no marker found + return e("expected marker","Corrupt JPEG"); + + case 0xC2: // SOF - progressive + return e("progressive jpeg","JPEG format not supported (progressive)"); + + case 0xDD: // DRI - specify restart interval + if (get16() != 4) return e("bad DRI len","Corrupt JPEG"); + restart_interval = get16(); + return 1; + + case 0xDB: // DQT - define quantization table + L = get16()-2; + while (L > 0) { + int z = get8(); + int p = z >> 4; + int t = z & 15,i; + if (p != 0) return e("bad DQT type","Corrupt JPEG"); + if (t > 3) return e("bad DQT table","Corrupt JPEG"); + for (i=0; i < 64; ++i) + dequant[t][dezigzag[i]] = get8u(); + L -= 65; + } + return L==0; + + case 0xC4: // DHT - define huffman table + L = get16()-2; + while (L > 0) { + uint8 *v; + int sizes[16],i,m=0; + int z = get8(); + int tc = z >> 4; + int th = z & 15; + if (tc > 1 || th > 3) return e("bad DHT header","Corrupt JPEG"); + for (i=0; i < 16; ++i) { + sizes[i] = get8(); + m += sizes[i]; + } + L -= 17; + if (tc == 0) { + if (!build_huffman(huff_dc+th, sizes)) return 0; + v = huff_dc[th].values; + } else { + if (!build_huffman(huff_ac+th, sizes)) return 0; + v = huff_ac[th].values; + } + for (i=0; i < m; ++i) + v[i] = get8u(); + L -= m; + } + return L==0; + } + // check for comment block or APP blocks + if ((m >= 0xE0 && m <= 0xEF) || m == 0xFE) { + skip(get16()-2); + return 1; + } + return 0; +} + +// after we see SOS +static int process_scan_header(void) +{ + int i; + int Ls = get16(); + scan_n = get8(); + if (scan_n < 1 || scan_n > 4 || scan_n > (int) img_n) return e("bad SOS component count","Corrupt JPEG"); + if (Ls != 6+2*scan_n) return e("bad SOS len","Corrupt JPEG"); + for (i=0; i < scan_n; ++i) { + int id = get8(), which; + int z = get8(); + for (which = 0; which < img_n; ++which) + if (img_comp[which].id == id) + break; + if (which == img_n) return 0; + img_comp[which].hd = z >> 4; if (img_comp[which].hd > 3) return e("bad DC huff","Corrupt JPEG"); + img_comp[which].ha = z & 15; if (img_comp[which].ha > 3) return e("bad AC huff","Corrupt JPEG"); + order[i] = which; + } + if (get8() != 0) return e("bad SOS","Corrupt JPEG"); + get8(); // should be 63, but might be 0 + if (get8() != 0) return e("bad SOS","Corrupt JPEG"); + + return 1; +} + +static int process_frame_header(int scan) +{ + int Lf,p,i,z, h_max=1,v_max=1; + Lf = get16(); if (Lf < 11) return e("bad SOF len","Corrupt JPEG"); // JPEG + p = get8(); if (p != 8) return e("only 8-bit","JPEG format not supported: 8-bit only"); // JPEG baseline + img_y = get16(); if (img_y == 0) return e("no header height", "JPEG format not supported: delayed height"); // Legal, but we don't handle it--but neither does IJG + img_x = get16(); if (img_x == 0) return e("0 width","Corrupt JPEG"); // JPEG requires + img_n = get8(); + if (img_n != 3 && img_n != 1) return e("bad component count","Corrupt JPEG"); // JFIF requires + + if (Lf != 8+3*img_n) return e("bad SOF len","Corrupt JPEG"); + + for (i=0; i < img_n; ++i) { + img_comp[i].id = get8(); + if (img_comp[i].id != i+1) // JFIF requires + if (img_comp[i].id != i) // jpegtran outputs non-JFIF-compliant files! + return e("bad component ID","Corrupt JPEG"); + z = get8(); + img_comp[i].h = (z >> 4); if (!img_comp[i].h || img_comp[i].h > 4) return e("bad H","Corrupt JPEG"); + img_comp[i].v = z & 15; if (!img_comp[i].v || img_comp[i].v > 4) return e("bad V","Corrupt JPEG"); + img_comp[i].tq = get8(); if (img_comp[i].tq > 3) return e("bad TQ","Corrupt JPEG"); + } + + if (scan != SCAN_load) return 1; + + if ((1 << 30) / img_x / img_n < img_y) return e("too large", "Image too large to decode"); + + for (i=0; i < img_n; ++i) { + if (img_comp[i].h > h_max) h_max = img_comp[i].h; + if (img_comp[i].v > v_max) v_max = img_comp[i].v; + } + + // compute interleaved mcu info + img_h_max = h_max; + img_v_max = v_max; + img_mcu_w = h_max * 8; + img_mcu_h = v_max * 8; + img_mcu_x = (img_x + img_mcu_w-1) / img_mcu_w; + img_mcu_y = (img_y + img_mcu_h-1) / img_mcu_h; + + for (i=0; i < img_n; ++i) { + // number of effective pixels (e.g. for non-interleaved MCU) + img_comp[i].x = (img_x * img_comp[i].h + h_max-1) / h_max; + img_comp[i].y = (img_y * img_comp[i].v + v_max-1) / v_max; + // to simplify generation, we'll allocate enough memory to decode + // the bogus oversized data from using interleaved MCUs and their + // big blocks (e.g. a 16x16 iMCU on an image of width 33); we won't + // discard the extra data until colorspace conversion + img_comp[i].w2 = img_mcu_x * img_comp[i].h * 8; + img_comp[i].h2 = img_mcu_y * img_comp[i].v * 8; + img_comp[i].data = (uint8 *) malloc(img_comp[i].w2 * img_comp[i].h2); + if (img_comp[i].data == NULL) { + for(--i; i >= 0; --i) + free(img_comp[i].data); + return e("outofmem", "Out of memory"); + } + } + + return 1; +} + +// use comparisons since in some cases we handle more than one case (e.g. SOF) +#define DNL(x) ((x) == 0xdc) +#define SOI(x) ((x) == 0xd8) +#define EOI(x) ((x) == 0xd9) +#define SOF(x) ((x) == 0xc0 || (x) == 0xc1) +#define SOS(x) ((x) == 0xda) + +static int decode_jpeg_header(int scan) +{ + int m; + marker = MARKER_none; // initialize cached marker to empty + m = get_marker(); + if (!SOI(m)) return e("no SOI","Corrupt JPEG"); + if (scan == SCAN_type) return 1; + m = get_marker(); + while (!SOF(m)) { + if (!process_marker(m)) return 0; + m = get_marker(); + while (m == MARKER_none) { + // some files have extra padding after their blocks, so ok, we'll scan + if (at_eof()) return e("no SOF", "Corrupt JPEG"); + m = get_marker(); + } + } + if (!process_frame_header(scan)) return 0; + return 1; +} + +static int decode_jpeg_image(void) +{ + int m; + restart_interval = 0; + if (!decode_jpeg_header(SCAN_load)) return 0; + m = get_marker(); + while (!EOI(m)) { + if (SOS(m)) { + if (!process_scan_header()) return 0; + if (!parse_entropy_coded_data()) return 0; + } else { + if (!process_marker(m)) return 0; + } + m = get_marker(); + } + return 1; +} + +// static jfif-centered resampling with cross-block smoothing +// here by cross-block smoothing what I mean is that the resampling +// is bilerp and crosses blocks; I dunno what IJG means + +#define div4(x) ((uint8) ((x) >> 2)) + +static void resample_v_2(uint8 *out1, uint8 *input, int w, int h, int s) +{ + // need to generate two samples vertically for every one in input + uint8 *above; + uint8 *below; + uint8 *source; + uint8 *out2; + int i,j; + source = input; + out2 = out1+w; + for (j=0; j < h; ++j) { + above = source; + source = input + j*s; + below = source + s; if (j == h-1) below = source; + for (i=0; i < w; ++i) { + int n = source[i]*3; + out1[i] = div4(above[i] + n); + out2[i] = div4(below[i] + n); + } + out1 += w*2; + out2 += w*2; + } +} + +static void resample_h_2(uint8 *out, uint8 *input, int w, int h, int s) +{ + // need to generate two samples horizontally for every one in input + int i,j; + if (w == 1) { + for (j=0; j < h; ++j) + out[j*2+0] = out[j*2+1] = input[j*s]; + return; + } + for (j=0; j < h; ++j) { + out[0] = input[0]; + out[1] = div4(input[0]*3 + input[1]); + for (i=1; i < w-1; ++i) { + int n = input[i]*3; + out[i*2-2] = div4(input[i-1] + n); + out[i*2-1] = div4(input[i+1] + n); + } + out[w*2-2] = div4(input[w-2]*3 + input[w-1]); + out[w*2-1] = input[w-1]; + out += w*2; + input += s; + } +} + +// .172 seconds on 3*anemones.jpg +static void resample_hv_2(uint8 *out, uint8 *input, int w, int h, int s) +{ + // need to generate 2x2 samples for every one in input + int i,j; + int os = w*2; + // generate edge samples... @TODO lerp them! + for (i=0; i < w; ++i) { + out[i*2+0] = out[i*2+1] = input[i]; + out[i*2+(2*h-1)*os+0] = out[i*2+(2*h-1)*os+1] = input[i+(h-1)*w]; + } + for (j=0; j < h; ++j) { + out[j*os*2+0] = out[j*os*2+os+0] = input[j*w]; + out[j*os*2+os-1] = out[j*os*2+os+os-1] = input[j*w+i-1]; + } + // now generate interior samples; i & j point to top left of input + for (j=0; j < h-1; ++j) { + uint8 *in1 = input+j*s; + uint8 *in2 = in1 + s; + uint8 *out1 = out + (j*2+1)*os + 1; + uint8 *out2 = out1 + os; + for (i=0; i < w-1; ++i) { + int p00 = in1[0], p01=in1[1], p10=in2[0], p11=in2[1]; + int p00_3 = p00*3, p01_3 = p01*3, p10_3 = p10*3, p11_3 = p11*3; + + #define div16(x) ((uint8) ((x) >> 4)) + + out1[0] = div16(p00*9 + p01_3 + p10_3 + p11); + out1[1] = div16(p01*9 + p00_3 + p01_3 + p10); + out2[0] = div16(p10*9 + p11_3 + p00_3 + p01); + out2[1] = div16(p11*9 + p10_3 + p01_3 + p00); + out1 += 2; + out2 += 2; + ++in1; + ++in2; + } + } +} + +#define float2fixed(x) ((int) ((x) * 65536 + 0.5)) + +// 0.38 seconds on 3*anemones.jpg (0.25 with processor = Pro) +// VC6 without processor=Pro is generating multiple LEAs per multiply! +static void YCbCr_to_RGB_row(uint8 *out, uint8 *y, uint8 *pcb, uint8 *pcr, int count, int step) +{ + int i; + for (i=0; i < count; ++i) { + int y_fixed = (y[i] << 16) + 32768; // rounding + int r,g,b; + int cr = pcr[i] - 128; + int cb = pcb[i] - 128; + r = y_fixed + cr*float2fixed(1.40200f); + g = y_fixed - cr*float2fixed(0.71414f) - cb*float2fixed(0.34414f); + b = y_fixed + cb*float2fixed(1.77200f); + r >>= 16; + g >>= 16; + b >>= 16; + if ((unsigned) r > 255) { if (r < 0) r = 0; else r = 255; } + if ((unsigned) g > 255) { if (g < 0) g = 0; else g = 255; } + if ((unsigned) b > 255) { if (b < 0) b = 0; else b = 255; } + out[0] = (uint8)r; + out[1] = (uint8)g; + out[2] = (uint8)b; + if (step == 4) out[3] = 255; + out += step; + } +} + +// clean up the temporary component buffers +static void cleanup_jpeg(void) +{ + int i; + for (i=0; i < img_n; ++i) { + if (img_comp[i].data) { + free(img_comp[i].data); + img_comp[i].data = NULL; + } + } +} + +static uint8 *load_jpeg_image(int *out_x, int *out_y, int *comp, int req_comp) +{ + int i, n; + // validate req_comp + if (req_comp < 0 || req_comp > 4) return epuc("bad req_comp", "Internal error"); + + // load a jpeg image from whichever source + if (!decode_jpeg_image()) { cleanup_jpeg(); return NULL; } + + // determine actual number of components to generate + n = req_comp ? req_comp : img_n; + + // resample components to full size... memory wasteful, but this + // lets us bilerp across blocks while upsampling + for (i=0; i < img_n; ++i) { + // if we're outputting fewer than 3 components, we're grey not RGB; + // in that case, don't bother upsampling Cb or Cr + if (n < 3 && i) continue; + + // check if the component scale is less than max; if so it needs upsampling + if (img_comp[i].h != img_h_max || img_comp[i].v != img_v_max) { + int stride = img_x; + // allocate final size; make sure it's big enough for upsampling off + // the edges with upsample up to 4x4 (although we only support 2x2 + // currently) + uint8 *new_data = (uint8 *) malloc((img_x+3)*(img_y+3)); + if (new_data == NULL) { + cleanup_jpeg(); + return epuc("outofmem", "Out of memory (image too large?)"); + } + if (img_comp[i].h*2 == img_h_max && img_comp[i].v*2 == img_v_max) { + int tx = (img_x+1)>>1; + resample_hv_2(new_data, img_comp[i].data, tx,(img_y+1)>>1, img_comp[i].w2); + stride = tx*2; + } else if (img_comp[i].h == img_h_max && img_comp[i].v*2 == img_v_max) { + resample_v_2(new_data, img_comp[i].data, img_x,(img_y+1)>>1, img_comp[i].w2); + } else if (img_comp[i].h*2 == img_h_max && img_comp[i].v == img_v_max) { + int tx = (img_x+1)>>1; + resample_h_2(new_data, img_comp[i].data, tx,img_y, img_comp[i].w2); + stride = tx*2; + } else { + // @TODO resample uncommon sampling pattern with nearest neighbor + free(new_data); + cleanup_jpeg(); + return epuc("uncommon H or V", "JPEG not supported: atypical downsampling mode"); + } + img_comp[i].w2 = stride; + free(img_comp[i].data); + img_comp[i].data = new_data; + } + } + + // now convert components to output image + { + uint32 i,j; + uint8 *output = (uint8 *) malloc(n * img_x * img_y + 1); + if (n >= 3) { // output STBI_rgb_* + for (j=0; j < img_y; ++j) { + uint8 *y = img_comp[0].data + j*img_comp[0].w2; + uint8 *out = output + n * img_x * j; + if (img_n == 3) { + uint8 *cb = img_comp[1].data + j*img_comp[1].w2; + uint8 *cr = img_comp[2].data + j*img_comp[2].w2; + YCbCr_to_RGB_row(out, y, cb, cr, img_x, n); + } else { + for (i=0; i < img_x; ++i) { + out[0] = out[1] = out[2] = y[i]; + out[3] = 255; // not used if n == 3 + out += n; + } + } + } + } else { // output STBI_grey_* + for (j=0; j < img_y; ++j) { + uint8 *y = img_comp[0].data + j*img_comp[0].w2; + uint8 *out = output + n * img_x * j; + if (n == 1) + for (i=0; i < img_x; ++i) *out++ = *y++; + else + for (i=0; i < img_x; ++i) *out++ = *y++, *out++ = 255; + } + } + cleanup_jpeg(); + *out_x = img_x; + *out_y = img_y; + if (comp) *comp = img_n; // report original components, not output + return output; + } +} + +#ifndef STBI_NO_STDIO +unsigned char *stbi_jpeg_load_from_file(FILE *f, int *x, int *y, int *comp, int req_comp) +{ + start_file(f); + return load_jpeg_image(x,y,comp,req_comp); +} + +unsigned char *stbi_jpeg_load(char *filename, int *x, int *y, int *comp, int req_comp) +{ + unsigned char *data; + FILE *f = fopen(filename, "rb"); + if (!f) return NULL; + data = stbi_jpeg_load_from_file(f,x,y,comp,req_comp); + fclose(f); + return data; +} +#endif + +unsigned char *stbi_jpeg_load_from_memory(stbi_uc *buffer, int len, int *x, int *y, int *comp, int req_comp) +{ + start_mem(buffer,len); + return load_jpeg_image(x,y,comp,req_comp); +} + +#ifndef STBI_NO_STDIO +int stbi_jpeg_test_file(FILE *f) +{ + int n,r; + n = ftell(f); + start_file(f); + r = decode_jpeg_header(SCAN_type); + fseek(f,n,SEEK_SET); + return r; +} +#endif + +#endif // __MOJOSETUP__ + +int stbi_jpeg_test_memory(unsigned char *buffer, int len) +{ +#ifndef STBI_NO_JPEG // __MOJOSETUP__ + start_mem(buffer,len); + return decode_jpeg_header(SCAN_type); +#else + return 0; +#endif // __MOJOSETUP__ +} + +// @TODO: +#ifndef STBI_NO_STDIO +extern int stbi_jpeg_info (char *filename, int *x, int *y, int *comp); +extern int stbi_jpeg_info_from_file (FILE *f, int *x, int *y, int *comp); +#endif +extern int stbi_jpeg_info_from_memory(stbi_uc *buffer, int len, int *x, int *y, int *comp); + + +#ifndef STBI_NO_ZLIB // __MOJOSETUP__ + +// public domain zlib decode v0.2 Sean Barrett 2006-11-18 +// simple implementation +// - all input must be provided in an upfront buffer +// - all output is written to a single output buffer (can malloc/realloc) +// performance +// - fast huffman + +// fast-way is faster to check than jpeg huffman, but slow way is slower +#define ZFAST_BITS 9 // accelerate all cases in default tables +#define ZFAST_MASK ((1 << ZFAST_BITS) - 1) + +// zlib-style huffman encoding +// (jpegs packs from left, zlib from right, so can't share code) +typedef struct +{ + uint16 fast[1 << ZFAST_BITS]; + uint16 firstcode[16]; + int maxcode[17]; + uint16 firstsymbol[16]; + uint8 size[288]; + uint16 value[288]; +} zhuffman; + +__forceinline static int bitreverse16(int n) +{ + n = ((n & 0xAAAA) >> 1) | ((n & 0x5555) << 1); + n = ((n & 0xCCCC) >> 2) | ((n & 0x3333) << 2); + n = ((n & 0xF0F0) >> 4) | ((n & 0x0F0F) << 4); + n = ((n & 0xFF00) >> 8) | ((n & 0x00FF) << 8); + return n; +} + +__forceinline static int bit_reverse(int v, int bits) +{ + assert(bits <= 16); + // to bit reverse n bits, reverse 16 and shift + // e.g. 11 bits, bit reverse and shift away 5 + return bitreverse16(v) >> (16-bits); +} + +static int zbuild_huffman(zhuffman *z, uint8 *sizelist, int num) +{ + int i,k=0; + int code, next_code[16], sizes[17]; + + // DEFLATE spec for generating codes + memset(sizes, 0, sizeof(sizes)); + memset(z->fast, 255, sizeof(z->fast)); + for (i=0; i < num; ++i) + ++sizes[sizelist[i]]; + sizes[0] = 0; + for (i=1; i < 16; ++i) + assert(sizes[i] <= (1 << i)); + code = 0; + for (i=1; i < 16; ++i) { + next_code[i] = code; + z->firstcode[i] = (uint16) code; + z->firstsymbol[i] = (uint16) k; + code = (code + sizes[i]); + if (sizes[i]) + if (code-1 >= (1 << i)) return e("bad codelengths","Corrupt JPEG"); + z->maxcode[i] = code << (16-i); // preshift for inner loop + code <<= 1; + k += sizes[i]; + } + z->maxcode[16] = 0x10000; // sentinel + for (i=0; i < num; ++i) { + int s = sizelist[i]; + if (s) { + int c = next_code[s] - z->firstcode[s] + z->firstsymbol[s]; + z->size[c] = (uint8)s; + z->value[c] = (uint16)i; + if (s <= ZFAST_BITS) { + int k = bit_reverse(next_code[s],s); + while (k < (1 << ZFAST_BITS)) { + z->fast[k] = (uint16) c; + k += (1 << s); + } + } + ++next_code[s]; + } + } + return 1; +} + +// zlib-from-memory implementation for PNG reading +// because PNG allows splitting the zlib stream arbitrarily, +// and it's annoying structurally to have PNG call ZLIB call PNG, +// we require PNG read all the IDATs and combine them into a single +// memory buffer + +static uint8 *zbuffer, *zbuffer_end; + +__forceinline static int zget8(void) +{ + if (zbuffer >= zbuffer_end) return 0; + return *zbuffer++; +} + +//static unsigned long code_buffer; +static int num_bits; + +static void fill_bits(void) +{ + do { + assert(code_buffer < (1U << num_bits)); + code_buffer |= zget8() << num_bits; + num_bits += 8; + } while (num_bits <= 24); +} + +__forceinline static unsigned int zreceive(int n) +{ + unsigned int k; + if (num_bits < n) fill_bits(); + k = code_buffer & ((1 << n) - 1); + code_buffer >>= n; + num_bits -= n; + return k; +} + +__forceinline static int zhuffman_decode(zhuffman *z) +{ + int b,s,k; + if (num_bits < 16) fill_bits(); + b = z->fast[code_buffer & ZFAST_MASK]; + if (b < 0xffff) { + s = z->size[b]; + code_buffer >>= s; + num_bits -= s; + return z->value[b]; + } + + // not resolved by fast table, so compute it the slow way + // use jpeg approach, which requires MSbits at top + k = bit_reverse(code_buffer, 16); + for (s=ZFAST_BITS+1; ; ++s) + if (k < z->maxcode[s]) + break; + if (s == 16) return -1; // invalid code! + // code size is s, so: + b = (k >> (16-s)) - z->firstcode[s] + z->firstsymbol[s]; + assert(z->size[b] == s); + code_buffer >>= s; + num_bits -= s; + return z->value[b]; +} + +static char *zout; +static char *zout_start; +static char *zout_end; +static int z_expandable; + +static int expand(int n) // need to make room for n bytes +{ + char *q; + int cur, limit; + if (!z_expandable) return e("output buffer limit","Corrupt PNG"); + cur = (int) (zout - zout_start); + limit = (int) (zout_end - zout_start); + while (cur + n > limit) + limit *= 2; + q = (char *) realloc(zout_start, limit); + if (q == NULL) return e("outofmem", "Out of memory"); + zout_start = q; + zout = q + cur; + zout_end = q + limit; + return 1; +} + +static zhuffman z_length, z_distance; + +static int length_base[31] = { + 3,4,5,6,7,8,9,10,11,13, + 15,17,19,23,27,31,35,43,51,59, + 67,83,99,115,131,163,195,227,258,0,0 }; + +static int length_extra[31]= +{ 0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0 }; + +static int dist_base[32] = { 1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193, +257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577,0,0}; + +static int dist_extra[32] = +{ 0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13}; + +static int parse_huffman_block(void) +{ + for(;;) { + int z = zhuffman_decode(&z_length); + if (z < 256) { + if (z < 0) return e("bad huffman code","Corrupt PNG"); // error in huffman codes + if (zout >= zout_end) if (!expand(1)) return 0; + *zout++ = (char) z; + } else { + uint8 *p; + int len,dist; + if (z == 256) return 1; + z -= 257; + len = length_base[z]; + if (length_extra[z]) len += zreceive(length_extra[z]); + z = zhuffman_decode(&z_distance); + if (z < 0) return e("bad huffman code","Corrupt PNG"); + dist = dist_base[z]; + if (dist_extra[z]) dist += zreceive(dist_extra[z]); + if (zout - zout_start < dist) return e("bad dist","Corrupt PNG"); + if (zout + len > zout_end) if (!expand(len)) return 0; + p = (uint8 *) (zout - dist); + while (len--) + *zout++ = *p++; + } + } +} + +static int compute_huffman_codes(void) +{ + static uint8 length_dezigzag[19] = { 16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15 }; + static zhuffman z_codelength; // static just to save stack space + uint8 lencodes[286+32+137];//padding for maximum single op + uint8 codelength_sizes[19]; + int i,n; + + int hlit = zreceive(5) + 257; + int hdist = zreceive(5) + 1; + int hclen = zreceive(4) + 4; + + memset(codelength_sizes, 0, sizeof(codelength_sizes)); + for (i=0; i < hclen; ++i) { + int s = zreceive(3); + codelength_sizes[length_dezigzag[i]] = (uint8) s; + } + if (!zbuild_huffman(&z_codelength, codelength_sizes, 19)) return 0; + + n = 0; + while (n < hlit + hdist) { + int c = zhuffman_decode(&z_codelength); + assert(c >= 0 && c < 19); + if (c < 16) + lencodes[n++] = (uint8) c; + else if (c == 16) { + c = zreceive(2)+3; + memset(lencodes+n, lencodes[n-1], c); + n += c; + } else if (c == 17) { + c = zreceive(3)+3; + memset(lencodes+n, 0, c); + n += c; + } else { + assert(c == 18); + c = zreceive(7)+11; + memset(lencodes+n, 0, c); + n += c; + } + } + if (n != hlit+hdist) return e("bad codelengths","Corrupt PNG"); + if (!zbuild_huffman(&z_length, lencodes, hlit)) return 0; + if (!zbuild_huffman(&z_distance, lencodes+hlit, hdist)) return 0; + return 1; +} + +static int parse_uncompressed_block(void) +{ + uint8 header[4]; + int len,nlen,k; + if (num_bits & 7) + zreceive(num_bits & 7); // discard + // drain the bit-packed data into header + k = 0; + while (num_bits > 0) { + header[k++] = (uint8) (code_buffer & 255); // wtf this warns? + code_buffer >>= 8; + num_bits -= 8; + } + assert(num_bits == 0); + // now fill header the normal way + while (k < 4) + header[k++] = (uint8) zget8(); + len = header[1] * 256 + header[0]; + nlen = header[3] * 256 + header[2]; + if (nlen != (len ^ 0xffff)) return e("zlib corrupt","Corrupt PNG"); + if (zbuffer + len > zbuffer_end) return e("read past buffer","Corrupt PNG"); + if (zout + len > zout_end) + if (!expand(len)) return 0; + memcpy(zout, zbuffer, len); + zbuffer += len; + zout += len; + return 1; +} + +static int parse_zlib_header(void) +{ + int cmf = zget8(); + int cm = cmf & 15; + /* int cinfo = cmf >> 4; */ + int flg = zget8(); + if ((cmf*256+flg) % 31 != 0) return e("bad zlib header","Corrupt PNG"); // zlib spec + if (flg & 32) return e("no preset dict","Corrupt PNG"); // preset dictionary not allowed in png + if (cm != 8) return e("bad compression","Corrupt PNG"); // DEFLATE required for png + // window = 1 << (8 + cinfo)... but who cares, we fully buffer output + return 1; +} + +static uint8 default_length[288], default_distance[32]; +static void init_defaults(void) +{ + int i; // use <= to match clearly with spec + for (i=0; i <= 143; ++i) default_length[i] = 8; + for ( ; i <= 255; ++i) default_length[i] = 9; + for ( ; i <= 279; ++i) default_length[i] = 7; + for ( ; i <= 287; ++i) default_length[i] = 8; + + for (i=0; i <= 31; ++i) default_distance[i] = 5; +} + +static int parse_zlib(int parse_header) +{ + int final, type; + if (parse_header) + if (!parse_zlib_header()) return 0; + num_bits = 0; + code_buffer = 0; + do { + final = zreceive(1); + type = zreceive(2); + if (type == 0) { + if (!parse_uncompressed_block()) return 0; + } else if (type == 3) { + return 0; + } else { + if (type == 1) { + // use fixed code lengths + if (!default_length[0]) init_defaults(); + if (!zbuild_huffman(&z_length , default_length , 288)) return 0; + if (!zbuild_huffman(&z_distance, default_distance, 32)) return 0; + } else { + if (!compute_huffman_codes()) return 0; + } + if (!parse_huffman_block()) return 0; + } + } while (!final); + return 1; +} + +static int do_zlib(char *obuf, int olen, int exp, int parse_header) +{ + zout_start = obuf; + zout = obuf; + zout_end = obuf + olen; + z_expandable = exp; + + return parse_zlib(parse_header); +} + +char *stbi_zlib_decode_malloc_guesssize(int initial_size, int *outlen) +{ + char *p = (char *) malloc(initial_size); + if (p == NULL) return NULL; + if (do_zlib(p, initial_size, 1, 1)) { + *outlen = (int) (zout - zout_start); + return zout_start; + } else { + free(zout_start); + return NULL; + } +} + +char *stbi_zlib_decode_malloc(char *buffer, int len, int *outlen) +{ + zbuffer = (uint8 *) buffer; + zbuffer_end = (uint8 *) buffer+len; + return stbi_zlib_decode_malloc_guesssize(16384, outlen); +} + +int stbi_zlib_decode_buffer(char *obuffer, int olen, char *ibuffer, int ilen) +{ + zbuffer = (uint8 *) ibuffer; + zbuffer_end = (uint8 *) ibuffer + ilen; + if (do_zlib(obuffer, olen, 0, 1)) + return (int) (zout - zout_start); + else + return -1; +} + +char *stbi_zlib_decode_noheader_malloc(char *buffer, int len, int *outlen) +{ + char *p = (char *) malloc(16384); + if (p == NULL) return NULL; + zbuffer = (uint8 *) buffer; + zbuffer_end = (uint8 *) buffer+len; + if (do_zlib(p, 16384, 1, 0)) { + *outlen = (int) (zout - zout_start); + return zout_start; + } else { + free(zout_start); + return NULL; + } +} + +int stbi_zlib_decode_noheader_buffer(char *obuffer, int olen, char *ibuffer, int ilen) +{ + zbuffer = (uint8 *) ibuffer; + zbuffer_end = (uint8 *) ibuffer + ilen; + if (do_zlib(obuffer, olen, 0, 0)) + return (int) (zout - zout_start); + else + return -1; +} + +#endif // __MOJOSETUP__ + + +#ifndef STBI_NO_PNG // __MOJOSETUP__ + +// public domain "baseline" PNG decoder v0.10 Sean Barrett 2006-11-18 +// simple implementation +// - only 8-bit samples +// - no CRC checking +// - allocates lots of intermediate memory +// - avoids problem of streaming data between subsystems +// - avoids explicit window management +// performance +// - uses stb_zlib, a PD zlib implementation with fast huffman decoding + + +typedef struct +{ + unsigned long length; + unsigned long type; +} chunk; + +#define PNG_TYPE(a,b,c,d) (((a) << 24) + ((b) << 16) + ((c) << 8) + (d)) + +static chunk get_chunk_header(void) +{ + chunk c; + c.length = get32(); + c.type = get32(); + return c; +} + +static int check_png_header(void) +{ + static uint8 png_sig[8] = { 137,80,78,71,13,10,26,10 }; + int i; + for (i=0; i < 8; ++i) + if (get8() != png_sig[i]) return e("bad png sig","Not a PNG"); + return 1; +} + +#if !__MOJOSETUP__ // moved elsewhere for #ifdef safety. +static uint8 *idata, *expanded, *out; +#endif + +enum { + F_none=0, F_sub=1, F_up=2, F_avg=3, F_paeth=4, + F_avg_first, F_paeth_first, +}; + +static uint8 first_row_filter[5] = +{ + F_none, F_sub, F_none, F_avg_first, F_paeth_first +}; + +static int paeth(int a, int b, int c) +{ + int p = a + b - c; + int pa = abs(p-a); + int pb = abs(p-b); + int pc = abs(p-c); + if (pa <= pb && pa <= pc) return a; + if (pb <= pc) return b; + return c; +} + +// create the png data from post-deflated data +static int create_png_image(uint8 *raw, uint32 raw_len, int out_n) +{ + uint32 i,j,stride = img_x*out_n; + int k; + assert(out_n == img_n || out_n == img_n+1); + out = (uint8 *) malloc(img_x * img_y * out_n); + if (!out) return e("outofmem", "Out of memory"); + if (raw_len != (img_n * img_x + 1) * img_y) return e("not enough pixels","Corrupt PNG"); + for (j=0; j < img_y; ++j) { + uint8 *cur = out + stride*j; + uint8 *prior = cur - stride; + int filter = *raw++; + if (filter > 4) return e("invalid filter","Corrupt PNG"); + // if first row, use special filter that doesn't sample previous row + if (j == 0) filter = first_row_filter[filter]; + // handle first pixel explicitly + for (k=0; k < img_n; ++k) { + switch(filter) { + case F_none : cur[k] = raw[k]; break; + case F_sub : cur[k] = raw[k]; break; + case F_up : cur[k] = raw[k] + prior[k]; break; + case F_avg : cur[k] = raw[k] + (prior[k]>>1); break; + case F_paeth : cur[k] = (uint8) (raw[k] + paeth(0,prior[k],0)); break; + case F_avg_first : cur[k] = raw[k]; break; + case F_paeth_first: cur[k] = raw[k]; break; + } + } + if (img_n != out_n) cur[img_n] = 255; + raw += img_n; + cur += out_n; + prior += out_n; + // this is a little gross, so that we don't switch per-pixel or per-component + if (img_n == out_n) { + #define CASE(f) \ + case f: \ + for (i=1; i < img_x; ++i, raw+=img_n,cur+=img_n,prior+=img_n) \ + for (k=0; k < img_n; ++k) + switch(filter) { + CASE(F_none) cur[k] = raw[k]; break; + CASE(F_sub) cur[k] = raw[k] + cur[k-img_n]; break; + CASE(F_up) cur[k] = raw[k] + prior[k]; break; + CASE(F_avg) cur[k] = raw[k] + ((prior[k] + cur[k-img_n])>>1); break; + CASE(F_paeth) cur[k] = (uint8) (raw[k] + paeth(cur[k-img_n],prior[k],prior[k-img_n])); break; + CASE(F_avg_first) cur[k] = raw[k] + (cur[k-img_n] >> 1); break; + CASE(F_paeth_first) cur[k] = (uint8) (raw[k] + paeth(cur[k-img_n],0,0)); break; + } + #undef CASE + } else { + assert(img_n+1 == out_n); + #define CASE(f) \ + case f: \ + for (i=1; i < img_x; ++i, cur[img_n]=255,raw+=img_n,cur+=out_n,prior+=out_n) \ + for (k=0; k < img_n; ++k) + switch(filter) { + CASE(F_none) cur[k] = raw[k]; break; + CASE(F_sub) cur[k] = raw[k] + cur[k-out_n]; break; + CASE(F_up) cur[k] = raw[k] + prior[k]; break; + CASE(F_avg) cur[k] = raw[k] + ((prior[k] + cur[k-out_n])>>1); break; + CASE(F_paeth) cur[k] = (uint8) (raw[k] + paeth(cur[k-out_n],prior[k],prior[k-out_n])); break; + CASE(F_avg_first) cur[k] = raw[k] + (cur[k-out_n] >> 1); break; + CASE(F_paeth_first) cur[k] = (uint8) (raw[k] + paeth(cur[k-out_n],0,0)); break; + } + #undef CASE + } + } + return 1; +} + +static int compute_transparency(uint8 tc[3], int out_n) +{ + uint32 i, pixel_count = img_x * img_y; + uint8 *p = out; + + // compute color-based transparency, assuming we've + // already got 255 as the alpha value in the output + assert(out_n == 2 || out_n == 4); + + p = out; + if (out_n == 2) { + for (i=0; i < pixel_count; ++i) { + p[1] = (p[0] == tc[0] ? 0 : 255); + p += 2; + } + } else { + for (i=0; i < pixel_count; ++i) { + if (p[0] == tc[0] && p[1] == tc[1] && p[2] == tc[2]) + p[3] = 0; + p += 4; + } + } + return 1; +} + +static int expand_palette(uint8 *palette, int len, int pal_img_n) +{ + uint32 i, pixel_count = img_x * img_y; + uint8 *p, *temp_out, *orig = out; + + p = (uint8 *) malloc(pixel_count * pal_img_n); + if (p == NULL) return e("outofmem", "Out of memory"); + + // between here and free(out) below, exitting would leak + temp_out = p; + + if (pal_img_n == 3) { + for (i=0; i < pixel_count; ++i) { + int n = orig[i]*4; + p[0] = palette[n ]; + p[1] = palette[n+1]; + p[2] = palette[n+2]; + p += 3; + } + } else { + for (i=0; i < pixel_count; ++i) { + int n = orig[i]*4; + p[0] = palette[n ]; + p[1] = palette[n+1]; + p[2] = palette[n+2]; + p[3] = palette[n+3]; + p += 4; + } + } + free(out); + out = temp_out; + return 1; +} + +static int parse_png_file(int scan, int req_comp) +{ + uint8 palette[1024], pal_img_n=0; + uint8 has_trans=0, tc[3]; + uint32 ioff=0, idata_limit=0, i, pal_len=0; + int first=1,k; + + if (!check_png_header()) return 0; + + if (scan == SCAN_type) return 1; + + for(;;first=0) { + chunk c = get_chunk_header(); + if (first && c.type != PNG_TYPE('I','H','D','R')) + return e("first not IHDR","Corrupt PNG"); + switch (c.type) { + case PNG_TYPE('I','H','D','R'): { + int depth,color,interlace,comp,filter; + if (!first) return e("multiple IHDR","Corrupt PNG"); + if (c.length != 13) return e("bad IHDR len","Corrupt PNG"); + img_x = get32(); if (img_x > (1 << 24)) return e("too large","Very large image (corrupt?)"); + img_y = get32(); if (img_y > (1 << 24)) return e("too large","Very large image (corrupt?)"); + depth = get8(); if (depth != 8) return e("8bit only","PNG not supported: 8-bit only"); + color = get8(); if (color > 6) return e("bad ctype","Corrupt PNG"); + if (color == 3) pal_img_n = 3; else if (color & 1) return e("bad ctype","Corrupt PNG"); + comp = get8(); if (comp) return e("bad comp method","Corrupt PNG"); + filter= get8(); if (filter) return e("bad filter method","Corrupt PNG"); + interlace = get8(); if (interlace) return e("interlaced","PNG not supported: interlaced mode"); + if (!img_x || !img_y) return e("0-pixel image","Corrupt PNG"); + if (!pal_img_n) { + img_n = (color & 2 ? 3 : 1) + (color & 4 ? 1 : 0); + if ((1 << 30) / img_x / img_n < img_y) return e("too large", "Image too large to decode"); + if (scan == SCAN_header) return 1; + } else { + // if paletted, then pal_n is our final components, and + // img_n is # components to decompress/filter. + img_n = 1; + if ((1 << 30) / img_x / 4 < img_y) return e("too large","Corrupt PNG"); + // if SCAN_header, have to scan to see if we have a tRNS + } + break; + } + + case PNG_TYPE('P','L','T','E'): { + if (c.length > 256*3) return e("invalid PLTE","Corrupt PNG"); + pal_len = c.length / 3; + if (pal_len * 3 != c.length) return e("invalid PLTE","Corrupt PNG"); + for (i=0; i < pal_len; ++i) { + palette[i*4+0] = get8u(); + palette[i*4+1] = get8u(); + palette[i*4+2] = get8u(); + palette[i*4+3] = 255; + } + break; + } + + case PNG_TYPE('t','R','N','S'): { + if (idata) return e("tRNS after IDAT","Corrupt PNG"); + if (pal_img_n) { + if (scan == SCAN_header) { img_n = 4; return 1; } + if (pal_len == 0) return e("tRNS before PLTE","Corrupt PNG"); + if (c.length > pal_len) return e("bad tRNS len","Corrupt PNG"); + pal_img_n = 4; + for (i=0; i < c.length; ++i) + palette[i*4+3] = get8u(); + } else { + if (!(img_n & 1)) return e("tRNS with alpha","Corrupt PNG"); + if (c.length != (uint32) img_n*2) return e("bad tRNS len","Corrupt PNG"); + has_trans = 1; + for (k=0; k < img_n; ++k) + tc[k] = (uint8) get16(); // non 8-bit images will be larger + } + break; + } + + case PNG_TYPE('I','D','A','T'): { + if (pal_img_n && !pal_len) return e("no PLTE","Corrupt PNG"); + if (scan == SCAN_header) { img_n = pal_img_n; return 1; } + if (ioff + c.length > idata_limit) { + uint8 *p; + if (idata_limit == 0) idata_limit = c.length > 4096 ? c.length : 4096; + while (ioff + c.length > idata_limit) + idata_limit *= 2; + p = (uint8 *) realloc(idata, idata_limit); if (p == NULL) return e("outofmem", "Out of memory"); + idata = p; + } + #ifndef STBI_NO_STDIO + if (img_file) + { + if (fread(idata+ioff,1,c.length,img_file) != c.length) return e("outofdata","Corrupt PNG"); + } + else + #endif + { + memcpy(idata+ioff, img_buffer, c.length); + img_buffer += c.length; + } + ioff += c.length; + break; + } + + case PNG_TYPE('I','E','N','D'): { + uint32 raw_len; + if (scan != SCAN_load) return 1; + if (idata == NULL) return e("no IDAT","Corrupt PNG"); + expanded = (uint8 *) stbi_zlib_decode_malloc((char *) idata, ioff, (int *) &raw_len); + if (expanded == NULL) return 0; // zlib should set error + free(idata); idata = NULL; + if ((req_comp == img_n+1 && req_comp != 3 && !pal_img_n) || has_trans) + img_out_n = img_n+1; + else + img_out_n = img_n; + if (!create_png_image(expanded, raw_len, img_out_n)) return 0; + if (has_trans) + if (!compute_transparency(tc, img_out_n)) return 0; + if (pal_img_n) { + // pal_img_n == 3 or 4 + img_n = pal_img_n; // record the actual colors we had + img_out_n = pal_img_n; + if (req_comp >= 3) img_out_n = req_comp; + if (!expand_palette(palette, pal_len, img_out_n)) + return 0; + } + free(expanded); expanded = NULL; + return 1; + } + + default: + // if critical, fail + if ((c.type & (1 << 29)) == 0) { + #ifndef STBI_NO_FAILURE_STRINGS + static char invalid_chunk[] = "XXXX chunk not known"; + invalid_chunk[0] = (uint8) (c.type >> 24); + invalid_chunk[1] = (uint8) (c.type >> 16); + invalid_chunk[2] = (uint8) (c.type >> 8); + invalid_chunk[3] = (uint8) (c.type >> 0); + #endif + return e(invalid_chunk, "PNG not supported: unknown chunk type"); + } + skip(c.length); + break; + } + // end of chunk, read and skip CRC + get8(); get8(); get8(); get8(); + } +} + +static unsigned char *do_png(int *x, int *y, int *n, int req_comp) +{ + unsigned char *result=NULL; + if (req_comp < 0 || req_comp > 4) return epuc("bad req_comp", "Internal error"); + if (parse_png_file(SCAN_load, req_comp)) { + result = out; + out = NULL; + if (req_comp && req_comp != img_out_n) { + result = convert_format(result, img_out_n, req_comp); + if (result == NULL) return result; + } + *x = img_x; + *y = img_y; + if (n) *n = img_n; + } + free(out); out = NULL; + free(expanded); expanded = NULL; + free(idata); idata = NULL; + + return result; +} + +#ifndef STBI_NO_STDIO +unsigned char *stbi_png_load_from_file(FILE *f, int *x, int *y, int *comp, int req_comp) +{ + start_file(f); + return do_png(x,y,comp,req_comp); +} + +unsigned char *stbi_png_load(char *filename, int *x, int *y, int *comp, int req_comp) +{ + unsigned char *data; + FILE *f = fopen(filename, "rb"); + if (!f) return NULL; + data = stbi_png_load_from_file(f,x,y,comp,req_comp); + fclose(f); + return data; +} +#endif + +unsigned char *stbi_png_load_from_memory(unsigned char *buffer, int len, int *x, int *y, int *comp, int req_comp) +{ + start_mem(buffer,len); + return do_png(x,y,comp,req_comp); +} + +#ifndef STBI_NO_STDIO +int stbi_png_test_file(FILE *f) +{ + int n,r; + n = ftell(f); + start_file(f); + r = parse_png_file(SCAN_type,STBI_default); + fseek(f,n,SEEK_SET); + return r; +} +#endif + +#endif // __MOJOSETUP__ + +int stbi_png_test_memory(unsigned char *buffer, int len) +{ +#ifndef STBI_NO_PNG // __MOJOSETUP__ + start_mem(buffer, len); + return parse_png_file(SCAN_type,STBI_default); +#else + return 0; +#endif // __MOJOSETUP__ +} + +// TODO: load header from png +#ifndef STBI_NO_STDIO +extern int stbi_png_info (char *filename, int *x, int *y, int *comp); +extern int stbi_png_info_from_file (FILE *f, int *x, int *y, int *comp); +#endif +extern int stbi_png_info_from_memory (stbi_uc *buffer, int len, int *x, int *y, int *comp); + + +#ifndef STBI_NO_BMP // __MOJOSETUP__ + +// Microsoft/Windows BMP image + +static int bmp_test(void) +{ + int sz; + if (get8() != 'B') return 0; + if (get8() != 'M') return 0; + get32le(); // discard filesize + get16le(); // discard reserved + get16le(); // discard reserved + get32le(); // discard data offset + sz = get32le(); + if (sz == 12 || sz == 40 || sz == 56 || sz == 108) return 1; + return 0; +} + +#ifndef STBI_NO_STDIO +int stbi_bmp_test_file (FILE *f) +{ + int r,n = ftell(f); + start_file(f); + r = bmp_test(); + fseek(f,n,SEEK_SET); + return r; +} +#endif + +#endif // __MOJOSETUP__ + + +int stbi_bmp_test_memory (stbi_uc *buffer, int len) +{ +#ifndef STBI_NO_BMP // __MOJOSETUP__ + start_mem(buffer, len); + return bmp_test(); +#else + return 0; +#endif // __MOJOSETUP__ +} + + +#ifndef STBI_NO_BMP // __MOJOSETUP__ + +// returns 0..31 for the highest set bit +static int high_bit(unsigned int z) +{ + int n=0; + if (z == 0) return -1; + if (z >= 0x10000) n += 16, z >>= 16; + if (z >= 0x00100) n += 8, z >>= 8; + if (z >= 0x00010) n += 4, z >>= 4; + if (z >= 0x00004) n += 2, z >>= 2; + if (z >= 0x00002) n += 1, z >>= 1; + return n; +} + +static int bitcount(unsigned int a) +{ + a = (a & 0x55555555) + ((a >> 1) & 0x55555555); // max 2 + a = (a & 0x33333333) + ((a >> 2) & 0x33333333); // max 4 + a = (a + (a >> 4)) & 0x0f0f0f0f; // max 8 per 4, now 8 bits + a = (a + (a >> 8)); // max 16 per 8 bits + a = (a + (a >> 16)); // max 32 per 8 bits + return a & 0xff; +} + +static int shiftsigned(int v, int shift, int bits) +{ + int result; + int z=0; + + if (shift < 0) v <<= -shift; + else v >>= shift; + result = v; + + z = bits; + while (z < 8) { + result += v >> z; + z += bits; + } + return result; +} + +static stbi_uc *bmp_load(int *x, int *y, int *comp, int req_comp) +{ + unsigned int mr=0,mg=0,mb=0,ma=0; + stbi_uc pal[256][4]; + int psize=0,i,j,compress=0,width; + int bpp, flip_vertically, pad, target, offset, hsz; + if (get8() != 'B' || get8() != 'M') return epuc("not BMP", "Corrupt BMP"); + get32le(); // discard filesize + get16le(); // discard reserved + get16le(); // discard reserved + offset = get32le(); + hsz = get32le(); + if (hsz != 12 && hsz != 40 && hsz != 56 && hsz != 108) return epuc("unknown BMP", "BMP type not supported: unknown"); + failure_reason = "bad BMP"; + if (hsz == 12) { + img_x = get16le(); + img_y = get16le(); + } else { + img_x = get32le(); + img_y = get32le(); + } + if (get16le() != 1) return 0; + bpp = get16le(); + if (bpp == 1) return epuc("monochrome", "BMP type not supported: 1-bit"); + flip_vertically = ((int) img_y) > 0; + img_y = abs((int) img_y); + if (hsz == 12) { + if (bpp < 24) + psize = (offset - 14 - 24) / 3; + } else { + compress = get32le(); + if (compress == 1 || compress == 2) return epuc("BMP RLE", "BMP type not supported: RLE"); + get32le(); // discard sizeof + get32le(); // discard hres + get32le(); // discard vres + get32le(); // discard colorsused + get32le(); // discard max important + if (hsz == 40 || hsz == 56) { + if (hsz == 56) { + get32le(); + get32le(); + get32le(); + get32le(); + } + if (bpp == 16 || bpp == 32) { + mr = mg = mb = 0; + if (compress == 0) { + if (bpp == 32) { + mr = 0xff << 16; + mg = 0xff << 8; + mb = 0xff << 0; + } else { + mr = 31 << 10; + mg = 31 << 5; + mb = 31 << 0; + } + } else if (compress == 3) { + mr = get32le(); + mg = get32le(); + mb = get32le(); + // not documented, but generated by photoshop and handled by mspaint + if (mr == mg && mg == mb) { + // ?!?!? + return NULL; + } + } else + return NULL; + } + } else { + assert(hsz == 108); + mr = get32le(); + mg = get32le(); + mb = get32le(); + ma = get32le(); + get32le(); // discard color space + for (i=0; i < 12; ++i) + get32le(); // discard color space parameters + } + if (bpp < 16) + psize = (offset - 14 - hsz) >> 2; + } + img_n = ma ? 4 : 3; + if (req_comp && req_comp >= 3) // we can directly decode 3 or 4 + target = req_comp; + else + target = img_n; // if they want monochrome, we'll post-convert + out = (stbi_uc *) malloc(target * img_x * img_y); + if (!out) return epuc("outofmem", "Out of memory"); + if (bpp < 16) { + int z=0; + if (psize == 0 || psize > 256) return epuc("invalid", "Corrupt BMP"); + for (i=0; i < psize; ++i) { + pal[i][2] = get8(); + pal[i][1] = get8(); + pal[i][0] = get8(); + if (hsz != 12) get8(); + pal[i][3] = 255; + } + skip(offset - 14 - hsz - psize * (hsz == 12 ? 3 : 4)); + if (bpp == 4) width = (img_x + 1) >> 1; + else if (bpp == 8) width = img_x; + else return epuc("bad bpp", "Corrupt BMP"); + pad = (-width)&3; + for (j=0; j < (int) img_y; ++j) { + for (i=0; i < (int) img_x; i += 2) { + int v=get8(),v2=0; + if (bpp == 4) { + v2 = v & 15; + v >>= 4; + } + out[z++] = pal[v][0]; + out[z++] = pal[v][1]; + out[z++] = pal[v][2]; + if (target == 4) out[z++] = 255; + if (i+1 == (int) img_x) break; + v = (bpp == 8) ? get8() : v2; + out[z++] = pal[v][0]; + out[z++] = pal[v][1]; + out[z++] = pal[v][2]; + if (target == 4) out[z++] = 255; + } + skip(pad); + } + } else { + int rshift=0,gshift=0,bshift=0,ashift=0,rcount=0,gcount=0,bcount=0,acount=0; + int z = 0; + int easy=0; + skip(offset - 14 - hsz); + if (bpp == 24) width = 3 * img_x; + else if (bpp == 16) width = 2*img_x; + else /* bpp = 32 and pad = 0 */ width=0; + pad = (-width) & 3; + if (bpp == 24) { + easy = 1; + } else if (bpp == 32) { + if (mb == 0xff && mg == 0xff00 && mr == 0xff000000 && ma == 0xff000000) + easy = 2; + } + if (!easy) { + if (!mr || !mg || !mb) return epuc("bad masks", "Corrupt BMP"); + // right shift amt to put high bit in position #7 + rshift = high_bit(mr)-7; rcount = bitcount(mr); + gshift = high_bit(mg)-7; gcount = bitcount(mr); + bshift = high_bit(mb)-7; bcount = bitcount(mr); + ashift = high_bit(ma)-7; acount = bitcount(mr); + } + for (j=0; j < (int) img_y; ++j) { + if (easy) { + for (i=0; i < (int) img_x; ++i) { + int a; + out[z+2] = get8(); + out[z+1] = get8(); + out[z+0] = get8(); + z += 3; + a = (easy == 2 ? get8() : 255); + if (target == 4) out[z++] = a; + } + } else { + for (i=0; i < (int) img_x; ++i) { + unsigned long v = (bpp == 16 ? get16le() : get32le()); + int a; + out[z++] = shiftsigned(v & mr, rshift, rcount); + out[z++] = shiftsigned(v & mg, gshift, gcount); + out[z++] = shiftsigned(v & mb, bshift, bcount); + a = (ma ? shiftsigned(v & ma, ashift, acount) : 255); + if (target == 4) out[z++] = a; + } + } + skip(pad); + } + } + if (flip_vertically) { + stbi_uc t; + for (j=0; j < (int) img_y>>1; ++j) { + stbi_uc *p1 = out + j *img_x*target; + stbi_uc *p2 = out + (img_y-1-j)*img_x*target; + for (i=0; i < (int) img_x*target; ++i) { + t = p1[i], p1[i] = p2[i], p2[i] = t; + } + } + } + + if (req_comp && req_comp != target) { + out = convert_format(out, target, req_comp); + if (out == NULL) return out; // convert_format frees input on failure + } + + *x = img_x; + *y = img_y; + if (comp) *comp = target; + return out; +} + +#ifndef STBI_NO_STDIO +stbi_uc *stbi_bmp_load (char *filename, int *x, int *y, int *comp, int req_comp) +{ + stbi_uc *data; + FILE *f = fopen(filename, "rb"); + if (!f) return NULL; + data = stbi_bmp_load_from_file(f, x,y,comp,req_comp); + fclose(f); + return data; +} + +stbi_uc *stbi_bmp_load_from_file (FILE *f, int *x, int *y, int *comp, int req_comp) +{ + start_file(f); + return bmp_load(x,y,comp,req_comp); +} +#endif + +stbi_uc *stbi_bmp_load_from_memory (stbi_uc *buffer, int len, int *x, int *y, int *comp, int req_comp) +{ + start_mem(buffer, len); + return bmp_load(x,y,comp,req_comp); +} + +#endif // __MOJOSETUP__ + + + +#ifndef STBI_NO_TGA // __MOJOSETUP__ + +// Targa Truevision - TGA +// by Jonathan Dummer + +static int tga_test(void) +{ + int sz; + get8u(); // discard Offset + sz = get8u(); // color type + if( sz > 1 ) return 0; // only RGB or indexed allowed + sz = get8u(); // image type + if( (sz != 1) && (sz != 2) && (sz != 3) && (sz != 9) && (sz != 10) && (sz != 11) ) return 0; // only RGB or grey allowed, +/- RLE + get16(); // discard palette start + get16(); // discard palette length + get8(); // discard bits per palette color entry + get16(); // discard x origin + get16(); // discard y origin + if( get16() < 1 ) return 0; // test width + if( get16() < 1 ) return 0; // test height + sz = get8(); // bits per pixel + if( (sz != 8) && (sz != 16) && (sz != 24) && (sz != 32) ) return 0; // only RGB or RGBA or grey allowed + return 1; // seems to have passed everything +} + +#ifndef STBI_NO_STDIO +int stbi_tga_test_file (FILE *f) +{ + int r,n = ftell(f); + start_file(f); + r = tga_test(); + fseek(f,n,SEEK_SET); + return r; +} +#endif + +#endif // __MOJOSETUP__ + + +int stbi_tga_test_memory (stbi_uc *buffer, int len) +{ +#ifndef STBI_NO_TGA // __MOJOSETUP__ + start_mem(buffer, len); + return tga_test(); +#else + return 0; +#endif // __MOJOSETUP__ +} + +#ifndef STBI_NO_TGA // __MOJOSETUP__ + +static stbi_uc *tga_load(int *x, int *y, int *comp, int req_comp) +{ + // read in the TGA header stuff + int tga_offset = get8u(); + int tga_indexed = get8u(); + int tga_image_type = get8u(); + int tga_is_RLE = 0; + int tga_palette_start = get16le(); + int tga_palette_len = get16le(); + int tga_palette_bits = get8u(); + int tga_x_origin = get16le(); + int tga_y_origin = get16le(); + int tga_width = get16le(); + int tga_height = get16le(); + int tga_bits_per_pixel = get8u(); + int tga_inverted = get8u(); + // image data + unsigned char *tga_data; + unsigned char *tga_palette = NULL; + int i, j; +#if __MOJOSETUP__ // gcc whining fixes. --ryan. + //unsigned char raw_data[4]; + //unsigned char trans_data[4]; + unsigned char raw_data[4] = { 0, 0, 0, 0 }; + unsigned char trans_data[4] = { 0, 0, 0, 0 }; +#endif + int RLE_count = 0; + int RLE_repeating = 0; + int read_next_pixel = 1; + // do a tiny bit of precessing + if( tga_image_type >= 8 ) + { + tga_image_type -= 8; + tga_is_RLE = 1; + } + /* int tga_alpha_bits = tga_inverted & 15; */ + tga_inverted = 1 - ((tga_inverted >> 5) & 1); + + // error check + if( //(tga_indexed) || + (tga_width < 1) || (tga_height < 1) || + (tga_image_type < 1) || (tga_image_type > 3) || + ((tga_bits_per_pixel != 8) && (tga_bits_per_pixel != 16) && + (tga_bits_per_pixel != 24) && (tga_bits_per_pixel != 32)) + ) + { + return NULL; + } + + // If I'm paletted, then I'll use the number of bits from the palette + if( tga_indexed ) + { + tga_bits_per_pixel = tga_palette_bits; + } + + // tga info + *x = tga_width; + *y = tga_height; + if( (req_comp < 1) || (req_comp > 4) ) + { + // just use whatever the file was + req_comp = tga_bits_per_pixel / 8; + *comp = req_comp; + } else + { + // force a new number of components + *comp = tga_bits_per_pixel/8; + } + tga_data = (unsigned char*)malloc( tga_width * tga_height * req_comp ); + + // skip to the data's starting position (offset usually = 0) + skip( tga_offset ); + // do I need to load a palette? + if( tga_indexed ) + { + // any data to skip? (offset usually = 0) + skip( tga_palette_start ); + // load the palette + tga_palette = (unsigned char*)malloc( tga_palette_len * tga_palette_bits / 8 ); + getn( tga_palette, tga_palette_len * tga_palette_bits / 8 ); + } + // load the data + for( i = 0; i < tga_width * tga_height; ++i ) + { + // if I'm in RLE mode, do I need to get a RLE chunk? + if( tga_is_RLE ) + { + if( RLE_count == 0 ) + { + // yep, get the next byte as a RLE command + int RLE_cmd = get8u(); + RLE_count = 1 + (RLE_cmd & 127); + RLE_repeating = RLE_cmd >> 7; + read_next_pixel = 1; + } else if( !RLE_repeating ) + { + read_next_pixel = 1; + } + } else + { + read_next_pixel = 1; + } + // OK, if I need to read a pixel, do it now + if( read_next_pixel ) + { + // load however much data we did have + if( tga_indexed ) + { + // read in 1 byte, then perform the lookup + int pal_idx = get8u(); + if( pal_idx >= tga_palette_len ) + { + // invalid index + pal_idx = 0; + } + pal_idx *= tga_bits_per_pixel / 8; + for( j = 0; j*8 < tga_bits_per_pixel; ++j ) + { + raw_data[j] = tga_palette[pal_idx+j]; + } + } else + { + // read in the data raw + for( j = 0; j*8 < tga_bits_per_pixel; ++j ) + { + raw_data[j] = get8u(); + } + } + // convert raw to the intermediate format + switch( tga_bits_per_pixel ) + { + case 8: + // Luminous => RGBA + trans_data[0] = raw_data[0]; + trans_data[1] = raw_data[0]; + trans_data[2] = raw_data[0]; + trans_data[3] = 255; + break; + case 16: + // Luminous,Alpha => RGBA + trans_data[0] = raw_data[0]; + trans_data[1] = raw_data[0]; + trans_data[2] = raw_data[0]; + trans_data[3] = raw_data[1]; + break; + case 24: + // BGR => RGBA + trans_data[0] = raw_data[2]; + trans_data[1] = raw_data[1]; + trans_data[2] = raw_data[0]; + trans_data[3] = 255; + break; + case 32: + // BGRA => RGBA + trans_data[0] = raw_data[2]; + trans_data[1] = raw_data[1]; + trans_data[2] = raw_data[0]; + trans_data[3] = raw_data[3]; + break; + } + // clear the reading flag for the next pixel + read_next_pixel = 0; + } // end of reading a pixel + // convert to final format + switch( req_comp ) + { + case 1: + // RGBA => Luminance + tga_data[i*req_comp+0] = compute_y(trans_data[0],trans_data[1],trans_data[2]); + break; + case 2: + // RGBA => Luminance,Alpha + tga_data[i*req_comp+0] = compute_y(trans_data[0],trans_data[1],trans_data[2]); + tga_data[i*req_comp+1] = trans_data[3]; + break; + case 3: + // RGBA => RGB + tga_data[i*req_comp+0] = trans_data[0]; + tga_data[i*req_comp+1] = trans_data[1]; + tga_data[i*req_comp+2] = trans_data[2]; + break; + case 4: + // RGBA => RGBA + tga_data[i*req_comp+0] = trans_data[0]; + tga_data[i*req_comp+1] = trans_data[1]; + tga_data[i*req_comp+2] = trans_data[2]; + tga_data[i*req_comp+3] = trans_data[3]; + break; + } + // in case we're in RLE mode, keep counting down + --RLE_count; + } + // do I need to invert the image? + if( tga_inverted ) + { + for( j = 0; j*2 < tga_height; ++j ) + { + int index1 = j * tga_width * req_comp; + int index2 = (tga_height - 1 - j) * tga_width * req_comp; + for( i = tga_width * req_comp; i > 0; --i ) + { + unsigned char temp = tga_data[index1]; + tga_data[index1] = tga_data[index2]; + tga_data[index2] = temp; + ++index1; + ++index2; + } + } + } + // clear my palette, if I had one + if( tga_palette != NULL ) + { + free( tga_palette ); + } + // the things I do to get rid of an error message, and yet keep + // Microsoft's C compilers happy... [8^( + tga_palette_start = tga_palette_len = tga_palette_bits = + tga_x_origin = tga_y_origin = 0; + // OK, done + return tga_data; +} + +#ifndef STBI_NO_STDIO +stbi_uc *stbi_tga_load (char *filename, int *x, int *y, int *comp, int req_comp) +{ + stbi_uc *data; + FILE *f = fopen(filename, "rb"); + if (!f) return NULL; + data = stbi_tga_load_from_file(f, x,y,comp,req_comp); + fclose(f); + return data; +} + +stbi_uc *stbi_tga_load_from_file (FILE *f, int *x, int *y, int *comp, int req_comp) +{ + start_file(f); + return tga_load(x,y,comp,req_comp); +} +#endif + +stbi_uc *stbi_tga_load_from_memory (stbi_uc *buffer, int len, int *x, int *y, int *comp, int req_comp) +{ + start_mem(buffer, len); + return tga_load(x,y,comp,req_comp); +} + +#endif // __MOJOSETUP__ + + +#ifndef STBI_NO_PSD // __MOJOSETUP__ + +// ************************************************************************************************* +// Photoshop PSD loader -- PD by Thatcher Ulrich, integration by Nicholas Schulz, tweaked by STB + +static int psd_test(void) +{ + if (get32() != 0x38425053) return 0; // "8BPS" + else return 1; +} + +#ifndef STBI_NO_STDIO +int stbi_psd_test_file(FILE *f) +{ + int r,n = ftell(f); + start_file(f); + r = psd_test(); + fseek(f,n,SEEK_SET); + return r; +} +#endif + +#endif // __MOJOSETUP__ + + +int stbi_psd_test_memory(stbi_uc *buffer, int len) +{ +#ifndef STBI_NO_PSD // __MOJOSETUP__ + start_mem(buffer, len); + return psd_test(); +#else + return 0; +#endif // __MOJOSETUP__ +} + + +#ifndef STBI_NO_PSD // __MOJOSETUP__ + +static stbi_uc *psd_load(int *x, int *y, int *comp, int req_comp) +{ + int pixelCount; + int channelCount, compression; + int channel, i, count, len; + int w,h; + + // Check identifier + if (get32() != 0x38425053) // "8BPS" + return epuc("not PSD", "Corrupt PSD image"); + + // Check file type version. + if (get16() != 1) + return epuc("wrong version", "Unsupported version of PSD image"); + + // Skip 6 reserved bytes. + skip( 6 ); + + // Read the number of channels (R, G, B, A, etc). + channelCount = get16(); + if (channelCount < 0 || channelCount > 16) + return epuc("wrong channel count", "Unsupported number of channels in PSD image"); + + // Read the rows and columns of the image. + h = get32(); + w = get32(); + + // Make sure the depth is 8 bits. + if (get16() != 8) + return epuc("unsupported bit depth", "PSD bit depth is not 8 bit"); + + // Make sure the color mode is RGB. + // Valid options are: + // 0: Bitmap + // 1: Grayscale + // 2: Indexed color + // 3: RGB color + // 4: CMYK color + // 7: Multichannel + // 8: Duotone + // 9: Lab color + if (get16() != 3) + return epuc("wrong color format", "PSD is not in RGB color format"); + + // Skip the Mode Data. (It's the palette for indexed color; other info for other modes.) + skip(get32() ); + + // Skip the image resources. (resolution, pen tool paths, etc) + skip( get32() ); + + // Skip the reserved data. + skip( get32() ); + + // Find out if the data is compressed. + // Known values: + // 0: no compression + // 1: RLE compressed + compression = get16(); + if (compression > 1) + return epuc("unknown compression type", "PSD has an unknown compression format"); + + // Create the destination image. + out = (stbi_uc *) malloc(4 * w*h); + if (!out) return epuc("outofmem", "Out of memory"); + pixelCount = w*h; + + // Initialize the data to zero. + //memset( out, 0, pixelCount * 4 ); + + // Finally, the image data. + if (compression) { + // RLE as used by .PSD and .TIFF + // Loop until you get the number of unpacked bytes you are expecting: + // Read the next source byte into n. + // If n is between 0 and 127 inclusive, copy the next n+1 bytes literally. + // Else if n is between -127 and -1 inclusive, copy the next byte -n+1 times. + // Else if n is 128, noop. + // Endloop + + // The RLE-compressed data is preceeded by a 2-byte data count for each row in the data, + // which we're going to just skip. + skip( h * channelCount * 2 ); + + // Read the RLE data by channel. + for (channel = 0; channel < 4; channel++) { + uint8 *p; + + p = out+channel; + if (channel >= channelCount) { + // Fill this channel with default data. + for (i = 0; i < pixelCount; i++) *p = (channel == 3 ? 255 : 0), p += 4; + } else { + // Read the RLE data. + count = 0; + while (count < pixelCount) { + len = get8(); + if (len == 128) { + // No-op. + } else if (len < 128) { + // Copy next len+1 bytes literally. + len++; + count += len; + while (len) { + *p = get8(); + p += 4; + len--; + } + } else if (len > 128) { + uint32 val; + // Next -len+1 bytes in the dest are replicated from next source byte. + // (Interpret len as a negative 8-bit int.) + len ^= 0x0FF; + len += 2; + val = get8(); + count += len; + while (len) { + *p = val; + p += 4; + len--; + } + } + } + } + } + + } else { + // We're at the raw image data. It's each channel in order (Red, Green, Blue, Alpha, ...) + // where each channel consists of an 8-bit value for each pixel in the image. + + // Read the data by channel. + for (channel = 0; channel < 4; channel++) { + uint8 *p; + + p = out + channel; + if (channel > channelCount) { + // Fill this channel with default data. + for (i = 0; i < pixelCount; i++) *p = channel == 3 ? 255 : 0, p += 4; + } else { + // Read the data. + count = 0; + for (i = 0; i < pixelCount; i++) + *p = get8(), p += 4; + } + } + } + + if (req_comp && req_comp != 4) { + out = convert_format(out, 4, req_comp); + if (out == NULL) return out; // convert_format frees input on failure + } + + if (comp) *comp = channelCount; + *y = h; + *x = w; + + return out; +} + +#ifndef STBI_NO_STDIO +stbi_uc *stbi_psd_load(char *filename, int *x, int *y, int *comp, int req_comp) +{ + stbi_uc *data; + FILE *f = fopen(filename, "rb"); + if (!f) return NULL; + data = stbi_psd_load_from_file(f, x,y,comp,req_comp); + fclose(f); + return data; +} + +stbi_uc *stbi_psd_load_from_file(FILE *f, int *x, int *y, int *comp, int req_comp) +{ + start_file(f); + return psd_load(x,y,comp,req_comp); +} +#endif + +stbi_uc *stbi_psd_load_from_memory (stbi_uc *buffer, int len, int *x, int *y, int *comp, int req_comp) +{ + start_mem(buffer, len); + return psd_load(x,y,comp,req_comp); +} + +#endif // __MOJOSETUP__ + + +// ************************************************************************************************* +// Radiance RGBE HDR loader +// originally by Nicolas Schulz +#ifndef STBI_NO_HDR +static int hdr_test(void) +{ + char *signature = "#?RADIANCE\n"; + int i; + for (i=0; signature[i]; ++i) + if (get8() != signature[i]) + return 0; + return 1; +} + +int stbi_hdr_test_memory(stbi_uc *buffer, int len) +{ + start_mem(buffer, len); + return hdr_test(); +} + +#ifndef STBI_NO_STDIO +int stbi_hdr_test_file(FILE *f) +{ + int r,n = ftell(f); + start_file(f); + r = hdr_test(); + fseek(f,n,SEEK_SET); + return r; +} +#endif + +#define HDR_BUFLEN 1024 +static char *hdr_gettoken(char *buffer) +{ + int len=0; + +#if __MOJOSETUP__ // compiler complained about unused variable. + char c = get8(); +#else + char *s = buffer, c = '\0'; + + c = get8(); +#endif + + while (!at_eof() && c != '\n') { + buffer[len++] = c; + if (len == HDR_BUFLEN-1) { + // flush to end of line + while (!at_eof() && get8() != '\n') + ; + break; + } + c = get8(); + } + + buffer[len] = 0; + return buffer; +} + +static void hdr_convert(float *output, stbi_uc *input, int req_comp) +{ + if( input[3] != 0 ) { + float f1; + // Exponent + f1 = (float) ldexp(1.0f, input[3] - (int)(128 + 8)); + if (req_comp <= 2) + output[0] = (input[0] + input[1] + input[2]) * f1 / 3; + else { + output[0] = input[0] * f1; + output[1] = input[1] * f1; + output[2] = input[2] * f1; + } + if (req_comp == 2) output[1] = 1; + if (req_comp == 4) output[3] = 1; + } else { + switch (req_comp) { + case 4: output[3] = 1; /* fallthrough */ + case 3: output[0] = output[1] = output[2] = 0; + break; + case 2: output[1] = 1; /* fallthrough */ + case 1: output[0] = 0; + break; + } + } +} + + +static float *hdr_load(int *x, int *y, int *comp, int req_comp) +{ + char buffer[HDR_BUFLEN]; + char *token; + int valid = 0; + int width, height; + stbi_uc *scanline; + float *hdr_data; + int len; + unsigned char count, value; + int i, j, k, c1,c2, z; + + + // Check identifier + if (strcmp(hdr_gettoken(buffer), "#?RADIANCE") != 0) + return epf("not HDR", "Corrupt HDR image"); + + // Parse header + while(1) { + token = hdr_gettoken(buffer); + if (token[0] == 0) break; + if (strcmp(token, "FORMAT=32-bit_rle_rgbe") == 0) valid = 1; + } + + if (!valid) return epf("unsupported format", "Unsupported HDR format"); + + // Parse width and height + // can't use sscanf() if we're not using stdio! + token = hdr_gettoken(buffer); + if (strncmp(token, "-Y ", 3)) return epf("unsupported data layout", "Unsupported HDR format"); + token += 3; + height = strtol(token, &token, 10); + while (*token == ' ') ++token; + if (strncmp(token, "+X ", 3)) return epf("unsupported data layout", "Unsupported HDR format"); + token += 3; + width = strtol(token, NULL, 10); + + *x = width; + *y = height; + + *comp = 3; + if (req_comp == 0) req_comp = 3; + + // Read data + hdr_data = (float *) malloc(height * width * req_comp * sizeof(float)); + + // Load image data + // image data is stored as some number of sca + if( width < 8 || width >= 32768) { + // Read flat data + for (j=0; j < height; ++j) { + for (i=0; i < width; ++i) { + stbi_uc rgbe[4]; + main_decode_loop: + getn(rgbe, 4); + hdr_convert(hdr_data + j * width * req_comp + i * req_comp, rgbe, req_comp); + } + } + } else { + // Read RLE-encoded data + scanline = NULL; + + for (j = 0; j < height; ++j) { + c1 = get8(); + c2 = get8(); + len = get8(); + if (c1 != 2 || c2 != 2 || (len & 0x80)) { + // not run-length encoded, so we have to actually use THIS data as a decoded + // pixel (note this can't be a valid pixel--one of RGB must be >= 128) + stbi_uc rgbe[4] = { c1,c2,len, get8() }; + hdr_convert(hdr_data, rgbe, req_comp); + i = 1; + j = 0; + free(scanline); + goto main_decode_loop; // yes, this is fucking insane; blame the fucking insane format + } + len <<= 8; + len |= get8(); + if (len != width) { free(hdr_data); free(scanline); return epf("invalid decoded scanline length", "corrupt HDR"); } + if (scanline == NULL) scanline = (stbi_uc *) malloc(width * 4); + + for (k = 0; k < 4; ++k) { + i = 0; + while (i < width) { + count = get8(); + if (count > 128) { + // Run + value = get8(); + count -= 128; + for (z = 0; z < count; ++z) + scanline[i++ * 4 + k] = value; + } else { + // Dump + for (z = 0; z < count; ++z) + scanline[i++ * 4 + k] = get8(); + } + } + } + for (i=0; i < width; ++i) + hdr_convert(hdr_data+(j*width + i)*req_comp, scanline + i*4, req_comp); + } + free(scanline); + } + + return hdr_data; +} + +#ifndef STBI_NO_STDIO +float *stbi_hdr_load_from_file(FILE *f, int *x, int *y, int *comp, int req_comp) +{ + start_file(f); + return hdr_load(x,y,comp,req_comp); +} +#endif + +float *stbi_hdr_load_from_memory(stbi_uc *buffer, int len, int *x, int *y, int *comp, int req_comp) +{ + start_mem(buffer, len); + return hdr_load(x,y,comp,req_comp); +} + +#endif // STBI_NO_HDR + +/////////////////////// write image /////////////////////// + +#ifndef STBI_NO_WRITE + +static void write8(FILE *f, int x) { uint8 z = (uint8) x; fwrite(&z,1,1,f); } + +static void writefv(FILE *f, char *fmt, va_list v) +{ + while (*fmt) { + switch (*fmt++) { + case ' ': break; + case '1': { uint8 x = va_arg(v, int); write8(f,x); break; } + case '2': { int16 x = va_arg(v, int); write8(f,x); write8(f,x>>8); break; } + case '4': { int32 x = va_arg(v, int); write8(f,x); write8(f,x>>8); write8(f,x>>16); write8(f,x>>24); break; } + default: + assert(0); + va_end(v); + return; + } + } +} + +static void writef(FILE *f, char *fmt, ...) +{ + va_list v; + va_start(v, fmt); + writefv(f,fmt,v); + va_end(v); +} + +static void write_pixels(FILE *f, int rgb_dir, int vdir, int x, int y, int comp, void *data, int write_alpha, int scanline_pad) +{ + uint8 bg[3] = { 255, 0, 255}, px[3]; + uint32 zero = 0; + int i,j,k, j_end; + + if (vdir < 0) + j_end = -1, j = y-1; + else + j_end = y, j = 0; + + for (; j != j_end; j += vdir) { + for (i=0; i < x; ++i) { + uint8 *d = (uint8 *) data + (j*x+i)*comp; + if (write_alpha < 0) + fwrite(&d[comp-1], 1, 1, f); + switch (comp) { + case 1: + case 2: writef(f, "111", d[0],d[0],d[0]); + break; + case 4: + if (!write_alpha) { + for (k=0; k < 3; ++k) + px[k] = bg[k] + ((d[k] - bg[k]) * d[3])/255; + writef(f, "111", px[1-rgb_dir],px[1],px[1+rgb_dir]); + break; + } + /* FALLTHROUGH */ + case 3: + writef(f, "111", d[1-rgb_dir],d[1],d[1+rgb_dir]); + break; + } + if (write_alpha > 0) + fwrite(&d[comp-1], 1, 1, f); + } + fwrite(&zero,scanline_pad,1,f); + } +} + +static int outfile(char *filename, int rgb_dir, int vdir, int x, int y, int comp, void *data, int alpha, int pad, char *fmt, ...) +{ + FILE *f = fopen(filename, "wb"); + if (f) { + va_list v; + va_start(v, fmt); + writefv(f, fmt, v); + va_end(v); + write_pixels(f,rgb_dir,vdir,x,y,comp,data,alpha,pad); + fclose(f); + } + return f != NULL; +} + +int stbi_write_bmp(char *filename, int x, int y, int comp, void *data) +{ + int pad = (-x*3) & 3; + return outfile(filename,-1,-1,x,y,comp,data,0,pad, + "11 4 22 4" "4 44 22 444444", + 'B', 'M', 14+40+(x*3+pad)*y, 0,0, 14+40, // file header + 40, x,y, 1,24, 0,0,0,0,0,0); // bitmap header +} + +int stbi_write_tga(char *filename, int x, int y, int comp, void *data) +{ + int has_alpha = !(comp & 1); + return outfile(filename, -1,-1, x, y, comp, data, has_alpha, 0, + "111 221 2222 11", 0,0,2, 0,0,0, 0,0,x,y, 24+8*has_alpha, 8*has_alpha); +} + +// any other image formats that do interleaved rgb data? +// PNG: requires adler32,crc32 -- significant amount of code +// PSD: no, channels output separately +// TIFF: no, stripwise-interleaved... i think + +#endif // STBI_NO_WRITE + +#if __MOJOSETUP__ +void stb_image_stop_compiler_whining(void) +{ + // a lot of these aren't used if you #ifdef out all graphic formats, + // which you might do if, say, you are shipping a stdio-only installer. + // Just put references to them here so the compiler doesn't think they + // are unused statics. + (void) img_n; + (void) start_mem; + (void) at_eof; + (void) get8u; + (void) skip; + (void) get32; + (void) get32le; + (void) getn; + (void) convert_format; + (void) idata; + (void) expanded; + (void) out; + (void) code_buffer; +} +#endif + diff --git a/mk/linux/mojosetup/universal.h b/mk/linux/mojosetup/universal.h new file mode 100644 index 00000000..09e82223 --- /dev/null +++ b/mk/linux/mojosetup/universal.h @@ -0,0 +1,416 @@ +/** + * MojoSetup; a portable, flexible installation application. + * + * Please see the file LICENSE.txt in the source's root directory. + * + * This file written by Ryan C. Gordon. + */ + +#ifndef _INCL_UNIVERSAL_H_ +#define _INCL_UNIVERSAL_H_ + +// Include this file from everywhere...it provides basic type sanity, etc. + +// Include the Holy Trinity... +#include +#include +#include + +// and some others... +#include +#include // !!! FIXME: maybe use this in platform layer? + +// Windows system headers conflict with MojoSetup typedefs, so chop out +// all the massive and unnecessary dependencies that windows.h pulls in... +#if PLATFORM_WINDOWS +#define WIN32_LEAN_AND_MEAN 1 +#endif + +#if _MSC_VER +#include // need this to get alloca() in MSVC. +// !!! FIXME: temporary solution. +#define snprintf _snprintf +#define strcasecmp(x,y) _stricmp(x,y) +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +// !!! FIXME: bad. +typedef char int8; +typedef unsigned char uint8; +typedef short int16; +typedef unsigned short uint16; +typedef int int32; +typedef unsigned int uint32; +typedef long long int64; +typedef unsigned long long uint64; + +// These are likely to get stolen by some overzealous library header... +#ifdef boolean +#error Something is defining boolean. Resolve this before including universal.h. +#endif +#ifdef true +#error Something is defining true. Resolve this before including universal.h. +#endif +#ifdef false +#error Something is defining false. Resolve this before including universal.h. +#endif + +typedef int boolean; +#define true 1 +#define false 0 + +// MSVC doesn't support the "inline" keyword for normal C sources, just C++. +#if defined(_MSC_VER) && !defined(__cplusplus) && !defined(inline) +#define inline __inline +#endif + +// Compiler-enforced printf() safety helper. +// This is appended to function declarations that use printf-style semantics, +// and will make sure your passed the right params to "..." for the +// format you specified, so gcc can catch programmer bugs at compile time. +#ifdef __GNUC__ +#define ISPRINTF(x,y) __attribute__((format (printf, x, y))) +#else +#define ISPRINTF(x,y) +#endif + +// Compiler-enforced sentinel safety helper. +// This is appended to function declarations that use sentinel-style semantics, +// and will make sure your passed the right params to "..." where a NULL +// is needed at the end of the list. +#ifdef __GNUC__ +#define ISSENTINEL __attribute__((sentinel)) +#else +#define ISSENTINEL +#endif + +// Command line access outside of main(). +extern int GArgc; +extern const char **GArgv; + +// Build-specific details. +extern const char *GBuildVer; + +// Static, non-stack memory for scratch work...not thread safe! +extern uint8 scratchbuf_128k[128 * 1024]; + + +#define UNICODE_BOGUS_CHAR_VALUE 0xFFFFFFFF +#define UNICODE_BOGUS_CHAR_CODEPOINT '?' +// !!! FIXME: document me! +uint32 utf8codepoint(const char **str); + +// !!! FIXME: document me! +int utf8len(const char *str); + +// !!! FIXME: document me! +char **splitText(const char *text, int scrw, int *_count, int *_w); + + +// Format a string, sort of (but not exactly!) like sprintf(). +// The only formatters accepted are %0 through %9 (and %%), which do not +// have to appear in order in the string, but match the varargs passed to the +// function. Only strings are accepted for varargs. This function allocates +// memory as necessary, so you need to free() the result, but don't need to +// preallocate a buffer and be concerned about overflowing it. +// This does not use scratchbuf_128k. +char *format(const char *fmt, ...); + +// Convert an int to a string. This uses incremental pieces of +// scratchbuf_128k for a buffer to store the results, and +// will overwrite itself after some number of calls when the memory +// is all used, but note that other things use scratchbuf_128k too, +// so this is only good for printf() things: +// fmtfunc("mission took %0 seconds, %1 points", numstr(secs), numstr(pts)); +const char *numstr(int val); + +// Call this for fatal errors that require immediate app termination. +// Does not clean up, or translate the error string. Try to avoid this. +// These are for crucial lowlevel issues that preclude any meaningful +// recovery (GUI didn't initialize, etc) +// Doesn't return, but if it did, you can assume it returns zero, so you can +// do: 'return panic("out of memory");' or whatnot. +int panic(const char *err); + +// Call this for a fatal problem that attempts an orderly shutdown (system +// is fully working, but config file is hosed, etc). +// This makes an attempt to clean up any files already created by the +// current installer (successfully run Setup.Install blocks in the config +// file are not cleaned up). +// If there's no GUI or Lua isn't initialized, this calls panic(). That's bad. +// Doesn't return, but if it did, you can assume it returns zero, so you can +// do: 'return fatal("missing config file");' or whatnot. +// THIS DOES NOT USE PRINTF-STYLE FORMAT CODES. Please see the comments for +// format() for details. +int fatal(const char *fmt, ...); + +// The platform layer should set up signal/exception handlers before calling +// MojoSetup_main(), that will call these functions. "crashed" for bug +// signals (SIGSEGV, GPF, etc), and "terminated" for external forces that +// destroy the process (SIGKILL, SIGINT, etc). These functions do not return. +void MojoSetup_crashed(void); +void MojoSetup_terminated(void); + +// Malloc replacements that blow up on allocation failure. +// Please note that xmalloc() will zero the newly-allocated memory buffer, +// like calloc() would, but xrealloc() makes no such promise! +void *xmalloc(size_t bytes); +void *xrealloc(void *ptr, size_t bytes); +char *xstrdup(const char *str); + +// strncpy() that promises to null-terminate the string, even on overflow. +char *xstrncpy(char *dst, const char *src, size_t len); + + +#ifdef malloc +#undef malloc +#endif +#define malloc(x) DO_NOT_CALL_MALLOC__USE_XMALLOC_INSTEAD + +#ifdef calloc +#undef calloc +#endif +#define calloc(x,y) DO_NOT_CALL_CALLOC__USE_XMALLOC_INSTEAD + +#ifdef realloc +#undef realloc +#endif +#define realloc(x,y) DO_NOT_CALL_REALLOC__USE_XREALLOC_INSTEAD + +#ifdef strdup +#undef strdup +#endif +#define strdup(x) DO_NOT_CALL_STRDUP__USE_XSTRDUP_INSTEAD + +#ifdef strncpy +#undef strncpy +#endif +#define strncpy(x,y,z) DO_NOT_CALL_STRNCPY__USE_XSTRNCPY_INSTEAD + +#if 0 // !!! FIXME: write me. +#ifdef strcasecmp +#undef strcasecmp +#endif +#define strcasecmp(x,y) DO_NOT_CALL_STRCASECMP__USE_UTF8STRICMP_INSTEAD +#endif + +#if 0 // !!! FIXME: write me. +#ifdef stricmp +#undef stricmp +#endif +#define stricmp(x,y) DO_NOT_CALL_STRICMP__USE_UTF8STRICMP_INSTEAD +#endif + +#if 0 // !!! FIXME: write me. +#ifdef strcmpi +#undef strcmpi +#endif +#define strcmpi(x,y) DO_NOT_CALL_STRCMPI__USE_UTF8STRICMP_INSTEAD +#endif + +// Localization support. +const char *translate(const char *str); +#ifdef _ +#undef _ +#endif +#define _(x) translate(x) + +// Call this with what you are profiling and the start time to log it: +// uint32 start = MojoPlatform_ticks(); +// ...do something... +// profile("Something I did", start); +uint32 profile(const char *what, uint32 start_time); + +// This tries to decode a graphic file in memory into an RGBA framebuffer, +// first with platform-specific facilities, if any, and then any built-in +// decoders, if that fails. +// (data) points to the compressed data, (size) is the number of bytes +// of compressed data. (*w) and (*h) will contain the images dimensions on +// return. +// Returns NULL on failure (unsupported, etc) and a pointer to the +// uncompressed data on success. Caller must free() the returned pointer! +uint8 *decodeImage(const uint8 *data, uint32 size, uint32 *w, uint32 *h); + +// See if a given string is in a valid product key format. +// (fmt) points to a string that would be a Setup.ProductKey.format. +// (key) is the key as it currently stands. It might be partially entered. +// Returns true if the key is valid for the format, false otherwise. +boolean isValidProductKey(const char *fmt, const char *key); + +// See if a given flag was on the command line +// +// cmdline("nosound") will return true if "-nosound", "--nosound", +// etc was on the command line. The option must start with a '-' on the +// command line to be noticed by this function. +// +// \param arg the command line flag to find +// \return true if arg was on the command line, false otherwise. +boolean cmdline(const char *arg); + + +// Get robust command line options, with optional default for missing ones. +// +// If the command line was ./myapp --a=b -c=d ----e f +// - cmdlinestr("a") will return "b" +// - cmdlinestr("c") will return "d" +// - cmdlinestr("e") will return "f" +// - cmdlinestr("g") will return the default string. +// +// Like cmdline(), the option must start with a '-'. +// +// \param arg The command line option to find. +// \param envr optional environment var to check if command line wasn't found. +// \param deflt The return value if (arg) isn't on the command line. +// \return The command line option, or (deflt) if the command line wasn't +// found. This return value is READ ONLY. Do not free it, either. +const char *cmdlinestr(const char *arg, const char *envr, const char *deflt); + +// Returns true if (str) matches (pattern), false otherwise. +// This is NOT a regexp! It only understands '?' and '*', similar to how +// wildcards worked in MS-DOS command lines. '?' matches one char, and +// '*' matches until the end of string or the next char in the pattern +// is seen. Case matters! +boolean wildcardMatch(const char *str, const char *pattern); + +// Logging functions. +typedef enum +{ + MOJOSETUP_LOG_NOTHING, + MOJOSETUP_LOG_ERRORS, + MOJOSETUP_LOG_WARNINGS, + MOJOSETUP_LOG_INFO, + MOJOSETUP_LOG_DEBUG, + MOJOSETUP_LOG_EVERYTHING +} MojoSetupLogLevel; + +extern MojoSetupLogLevel MojoLog_logLevel; +void MojoLog_initLogging(void); +void MojoLog_deinitLogging(void); + +// Logging facilities. +// THESE DO NOT USE PRINTF-STYLE FORMAT CODES. Please see the comments for +// format() for details. +void logWarning(const char *fmt, ...); +void logError(const char *fmt, ...); +void logInfo(const char *fmt, ...); +void logDebug(const char *fmt, ...); + + +// Checksums. + +typedef uint32 MojoCrc32; +void MojoCrc32_init(MojoCrc32 *context); +void MojoCrc32_append(MojoCrc32 *context, const uint8 *buf, uint32 len); +void MojoCrc32_finish(MojoCrc32 *context, uint32 *digest); + + +typedef struct MojoMd5 +{ + uint32 count[2]; + uint32 abcd[4]; + uint8 buf[64]; +} MojoMd5; + +void MojoMd5_init(MojoMd5 *pms); +void MojoMd5_append(MojoMd5 *pms, const uint8 *data, int nbytes); +void MojoMd5_finish(MojoMd5 *pms, uint8 digest[16]); + + +typedef struct +{ + uint32 state[5]; + uint32 count[2]; + uint8 buffer[64]; +} MojoSha1; + +void MojoSha1_init(MojoSha1 *context); +void MojoSha1_append(MojoSha1 *context, const uint8 *data, uint32 len); +void MojoSha1_finish(MojoSha1 *context, uint8 digest[20]); + +typedef struct MojoChecksumContext +{ + MojoCrc32 crc32; + MojoMd5 md5; + MojoSha1 sha1; +} MojoChecksumContext; + + +typedef struct MojoChecksums +{ + uint32 crc32; + uint8 md5[16]; + uint8 sha1[20]; +} MojoChecksums; + + +void MojoChecksum_init(MojoChecksumContext *ctx); +void MojoChecksum_append(MojoChecksumContext *c, const uint8 *data, uint32 ln); +void MojoChecksum_finish(MojoChecksumContext *c, MojoChecksums *sums); + + +// A pointer to this struct is passed to plugins, so they can access +// functionality in the base application. (Add to this as you need to.) +typedef struct MojoSetupEntryPoints +{ + void *(*xmalloc)(size_t bytes); + void *(*xrealloc)(void *ptr, size_t bytes); + char *(*xstrdup)(const char *str); + char *(*xstrncpy)(char *dst, const char *src, size_t len); + const char *(*translate)(const char *str); + void (*logWarning)(const char *fmt, ...); + void (*logError)(const char *fmt, ...); + void (*logInfo)(const char *fmt, ...); + void (*logDebug)(const char *fmt, ...); + char *(*format)(const char *fmt, ...); + const char *(*numstr)(int val); + uint32 (*ticks)(void); + uint32 (*utf8codepoint)(const char **_str); + int (*utf8len)(const char *str); + char **(*splitText)(const char *text, int scrw, int *_count, int *_w); + boolean (*isValidProductKey)(const char *f, const char *k); +} MojoSetupEntryPoints; +extern MojoSetupEntryPoints GEntryPoints; + + +#ifndef DOXYGEN_SHOULD_IGNORE_THIS +#if ((defined _MSC_VER) || (PLATFORM_BEOS)) +#define __EXPORT__ __declspec(dllexport) +#elif (defined SUNPRO_C) +#define __EXPORT__ __global +#elif (__GNUC__ >= 3) +#define __EXPORT__ __attribute__((visibility("default"))) +#else +#define __EXPORT__ +#endif +#endif // DOXYGEN_SHOULD_IGNORE_THIS + +#define DEFINE_TO_STR2(x) #x +#define DEFINE_TO_STR(x) DEFINE_TO_STR2(x) + +#ifndef DOXYGEN_SHOULD_IGNORE_THIS +#define STUBBED2(prelog, x) \ +do { \ + static boolean seen_this = false; \ + if (!seen_this) \ + { \ + seen_this = true; \ + prelog logDebug("STUBBED: %0 at %1 (%2:%3)\n", x, __FUNCTION__, \ + __FILE__, DEFINE_TO_STR(__LINE__)); \ + } \ +} while (false) +#define STUBBED(x) STUBBED2(,x) +#endif + +#define STATICARRAYLEN(x) ( (sizeof ((x))) / (sizeof ((x)[0])) ) + +#ifdef __cplusplus +} +#endif + +#endif + +// end of universal.h ... + diff --git a/mk/linux/mojosetup/zlib/adler32.c b/mk/linux/mojosetup/zlib/adler32.c new file mode 100644 index 00000000..65ad6a5a --- /dev/null +++ b/mk/linux/mojosetup/zlib/adler32.c @@ -0,0 +1,169 @@ +/* adler32.c -- compute the Adler-32 checksum of a data stream + * Copyright (C) 1995-2007 Mark Adler + * For conditions of distribution and use, see copyright notice in zlib.h + */ + +/* @(#) $Id$ */ + +#include "zutil.h" + +#define local static + +local uLong adler32_combine_(uLong adler1, uLong adler2, z_off64_t len2); + +#define BASE 65521UL /* largest prime smaller than 65536 */ +#define NMAX 5552 +/* NMAX is the largest n such that 255n(n+1)/2 + (n+1)(BASE-1) <= 2^32-1 */ + +#define DO1(buf,i) {adler += (buf)[i]; sum2 += adler;} +#define DO2(buf,i) DO1(buf,i); DO1(buf,i+1); +#define DO4(buf,i) DO2(buf,i); DO2(buf,i+2); +#define DO8(buf,i) DO4(buf,i); DO4(buf,i+4); +#define DO16(buf) DO8(buf,0); DO8(buf,8); + +/* use NO_DIVIDE if your processor does not do division in hardware */ +#ifdef NO_DIVIDE +# define MOD(a) \ + do { \ + if (a >= (BASE << 16)) a -= (BASE << 16); \ + if (a >= (BASE << 15)) a -= (BASE << 15); \ + if (a >= (BASE << 14)) a -= (BASE << 14); \ + if (a >= (BASE << 13)) a -= (BASE << 13); \ + if (a >= (BASE << 12)) a -= (BASE << 12); \ + if (a >= (BASE << 11)) a -= (BASE << 11); \ + if (a >= (BASE << 10)) a -= (BASE << 10); \ + if (a >= (BASE << 9)) a -= (BASE << 9); \ + if (a >= (BASE << 8)) a -= (BASE << 8); \ + if (a >= (BASE << 7)) a -= (BASE << 7); \ + if (a >= (BASE << 6)) a -= (BASE << 6); \ + if (a >= (BASE << 5)) a -= (BASE << 5); \ + if (a >= (BASE << 4)) a -= (BASE << 4); \ + if (a >= (BASE << 3)) a -= (BASE << 3); \ + if (a >= (BASE << 2)) a -= (BASE << 2); \ + if (a >= (BASE << 1)) a -= (BASE << 1); \ + if (a >= BASE) a -= BASE; \ + } while (0) +# define MOD4(a) \ + do { \ + if (a >= (BASE << 4)) a -= (BASE << 4); \ + if (a >= (BASE << 3)) a -= (BASE << 3); \ + if (a >= (BASE << 2)) a -= (BASE << 2); \ + if (a >= (BASE << 1)) a -= (BASE << 1); \ + if (a >= BASE) a -= BASE; \ + } while (0) +#else +# define MOD(a) a %= BASE +# define MOD4(a) a %= BASE +#endif + +/* ========================================================================= */ +uLong ZEXPORT adler32(adler, buf, len) + uLong adler; + const Bytef *buf; + uInt len; +{ + unsigned long sum2; + unsigned n; + + /* split Adler-32 into component sums */ + sum2 = (adler >> 16) & 0xffff; + adler &= 0xffff; + + /* in case user likes doing a byte at a time, keep it fast */ + if (len == 1) { + adler += buf[0]; + if (adler >= BASE) + adler -= BASE; + sum2 += adler; + if (sum2 >= BASE) + sum2 -= BASE; + return adler | (sum2 << 16); + } + + /* initial Adler-32 value (deferred check for len == 1 speed) */ + if (buf == Z_NULL) + return 1L; + + /* in case short lengths are provided, keep it somewhat fast */ + if (len < 16) { + while (len--) { + adler += *buf++; + sum2 += adler; + } + if (adler >= BASE) + adler -= BASE; + MOD4(sum2); /* only added so many BASE's */ + return adler | (sum2 << 16); + } + + /* do length NMAX blocks -- requires just one modulo operation */ + while (len >= NMAX) { + len -= NMAX; + n = NMAX / 16; /* NMAX is divisible by 16 */ + do { + DO16(buf); /* 16 sums unrolled */ + buf += 16; + } while (--n); + MOD(adler); + MOD(sum2); + } + + /* do remaining bytes (less than NMAX, still just one modulo) */ + if (len) { /* avoid modulos if none remaining */ + while (len >= 16) { + len -= 16; + DO16(buf); + buf += 16; + } + while (len--) { + adler += *buf++; + sum2 += adler; + } + MOD(adler); + MOD(sum2); + } + + /* return recombined sums */ + return adler | (sum2 << 16); +} + +/* ========================================================================= */ +local uLong adler32_combine_(adler1, adler2, len2) + uLong adler1; + uLong adler2; + z_off64_t len2; +{ + unsigned long sum1; + unsigned long sum2; + unsigned rem; + + /* the derivation of this formula is left as an exercise for the reader */ + rem = (unsigned)(len2 % BASE); + sum1 = adler1 & 0xffff; + sum2 = rem * sum1; + MOD(sum2); + sum1 += (adler2 & 0xffff) + BASE - 1; + sum2 += ((adler1 >> 16) & 0xffff) + ((adler2 >> 16) & 0xffff) + BASE - rem; + if (sum1 >= BASE) sum1 -= BASE; + if (sum1 >= BASE) sum1 -= BASE; + if (sum2 >= (BASE << 1)) sum2 -= (BASE << 1); + if (sum2 >= BASE) sum2 -= BASE; + return sum1 | (sum2 << 16); +} + +/* ========================================================================= */ +uLong ZEXPORT adler32_combine(adler1, adler2, len2) + uLong adler1; + uLong adler2; + z_off_t len2; +{ + return adler32_combine_(adler1, adler2, len2); +} + +uLong ZEXPORT adler32_combine64(adler1, adler2, len2) + uLong adler1; + uLong adler2; + z_off64_t len2; +{ + return adler32_combine_(adler1, adler2, len2); +} diff --git a/mk/linux/mojosetup/zlib/compress.c b/mk/linux/mojosetup/zlib/compress.c new file mode 100644 index 00000000..ea4dfbe9 --- /dev/null +++ b/mk/linux/mojosetup/zlib/compress.c @@ -0,0 +1,80 @@ +/* compress.c -- compress a memory buffer + * Copyright (C) 1995-2005 Jean-loup Gailly. + * For conditions of distribution and use, see copyright notice in zlib.h + */ + +/* @(#) $Id$ */ + +#define ZLIB_INTERNAL +#include "zlib.h" + +/* =========================================================================== + Compresses the source buffer into the destination buffer. The level + parameter has the same meaning as in deflateInit. sourceLen is the byte + length of the source buffer. Upon entry, destLen is the total size of the + destination buffer, which must be at least 0.1% larger than sourceLen plus + 12 bytes. Upon exit, destLen is the actual size of the compressed buffer. + + compress2 returns Z_OK if success, Z_MEM_ERROR if there was not enough + memory, Z_BUF_ERROR if there was not enough room in the output buffer, + Z_STREAM_ERROR if the level parameter is invalid. +*/ +int ZEXPORT compress2 (dest, destLen, source, sourceLen, level) + Bytef *dest; + uLongf *destLen; + const Bytef *source; + uLong sourceLen; + int level; +{ + z_stream stream; + int err; + + stream.next_in = (Bytef*)source; + stream.avail_in = (uInt)sourceLen; +#ifdef MAXSEG_64K + /* Check for source > 64K on 16-bit machine: */ + if ((uLong)stream.avail_in != sourceLen) return Z_BUF_ERROR; +#endif + stream.next_out = dest; + stream.avail_out = (uInt)*destLen; + if ((uLong)stream.avail_out != *destLen) return Z_BUF_ERROR; + + stream.zalloc = (alloc_func)0; + stream.zfree = (free_func)0; + stream.opaque = (voidpf)0; + + err = deflateInit(&stream, level); + if (err != Z_OK) return err; + + err = deflate(&stream, Z_FINISH); + if (err != Z_STREAM_END) { + deflateEnd(&stream); + return err == Z_OK ? Z_BUF_ERROR : err; + } + *destLen = stream.total_out; + + err = deflateEnd(&stream); + return err; +} + +/* =========================================================================== + */ +int ZEXPORT compress (dest, destLen, source, sourceLen) + Bytef *dest; + uLongf *destLen; + const Bytef *source; + uLong sourceLen; +{ + return compress2(dest, destLen, source, sourceLen, Z_DEFAULT_COMPRESSION); +} + +/* =========================================================================== + If the default memLevel or windowBits for deflateInit() is changed, then + this function needs to be updated. + */ +uLong ZEXPORT compressBound (sourceLen) + uLong sourceLen; +{ + return sourceLen + (sourceLen >> 12) + (sourceLen >> 14) + + (sourceLen >> 25) + 13; +} diff --git a/mk/linux/mojosetup/zlib/crc32.c b/mk/linux/mojosetup/zlib/crc32.c new file mode 100644 index 00000000..1acc7ed8 --- /dev/null +++ b/mk/linux/mojosetup/zlib/crc32.c @@ -0,0 +1,442 @@ +/* crc32.c -- compute the CRC-32 of a data stream + * Copyright (C) 1995-2006 Mark Adler + * For conditions of distribution and use, see copyright notice in zlib.h + * + * Thanks to Rodney Brown for his contribution of faster + * CRC methods: exclusive-oring 32 bits of data at a time, and pre-computing + * tables for updating the shift register in one step with three exclusive-ors + * instead of four steps with four exclusive-ors. This results in about a + * factor of two increase in speed on a Power PC G4 (PPC7455) using gcc -O3. + */ + +/* @(#) $Id$ */ + +/* + Note on the use of DYNAMIC_CRC_TABLE: there is no mutex or semaphore + protection on the static variables used to control the first-use generation + of the crc tables. Therefore, if you #define DYNAMIC_CRC_TABLE, you should + first call get_crc_table() to initialize the tables before allowing more than + one thread to use crc32(). + */ + +#ifdef MAKECRCH +# include +# ifndef DYNAMIC_CRC_TABLE +# define DYNAMIC_CRC_TABLE +# endif /* !DYNAMIC_CRC_TABLE */ +#endif /* MAKECRCH */ + +#include "zutil.h" /* for STDC and FAR definitions */ + +#define local static + +/* Find a four-byte integer type for crc32_little() and crc32_big(). */ +#ifndef NOBYFOUR +# ifdef STDC /* need ANSI C limits.h to determine sizes */ +# include +# define BYFOUR +# if (UINT_MAX == 0xffffffffUL) + typedef unsigned int u4; +# else +# if (ULONG_MAX == 0xffffffffUL) + typedef unsigned long u4; +# else +# if (USHRT_MAX == 0xffffffffUL) + typedef unsigned short u4; +# else +# undef BYFOUR /* can't find a four-byte integer type! */ +# endif +# endif +# endif +# endif /* STDC */ +#endif /* !NOBYFOUR */ + +/* Definitions for doing the crc four data bytes at a time. */ +#ifdef BYFOUR +# define REV(w) ((((w)>>24)&0xff)+(((w)>>8)&0xff00)+ \ + (((w)&0xff00)<<8)+(((w)&0xff)<<24)) + local unsigned long crc32_little OF((unsigned long, + const unsigned char FAR *, unsigned)); + local unsigned long crc32_big OF((unsigned long, + const unsigned char FAR *, unsigned)); +# define TBLS 8 +#else +# define TBLS 1 +#endif /* BYFOUR */ + +/* Local functions for crc concatenation */ +local unsigned long gf2_matrix_times OF((unsigned long *mat, + unsigned long vec)); +local void gf2_matrix_square OF((unsigned long *square, unsigned long *mat)); +local uLong crc32_combine_(uLong crc1, uLong crc2, z_off64_t len2); + + +#ifdef DYNAMIC_CRC_TABLE + +local volatile int crc_table_empty = 1; +local unsigned long FAR crc_table[TBLS][256]; +local void make_crc_table OF((void)); +#ifdef MAKECRCH + local void write_table OF((FILE *, const unsigned long FAR *)); +#endif /* MAKECRCH */ +/* + Generate tables for a byte-wise 32-bit CRC calculation on the polynomial: + x^32+x^26+x^23+x^22+x^16+x^12+x^11+x^10+x^8+x^7+x^5+x^4+x^2+x+1. + + Polynomials over GF(2) are represented in binary, one bit per coefficient, + with the lowest powers in the most significant bit. Then adding polynomials + is just exclusive-or, and multiplying a polynomial by x is a right shift by + one. If we call the above polynomial p, and represent a byte as the + polynomial q, also with the lowest power in the most significant bit (so the + byte 0xb1 is the polynomial x^7+x^3+x+1), then the CRC is (q*x^32) mod p, + where a mod b means the remainder after dividing a by b. + + This calculation is done using the shift-register method of multiplying and + taking the remainder. The register is initialized to zero, and for each + incoming bit, x^32 is added mod p to the register if the bit is a one (where + x^32 mod p is p+x^32 = x^26+...+1), and the register is multiplied mod p by + x (which is shifting right by one and adding x^32 mod p if the bit shifted + out is a one). We start with the highest power (least significant bit) of + q and repeat for all eight bits of q. + + The first table is simply the CRC of all possible eight bit values. This is + all the information needed to generate CRCs on data a byte at a time for all + combinations of CRC register values and incoming bytes. The remaining tables + allow for word-at-a-time CRC calculation for both big-endian and little- + endian machines, where a word is four bytes. +*/ +local void make_crc_table() +{ + unsigned long c; + int n, k; + unsigned long poly; /* polynomial exclusive-or pattern */ + /* terms of polynomial defining this crc (except x^32): */ + static volatile int first = 1; /* flag to limit concurrent making */ + static const unsigned char p[] = {0,1,2,4,5,7,8,10,11,12,16,22,23,26}; + + /* See if another task is already doing this (not thread-safe, but better + than nothing -- significantly reduces duration of vulnerability in + case the advice about DYNAMIC_CRC_TABLE is ignored) */ + if (first) { + first = 0; + + /* make exclusive-or pattern from polynomial (0xedb88320UL) */ + poly = 0UL; + for (n = 0; n < sizeof(p)/sizeof(unsigned char); n++) + poly |= 1UL << (31 - p[n]); + + /* generate a crc for every 8-bit value */ + for (n = 0; n < 256; n++) { + c = (unsigned long)n; + for (k = 0; k < 8; k++) + c = c & 1 ? poly ^ (c >> 1) : c >> 1; + crc_table[0][n] = c; + } + +#ifdef BYFOUR + /* generate crc for each value followed by one, two, and three zeros, + and then the byte reversal of those as well as the first table */ + for (n = 0; n < 256; n++) { + c = crc_table[0][n]; + crc_table[4][n] = REV(c); + for (k = 1; k < 4; k++) { + c = crc_table[0][c & 0xff] ^ (c >> 8); + crc_table[k][n] = c; + crc_table[k + 4][n] = REV(c); + } + } +#endif /* BYFOUR */ + + crc_table_empty = 0; + } + else { /* not first */ + /* wait for the other guy to finish (not efficient, but rare) */ + while (crc_table_empty) + ; + } + +#ifdef MAKECRCH + /* write out CRC tables to crc32.h */ + { + FILE *out; + + out = fopen("crc32.h", "w"); + if (out == NULL) return; + fprintf(out, "/* crc32.h -- tables for rapid CRC calculation\n"); + fprintf(out, " * Generated automatically by crc32.c\n */\n\n"); + fprintf(out, "local const unsigned long FAR "); + fprintf(out, "crc_table[TBLS][256] =\n{\n {\n"); + write_table(out, crc_table[0]); +# ifdef BYFOUR + fprintf(out, "#ifdef BYFOUR\n"); + for (k = 1; k < 8; k++) { + fprintf(out, " },\n {\n"); + write_table(out, crc_table[k]); + } + fprintf(out, "#endif\n"); +# endif /* BYFOUR */ + fprintf(out, " }\n};\n"); + fclose(out); + } +#endif /* MAKECRCH */ +} + +#ifdef MAKECRCH +local void write_table(out, table) + FILE *out; + const unsigned long FAR *table; +{ + int n; + + for (n = 0; n < 256; n++) + fprintf(out, "%s0x%08lxUL%s", n % 5 ? "" : " ", table[n], + n == 255 ? "\n" : (n % 5 == 4 ? ",\n" : ", ")); +} +#endif /* MAKECRCH */ + +#else /* !DYNAMIC_CRC_TABLE */ +/* ======================================================================== + * Tables of CRC-32s of all single-byte values, made by make_crc_table(). + */ +#include "crc32.h" +#endif /* DYNAMIC_CRC_TABLE */ + +/* ========================================================================= + * This function can be used by asm versions of crc32() + */ +const unsigned long FAR * ZEXPORT get_crc_table() +{ +#ifdef DYNAMIC_CRC_TABLE + if (crc_table_empty) + make_crc_table(); +#endif /* DYNAMIC_CRC_TABLE */ + return (const unsigned long FAR *)crc_table; +} + +/* ========================================================================= */ +#define DO1 crc = crc_table[0][((int)crc ^ (*buf++)) & 0xff] ^ (crc >> 8) +#define DO8 DO1; DO1; DO1; DO1; DO1; DO1; DO1; DO1 + +/* ========================================================================= */ +unsigned long ZEXPORT crc32(crc, buf, len) + unsigned long crc; + const unsigned char FAR *buf; + unsigned len; +{ + if (buf == Z_NULL) return 0UL; + +#ifdef DYNAMIC_CRC_TABLE + if (crc_table_empty) + make_crc_table(); +#endif /* DYNAMIC_CRC_TABLE */ + +#ifdef BYFOUR + if (sizeof(void *) == sizeof(ptrdiff_t)) { + u4 endian; + + endian = 1; + if (*((unsigned char *)(&endian))) + return crc32_little(crc, buf, len); + else + return crc32_big(crc, buf, len); + } +#endif /* BYFOUR */ + crc = crc ^ 0xffffffffUL; + while (len >= 8) { + DO8; + len -= 8; + } + if (len) do { + DO1; + } while (--len); + return crc ^ 0xffffffffUL; +} + +#ifdef BYFOUR + +/* ========================================================================= */ +#define DOLIT4 c ^= *buf4++; \ + c = crc_table[3][c & 0xff] ^ crc_table[2][(c >> 8) & 0xff] ^ \ + crc_table[1][(c >> 16) & 0xff] ^ crc_table[0][c >> 24] +#define DOLIT32 DOLIT4; DOLIT4; DOLIT4; DOLIT4; DOLIT4; DOLIT4; DOLIT4; DOLIT4 + +/* ========================================================================= */ +local unsigned long crc32_little(crc, buf, len) + unsigned long crc; + const unsigned char FAR *buf; + unsigned len; +{ + register u4 c; + register const u4 FAR *buf4; + + c = (u4)crc; + c = ~c; + while (len && ((ptrdiff_t)buf & 3)) { + c = crc_table[0][(c ^ *buf++) & 0xff] ^ (c >> 8); + len--; + } + + buf4 = (const u4 FAR *)(const void FAR *)buf; + while (len >= 32) { + DOLIT32; + len -= 32; + } + while (len >= 4) { + DOLIT4; + len -= 4; + } + buf = (const unsigned char FAR *)buf4; + + if (len) do { + c = crc_table[0][(c ^ *buf++) & 0xff] ^ (c >> 8); + } while (--len); + c = ~c; + return (unsigned long)c; +} + +/* ========================================================================= */ +#define DOBIG4 c ^= *++buf4; \ + c = crc_table[4][c & 0xff] ^ crc_table[5][(c >> 8) & 0xff] ^ \ + crc_table[6][(c >> 16) & 0xff] ^ crc_table[7][c >> 24] +#define DOBIG32 DOBIG4; DOBIG4; DOBIG4; DOBIG4; DOBIG4; DOBIG4; DOBIG4; DOBIG4 + +/* ========================================================================= */ +local unsigned long crc32_big(crc, buf, len) + unsigned long crc; + const unsigned char FAR *buf; + unsigned len; +{ + register u4 c; + register const u4 FAR *buf4; + + c = REV((u4)crc); + c = ~c; + while (len && ((ptrdiff_t)buf & 3)) { + c = crc_table[4][(c >> 24) ^ *buf++] ^ (c << 8); + len--; + } + + buf4 = (const u4 FAR *)(const void FAR *)buf; + buf4--; + while (len >= 32) { + DOBIG32; + len -= 32; + } + while (len >= 4) { + DOBIG4; + len -= 4; + } + buf4++; + buf = (const unsigned char FAR *)buf4; + + if (len) do { + c = crc_table[4][(c >> 24) ^ *buf++] ^ (c << 8); + } while (--len); + c = ~c; + return (unsigned long)(REV(c)); +} + +#endif /* BYFOUR */ + +#define GF2_DIM 32 /* dimension of GF(2) vectors (length of CRC) */ + +/* ========================================================================= */ +local unsigned long gf2_matrix_times(mat, vec) + unsigned long *mat; + unsigned long vec; +{ + unsigned long sum; + + sum = 0; + while (vec) { + if (vec & 1) + sum ^= *mat; + vec >>= 1; + mat++; + } + return sum; +} + +/* ========================================================================= */ +local void gf2_matrix_square(square, mat) + unsigned long *square; + unsigned long *mat; +{ + int n; + + for (n = 0; n < GF2_DIM; n++) + square[n] = gf2_matrix_times(mat, mat[n]); +} + +/* ========================================================================= */ +local uLong crc32_combine_(crc1, crc2, len2) + uLong crc1; + uLong crc2; + z_off64_t len2; +{ + int n; + unsigned long row; + unsigned long even[GF2_DIM]; /* even-power-of-two zeros operator */ + unsigned long odd[GF2_DIM]; /* odd-power-of-two zeros operator */ + + /* degenerate case (also disallow negative lengths) */ + if (len2 <= 0) + return crc1; + + /* put operator for one zero bit in odd */ + odd[0] = 0xedb88320UL; /* CRC-32 polynomial */ + row = 1; + for (n = 1; n < GF2_DIM; n++) { + odd[n] = row; + row <<= 1; + } + + /* put operator for two zero bits in even */ + gf2_matrix_square(even, odd); + + /* put operator for four zero bits in odd */ + gf2_matrix_square(odd, even); + + /* apply len2 zeros to crc1 (first square will put the operator for one + zero byte, eight zero bits, in even) */ + do { + /* apply zeros operator for this bit of len2 */ + gf2_matrix_square(even, odd); + if (len2 & 1) + crc1 = gf2_matrix_times(even, crc1); + len2 >>= 1; + + /* if no more bits set, then done */ + if (len2 == 0) + break; + + /* another iteration of the loop with odd and even swapped */ + gf2_matrix_square(odd, even); + if (len2 & 1) + crc1 = gf2_matrix_times(odd, crc1); + len2 >>= 1; + + /* if no more bits set, then done */ + } while (len2 != 0); + + /* return combined crc */ + crc1 ^= crc2; + return crc1; +} + +/* ========================================================================= */ +uLong ZEXPORT crc32_combine(crc1, crc2, len2) + uLong crc1; + uLong crc2; + z_off_t len2; +{ + return crc32_combine_(crc1, crc2, len2); +} + +uLong ZEXPORT crc32_combine64(crc1, crc2, len2) + uLong crc1; + uLong crc2; + z_off64_t len2; +{ + return crc32_combine_(crc1, crc2, len2); +} diff --git a/mk/linux/mojosetup/zlib/crc32.h b/mk/linux/mojosetup/zlib/crc32.h new file mode 100644 index 00000000..8053b611 --- /dev/null +++ b/mk/linux/mojosetup/zlib/crc32.h @@ -0,0 +1,441 @@ +/* crc32.h -- tables for rapid CRC calculation + * Generated automatically by crc32.c + */ + +local const unsigned long FAR crc_table[TBLS][256] = +{ + { + 0x00000000UL, 0x77073096UL, 0xee0e612cUL, 0x990951baUL, 0x076dc419UL, + 0x706af48fUL, 0xe963a535UL, 0x9e6495a3UL, 0x0edb8832UL, 0x79dcb8a4UL, + 0xe0d5e91eUL, 0x97d2d988UL, 0x09b64c2bUL, 0x7eb17cbdUL, 0xe7b82d07UL, + 0x90bf1d91UL, 0x1db71064UL, 0x6ab020f2UL, 0xf3b97148UL, 0x84be41deUL, + 0x1adad47dUL, 0x6ddde4ebUL, 0xf4d4b551UL, 0x83d385c7UL, 0x136c9856UL, + 0x646ba8c0UL, 0xfd62f97aUL, 0x8a65c9ecUL, 0x14015c4fUL, 0x63066cd9UL, + 0xfa0f3d63UL, 0x8d080df5UL, 0x3b6e20c8UL, 0x4c69105eUL, 0xd56041e4UL, + 0xa2677172UL, 0x3c03e4d1UL, 0x4b04d447UL, 0xd20d85fdUL, 0xa50ab56bUL, + 0x35b5a8faUL, 0x42b2986cUL, 0xdbbbc9d6UL, 0xacbcf940UL, 0x32d86ce3UL, + 0x45df5c75UL, 0xdcd60dcfUL, 0xabd13d59UL, 0x26d930acUL, 0x51de003aUL, + 0xc8d75180UL, 0xbfd06116UL, 0x21b4f4b5UL, 0x56b3c423UL, 0xcfba9599UL, + 0xb8bda50fUL, 0x2802b89eUL, 0x5f058808UL, 0xc60cd9b2UL, 0xb10be924UL, + 0x2f6f7c87UL, 0x58684c11UL, 0xc1611dabUL, 0xb6662d3dUL, 0x76dc4190UL, + 0x01db7106UL, 0x98d220bcUL, 0xefd5102aUL, 0x71b18589UL, 0x06b6b51fUL, + 0x9fbfe4a5UL, 0xe8b8d433UL, 0x7807c9a2UL, 0x0f00f934UL, 0x9609a88eUL, + 0xe10e9818UL, 0x7f6a0dbbUL, 0x086d3d2dUL, 0x91646c97UL, 0xe6635c01UL, + 0x6b6b51f4UL, 0x1c6c6162UL, 0x856530d8UL, 0xf262004eUL, 0x6c0695edUL, + 0x1b01a57bUL, 0x8208f4c1UL, 0xf50fc457UL, 0x65b0d9c6UL, 0x12b7e950UL, + 0x8bbeb8eaUL, 0xfcb9887cUL, 0x62dd1ddfUL, 0x15da2d49UL, 0x8cd37cf3UL, + 0xfbd44c65UL, 0x4db26158UL, 0x3ab551ceUL, 0xa3bc0074UL, 0xd4bb30e2UL, + 0x4adfa541UL, 0x3dd895d7UL, 0xa4d1c46dUL, 0xd3d6f4fbUL, 0x4369e96aUL, + 0x346ed9fcUL, 0xad678846UL, 0xda60b8d0UL, 0x44042d73UL, 0x33031de5UL, + 0xaa0a4c5fUL, 0xdd0d7cc9UL, 0x5005713cUL, 0x270241aaUL, 0xbe0b1010UL, + 0xc90c2086UL, 0x5768b525UL, 0x206f85b3UL, 0xb966d409UL, 0xce61e49fUL, + 0x5edef90eUL, 0x29d9c998UL, 0xb0d09822UL, 0xc7d7a8b4UL, 0x59b33d17UL, + 0x2eb40d81UL, 0xb7bd5c3bUL, 0xc0ba6cadUL, 0xedb88320UL, 0x9abfb3b6UL, + 0x03b6e20cUL, 0x74b1d29aUL, 0xead54739UL, 0x9dd277afUL, 0x04db2615UL, + 0x73dc1683UL, 0xe3630b12UL, 0x94643b84UL, 0x0d6d6a3eUL, 0x7a6a5aa8UL, + 0xe40ecf0bUL, 0x9309ff9dUL, 0x0a00ae27UL, 0x7d079eb1UL, 0xf00f9344UL, + 0x8708a3d2UL, 0x1e01f268UL, 0x6906c2feUL, 0xf762575dUL, 0x806567cbUL, + 0x196c3671UL, 0x6e6b06e7UL, 0xfed41b76UL, 0x89d32be0UL, 0x10da7a5aUL, + 0x67dd4accUL, 0xf9b9df6fUL, 0x8ebeeff9UL, 0x17b7be43UL, 0x60b08ed5UL, + 0xd6d6a3e8UL, 0xa1d1937eUL, 0x38d8c2c4UL, 0x4fdff252UL, 0xd1bb67f1UL, + 0xa6bc5767UL, 0x3fb506ddUL, 0x48b2364bUL, 0xd80d2bdaUL, 0xaf0a1b4cUL, + 0x36034af6UL, 0x41047a60UL, 0xdf60efc3UL, 0xa867df55UL, 0x316e8eefUL, + 0x4669be79UL, 0xcb61b38cUL, 0xbc66831aUL, 0x256fd2a0UL, 0x5268e236UL, + 0xcc0c7795UL, 0xbb0b4703UL, 0x220216b9UL, 0x5505262fUL, 0xc5ba3bbeUL, + 0xb2bd0b28UL, 0x2bb45a92UL, 0x5cb36a04UL, 0xc2d7ffa7UL, 0xb5d0cf31UL, + 0x2cd99e8bUL, 0x5bdeae1dUL, 0x9b64c2b0UL, 0xec63f226UL, 0x756aa39cUL, + 0x026d930aUL, 0x9c0906a9UL, 0xeb0e363fUL, 0x72076785UL, 0x05005713UL, + 0x95bf4a82UL, 0xe2b87a14UL, 0x7bb12baeUL, 0x0cb61b38UL, 0x92d28e9bUL, + 0xe5d5be0dUL, 0x7cdcefb7UL, 0x0bdbdf21UL, 0x86d3d2d4UL, 0xf1d4e242UL, + 0x68ddb3f8UL, 0x1fda836eUL, 0x81be16cdUL, 0xf6b9265bUL, 0x6fb077e1UL, + 0x18b74777UL, 0x88085ae6UL, 0xff0f6a70UL, 0x66063bcaUL, 0x11010b5cUL, + 0x8f659effUL, 0xf862ae69UL, 0x616bffd3UL, 0x166ccf45UL, 0xa00ae278UL, + 0xd70dd2eeUL, 0x4e048354UL, 0x3903b3c2UL, 0xa7672661UL, 0xd06016f7UL, + 0x4969474dUL, 0x3e6e77dbUL, 0xaed16a4aUL, 0xd9d65adcUL, 0x40df0b66UL, + 0x37d83bf0UL, 0xa9bcae53UL, 0xdebb9ec5UL, 0x47b2cf7fUL, 0x30b5ffe9UL, + 0xbdbdf21cUL, 0xcabac28aUL, 0x53b39330UL, 0x24b4a3a6UL, 0xbad03605UL, + 0xcdd70693UL, 0x54de5729UL, 0x23d967bfUL, 0xb3667a2eUL, 0xc4614ab8UL, + 0x5d681b02UL, 0x2a6f2b94UL, 0xb40bbe37UL, 0xc30c8ea1UL, 0x5a05df1bUL, + 0x2d02ef8dUL +#ifdef BYFOUR + }, + { + 0x00000000UL, 0x191b3141UL, 0x32366282UL, 0x2b2d53c3UL, 0x646cc504UL, + 0x7d77f445UL, 0x565aa786UL, 0x4f4196c7UL, 0xc8d98a08UL, 0xd1c2bb49UL, + 0xfaefe88aUL, 0xe3f4d9cbUL, 0xacb54f0cUL, 0xb5ae7e4dUL, 0x9e832d8eUL, + 0x87981ccfUL, 0x4ac21251UL, 0x53d92310UL, 0x78f470d3UL, 0x61ef4192UL, + 0x2eaed755UL, 0x37b5e614UL, 0x1c98b5d7UL, 0x05838496UL, 0x821b9859UL, + 0x9b00a918UL, 0xb02dfadbUL, 0xa936cb9aUL, 0xe6775d5dUL, 0xff6c6c1cUL, + 0xd4413fdfUL, 0xcd5a0e9eUL, 0x958424a2UL, 0x8c9f15e3UL, 0xa7b24620UL, + 0xbea97761UL, 0xf1e8e1a6UL, 0xe8f3d0e7UL, 0xc3de8324UL, 0xdac5b265UL, + 0x5d5daeaaUL, 0x44469febUL, 0x6f6bcc28UL, 0x7670fd69UL, 0x39316baeUL, + 0x202a5aefUL, 0x0b07092cUL, 0x121c386dUL, 0xdf4636f3UL, 0xc65d07b2UL, + 0xed705471UL, 0xf46b6530UL, 0xbb2af3f7UL, 0xa231c2b6UL, 0x891c9175UL, + 0x9007a034UL, 0x179fbcfbUL, 0x0e848dbaUL, 0x25a9de79UL, 0x3cb2ef38UL, + 0x73f379ffUL, 0x6ae848beUL, 0x41c51b7dUL, 0x58de2a3cUL, 0xf0794f05UL, + 0xe9627e44UL, 0xc24f2d87UL, 0xdb541cc6UL, 0x94158a01UL, 0x8d0ebb40UL, + 0xa623e883UL, 0xbf38d9c2UL, 0x38a0c50dUL, 0x21bbf44cUL, 0x0a96a78fUL, + 0x138d96ceUL, 0x5ccc0009UL, 0x45d73148UL, 0x6efa628bUL, 0x77e153caUL, + 0xbabb5d54UL, 0xa3a06c15UL, 0x888d3fd6UL, 0x91960e97UL, 0xded79850UL, + 0xc7cca911UL, 0xece1fad2UL, 0xf5facb93UL, 0x7262d75cUL, 0x6b79e61dUL, + 0x4054b5deUL, 0x594f849fUL, 0x160e1258UL, 0x0f152319UL, 0x243870daUL, + 0x3d23419bUL, 0x65fd6ba7UL, 0x7ce65ae6UL, 0x57cb0925UL, 0x4ed03864UL, + 0x0191aea3UL, 0x188a9fe2UL, 0x33a7cc21UL, 0x2abcfd60UL, 0xad24e1afUL, + 0xb43fd0eeUL, 0x9f12832dUL, 0x8609b26cUL, 0xc94824abUL, 0xd05315eaUL, + 0xfb7e4629UL, 0xe2657768UL, 0x2f3f79f6UL, 0x362448b7UL, 0x1d091b74UL, + 0x04122a35UL, 0x4b53bcf2UL, 0x52488db3UL, 0x7965de70UL, 0x607eef31UL, + 0xe7e6f3feUL, 0xfefdc2bfUL, 0xd5d0917cUL, 0xcccba03dUL, 0x838a36faUL, + 0x9a9107bbUL, 0xb1bc5478UL, 0xa8a76539UL, 0x3b83984bUL, 0x2298a90aUL, + 0x09b5fac9UL, 0x10aecb88UL, 0x5fef5d4fUL, 0x46f46c0eUL, 0x6dd93fcdUL, + 0x74c20e8cUL, 0xf35a1243UL, 0xea412302UL, 0xc16c70c1UL, 0xd8774180UL, + 0x9736d747UL, 0x8e2de606UL, 0xa500b5c5UL, 0xbc1b8484UL, 0x71418a1aUL, + 0x685abb5bUL, 0x4377e898UL, 0x5a6cd9d9UL, 0x152d4f1eUL, 0x0c367e5fUL, + 0x271b2d9cUL, 0x3e001cddUL, 0xb9980012UL, 0xa0833153UL, 0x8bae6290UL, + 0x92b553d1UL, 0xddf4c516UL, 0xc4eff457UL, 0xefc2a794UL, 0xf6d996d5UL, + 0xae07bce9UL, 0xb71c8da8UL, 0x9c31de6bUL, 0x852aef2aUL, 0xca6b79edUL, + 0xd37048acUL, 0xf85d1b6fUL, 0xe1462a2eUL, 0x66de36e1UL, 0x7fc507a0UL, + 0x54e85463UL, 0x4df36522UL, 0x02b2f3e5UL, 0x1ba9c2a4UL, 0x30849167UL, + 0x299fa026UL, 0xe4c5aeb8UL, 0xfdde9ff9UL, 0xd6f3cc3aUL, 0xcfe8fd7bUL, + 0x80a96bbcUL, 0x99b25afdUL, 0xb29f093eUL, 0xab84387fUL, 0x2c1c24b0UL, + 0x350715f1UL, 0x1e2a4632UL, 0x07317773UL, 0x4870e1b4UL, 0x516bd0f5UL, + 0x7a468336UL, 0x635db277UL, 0xcbfad74eUL, 0xd2e1e60fUL, 0xf9ccb5ccUL, + 0xe0d7848dUL, 0xaf96124aUL, 0xb68d230bUL, 0x9da070c8UL, 0x84bb4189UL, + 0x03235d46UL, 0x1a386c07UL, 0x31153fc4UL, 0x280e0e85UL, 0x674f9842UL, + 0x7e54a903UL, 0x5579fac0UL, 0x4c62cb81UL, 0x8138c51fUL, 0x9823f45eUL, + 0xb30ea79dUL, 0xaa1596dcUL, 0xe554001bUL, 0xfc4f315aUL, 0xd7626299UL, + 0xce7953d8UL, 0x49e14f17UL, 0x50fa7e56UL, 0x7bd72d95UL, 0x62cc1cd4UL, + 0x2d8d8a13UL, 0x3496bb52UL, 0x1fbbe891UL, 0x06a0d9d0UL, 0x5e7ef3ecUL, + 0x4765c2adUL, 0x6c48916eUL, 0x7553a02fUL, 0x3a1236e8UL, 0x230907a9UL, + 0x0824546aUL, 0x113f652bUL, 0x96a779e4UL, 0x8fbc48a5UL, 0xa4911b66UL, + 0xbd8a2a27UL, 0xf2cbbce0UL, 0xebd08da1UL, 0xc0fdde62UL, 0xd9e6ef23UL, + 0x14bce1bdUL, 0x0da7d0fcUL, 0x268a833fUL, 0x3f91b27eUL, 0x70d024b9UL, + 0x69cb15f8UL, 0x42e6463bUL, 0x5bfd777aUL, 0xdc656bb5UL, 0xc57e5af4UL, + 0xee530937UL, 0xf7483876UL, 0xb809aeb1UL, 0xa1129ff0UL, 0x8a3fcc33UL, + 0x9324fd72UL + }, + { + 0x00000000UL, 0x01c26a37UL, 0x0384d46eUL, 0x0246be59UL, 0x0709a8dcUL, + 0x06cbc2ebUL, 0x048d7cb2UL, 0x054f1685UL, 0x0e1351b8UL, 0x0fd13b8fUL, + 0x0d9785d6UL, 0x0c55efe1UL, 0x091af964UL, 0x08d89353UL, 0x0a9e2d0aUL, + 0x0b5c473dUL, 0x1c26a370UL, 0x1de4c947UL, 0x1fa2771eUL, 0x1e601d29UL, + 0x1b2f0bacUL, 0x1aed619bUL, 0x18abdfc2UL, 0x1969b5f5UL, 0x1235f2c8UL, + 0x13f798ffUL, 0x11b126a6UL, 0x10734c91UL, 0x153c5a14UL, 0x14fe3023UL, + 0x16b88e7aUL, 0x177ae44dUL, 0x384d46e0UL, 0x398f2cd7UL, 0x3bc9928eUL, + 0x3a0bf8b9UL, 0x3f44ee3cUL, 0x3e86840bUL, 0x3cc03a52UL, 0x3d025065UL, + 0x365e1758UL, 0x379c7d6fUL, 0x35dac336UL, 0x3418a901UL, 0x3157bf84UL, + 0x3095d5b3UL, 0x32d36beaUL, 0x331101ddUL, 0x246be590UL, 0x25a98fa7UL, + 0x27ef31feUL, 0x262d5bc9UL, 0x23624d4cUL, 0x22a0277bUL, 0x20e69922UL, + 0x2124f315UL, 0x2a78b428UL, 0x2bbade1fUL, 0x29fc6046UL, 0x283e0a71UL, + 0x2d711cf4UL, 0x2cb376c3UL, 0x2ef5c89aUL, 0x2f37a2adUL, 0x709a8dc0UL, + 0x7158e7f7UL, 0x731e59aeUL, 0x72dc3399UL, 0x7793251cUL, 0x76514f2bUL, + 0x7417f172UL, 0x75d59b45UL, 0x7e89dc78UL, 0x7f4bb64fUL, 0x7d0d0816UL, + 0x7ccf6221UL, 0x798074a4UL, 0x78421e93UL, 0x7a04a0caUL, 0x7bc6cafdUL, + 0x6cbc2eb0UL, 0x6d7e4487UL, 0x6f38fadeUL, 0x6efa90e9UL, 0x6bb5866cUL, + 0x6a77ec5bUL, 0x68315202UL, 0x69f33835UL, 0x62af7f08UL, 0x636d153fUL, + 0x612bab66UL, 0x60e9c151UL, 0x65a6d7d4UL, 0x6464bde3UL, 0x662203baUL, + 0x67e0698dUL, 0x48d7cb20UL, 0x4915a117UL, 0x4b531f4eUL, 0x4a917579UL, + 0x4fde63fcUL, 0x4e1c09cbUL, 0x4c5ab792UL, 0x4d98dda5UL, 0x46c49a98UL, + 0x4706f0afUL, 0x45404ef6UL, 0x448224c1UL, 0x41cd3244UL, 0x400f5873UL, + 0x4249e62aUL, 0x438b8c1dUL, 0x54f16850UL, 0x55330267UL, 0x5775bc3eUL, + 0x56b7d609UL, 0x53f8c08cUL, 0x523aaabbUL, 0x507c14e2UL, 0x51be7ed5UL, + 0x5ae239e8UL, 0x5b2053dfUL, 0x5966ed86UL, 0x58a487b1UL, 0x5deb9134UL, + 0x5c29fb03UL, 0x5e6f455aUL, 0x5fad2f6dUL, 0xe1351b80UL, 0xe0f771b7UL, + 0xe2b1cfeeUL, 0xe373a5d9UL, 0xe63cb35cUL, 0xe7fed96bUL, 0xe5b86732UL, + 0xe47a0d05UL, 0xef264a38UL, 0xeee4200fUL, 0xeca29e56UL, 0xed60f461UL, + 0xe82fe2e4UL, 0xe9ed88d3UL, 0xebab368aUL, 0xea695cbdUL, 0xfd13b8f0UL, + 0xfcd1d2c7UL, 0xfe976c9eUL, 0xff5506a9UL, 0xfa1a102cUL, 0xfbd87a1bUL, + 0xf99ec442UL, 0xf85cae75UL, 0xf300e948UL, 0xf2c2837fUL, 0xf0843d26UL, + 0xf1465711UL, 0xf4094194UL, 0xf5cb2ba3UL, 0xf78d95faUL, 0xf64fffcdUL, + 0xd9785d60UL, 0xd8ba3757UL, 0xdafc890eUL, 0xdb3ee339UL, 0xde71f5bcUL, + 0xdfb39f8bUL, 0xddf521d2UL, 0xdc374be5UL, 0xd76b0cd8UL, 0xd6a966efUL, + 0xd4efd8b6UL, 0xd52db281UL, 0xd062a404UL, 0xd1a0ce33UL, 0xd3e6706aUL, + 0xd2241a5dUL, 0xc55efe10UL, 0xc49c9427UL, 0xc6da2a7eUL, 0xc7184049UL, + 0xc25756ccUL, 0xc3953cfbUL, 0xc1d382a2UL, 0xc011e895UL, 0xcb4dafa8UL, + 0xca8fc59fUL, 0xc8c97bc6UL, 0xc90b11f1UL, 0xcc440774UL, 0xcd866d43UL, + 0xcfc0d31aUL, 0xce02b92dUL, 0x91af9640UL, 0x906dfc77UL, 0x922b422eUL, + 0x93e92819UL, 0x96a63e9cUL, 0x976454abUL, 0x9522eaf2UL, 0x94e080c5UL, + 0x9fbcc7f8UL, 0x9e7eadcfUL, 0x9c381396UL, 0x9dfa79a1UL, 0x98b56f24UL, + 0x99770513UL, 0x9b31bb4aUL, 0x9af3d17dUL, 0x8d893530UL, 0x8c4b5f07UL, + 0x8e0de15eUL, 0x8fcf8b69UL, 0x8a809decUL, 0x8b42f7dbUL, 0x89044982UL, + 0x88c623b5UL, 0x839a6488UL, 0x82580ebfUL, 0x801eb0e6UL, 0x81dcdad1UL, + 0x8493cc54UL, 0x8551a663UL, 0x8717183aUL, 0x86d5720dUL, 0xa9e2d0a0UL, + 0xa820ba97UL, 0xaa6604ceUL, 0xaba46ef9UL, 0xaeeb787cUL, 0xaf29124bUL, + 0xad6fac12UL, 0xacadc625UL, 0xa7f18118UL, 0xa633eb2fUL, 0xa4755576UL, + 0xa5b73f41UL, 0xa0f829c4UL, 0xa13a43f3UL, 0xa37cfdaaUL, 0xa2be979dUL, + 0xb5c473d0UL, 0xb40619e7UL, 0xb640a7beUL, 0xb782cd89UL, 0xb2cddb0cUL, + 0xb30fb13bUL, 0xb1490f62UL, 0xb08b6555UL, 0xbbd72268UL, 0xba15485fUL, + 0xb853f606UL, 0xb9919c31UL, 0xbcde8ab4UL, 0xbd1ce083UL, 0xbf5a5edaUL, + 0xbe9834edUL + }, + { + 0x00000000UL, 0xb8bc6765UL, 0xaa09c88bUL, 0x12b5afeeUL, 0x8f629757UL, + 0x37def032UL, 0x256b5fdcUL, 0x9dd738b9UL, 0xc5b428efUL, 0x7d084f8aUL, + 0x6fbde064UL, 0xd7018701UL, 0x4ad6bfb8UL, 0xf26ad8ddUL, 0xe0df7733UL, + 0x58631056UL, 0x5019579fUL, 0xe8a530faUL, 0xfa109f14UL, 0x42acf871UL, + 0xdf7bc0c8UL, 0x67c7a7adUL, 0x75720843UL, 0xcdce6f26UL, 0x95ad7f70UL, + 0x2d111815UL, 0x3fa4b7fbUL, 0x8718d09eUL, 0x1acfe827UL, 0xa2738f42UL, + 0xb0c620acUL, 0x087a47c9UL, 0xa032af3eUL, 0x188ec85bUL, 0x0a3b67b5UL, + 0xb28700d0UL, 0x2f503869UL, 0x97ec5f0cUL, 0x8559f0e2UL, 0x3de59787UL, + 0x658687d1UL, 0xdd3ae0b4UL, 0xcf8f4f5aUL, 0x7733283fUL, 0xeae41086UL, + 0x525877e3UL, 0x40edd80dUL, 0xf851bf68UL, 0xf02bf8a1UL, 0x48979fc4UL, + 0x5a22302aUL, 0xe29e574fUL, 0x7f496ff6UL, 0xc7f50893UL, 0xd540a77dUL, + 0x6dfcc018UL, 0x359fd04eUL, 0x8d23b72bUL, 0x9f9618c5UL, 0x272a7fa0UL, + 0xbafd4719UL, 0x0241207cUL, 0x10f48f92UL, 0xa848e8f7UL, 0x9b14583dUL, + 0x23a83f58UL, 0x311d90b6UL, 0x89a1f7d3UL, 0x1476cf6aUL, 0xaccaa80fUL, + 0xbe7f07e1UL, 0x06c36084UL, 0x5ea070d2UL, 0xe61c17b7UL, 0xf4a9b859UL, + 0x4c15df3cUL, 0xd1c2e785UL, 0x697e80e0UL, 0x7bcb2f0eUL, 0xc377486bUL, + 0xcb0d0fa2UL, 0x73b168c7UL, 0x6104c729UL, 0xd9b8a04cUL, 0x446f98f5UL, + 0xfcd3ff90UL, 0xee66507eUL, 0x56da371bUL, 0x0eb9274dUL, 0xb6054028UL, + 0xa4b0efc6UL, 0x1c0c88a3UL, 0x81dbb01aUL, 0x3967d77fUL, 0x2bd27891UL, + 0x936e1ff4UL, 0x3b26f703UL, 0x839a9066UL, 0x912f3f88UL, 0x299358edUL, + 0xb4446054UL, 0x0cf80731UL, 0x1e4da8dfUL, 0xa6f1cfbaUL, 0xfe92dfecUL, + 0x462eb889UL, 0x549b1767UL, 0xec277002UL, 0x71f048bbUL, 0xc94c2fdeUL, + 0xdbf98030UL, 0x6345e755UL, 0x6b3fa09cUL, 0xd383c7f9UL, 0xc1366817UL, + 0x798a0f72UL, 0xe45d37cbUL, 0x5ce150aeUL, 0x4e54ff40UL, 0xf6e89825UL, + 0xae8b8873UL, 0x1637ef16UL, 0x048240f8UL, 0xbc3e279dUL, 0x21e91f24UL, + 0x99557841UL, 0x8be0d7afUL, 0x335cb0caUL, 0xed59b63bUL, 0x55e5d15eUL, + 0x47507eb0UL, 0xffec19d5UL, 0x623b216cUL, 0xda874609UL, 0xc832e9e7UL, + 0x708e8e82UL, 0x28ed9ed4UL, 0x9051f9b1UL, 0x82e4565fUL, 0x3a58313aUL, + 0xa78f0983UL, 0x1f336ee6UL, 0x0d86c108UL, 0xb53aa66dUL, 0xbd40e1a4UL, + 0x05fc86c1UL, 0x1749292fUL, 0xaff54e4aUL, 0x322276f3UL, 0x8a9e1196UL, + 0x982bbe78UL, 0x2097d91dUL, 0x78f4c94bUL, 0xc048ae2eUL, 0xd2fd01c0UL, + 0x6a4166a5UL, 0xf7965e1cUL, 0x4f2a3979UL, 0x5d9f9697UL, 0xe523f1f2UL, + 0x4d6b1905UL, 0xf5d77e60UL, 0xe762d18eUL, 0x5fdeb6ebUL, 0xc2098e52UL, + 0x7ab5e937UL, 0x680046d9UL, 0xd0bc21bcUL, 0x88df31eaUL, 0x3063568fUL, + 0x22d6f961UL, 0x9a6a9e04UL, 0x07bda6bdUL, 0xbf01c1d8UL, 0xadb46e36UL, + 0x15080953UL, 0x1d724e9aUL, 0xa5ce29ffUL, 0xb77b8611UL, 0x0fc7e174UL, + 0x9210d9cdUL, 0x2aacbea8UL, 0x38191146UL, 0x80a57623UL, 0xd8c66675UL, + 0x607a0110UL, 0x72cfaefeUL, 0xca73c99bUL, 0x57a4f122UL, 0xef189647UL, + 0xfdad39a9UL, 0x45115eccUL, 0x764dee06UL, 0xcef18963UL, 0xdc44268dUL, + 0x64f841e8UL, 0xf92f7951UL, 0x41931e34UL, 0x5326b1daUL, 0xeb9ad6bfUL, + 0xb3f9c6e9UL, 0x0b45a18cUL, 0x19f00e62UL, 0xa14c6907UL, 0x3c9b51beUL, + 0x842736dbUL, 0x96929935UL, 0x2e2efe50UL, 0x2654b999UL, 0x9ee8defcUL, + 0x8c5d7112UL, 0x34e11677UL, 0xa9362eceUL, 0x118a49abUL, 0x033fe645UL, + 0xbb838120UL, 0xe3e09176UL, 0x5b5cf613UL, 0x49e959fdUL, 0xf1553e98UL, + 0x6c820621UL, 0xd43e6144UL, 0xc68bceaaUL, 0x7e37a9cfUL, 0xd67f4138UL, + 0x6ec3265dUL, 0x7c7689b3UL, 0xc4caeed6UL, 0x591dd66fUL, 0xe1a1b10aUL, + 0xf3141ee4UL, 0x4ba87981UL, 0x13cb69d7UL, 0xab770eb2UL, 0xb9c2a15cUL, + 0x017ec639UL, 0x9ca9fe80UL, 0x241599e5UL, 0x36a0360bUL, 0x8e1c516eUL, + 0x866616a7UL, 0x3eda71c2UL, 0x2c6fde2cUL, 0x94d3b949UL, 0x090481f0UL, + 0xb1b8e695UL, 0xa30d497bUL, 0x1bb12e1eUL, 0x43d23e48UL, 0xfb6e592dUL, + 0xe9dbf6c3UL, 0x516791a6UL, 0xccb0a91fUL, 0x740cce7aUL, 0x66b96194UL, + 0xde0506f1UL + }, + { + 0x00000000UL, 0x96300777UL, 0x2c610eeeUL, 0xba510999UL, 0x19c46d07UL, + 0x8ff46a70UL, 0x35a563e9UL, 0xa395649eUL, 0x3288db0eUL, 0xa4b8dc79UL, + 0x1ee9d5e0UL, 0x88d9d297UL, 0x2b4cb609UL, 0xbd7cb17eUL, 0x072db8e7UL, + 0x911dbf90UL, 0x6410b71dUL, 0xf220b06aUL, 0x4871b9f3UL, 0xde41be84UL, + 0x7dd4da1aUL, 0xebe4dd6dUL, 0x51b5d4f4UL, 0xc785d383UL, 0x56986c13UL, + 0xc0a86b64UL, 0x7af962fdUL, 0xecc9658aUL, 0x4f5c0114UL, 0xd96c0663UL, + 0x633d0ffaUL, 0xf50d088dUL, 0xc8206e3bUL, 0x5e10694cUL, 0xe44160d5UL, + 0x727167a2UL, 0xd1e4033cUL, 0x47d4044bUL, 0xfd850dd2UL, 0x6bb50aa5UL, + 0xfaa8b535UL, 0x6c98b242UL, 0xd6c9bbdbUL, 0x40f9bcacUL, 0xe36cd832UL, + 0x755cdf45UL, 0xcf0dd6dcUL, 0x593dd1abUL, 0xac30d926UL, 0x3a00de51UL, + 0x8051d7c8UL, 0x1661d0bfUL, 0xb5f4b421UL, 0x23c4b356UL, 0x9995bacfUL, + 0x0fa5bdb8UL, 0x9eb80228UL, 0x0888055fUL, 0xb2d90cc6UL, 0x24e90bb1UL, + 0x877c6f2fUL, 0x114c6858UL, 0xab1d61c1UL, 0x3d2d66b6UL, 0x9041dc76UL, + 0x0671db01UL, 0xbc20d298UL, 0x2a10d5efUL, 0x8985b171UL, 0x1fb5b606UL, + 0xa5e4bf9fUL, 0x33d4b8e8UL, 0xa2c90778UL, 0x34f9000fUL, 0x8ea80996UL, + 0x18980ee1UL, 0xbb0d6a7fUL, 0x2d3d6d08UL, 0x976c6491UL, 0x015c63e6UL, + 0xf4516b6bUL, 0x62616c1cUL, 0xd8306585UL, 0x4e0062f2UL, 0xed95066cUL, + 0x7ba5011bUL, 0xc1f40882UL, 0x57c40ff5UL, 0xc6d9b065UL, 0x50e9b712UL, + 0xeab8be8bUL, 0x7c88b9fcUL, 0xdf1ddd62UL, 0x492dda15UL, 0xf37cd38cUL, + 0x654cd4fbUL, 0x5861b24dUL, 0xce51b53aUL, 0x7400bca3UL, 0xe230bbd4UL, + 0x41a5df4aUL, 0xd795d83dUL, 0x6dc4d1a4UL, 0xfbf4d6d3UL, 0x6ae96943UL, + 0xfcd96e34UL, 0x468867adUL, 0xd0b860daUL, 0x732d0444UL, 0xe51d0333UL, + 0x5f4c0aaaUL, 0xc97c0dddUL, 0x3c710550UL, 0xaa410227UL, 0x10100bbeUL, + 0x86200cc9UL, 0x25b56857UL, 0xb3856f20UL, 0x09d466b9UL, 0x9fe461ceUL, + 0x0ef9de5eUL, 0x98c9d929UL, 0x2298d0b0UL, 0xb4a8d7c7UL, 0x173db359UL, + 0x810db42eUL, 0x3b5cbdb7UL, 0xad6cbac0UL, 0x2083b8edUL, 0xb6b3bf9aUL, + 0x0ce2b603UL, 0x9ad2b174UL, 0x3947d5eaUL, 0xaf77d29dUL, 0x1526db04UL, + 0x8316dc73UL, 0x120b63e3UL, 0x843b6494UL, 0x3e6a6d0dUL, 0xa85a6a7aUL, + 0x0bcf0ee4UL, 0x9dff0993UL, 0x27ae000aUL, 0xb19e077dUL, 0x44930ff0UL, + 0xd2a30887UL, 0x68f2011eUL, 0xfec20669UL, 0x5d5762f7UL, 0xcb676580UL, + 0x71366c19UL, 0xe7066b6eUL, 0x761bd4feUL, 0xe02bd389UL, 0x5a7ada10UL, + 0xcc4add67UL, 0x6fdfb9f9UL, 0xf9efbe8eUL, 0x43beb717UL, 0xd58eb060UL, + 0xe8a3d6d6UL, 0x7e93d1a1UL, 0xc4c2d838UL, 0x52f2df4fUL, 0xf167bbd1UL, + 0x6757bca6UL, 0xdd06b53fUL, 0x4b36b248UL, 0xda2b0dd8UL, 0x4c1b0aafUL, + 0xf64a0336UL, 0x607a0441UL, 0xc3ef60dfUL, 0x55df67a8UL, 0xef8e6e31UL, + 0x79be6946UL, 0x8cb361cbUL, 0x1a8366bcUL, 0xa0d26f25UL, 0x36e26852UL, + 0x95770cccUL, 0x03470bbbUL, 0xb9160222UL, 0x2f260555UL, 0xbe3bbac5UL, + 0x280bbdb2UL, 0x925ab42bUL, 0x046ab35cUL, 0xa7ffd7c2UL, 0x31cfd0b5UL, + 0x8b9ed92cUL, 0x1daede5bUL, 0xb0c2649bUL, 0x26f263ecUL, 0x9ca36a75UL, + 0x0a936d02UL, 0xa906099cUL, 0x3f360eebUL, 0x85670772UL, 0x13570005UL, + 0x824abf95UL, 0x147ab8e2UL, 0xae2bb17bUL, 0x381bb60cUL, 0x9b8ed292UL, + 0x0dbed5e5UL, 0xb7efdc7cUL, 0x21dfdb0bUL, 0xd4d2d386UL, 0x42e2d4f1UL, + 0xf8b3dd68UL, 0x6e83da1fUL, 0xcd16be81UL, 0x5b26b9f6UL, 0xe177b06fUL, + 0x7747b718UL, 0xe65a0888UL, 0x706a0fffUL, 0xca3b0666UL, 0x5c0b0111UL, + 0xff9e658fUL, 0x69ae62f8UL, 0xd3ff6b61UL, 0x45cf6c16UL, 0x78e20aa0UL, + 0xeed20dd7UL, 0x5483044eUL, 0xc2b30339UL, 0x612667a7UL, 0xf71660d0UL, + 0x4d476949UL, 0xdb776e3eUL, 0x4a6ad1aeUL, 0xdc5ad6d9UL, 0x660bdf40UL, + 0xf03bd837UL, 0x53aebca9UL, 0xc59ebbdeUL, 0x7fcfb247UL, 0xe9ffb530UL, + 0x1cf2bdbdUL, 0x8ac2bacaUL, 0x3093b353UL, 0xa6a3b424UL, 0x0536d0baUL, + 0x9306d7cdUL, 0x2957de54UL, 0xbf67d923UL, 0x2e7a66b3UL, 0xb84a61c4UL, + 0x021b685dUL, 0x942b6f2aUL, 0x37be0bb4UL, 0xa18e0cc3UL, 0x1bdf055aUL, + 0x8def022dUL + }, + { + 0x00000000UL, 0x41311b19UL, 0x82623632UL, 0xc3532d2bUL, 0x04c56c64UL, + 0x45f4777dUL, 0x86a75a56UL, 0xc796414fUL, 0x088ad9c8UL, 0x49bbc2d1UL, + 0x8ae8effaUL, 0xcbd9f4e3UL, 0x0c4fb5acUL, 0x4d7eaeb5UL, 0x8e2d839eUL, + 0xcf1c9887UL, 0x5112c24aUL, 0x1023d953UL, 0xd370f478UL, 0x9241ef61UL, + 0x55d7ae2eUL, 0x14e6b537UL, 0xd7b5981cUL, 0x96848305UL, 0x59981b82UL, + 0x18a9009bUL, 0xdbfa2db0UL, 0x9acb36a9UL, 0x5d5d77e6UL, 0x1c6c6cffUL, + 0xdf3f41d4UL, 0x9e0e5acdUL, 0xa2248495UL, 0xe3159f8cUL, 0x2046b2a7UL, + 0x6177a9beUL, 0xa6e1e8f1UL, 0xe7d0f3e8UL, 0x2483dec3UL, 0x65b2c5daUL, + 0xaaae5d5dUL, 0xeb9f4644UL, 0x28cc6b6fUL, 0x69fd7076UL, 0xae6b3139UL, + 0xef5a2a20UL, 0x2c09070bUL, 0x6d381c12UL, 0xf33646dfUL, 0xb2075dc6UL, + 0x715470edUL, 0x30656bf4UL, 0xf7f32abbUL, 0xb6c231a2UL, 0x75911c89UL, + 0x34a00790UL, 0xfbbc9f17UL, 0xba8d840eUL, 0x79dea925UL, 0x38efb23cUL, + 0xff79f373UL, 0xbe48e86aUL, 0x7d1bc541UL, 0x3c2ade58UL, 0x054f79f0UL, + 0x447e62e9UL, 0x872d4fc2UL, 0xc61c54dbUL, 0x018a1594UL, 0x40bb0e8dUL, + 0x83e823a6UL, 0xc2d938bfUL, 0x0dc5a038UL, 0x4cf4bb21UL, 0x8fa7960aUL, + 0xce968d13UL, 0x0900cc5cUL, 0x4831d745UL, 0x8b62fa6eUL, 0xca53e177UL, + 0x545dbbbaUL, 0x156ca0a3UL, 0xd63f8d88UL, 0x970e9691UL, 0x5098d7deUL, + 0x11a9ccc7UL, 0xd2fae1ecUL, 0x93cbfaf5UL, 0x5cd76272UL, 0x1de6796bUL, + 0xdeb55440UL, 0x9f844f59UL, 0x58120e16UL, 0x1923150fUL, 0xda703824UL, + 0x9b41233dUL, 0xa76bfd65UL, 0xe65ae67cUL, 0x2509cb57UL, 0x6438d04eUL, + 0xa3ae9101UL, 0xe29f8a18UL, 0x21cca733UL, 0x60fdbc2aUL, 0xafe124adUL, + 0xeed03fb4UL, 0x2d83129fUL, 0x6cb20986UL, 0xab2448c9UL, 0xea1553d0UL, + 0x29467efbUL, 0x687765e2UL, 0xf6793f2fUL, 0xb7482436UL, 0x741b091dUL, + 0x352a1204UL, 0xf2bc534bUL, 0xb38d4852UL, 0x70de6579UL, 0x31ef7e60UL, + 0xfef3e6e7UL, 0xbfc2fdfeUL, 0x7c91d0d5UL, 0x3da0cbccUL, 0xfa368a83UL, + 0xbb07919aUL, 0x7854bcb1UL, 0x3965a7a8UL, 0x4b98833bUL, 0x0aa99822UL, + 0xc9fab509UL, 0x88cbae10UL, 0x4f5def5fUL, 0x0e6cf446UL, 0xcd3fd96dUL, + 0x8c0ec274UL, 0x43125af3UL, 0x022341eaUL, 0xc1706cc1UL, 0x804177d8UL, + 0x47d73697UL, 0x06e62d8eUL, 0xc5b500a5UL, 0x84841bbcUL, 0x1a8a4171UL, + 0x5bbb5a68UL, 0x98e87743UL, 0xd9d96c5aUL, 0x1e4f2d15UL, 0x5f7e360cUL, + 0x9c2d1b27UL, 0xdd1c003eUL, 0x120098b9UL, 0x533183a0UL, 0x9062ae8bUL, + 0xd153b592UL, 0x16c5f4ddUL, 0x57f4efc4UL, 0x94a7c2efUL, 0xd596d9f6UL, + 0xe9bc07aeUL, 0xa88d1cb7UL, 0x6bde319cUL, 0x2aef2a85UL, 0xed796bcaUL, + 0xac4870d3UL, 0x6f1b5df8UL, 0x2e2a46e1UL, 0xe136de66UL, 0xa007c57fUL, + 0x6354e854UL, 0x2265f34dUL, 0xe5f3b202UL, 0xa4c2a91bUL, 0x67918430UL, + 0x26a09f29UL, 0xb8aec5e4UL, 0xf99fdefdUL, 0x3accf3d6UL, 0x7bfde8cfUL, + 0xbc6ba980UL, 0xfd5ab299UL, 0x3e099fb2UL, 0x7f3884abUL, 0xb0241c2cUL, + 0xf1150735UL, 0x32462a1eUL, 0x73773107UL, 0xb4e17048UL, 0xf5d06b51UL, + 0x3683467aUL, 0x77b25d63UL, 0x4ed7facbUL, 0x0fe6e1d2UL, 0xccb5ccf9UL, + 0x8d84d7e0UL, 0x4a1296afUL, 0x0b238db6UL, 0xc870a09dUL, 0x8941bb84UL, + 0x465d2303UL, 0x076c381aUL, 0xc43f1531UL, 0x850e0e28UL, 0x42984f67UL, + 0x03a9547eUL, 0xc0fa7955UL, 0x81cb624cUL, 0x1fc53881UL, 0x5ef42398UL, + 0x9da70eb3UL, 0xdc9615aaUL, 0x1b0054e5UL, 0x5a314ffcUL, 0x996262d7UL, + 0xd85379ceUL, 0x174fe149UL, 0x567efa50UL, 0x952dd77bUL, 0xd41ccc62UL, + 0x138a8d2dUL, 0x52bb9634UL, 0x91e8bb1fUL, 0xd0d9a006UL, 0xecf37e5eUL, + 0xadc26547UL, 0x6e91486cUL, 0x2fa05375UL, 0xe836123aUL, 0xa9070923UL, + 0x6a542408UL, 0x2b653f11UL, 0xe479a796UL, 0xa548bc8fUL, 0x661b91a4UL, + 0x272a8abdUL, 0xe0bccbf2UL, 0xa18dd0ebUL, 0x62defdc0UL, 0x23efe6d9UL, + 0xbde1bc14UL, 0xfcd0a70dUL, 0x3f838a26UL, 0x7eb2913fUL, 0xb924d070UL, + 0xf815cb69UL, 0x3b46e642UL, 0x7a77fd5bUL, 0xb56b65dcUL, 0xf45a7ec5UL, + 0x370953eeUL, 0x763848f7UL, 0xb1ae09b8UL, 0xf09f12a1UL, 0x33cc3f8aUL, + 0x72fd2493UL + }, + { + 0x00000000UL, 0x376ac201UL, 0x6ed48403UL, 0x59be4602UL, 0xdca80907UL, + 0xebc2cb06UL, 0xb27c8d04UL, 0x85164f05UL, 0xb851130eUL, 0x8f3bd10fUL, + 0xd685970dUL, 0xe1ef550cUL, 0x64f91a09UL, 0x5393d808UL, 0x0a2d9e0aUL, + 0x3d475c0bUL, 0x70a3261cUL, 0x47c9e41dUL, 0x1e77a21fUL, 0x291d601eUL, + 0xac0b2f1bUL, 0x9b61ed1aUL, 0xc2dfab18UL, 0xf5b56919UL, 0xc8f23512UL, + 0xff98f713UL, 0xa626b111UL, 0x914c7310UL, 0x145a3c15UL, 0x2330fe14UL, + 0x7a8eb816UL, 0x4de47a17UL, 0xe0464d38UL, 0xd72c8f39UL, 0x8e92c93bUL, + 0xb9f80b3aUL, 0x3cee443fUL, 0x0b84863eUL, 0x523ac03cUL, 0x6550023dUL, + 0x58175e36UL, 0x6f7d9c37UL, 0x36c3da35UL, 0x01a91834UL, 0x84bf5731UL, + 0xb3d59530UL, 0xea6bd332UL, 0xdd011133UL, 0x90e56b24UL, 0xa78fa925UL, + 0xfe31ef27UL, 0xc95b2d26UL, 0x4c4d6223UL, 0x7b27a022UL, 0x2299e620UL, + 0x15f32421UL, 0x28b4782aUL, 0x1fdeba2bUL, 0x4660fc29UL, 0x710a3e28UL, + 0xf41c712dUL, 0xc376b32cUL, 0x9ac8f52eUL, 0xada2372fUL, 0xc08d9a70UL, + 0xf7e75871UL, 0xae591e73UL, 0x9933dc72UL, 0x1c259377UL, 0x2b4f5176UL, + 0x72f11774UL, 0x459bd575UL, 0x78dc897eUL, 0x4fb64b7fUL, 0x16080d7dUL, + 0x2162cf7cUL, 0xa4748079UL, 0x931e4278UL, 0xcaa0047aUL, 0xfdcac67bUL, + 0xb02ebc6cUL, 0x87447e6dUL, 0xdefa386fUL, 0xe990fa6eUL, 0x6c86b56bUL, + 0x5bec776aUL, 0x02523168UL, 0x3538f369UL, 0x087faf62UL, 0x3f156d63UL, + 0x66ab2b61UL, 0x51c1e960UL, 0xd4d7a665UL, 0xe3bd6464UL, 0xba032266UL, + 0x8d69e067UL, 0x20cbd748UL, 0x17a11549UL, 0x4e1f534bUL, 0x7975914aUL, + 0xfc63de4fUL, 0xcb091c4eUL, 0x92b75a4cUL, 0xa5dd984dUL, 0x989ac446UL, + 0xaff00647UL, 0xf64e4045UL, 0xc1248244UL, 0x4432cd41UL, 0x73580f40UL, + 0x2ae64942UL, 0x1d8c8b43UL, 0x5068f154UL, 0x67023355UL, 0x3ebc7557UL, + 0x09d6b756UL, 0x8cc0f853UL, 0xbbaa3a52UL, 0xe2147c50UL, 0xd57ebe51UL, + 0xe839e25aUL, 0xdf53205bUL, 0x86ed6659UL, 0xb187a458UL, 0x3491eb5dUL, + 0x03fb295cUL, 0x5a456f5eUL, 0x6d2fad5fUL, 0x801b35e1UL, 0xb771f7e0UL, + 0xeecfb1e2UL, 0xd9a573e3UL, 0x5cb33ce6UL, 0x6bd9fee7UL, 0x3267b8e5UL, + 0x050d7ae4UL, 0x384a26efUL, 0x0f20e4eeUL, 0x569ea2ecUL, 0x61f460edUL, + 0xe4e22fe8UL, 0xd388ede9UL, 0x8a36abebUL, 0xbd5c69eaUL, 0xf0b813fdUL, + 0xc7d2d1fcUL, 0x9e6c97feUL, 0xa90655ffUL, 0x2c101afaUL, 0x1b7ad8fbUL, + 0x42c49ef9UL, 0x75ae5cf8UL, 0x48e900f3UL, 0x7f83c2f2UL, 0x263d84f0UL, + 0x115746f1UL, 0x944109f4UL, 0xa32bcbf5UL, 0xfa958df7UL, 0xcdff4ff6UL, + 0x605d78d9UL, 0x5737bad8UL, 0x0e89fcdaUL, 0x39e33edbUL, 0xbcf571deUL, + 0x8b9fb3dfUL, 0xd221f5ddUL, 0xe54b37dcUL, 0xd80c6bd7UL, 0xef66a9d6UL, + 0xb6d8efd4UL, 0x81b22dd5UL, 0x04a462d0UL, 0x33cea0d1UL, 0x6a70e6d3UL, + 0x5d1a24d2UL, 0x10fe5ec5UL, 0x27949cc4UL, 0x7e2adac6UL, 0x494018c7UL, + 0xcc5657c2UL, 0xfb3c95c3UL, 0xa282d3c1UL, 0x95e811c0UL, 0xa8af4dcbUL, + 0x9fc58fcaUL, 0xc67bc9c8UL, 0xf1110bc9UL, 0x740744ccUL, 0x436d86cdUL, + 0x1ad3c0cfUL, 0x2db902ceUL, 0x4096af91UL, 0x77fc6d90UL, 0x2e422b92UL, + 0x1928e993UL, 0x9c3ea696UL, 0xab546497UL, 0xf2ea2295UL, 0xc580e094UL, + 0xf8c7bc9fUL, 0xcfad7e9eUL, 0x9613389cUL, 0xa179fa9dUL, 0x246fb598UL, + 0x13057799UL, 0x4abb319bUL, 0x7dd1f39aUL, 0x3035898dUL, 0x075f4b8cUL, + 0x5ee10d8eUL, 0x698bcf8fUL, 0xec9d808aUL, 0xdbf7428bUL, 0x82490489UL, + 0xb523c688UL, 0x88649a83UL, 0xbf0e5882UL, 0xe6b01e80UL, 0xd1dadc81UL, + 0x54cc9384UL, 0x63a65185UL, 0x3a181787UL, 0x0d72d586UL, 0xa0d0e2a9UL, + 0x97ba20a8UL, 0xce0466aaUL, 0xf96ea4abUL, 0x7c78ebaeUL, 0x4b1229afUL, + 0x12ac6fadUL, 0x25c6adacUL, 0x1881f1a7UL, 0x2feb33a6UL, 0x765575a4UL, + 0x413fb7a5UL, 0xc429f8a0UL, 0xf3433aa1UL, 0xaafd7ca3UL, 0x9d97bea2UL, + 0xd073c4b5UL, 0xe71906b4UL, 0xbea740b6UL, 0x89cd82b7UL, 0x0cdbcdb2UL, + 0x3bb10fb3UL, 0x620f49b1UL, 0x55658bb0UL, 0x6822d7bbUL, 0x5f4815baUL, + 0x06f653b8UL, 0x319c91b9UL, 0xb48adebcUL, 0x83e01cbdUL, 0xda5e5abfUL, + 0xed3498beUL + }, + { + 0x00000000UL, 0x6567bcb8UL, 0x8bc809aaUL, 0xeeafb512UL, 0x5797628fUL, + 0x32f0de37UL, 0xdc5f6b25UL, 0xb938d79dUL, 0xef28b4c5UL, 0x8a4f087dUL, + 0x64e0bd6fUL, 0x018701d7UL, 0xb8bfd64aUL, 0xddd86af2UL, 0x3377dfe0UL, + 0x56106358UL, 0x9f571950UL, 0xfa30a5e8UL, 0x149f10faUL, 0x71f8ac42UL, + 0xc8c07bdfUL, 0xada7c767UL, 0x43087275UL, 0x266fcecdUL, 0x707fad95UL, + 0x1518112dUL, 0xfbb7a43fUL, 0x9ed01887UL, 0x27e8cf1aUL, 0x428f73a2UL, + 0xac20c6b0UL, 0xc9477a08UL, 0x3eaf32a0UL, 0x5bc88e18UL, 0xb5673b0aUL, + 0xd00087b2UL, 0x6938502fUL, 0x0c5fec97UL, 0xe2f05985UL, 0x8797e53dUL, + 0xd1878665UL, 0xb4e03addUL, 0x5a4f8fcfUL, 0x3f283377UL, 0x8610e4eaUL, + 0xe3775852UL, 0x0dd8ed40UL, 0x68bf51f8UL, 0xa1f82bf0UL, 0xc49f9748UL, + 0x2a30225aUL, 0x4f579ee2UL, 0xf66f497fUL, 0x9308f5c7UL, 0x7da740d5UL, + 0x18c0fc6dUL, 0x4ed09f35UL, 0x2bb7238dUL, 0xc518969fUL, 0xa07f2a27UL, + 0x1947fdbaUL, 0x7c204102UL, 0x928ff410UL, 0xf7e848a8UL, 0x3d58149bUL, + 0x583fa823UL, 0xb6901d31UL, 0xd3f7a189UL, 0x6acf7614UL, 0x0fa8caacUL, + 0xe1077fbeUL, 0x8460c306UL, 0xd270a05eUL, 0xb7171ce6UL, 0x59b8a9f4UL, + 0x3cdf154cUL, 0x85e7c2d1UL, 0xe0807e69UL, 0x0e2fcb7bUL, 0x6b4877c3UL, + 0xa20f0dcbUL, 0xc768b173UL, 0x29c70461UL, 0x4ca0b8d9UL, 0xf5986f44UL, + 0x90ffd3fcUL, 0x7e5066eeUL, 0x1b37da56UL, 0x4d27b90eUL, 0x284005b6UL, + 0xc6efb0a4UL, 0xa3880c1cUL, 0x1ab0db81UL, 0x7fd76739UL, 0x9178d22bUL, + 0xf41f6e93UL, 0x03f7263bUL, 0x66909a83UL, 0x883f2f91UL, 0xed589329UL, + 0x546044b4UL, 0x3107f80cUL, 0xdfa84d1eUL, 0xbacff1a6UL, 0xecdf92feUL, + 0x89b82e46UL, 0x67179b54UL, 0x027027ecUL, 0xbb48f071UL, 0xde2f4cc9UL, + 0x3080f9dbUL, 0x55e74563UL, 0x9ca03f6bUL, 0xf9c783d3UL, 0x176836c1UL, + 0x720f8a79UL, 0xcb375de4UL, 0xae50e15cUL, 0x40ff544eUL, 0x2598e8f6UL, + 0x73888baeUL, 0x16ef3716UL, 0xf8408204UL, 0x9d273ebcUL, 0x241fe921UL, + 0x41785599UL, 0xafd7e08bUL, 0xcab05c33UL, 0x3bb659edUL, 0x5ed1e555UL, + 0xb07e5047UL, 0xd519ecffUL, 0x6c213b62UL, 0x094687daUL, 0xe7e932c8UL, + 0x828e8e70UL, 0xd49eed28UL, 0xb1f95190UL, 0x5f56e482UL, 0x3a31583aUL, + 0x83098fa7UL, 0xe66e331fUL, 0x08c1860dUL, 0x6da63ab5UL, 0xa4e140bdUL, + 0xc186fc05UL, 0x2f294917UL, 0x4a4ef5afUL, 0xf3762232UL, 0x96119e8aUL, + 0x78be2b98UL, 0x1dd99720UL, 0x4bc9f478UL, 0x2eae48c0UL, 0xc001fdd2UL, + 0xa566416aUL, 0x1c5e96f7UL, 0x79392a4fUL, 0x97969f5dUL, 0xf2f123e5UL, + 0x05196b4dUL, 0x607ed7f5UL, 0x8ed162e7UL, 0xebb6de5fUL, 0x528e09c2UL, + 0x37e9b57aUL, 0xd9460068UL, 0xbc21bcd0UL, 0xea31df88UL, 0x8f566330UL, + 0x61f9d622UL, 0x049e6a9aUL, 0xbda6bd07UL, 0xd8c101bfUL, 0x366eb4adUL, + 0x53090815UL, 0x9a4e721dUL, 0xff29cea5UL, 0x11867bb7UL, 0x74e1c70fUL, + 0xcdd91092UL, 0xa8beac2aUL, 0x46111938UL, 0x2376a580UL, 0x7566c6d8UL, + 0x10017a60UL, 0xfeaecf72UL, 0x9bc973caUL, 0x22f1a457UL, 0x479618efUL, + 0xa939adfdUL, 0xcc5e1145UL, 0x06ee4d76UL, 0x6389f1ceUL, 0x8d2644dcUL, + 0xe841f864UL, 0x51792ff9UL, 0x341e9341UL, 0xdab12653UL, 0xbfd69aebUL, + 0xe9c6f9b3UL, 0x8ca1450bUL, 0x620ef019UL, 0x07694ca1UL, 0xbe519b3cUL, + 0xdb362784UL, 0x35999296UL, 0x50fe2e2eUL, 0x99b95426UL, 0xfcdee89eUL, + 0x12715d8cUL, 0x7716e134UL, 0xce2e36a9UL, 0xab498a11UL, 0x45e63f03UL, + 0x208183bbUL, 0x7691e0e3UL, 0x13f65c5bUL, 0xfd59e949UL, 0x983e55f1UL, + 0x2106826cUL, 0x44613ed4UL, 0xaace8bc6UL, 0xcfa9377eUL, 0x38417fd6UL, + 0x5d26c36eUL, 0xb389767cUL, 0xd6eecac4UL, 0x6fd61d59UL, 0x0ab1a1e1UL, + 0xe41e14f3UL, 0x8179a84bUL, 0xd769cb13UL, 0xb20e77abUL, 0x5ca1c2b9UL, + 0x39c67e01UL, 0x80fea99cUL, 0xe5991524UL, 0x0b36a036UL, 0x6e511c8eUL, + 0xa7166686UL, 0xc271da3eUL, 0x2cde6f2cUL, 0x49b9d394UL, 0xf0810409UL, + 0x95e6b8b1UL, 0x7b490da3UL, 0x1e2eb11bUL, 0x483ed243UL, 0x2d596efbUL, + 0xc3f6dbe9UL, 0xa6916751UL, 0x1fa9b0ccUL, 0x7ace0c74UL, 0x9461b966UL, + 0xf10605deUL +#endif + } +}; diff --git a/mk/linux/mojosetup/zlib/deflate.c b/mk/linux/mojosetup/zlib/deflate.c new file mode 100644 index 00000000..fcd698cc --- /dev/null +++ b/mk/linux/mojosetup/zlib/deflate.c @@ -0,0 +1,1834 @@ +/* deflate.c -- compress data using the deflation algorithm + * Copyright (C) 1995-2010 Jean-loup Gailly and Mark Adler + * For conditions of distribution and use, see copyright notice in zlib.h + */ + +/* + * ALGORITHM + * + * The "deflation" process depends on being able to identify portions + * of the input text which are identical to earlier input (within a + * sliding window trailing behind the input currently being processed). + * + * The most straightforward technique turns out to be the fastest for + * most input files: try all possible matches and select the longest. + * The key feature of this algorithm is that insertions into the string + * dictionary are very simple and thus fast, and deletions are avoided + * completely. Insertions are performed at each input character, whereas + * string matches are performed only when the previous match ends. So it + * is preferable to spend more time in matches to allow very fast string + * insertions and avoid deletions. The matching algorithm for small + * strings is inspired from that of Rabin & Karp. A brute force approach + * is used to find longer strings when a small match has been found. + * A similar algorithm is used in comic (by Jan-Mark Wams) and freeze + * (by Leonid Broukhis). + * A previous version of this file used a more sophisticated algorithm + * (by Fiala and Greene) which is guaranteed to run in linear amortized + * time, but has a larger average cost, uses more memory and is patented. + * However the F&G algorithm may be faster for some highly redundant + * files if the parameter max_chain_length (described below) is too large. + * + * ACKNOWLEDGEMENTS + * + * The idea of lazy evaluation of matches is due to Jan-Mark Wams, and + * I found it in 'freeze' written by Leonid Broukhis. + * Thanks to many people for bug reports and testing. + * + * REFERENCES + * + * Deutsch, L.P.,"DEFLATE Compressed Data Format Specification". + * Available in http://www.ietf.org/rfc/rfc1951.txt + * + * A description of the Rabin and Karp algorithm is given in the book + * "Algorithms" by R. Sedgewick, Addison-Wesley, p252. + * + * Fiala,E.R., and Greene,D.H. + * Data Compression with Finite Windows, Comm.ACM, 32,4 (1989) 490-595 + * + */ + +/* @(#) $Id$ */ + +#include "deflate.h" + +const char deflate_copyright[] = + " deflate 1.2.4 Copyright 1995-2010 Jean-loup Gailly and Mark Adler "; +/* + If you use the zlib library in a product, an acknowledgment is welcome + in the documentation of your product. If for some reason you cannot + include such an acknowledgment, I would appreciate that you keep this + copyright string in the executable of your product. + */ + +/* =========================================================================== + * Function prototypes. + */ +typedef enum { + need_more, /* block not completed, need more input or more output */ + block_done, /* block flush performed */ + finish_started, /* finish started, need only more output at next deflate */ + finish_done /* finish done, accept no more input or output */ +} block_state; + +typedef block_state (*compress_func) OF((deflate_state *s, int flush)); +/* Compression function. Returns the block state after the call. */ + +local void fill_window OF((deflate_state *s)); +local block_state deflate_stored OF((deflate_state *s, int flush)); +local block_state deflate_fast OF((deflate_state *s, int flush)); +#ifndef FASTEST +local block_state deflate_slow OF((deflate_state *s, int flush)); +#endif +local block_state deflate_rle OF((deflate_state *s, int flush)); +local block_state deflate_huff OF((deflate_state *s, int flush)); +local void lm_init OF((deflate_state *s)); +local void putShortMSB OF((deflate_state *s, uInt b)); +local void flush_pending OF((z_streamp strm)); +local int read_buf OF((z_streamp strm, Bytef *buf, unsigned size)); +#ifdef ASMV + void match_init OF((void)); /* asm code initialization */ + uInt longest_match OF((deflate_state *s, IPos cur_match)); +#else +local uInt longest_match OF((deflate_state *s, IPos cur_match)); +#endif + +#ifdef DEBUG +local void check_match OF((deflate_state *s, IPos start, IPos match, + int length)); +#endif + +/* =========================================================================== + * Local data + */ + +#define NIL 0 +/* Tail of hash chains */ + +#ifndef TOO_FAR +# define TOO_FAR 4096 +#endif +/* Matches of length 3 are discarded if their distance exceeds TOO_FAR */ + +/* Values for max_lazy_match, good_match and max_chain_length, depending on + * the desired pack level (0..9). The values given below have been tuned to + * exclude worst case performance for pathological files. Better values may be + * found for specific files. + */ +typedef struct config_s { + ush good_length; /* reduce lazy search above this match length */ + ush max_lazy; /* do not perform lazy search above this match length */ + ush nice_length; /* quit search above this match length */ + ush max_chain; + compress_func func; +} config; + +#ifdef FASTEST +local const config configuration_table[2] = { +/* good lazy nice chain */ +/* 0 */ {0, 0, 0, 0, deflate_stored}, /* store only */ +/* 1 */ {4, 4, 8, 4, deflate_fast}}; /* max speed, no lazy matches */ +#else +local const config configuration_table[10] = { +/* good lazy nice chain */ +/* 0 */ {0, 0, 0, 0, deflate_stored}, /* store only */ +/* 1 */ {4, 4, 8, 4, deflate_fast}, /* max speed, no lazy matches */ +/* 2 */ {4, 5, 16, 8, deflate_fast}, +/* 3 */ {4, 6, 32, 32, deflate_fast}, + +/* 4 */ {4, 4, 16, 16, deflate_slow}, /* lazy matches */ +/* 5 */ {8, 16, 32, 32, deflate_slow}, +/* 6 */ {8, 16, 128, 128, deflate_slow}, +/* 7 */ {8, 32, 128, 256, deflate_slow}, +/* 8 */ {32, 128, 258, 1024, deflate_slow}, +/* 9 */ {32, 258, 258, 4096, deflate_slow}}; /* max compression */ +#endif + +/* Note: the deflate() code requires max_lazy >= MIN_MATCH and max_chain >= 4 + * For deflate_fast() (levels <= 3) good is ignored and lazy has a different + * meaning. + */ + +#define EQUAL 0 +/* result of memcmp for equal strings */ + +#ifndef NO_DUMMY_DECL +struct static_tree_desc_s {int dummy;}; /* for buggy compilers */ +#endif + +/* =========================================================================== + * Update a hash value with the given input byte + * IN assertion: all calls to to UPDATE_HASH are made with consecutive + * input characters, so that a running hash key can be computed from the + * previous key instead of complete recalculation each time. + */ +#define UPDATE_HASH(s,h,c) (h = (((h)<hash_shift) ^ (c)) & s->hash_mask) + + +/* =========================================================================== + * Insert string str in the dictionary and set match_head to the previous head + * of the hash chain (the most recent string with same hash key). Return + * the previous length of the hash chain. + * If this file is compiled with -DFASTEST, the compression level is forced + * to 1, and no hash chains are maintained. + * IN assertion: all calls to to INSERT_STRING are made with consecutive + * input characters and the first MIN_MATCH bytes of str are valid + * (except for the last MIN_MATCH-1 bytes of the input file). + */ +#ifdef FASTEST +#define INSERT_STRING(s, str, match_head) \ + (UPDATE_HASH(s, s->ins_h, s->window[(str) + (MIN_MATCH-1)]), \ + match_head = s->head[s->ins_h], \ + s->head[s->ins_h] = (Pos)(str)) +#else +#define INSERT_STRING(s, str, match_head) \ + (UPDATE_HASH(s, s->ins_h, s->window[(str) + (MIN_MATCH-1)]), \ + match_head = s->prev[(str) & s->w_mask] = s->head[s->ins_h], \ + s->head[s->ins_h] = (Pos)(str)) +#endif + +/* =========================================================================== + * Initialize the hash table (avoiding 64K overflow for 16 bit systems). + * prev[] will be initialized on the fly. + */ +#define CLEAR_HASH(s) \ + s->head[s->hash_size-1] = NIL; \ + zmemzero((Bytef *)s->head, (unsigned)(s->hash_size-1)*sizeof(*s->head)); + +/* ========================================================================= */ +int ZEXPORT deflateInit_(strm, level, version, stream_size) + z_streamp strm; + int level; + const char *version; + int stream_size; +{ + return deflateInit2_(strm, level, Z_DEFLATED, MAX_WBITS, DEF_MEM_LEVEL, + Z_DEFAULT_STRATEGY, version, stream_size); + /* To do: ignore strm->next_in if we use it as window */ +} + +/* ========================================================================= */ +int ZEXPORT deflateInit2_(strm, level, method, windowBits, memLevel, strategy, + version, stream_size) + z_streamp strm; + int level; + int method; + int windowBits; + int memLevel; + int strategy; + const char *version; + int stream_size; +{ + deflate_state *s; + int wrap = 1; + static const char my_version[] = ZLIB_VERSION; + + ushf *overlay; + /* We overlay pending_buf and d_buf+l_buf. This works since the average + * output size for (length,distance) codes is <= 24 bits. + */ + + if (version == Z_NULL || version[0] != my_version[0] || + stream_size != sizeof(z_stream)) { + return Z_VERSION_ERROR; + } + if (strm == Z_NULL) return Z_STREAM_ERROR; + + strm->msg = Z_NULL; + if (strm->zalloc == (alloc_func)0) { + strm->zalloc = zcalloc; + strm->opaque = (voidpf)0; + } + if (strm->zfree == (free_func)0) strm->zfree = zcfree; + +#ifdef FASTEST + if (level != 0) level = 1; +#else + if (level == Z_DEFAULT_COMPRESSION) level = 6; +#endif + + if (windowBits < 0) { /* suppress zlib wrapper */ + wrap = 0; + windowBits = -windowBits; + } +#ifdef GZIP + else if (windowBits > 15) { + wrap = 2; /* write gzip wrapper instead */ + windowBits -= 16; + } +#endif + if (memLevel < 1 || memLevel > MAX_MEM_LEVEL || method != Z_DEFLATED || + windowBits < 8 || windowBits > 15 || level < 0 || level > 9 || + strategy < 0 || strategy > Z_FIXED) { + return Z_STREAM_ERROR; + } + if (windowBits == 8) windowBits = 9; /* until 256-byte window bug fixed */ + s = (deflate_state *) ZALLOC(strm, 1, sizeof(deflate_state)); + if (s == Z_NULL) return Z_MEM_ERROR; + strm->state = (struct internal_state FAR *)s; + s->strm = strm; + + s->wrap = wrap; + s->gzhead = Z_NULL; + s->w_bits = windowBits; + s->w_size = 1 << s->w_bits; + s->w_mask = s->w_size - 1; + + s->hash_bits = memLevel + 7; + s->hash_size = 1 << s->hash_bits; + s->hash_mask = s->hash_size - 1; + s->hash_shift = ((s->hash_bits+MIN_MATCH-1)/MIN_MATCH); + + s->window = (Bytef *) ZALLOC(strm, s->w_size, 2*sizeof(Byte)); + s->prev = (Posf *) ZALLOC(strm, s->w_size, sizeof(Pos)); + s->head = (Posf *) ZALLOC(strm, s->hash_size, sizeof(Pos)); + + s->high_water = 0; /* nothing written to s->window yet */ + + s->lit_bufsize = 1 << (memLevel + 6); /* 16K elements by default */ + + overlay = (ushf *) ZALLOC(strm, s->lit_bufsize, sizeof(ush)+2); + s->pending_buf = (uchf *) overlay; + s->pending_buf_size = (ulg)s->lit_bufsize * (sizeof(ush)+2L); + + if (s->window == Z_NULL || s->prev == Z_NULL || s->head == Z_NULL || + s->pending_buf == Z_NULL) { + s->status = FINISH_STATE; + strm->msg = (char*)ERR_MSG(Z_MEM_ERROR); + deflateEnd (strm); + return Z_MEM_ERROR; + } + s->d_buf = overlay + s->lit_bufsize/sizeof(ush); + s->l_buf = s->pending_buf + (1+sizeof(ush))*s->lit_bufsize; + + s->level = level; + s->strategy = strategy; + s->method = (Byte)method; + + return deflateReset(strm); +} + +/* ========================================================================= */ +int ZEXPORT deflateSetDictionary (strm, dictionary, dictLength) + z_streamp strm; + const Bytef *dictionary; + uInt dictLength; +{ + deflate_state *s; + uInt length = dictLength; + uInt n; + IPos hash_head = 0; + + if (strm == Z_NULL || strm->state == Z_NULL || dictionary == Z_NULL || + strm->state->wrap == 2 || + (strm->state->wrap == 1 && strm->state->status != INIT_STATE)) + return Z_STREAM_ERROR; + + s = strm->state; + if (s->wrap) + strm->adler = adler32(strm->adler, dictionary, dictLength); + + if (length < MIN_MATCH) return Z_OK; + if (length > s->w_size) { + length = s->w_size; + dictionary += dictLength - length; /* use the tail of the dictionary */ + } + zmemcpy(s->window, dictionary, length); + s->strstart = length; + s->block_start = (long)length; + + /* Insert all strings in the hash table (except for the last two bytes). + * s->lookahead stays null, so s->ins_h will be recomputed at the next + * call of fill_window. + */ + s->ins_h = s->window[0]; + UPDATE_HASH(s, s->ins_h, s->window[1]); + for (n = 0; n <= length - MIN_MATCH; n++) { + INSERT_STRING(s, n, hash_head); + } + if (hash_head) hash_head = 0; /* to make compiler happy */ + return Z_OK; +} + +/* ========================================================================= */ +int ZEXPORT deflateReset (strm) + z_streamp strm; +{ + deflate_state *s; + + if (strm == Z_NULL || strm->state == Z_NULL || + strm->zalloc == (alloc_func)0 || strm->zfree == (free_func)0) { + return Z_STREAM_ERROR; + } + + strm->total_in = strm->total_out = 0; + strm->msg = Z_NULL; /* use zfree if we ever allocate msg dynamically */ + strm->data_type = Z_UNKNOWN; + + s = (deflate_state *)strm->state; + s->pending = 0; + s->pending_out = s->pending_buf; + + if (s->wrap < 0) { + s->wrap = -s->wrap; /* was made negative by deflate(..., Z_FINISH); */ + } + s->status = s->wrap ? INIT_STATE : BUSY_STATE; + strm->adler = +#ifdef GZIP + s->wrap == 2 ? crc32(0L, Z_NULL, 0) : +#endif + adler32(0L, Z_NULL, 0); + s->last_flush = Z_NO_FLUSH; + + _tr_init(s); + lm_init(s); + + return Z_OK; +} + +/* ========================================================================= */ +int ZEXPORT deflateSetHeader (strm, head) + z_streamp strm; + gz_headerp head; +{ + if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR; + if (strm->state->wrap != 2) return Z_STREAM_ERROR; + strm->state->gzhead = head; + return Z_OK; +} + +/* ========================================================================= */ +int ZEXPORT deflatePrime (strm, bits, value) + z_streamp strm; + int bits; + int value; +{ + if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR; + strm->state->bi_valid = bits; + strm->state->bi_buf = (ush)(value & ((1 << bits) - 1)); + return Z_OK; +} + +/* ========================================================================= */ +int ZEXPORT deflateParams(strm, level, strategy) + z_streamp strm; + int level; + int strategy; +{ + deflate_state *s; + compress_func func; + int err = Z_OK; + + if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR; + s = strm->state; + +#ifdef FASTEST + if (level != 0) level = 1; +#else + if (level == Z_DEFAULT_COMPRESSION) level = 6; +#endif + if (level < 0 || level > 9 || strategy < 0 || strategy > Z_FIXED) { + return Z_STREAM_ERROR; + } + func = configuration_table[s->level].func; + + if ((strategy != s->strategy || func != configuration_table[level].func) && + strm->total_in != 0) { + /* Flush the last buffer: */ + err = deflate(strm, Z_BLOCK); + } + if (s->level != level) { + s->level = level; + s->max_lazy_match = configuration_table[level].max_lazy; + s->good_match = configuration_table[level].good_length; + s->nice_match = configuration_table[level].nice_length; + s->max_chain_length = configuration_table[level].max_chain; + } + s->strategy = strategy; + return err; +} + +/* ========================================================================= */ +int ZEXPORT deflateTune(strm, good_length, max_lazy, nice_length, max_chain) + z_streamp strm; + int good_length; + int max_lazy; + int nice_length; + int max_chain; +{ + deflate_state *s; + + if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR; + s = strm->state; + s->good_match = good_length; + s->max_lazy_match = max_lazy; + s->nice_match = nice_length; + s->max_chain_length = max_chain; + return Z_OK; +} + +/* ========================================================================= + * For the default windowBits of 15 and memLevel of 8, this function returns + * a close to exact, as well as small, upper bound on the compressed size. + * They are coded as constants here for a reason--if the #define's are + * changed, then this function needs to be changed as well. The return + * value for 15 and 8 only works for those exact settings. + * + * For any setting other than those defaults for windowBits and memLevel, + * the value returned is a conservative worst case for the maximum expansion + * resulting from using fixed blocks instead of stored blocks, which deflate + * can emit on compressed data for some combinations of the parameters. + * + * This function could be more sophisticated to provide closer upper bounds for + * every combination of windowBits and memLevel. But even the conservative + * upper bound of about 14% expansion does not seem onerous for output buffer + * allocation. + */ +uLong ZEXPORT deflateBound(strm, sourceLen) + z_streamp strm; + uLong sourceLen; +{ + deflate_state *s; + uLong complen, wraplen; + Bytef *str; + + /* conservative upper bound for compressed data */ + complen = sourceLen + + ((sourceLen + 7) >> 3) + ((sourceLen + 63) >> 6) + 5; + + /* if can't get parameters, return conservative bound plus zlib wrapper */ + if (strm == Z_NULL || strm->state == Z_NULL) + return complen + 6; + + /* compute wrapper length */ + s = strm->state; + switch (s->wrap) { + case 0: /* raw deflate */ + wraplen = 0; + break; + case 1: /* zlib wrapper */ + wraplen = 6 + (s->strstart ? 4 : 0); + break; + case 2: /* gzip wrapper */ + wraplen = 18; + if (s->gzhead != Z_NULL) { /* user-supplied gzip header */ + if (s->gzhead->extra != Z_NULL) + wraplen += 2 + s->gzhead->extra_len; + str = s->gzhead->name; + if (str != Z_NULL) + do { + wraplen++; + } while (*str++); + str = s->gzhead->comment; + if (str != Z_NULL) + do { + wraplen++; + } while (*str++); + if (s->gzhead->hcrc) + wraplen += 2; + } + break; + default: /* for compiler happiness */ + wraplen = 6; + } + + /* if not default parameters, return conservative bound */ + if (s->w_bits != 15 || s->hash_bits != 8 + 7) + return complen + wraplen; + + /* default settings: return tight bound for that case */ + return sourceLen + (sourceLen >> 12) + (sourceLen >> 14) + + (sourceLen >> 25) + 13 - 6 + wraplen; +} + +/* ========================================================================= + * Put a short in the pending buffer. The 16-bit value is put in MSB order. + * IN assertion: the stream state is correct and there is enough room in + * pending_buf. + */ +local void putShortMSB (s, b) + deflate_state *s; + uInt b; +{ + put_byte(s, (Byte)(b >> 8)); + put_byte(s, (Byte)(b & 0xff)); +} + +/* ========================================================================= + * Flush as much pending output as possible. All deflate() output goes + * through this function so some applications may wish to modify it + * to avoid allocating a large strm->next_out buffer and copying into it. + * (See also read_buf()). + */ +local void flush_pending(strm) + z_streamp strm; +{ + unsigned len = strm->state->pending; + + if (len > strm->avail_out) len = strm->avail_out; + if (len == 0) return; + + zmemcpy(strm->next_out, strm->state->pending_out, len); + strm->next_out += len; + strm->state->pending_out += len; + strm->total_out += len; + strm->avail_out -= len; + strm->state->pending -= len; + if (strm->state->pending == 0) { + strm->state->pending_out = strm->state->pending_buf; + } +} + +/* ========================================================================= */ +int ZEXPORT deflate (strm, flush) + z_streamp strm; + int flush; +{ + int old_flush; /* value of flush param for previous deflate call */ + deflate_state *s; + + if (strm == Z_NULL || strm->state == Z_NULL || + flush > Z_BLOCK || flush < 0) { + return Z_STREAM_ERROR; + } + s = strm->state; + + if (strm->next_out == Z_NULL || + (strm->next_in == Z_NULL && strm->avail_in != 0) || + (s->status == FINISH_STATE && flush != Z_FINISH)) { + ERR_RETURN(strm, Z_STREAM_ERROR); + } + if (strm->avail_out == 0) ERR_RETURN(strm, Z_BUF_ERROR); + + s->strm = strm; /* just in case */ + old_flush = s->last_flush; + s->last_flush = flush; + + /* Write the header */ + if (s->status == INIT_STATE) { +#ifdef GZIP + if (s->wrap == 2) { + strm->adler = crc32(0L, Z_NULL, 0); + put_byte(s, 31); + put_byte(s, 139); + put_byte(s, 8); + if (s->gzhead == Z_NULL) { + put_byte(s, 0); + put_byte(s, 0); + put_byte(s, 0); + put_byte(s, 0); + put_byte(s, 0); + put_byte(s, s->level == 9 ? 2 : + (s->strategy >= Z_HUFFMAN_ONLY || s->level < 2 ? + 4 : 0)); + put_byte(s, OS_CODE); + s->status = BUSY_STATE; + } + else { + put_byte(s, (s->gzhead->text ? 1 : 0) + + (s->gzhead->hcrc ? 2 : 0) + + (s->gzhead->extra == Z_NULL ? 0 : 4) + + (s->gzhead->name == Z_NULL ? 0 : 8) + + (s->gzhead->comment == Z_NULL ? 0 : 16) + ); + put_byte(s, (Byte)(s->gzhead->time & 0xff)); + put_byte(s, (Byte)((s->gzhead->time >> 8) & 0xff)); + put_byte(s, (Byte)((s->gzhead->time >> 16) & 0xff)); + put_byte(s, (Byte)((s->gzhead->time >> 24) & 0xff)); + put_byte(s, s->level == 9 ? 2 : + (s->strategy >= Z_HUFFMAN_ONLY || s->level < 2 ? + 4 : 0)); + put_byte(s, s->gzhead->os & 0xff); + if (s->gzhead->extra != Z_NULL) { + put_byte(s, s->gzhead->extra_len & 0xff); + put_byte(s, (s->gzhead->extra_len >> 8) & 0xff); + } + if (s->gzhead->hcrc) + strm->adler = crc32(strm->adler, s->pending_buf, + s->pending); + s->gzindex = 0; + s->status = EXTRA_STATE; + } + } + else +#endif + { + uInt header = (Z_DEFLATED + ((s->w_bits-8)<<4)) << 8; + uInt level_flags; + + if (s->strategy >= Z_HUFFMAN_ONLY || s->level < 2) + level_flags = 0; + else if (s->level < 6) + level_flags = 1; + else if (s->level == 6) + level_flags = 2; + else + level_flags = 3; + header |= (level_flags << 6); + if (s->strstart != 0) header |= PRESET_DICT; + header += 31 - (header % 31); + + s->status = BUSY_STATE; + putShortMSB(s, header); + + /* Save the adler32 of the preset dictionary: */ + if (s->strstart != 0) { + putShortMSB(s, (uInt)(strm->adler >> 16)); + putShortMSB(s, (uInt)(strm->adler & 0xffff)); + } + strm->adler = adler32(0L, Z_NULL, 0); + } + } +#ifdef GZIP + if (s->status == EXTRA_STATE) { + if (s->gzhead->extra != Z_NULL) { + uInt beg = s->pending; /* start of bytes to update crc */ + + while (s->gzindex < (s->gzhead->extra_len & 0xffff)) { + if (s->pending == s->pending_buf_size) { + if (s->gzhead->hcrc && s->pending > beg) + strm->adler = crc32(strm->adler, s->pending_buf + beg, + s->pending - beg); + flush_pending(strm); + beg = s->pending; + if (s->pending == s->pending_buf_size) + break; + } + put_byte(s, s->gzhead->extra[s->gzindex]); + s->gzindex++; + } + if (s->gzhead->hcrc && s->pending > beg) + strm->adler = crc32(strm->adler, s->pending_buf + beg, + s->pending - beg); + if (s->gzindex == s->gzhead->extra_len) { + s->gzindex = 0; + s->status = NAME_STATE; + } + } + else + s->status = NAME_STATE; + } + if (s->status == NAME_STATE) { + if (s->gzhead->name != Z_NULL) { + uInt beg = s->pending; /* start of bytes to update crc */ + int val; + + do { + if (s->pending == s->pending_buf_size) { + if (s->gzhead->hcrc && s->pending > beg) + strm->adler = crc32(strm->adler, s->pending_buf + beg, + s->pending - beg); + flush_pending(strm); + beg = s->pending; + if (s->pending == s->pending_buf_size) { + val = 1; + break; + } + } + val = s->gzhead->name[s->gzindex++]; + put_byte(s, val); + } while (val != 0); + if (s->gzhead->hcrc && s->pending > beg) + strm->adler = crc32(strm->adler, s->pending_buf + beg, + s->pending - beg); + if (val == 0) { + s->gzindex = 0; + s->status = COMMENT_STATE; + } + } + else + s->status = COMMENT_STATE; + } + if (s->status == COMMENT_STATE) { + if (s->gzhead->comment != Z_NULL) { + uInt beg = s->pending; /* start of bytes to update crc */ + int val; + + do { + if (s->pending == s->pending_buf_size) { + if (s->gzhead->hcrc && s->pending > beg) + strm->adler = crc32(strm->adler, s->pending_buf + beg, + s->pending - beg); + flush_pending(strm); + beg = s->pending; + if (s->pending == s->pending_buf_size) { + val = 1; + break; + } + } + val = s->gzhead->comment[s->gzindex++]; + put_byte(s, val); + } while (val != 0); + if (s->gzhead->hcrc && s->pending > beg) + strm->adler = crc32(strm->adler, s->pending_buf + beg, + s->pending - beg); + if (val == 0) + s->status = HCRC_STATE; + } + else + s->status = HCRC_STATE; + } + if (s->status == HCRC_STATE) { + if (s->gzhead->hcrc) { + if (s->pending + 2 > s->pending_buf_size) + flush_pending(strm); + if (s->pending + 2 <= s->pending_buf_size) { + put_byte(s, (Byte)(strm->adler & 0xff)); + put_byte(s, (Byte)((strm->adler >> 8) & 0xff)); + strm->adler = crc32(0L, Z_NULL, 0); + s->status = BUSY_STATE; + } + } + else + s->status = BUSY_STATE; + } +#endif + + /* Flush as much pending output as possible */ + if (s->pending != 0) { + flush_pending(strm); + if (strm->avail_out == 0) { + /* Since avail_out is 0, deflate will be called again with + * more output space, but possibly with both pending and + * avail_in equal to zero. There won't be anything to do, + * but this is not an error situation so make sure we + * return OK instead of BUF_ERROR at next call of deflate: + */ + s->last_flush = -1; + return Z_OK; + } + + /* Make sure there is something to do and avoid duplicate consecutive + * flushes. For repeated and useless calls with Z_FINISH, we keep + * returning Z_STREAM_END instead of Z_BUF_ERROR. + */ + } else if (strm->avail_in == 0 && flush <= old_flush && + flush != Z_FINISH) { + ERR_RETURN(strm, Z_BUF_ERROR); + } + + /* User must not provide more input after the first FINISH: */ + if (s->status == FINISH_STATE && strm->avail_in != 0) { + ERR_RETURN(strm, Z_BUF_ERROR); + } + + /* Start a new block or continue the current one. + */ + if (strm->avail_in != 0 || s->lookahead != 0 || + (flush != Z_NO_FLUSH && s->status != FINISH_STATE)) { + block_state bstate; + + bstate = s->strategy == Z_HUFFMAN_ONLY ? deflate_huff(s, flush) : + (s->strategy == Z_RLE ? deflate_rle(s, flush) : + (*(configuration_table[s->level].func))(s, flush)); + + if (bstate == finish_started || bstate == finish_done) { + s->status = FINISH_STATE; + } + if (bstate == need_more || bstate == finish_started) { + if (strm->avail_out == 0) { + s->last_flush = -1; /* avoid BUF_ERROR next call, see above */ + } + return Z_OK; + /* If flush != Z_NO_FLUSH && avail_out == 0, the next call + * of deflate should use the same flush parameter to make sure + * that the flush is complete. So we don't have to output an + * empty block here, this will be done at next call. This also + * ensures that for a very small output buffer, we emit at most + * one empty block. + */ + } + if (bstate == block_done) { + if (flush == Z_PARTIAL_FLUSH) { + _tr_align(s); + } else if (flush != Z_BLOCK) { /* FULL_FLUSH or SYNC_FLUSH */ + _tr_stored_block(s, (char*)0, 0L, 0); + /* For a full flush, this empty block will be recognized + * as a special marker by inflate_sync(). + */ + if (flush == Z_FULL_FLUSH) { + CLEAR_HASH(s); /* forget history */ + if (s->lookahead == 0) { + s->strstart = 0; + s->block_start = 0L; + } + } + } + flush_pending(strm); + if (strm->avail_out == 0) { + s->last_flush = -1; /* avoid BUF_ERROR at next call, see above */ + return Z_OK; + } + } + } + Assert(strm->avail_out > 0, "bug2"); + + if (flush != Z_FINISH) return Z_OK; + if (s->wrap <= 0) return Z_STREAM_END; + + /* Write the trailer */ +#ifdef GZIP + if (s->wrap == 2) { + put_byte(s, (Byte)(strm->adler & 0xff)); + put_byte(s, (Byte)((strm->adler >> 8) & 0xff)); + put_byte(s, (Byte)((strm->adler >> 16) & 0xff)); + put_byte(s, (Byte)((strm->adler >> 24) & 0xff)); + put_byte(s, (Byte)(strm->total_in & 0xff)); + put_byte(s, (Byte)((strm->total_in >> 8) & 0xff)); + put_byte(s, (Byte)((strm->total_in >> 16) & 0xff)); + put_byte(s, (Byte)((strm->total_in >> 24) & 0xff)); + } + else +#endif + { + putShortMSB(s, (uInt)(strm->adler >> 16)); + putShortMSB(s, (uInt)(strm->adler & 0xffff)); + } + flush_pending(strm); + /* If avail_out is zero, the application will call deflate again + * to flush the rest. + */ + if (s->wrap > 0) s->wrap = -s->wrap; /* write the trailer only once! */ + return s->pending != 0 ? Z_OK : Z_STREAM_END; +} + +/* ========================================================================= */ +int ZEXPORT deflateEnd (strm) + z_streamp strm; +{ + int status; + + if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR; + + status = strm->state->status; + if (status != INIT_STATE && + status != EXTRA_STATE && + status != NAME_STATE && + status != COMMENT_STATE && + status != HCRC_STATE && + status != BUSY_STATE && + status != FINISH_STATE) { + return Z_STREAM_ERROR; + } + + /* Deallocate in reverse order of allocations: */ + TRY_FREE(strm, strm->state->pending_buf); + TRY_FREE(strm, strm->state->head); + TRY_FREE(strm, strm->state->prev); + TRY_FREE(strm, strm->state->window); + + ZFREE(strm, strm->state); + strm->state = Z_NULL; + + return status == BUSY_STATE ? Z_DATA_ERROR : Z_OK; +} + +/* ========================================================================= + * Copy the source state to the destination state. + * To simplify the source, this is not supported for 16-bit MSDOS (which + * doesn't have enough memory anyway to duplicate compression states). + */ +int ZEXPORT deflateCopy (dest, source) + z_streamp dest; + z_streamp source; +{ +#ifdef MAXSEG_64K + return Z_STREAM_ERROR; +#else + deflate_state *ds; + deflate_state *ss; + ushf *overlay; + + + if (source == Z_NULL || dest == Z_NULL || source->state == Z_NULL) { + return Z_STREAM_ERROR; + } + + ss = source->state; + + zmemcpy(dest, source, sizeof(z_stream)); + + ds = (deflate_state *) ZALLOC(dest, 1, sizeof(deflate_state)); + if (ds == Z_NULL) return Z_MEM_ERROR; + dest->state = (struct internal_state FAR *) ds; + zmemcpy(ds, ss, sizeof(deflate_state)); + ds->strm = dest; + + ds->window = (Bytef *) ZALLOC(dest, ds->w_size, 2*sizeof(Byte)); + ds->prev = (Posf *) ZALLOC(dest, ds->w_size, sizeof(Pos)); + ds->head = (Posf *) ZALLOC(dest, ds->hash_size, sizeof(Pos)); + overlay = (ushf *) ZALLOC(dest, ds->lit_bufsize, sizeof(ush)+2); + ds->pending_buf = (uchf *) overlay; + + if (ds->window == Z_NULL || ds->prev == Z_NULL || ds->head == Z_NULL || + ds->pending_buf == Z_NULL) { + deflateEnd (dest); + return Z_MEM_ERROR; + } + /* following zmemcpy do not work for 16-bit MSDOS */ + zmemcpy(ds->window, ss->window, ds->w_size * 2 * sizeof(Byte)); + zmemcpy(ds->prev, ss->prev, ds->w_size * sizeof(Pos)); + zmemcpy(ds->head, ss->head, ds->hash_size * sizeof(Pos)); + zmemcpy(ds->pending_buf, ss->pending_buf, (uInt)ds->pending_buf_size); + + ds->pending_out = ds->pending_buf + (ss->pending_out - ss->pending_buf); + ds->d_buf = overlay + ds->lit_bufsize/sizeof(ush); + ds->l_buf = ds->pending_buf + (1+sizeof(ush))*ds->lit_bufsize; + + ds->l_desc.dyn_tree = ds->dyn_ltree; + ds->d_desc.dyn_tree = ds->dyn_dtree; + ds->bl_desc.dyn_tree = ds->bl_tree; + + return Z_OK; +#endif /* MAXSEG_64K */ +} + +/* =========================================================================== + * Read a new buffer from the current input stream, update the adler32 + * and total number of bytes read. All deflate() input goes through + * this function so some applications may wish to modify it to avoid + * allocating a large strm->next_in buffer and copying from it. + * (See also flush_pending()). + */ +local int read_buf(strm, buf, size) + z_streamp strm; + Bytef *buf; + unsigned size; +{ + unsigned len = strm->avail_in; + + if (len > size) len = size; + if (len == 0) return 0; + + strm->avail_in -= len; + + if (strm->state->wrap == 1) { + strm->adler = adler32(strm->adler, strm->next_in, len); + } +#ifdef GZIP + else if (strm->state->wrap == 2) { + strm->adler = crc32(strm->adler, strm->next_in, len); + } +#endif + zmemcpy(buf, strm->next_in, len); + strm->next_in += len; + strm->total_in += len; + + return (int)len; +} + +/* =========================================================================== + * Initialize the "longest match" routines for a new zlib stream + */ +local void lm_init (s) + deflate_state *s; +{ + s->window_size = (ulg)2L*s->w_size; + + CLEAR_HASH(s); + + /* Set the default configuration parameters: + */ + s->max_lazy_match = configuration_table[s->level].max_lazy; + s->good_match = configuration_table[s->level].good_length; + s->nice_match = configuration_table[s->level].nice_length; + s->max_chain_length = configuration_table[s->level].max_chain; + + s->strstart = 0; + s->block_start = 0L; + s->lookahead = 0; + s->match_length = s->prev_length = MIN_MATCH-1; + s->match_available = 0; + s->ins_h = 0; +#ifndef FASTEST +#ifdef ASMV + match_init(); /* initialize the asm code */ +#endif +#endif +} + +#ifndef FASTEST +/* =========================================================================== + * Set match_start to the longest match starting at the given string and + * return its length. Matches shorter or equal to prev_length are discarded, + * in which case the result is equal to prev_length and match_start is + * garbage. + * IN assertions: cur_match is the head of the hash chain for the current + * string (strstart) and its distance is <= MAX_DIST, and prev_length >= 1 + * OUT assertion: the match length is not greater than s->lookahead. + */ +#ifndef ASMV +/* For 80x86 and 680x0, an optimized version will be provided in match.asm or + * match.S. The code will be functionally equivalent. + */ +local uInt longest_match(s, cur_match) + deflate_state *s; + IPos cur_match; /* current match */ +{ + unsigned chain_length = s->max_chain_length;/* max hash chain length */ + register Bytef *scan = s->window + s->strstart; /* current string */ + register Bytef *match; /* matched string */ + register int len; /* length of current match */ + int best_len = s->prev_length; /* best match length so far */ + int nice_match = s->nice_match; /* stop if match long enough */ + IPos limit = s->strstart > (IPos)MAX_DIST(s) ? + s->strstart - (IPos)MAX_DIST(s) : NIL; + /* Stop when cur_match becomes <= limit. To simplify the code, + * we prevent matches with the string of window index 0. + */ + Posf *prev = s->prev; + uInt wmask = s->w_mask; + +#ifdef UNALIGNED_OK + /* Compare two bytes at a time. Note: this is not always beneficial. + * Try with and without -DUNALIGNED_OK to check. + */ + register Bytef *strend = s->window + s->strstart + MAX_MATCH - 1; + register ush scan_start = *(ushf*)scan; + register ush scan_end = *(ushf*)(scan+best_len-1); +#else + register Bytef *strend = s->window + s->strstart + MAX_MATCH; + register Byte scan_end1 = scan[best_len-1]; + register Byte scan_end = scan[best_len]; +#endif + + /* The code is optimized for HASH_BITS >= 8 and MAX_MATCH-2 multiple of 16. + * It is easy to get rid of this optimization if necessary. + */ + Assert(s->hash_bits >= 8 && MAX_MATCH == 258, "Code too clever"); + + /* Do not waste too much time if we already have a good match: */ + if (s->prev_length >= s->good_match) { + chain_length >>= 2; + } + /* Do not look for matches beyond the end of the input. This is necessary + * to make deflate deterministic. + */ + if ((uInt)nice_match > s->lookahead) nice_match = s->lookahead; + + Assert((ulg)s->strstart <= s->window_size-MIN_LOOKAHEAD, "need lookahead"); + + do { + Assert(cur_match < s->strstart, "no future"); + match = s->window + cur_match; + + /* Skip to next match if the match length cannot increase + * or if the match length is less than 2. Note that the checks below + * for insufficient lookahead only occur occasionally for performance + * reasons. Therefore uninitialized memory will be accessed, and + * conditional jumps will be made that depend on those values. + * However the length of the match is limited to the lookahead, so + * the output of deflate is not affected by the uninitialized values. + */ +#if (defined(UNALIGNED_OK) && MAX_MATCH == 258) + /* This code assumes sizeof(unsigned short) == 2. Do not use + * UNALIGNED_OK if your compiler uses a different size. + */ + if (*(ushf*)(match+best_len-1) != scan_end || + *(ushf*)match != scan_start) continue; + + /* It is not necessary to compare scan[2] and match[2] since they are + * always equal when the other bytes match, given that the hash keys + * are equal and that HASH_BITS >= 8. Compare 2 bytes at a time at + * strstart+3, +5, ... up to strstart+257. We check for insufficient + * lookahead only every 4th comparison; the 128th check will be made + * at strstart+257. If MAX_MATCH-2 is not a multiple of 8, it is + * necessary to put more guard bytes at the end of the window, or + * to check more often for insufficient lookahead. + */ + Assert(scan[2] == match[2], "scan[2]?"); + scan++, match++; + do { + } while (*(ushf*)(scan+=2) == *(ushf*)(match+=2) && + *(ushf*)(scan+=2) == *(ushf*)(match+=2) && + *(ushf*)(scan+=2) == *(ushf*)(match+=2) && + *(ushf*)(scan+=2) == *(ushf*)(match+=2) && + scan < strend); + /* The funny "do {}" generates better code on most compilers */ + + /* Here, scan <= window+strstart+257 */ + Assert(scan <= s->window+(unsigned)(s->window_size-1), "wild scan"); + if (*scan == *match) scan++; + + len = (MAX_MATCH - 1) - (int)(strend-scan); + scan = strend - (MAX_MATCH-1); + +#else /* UNALIGNED_OK */ + + if (match[best_len] != scan_end || + match[best_len-1] != scan_end1 || + *match != *scan || + *++match != scan[1]) continue; + + /* The check at best_len-1 can be removed because it will be made + * again later. (This heuristic is not always a win.) + * It is not necessary to compare scan[2] and match[2] since they + * are always equal when the other bytes match, given that + * the hash keys are equal and that HASH_BITS >= 8. + */ + scan += 2, match++; + Assert(*scan == *match, "match[2]?"); + + /* We check for insufficient lookahead only every 8th comparison; + * the 256th check will be made at strstart+258. + */ + do { + } while (*++scan == *++match && *++scan == *++match && + *++scan == *++match && *++scan == *++match && + *++scan == *++match && *++scan == *++match && + *++scan == *++match && *++scan == *++match && + scan < strend); + + Assert(scan <= s->window+(unsigned)(s->window_size-1), "wild scan"); + + len = MAX_MATCH - (int)(strend - scan); + scan = strend - MAX_MATCH; + +#endif /* UNALIGNED_OK */ + + if (len > best_len) { + s->match_start = cur_match; + best_len = len; + if (len >= nice_match) break; +#ifdef UNALIGNED_OK + scan_end = *(ushf*)(scan+best_len-1); +#else + scan_end1 = scan[best_len-1]; + scan_end = scan[best_len]; +#endif + } + } while ((cur_match = prev[cur_match & wmask]) > limit + && --chain_length != 0); + + if ((uInt)best_len <= s->lookahead) return (uInt)best_len; + return s->lookahead; +} +#endif /* ASMV */ + +#else /* FASTEST */ + +/* --------------------------------------------------------------------------- + * Optimized version for FASTEST only + */ +local uInt longest_match(s, cur_match) + deflate_state *s; + IPos cur_match; /* current match */ +{ + register Bytef *scan = s->window + s->strstart; /* current string */ + register Bytef *match; /* matched string */ + register int len; /* length of current match */ + register Bytef *strend = s->window + s->strstart + MAX_MATCH; + + /* The code is optimized for HASH_BITS >= 8 and MAX_MATCH-2 multiple of 16. + * It is easy to get rid of this optimization if necessary. + */ + Assert(s->hash_bits >= 8 && MAX_MATCH == 258, "Code too clever"); + + Assert((ulg)s->strstart <= s->window_size-MIN_LOOKAHEAD, "need lookahead"); + + Assert(cur_match < s->strstart, "no future"); + + match = s->window + cur_match; + + /* Return failure if the match length is less than 2: + */ + if (match[0] != scan[0] || match[1] != scan[1]) return MIN_MATCH-1; + + /* The check at best_len-1 can be removed because it will be made + * again later. (This heuristic is not always a win.) + * It is not necessary to compare scan[2] and match[2] since they + * are always equal when the other bytes match, given that + * the hash keys are equal and that HASH_BITS >= 8. + */ + scan += 2, match += 2; + Assert(*scan == *match, "match[2]?"); + + /* We check for insufficient lookahead only every 8th comparison; + * the 256th check will be made at strstart+258. + */ + do { + } while (*++scan == *++match && *++scan == *++match && + *++scan == *++match && *++scan == *++match && + *++scan == *++match && *++scan == *++match && + *++scan == *++match && *++scan == *++match && + scan < strend); + + Assert(scan <= s->window+(unsigned)(s->window_size-1), "wild scan"); + + len = MAX_MATCH - (int)(strend - scan); + + if (len < MIN_MATCH) return MIN_MATCH - 1; + + s->match_start = cur_match; + return (uInt)len <= s->lookahead ? (uInt)len : s->lookahead; +} + +#endif /* FASTEST */ + +#ifdef DEBUG +/* =========================================================================== + * Check that the match at match_start is indeed a match. + */ +local void check_match(s, start, match, length) + deflate_state *s; + IPos start, match; + int length; +{ + /* check that the match is indeed a match */ + if (zmemcmp(s->window + match, + s->window + start, length) != EQUAL) { + fprintf(stderr, " start %u, match %u, length %d\n", + start, match, length); + do { + fprintf(stderr, "%c%c", s->window[match++], s->window[start++]); + } while (--length != 0); + z_error("invalid match"); + } + if (z_verbose > 1) { + fprintf(stderr,"\\[%d,%d]", start-match, length); + do { putc(s->window[start++], stderr); } while (--length != 0); + } +} +#else +# define check_match(s, start, match, length) +#endif /* DEBUG */ + +/* =========================================================================== + * Fill the window when the lookahead becomes insufficient. + * Updates strstart and lookahead. + * + * IN assertion: lookahead < MIN_LOOKAHEAD + * OUT assertions: strstart <= window_size-MIN_LOOKAHEAD + * At least one byte has been read, or avail_in == 0; reads are + * performed for at least two bytes (required for the zip translate_eol + * option -- not supported here). + */ +local void fill_window(s) + deflate_state *s; +{ + register unsigned n, m; + register Posf *p; + unsigned more; /* Amount of free space at the end of the window. */ + uInt wsize = s->w_size; + + do { + more = (unsigned)(s->window_size -(ulg)s->lookahead -(ulg)s->strstart); + + /* Deal with !@#$% 64K limit: */ + if (sizeof(int) <= 2) { + if (more == 0 && s->strstart == 0 && s->lookahead == 0) { + more = wsize; + + } else if (more == (unsigned)(-1)) { + /* Very unlikely, but possible on 16 bit machine if + * strstart == 0 && lookahead == 1 (input done a byte at time) + */ + more--; + } + } + + /* If the window is almost full and there is insufficient lookahead, + * move the upper half to the lower one to make room in the upper half. + */ + if (s->strstart >= wsize+MAX_DIST(s)) { + + zmemcpy(s->window, s->window+wsize, (unsigned)wsize); + s->match_start -= wsize; + s->strstart -= wsize; /* we now have strstart >= MAX_DIST */ + s->block_start -= (long) wsize; + + /* Slide the hash table (could be avoided with 32 bit values + at the expense of memory usage). We slide even when level == 0 + to keep the hash table consistent if we switch back to level > 0 + later. (Using level 0 permanently is not an optimal usage of + zlib, so we don't care about this pathological case.) + */ + n = s->hash_size; + p = &s->head[n]; + do { + m = *--p; + *p = (Pos)(m >= wsize ? m-wsize : NIL); + } while (--n); + + n = wsize; +#ifndef FASTEST + p = &s->prev[n]; + do { + m = *--p; + *p = (Pos)(m >= wsize ? m-wsize : NIL); + /* If n is not on any hash chain, prev[n] is garbage but + * its value will never be used. + */ + } while (--n); +#endif + more += wsize; + } + if (s->strm->avail_in == 0) return; + + /* If there was no sliding: + * strstart <= WSIZE+MAX_DIST-1 && lookahead <= MIN_LOOKAHEAD - 1 && + * more == window_size - lookahead - strstart + * => more >= window_size - (MIN_LOOKAHEAD-1 + WSIZE + MAX_DIST-1) + * => more >= window_size - 2*WSIZE + 2 + * In the BIG_MEM or MMAP case (not yet supported), + * window_size == input_size + MIN_LOOKAHEAD && + * strstart + s->lookahead <= input_size => more >= MIN_LOOKAHEAD. + * Otherwise, window_size == 2*WSIZE so more >= 2. + * If there was sliding, more >= WSIZE. So in all cases, more >= 2. + */ + Assert(more >= 2, "more < 2"); + + n = read_buf(s->strm, s->window + s->strstart + s->lookahead, more); + s->lookahead += n; + + /* Initialize the hash value now that we have some input: */ + if (s->lookahead >= MIN_MATCH) { + s->ins_h = s->window[s->strstart]; + UPDATE_HASH(s, s->ins_h, s->window[s->strstart+1]); +#if MIN_MATCH != 3 + Call UPDATE_HASH() MIN_MATCH-3 more times +#endif + } + /* If the whole input has less than MIN_MATCH bytes, ins_h is garbage, + * but this is not important since only literal bytes will be emitted. + */ + + } while (s->lookahead < MIN_LOOKAHEAD && s->strm->avail_in != 0); + + /* If the WIN_INIT bytes after the end of the current data have never been + * written, then zero those bytes in order to avoid memory check reports of + * the use of uninitialized (or uninitialised as Julian writes) bytes by + * the longest match routines. Update the high water mark for the next + * time through here. WIN_INIT is set to MAX_MATCH since the longest match + * routines allow scanning to strstart + MAX_MATCH, ignoring lookahead. + */ + if (s->high_water < s->window_size) { + ulg curr = s->strstart + (ulg)(s->lookahead); + ulg init; + + if (s->high_water < curr) { + /* Previous high water mark below current data -- zero WIN_INIT + * bytes or up to end of window, whichever is less. + */ + init = s->window_size - curr; + if (init > WIN_INIT) + init = WIN_INIT; + zmemzero(s->window + curr, (unsigned)init); + s->high_water = curr + init; + } + else if (s->high_water < (ulg)curr + WIN_INIT) { + /* High water mark at or above current data, but below current data + * plus WIN_INIT -- zero out to current data plus WIN_INIT, or up + * to end of window, whichever is less. + */ + init = (ulg)curr + WIN_INIT - s->high_water; + if (init > s->window_size - s->high_water) + init = s->window_size - s->high_water; + zmemzero(s->window + s->high_water, (unsigned)init); + s->high_water += init; + } + } +} + +/* =========================================================================== + * Flush the current block, with given end-of-file flag. + * IN assertion: strstart is set to the end of the current match. + */ +#define FLUSH_BLOCK_ONLY(s, last) { \ + _tr_flush_block(s, (s->block_start >= 0L ? \ + (charf *)&s->window[(unsigned)s->block_start] : \ + (charf *)Z_NULL), \ + (ulg)((long)s->strstart - s->block_start), \ + (last)); \ + s->block_start = s->strstart; \ + flush_pending(s->strm); \ + Tracev((stderr,"[FLUSH]")); \ +} + +/* Same but force premature exit if necessary. */ +#define FLUSH_BLOCK(s, last) { \ + FLUSH_BLOCK_ONLY(s, last); \ + if (s->strm->avail_out == 0) return (last) ? finish_started : need_more; \ +} + +/* =========================================================================== + * Copy without compression as much as possible from the input stream, return + * the current block state. + * This function does not insert new strings in the dictionary since + * uncompressible data is probably not useful. This function is used + * only for the level=0 compression option. + * NOTE: this function should be optimized to avoid extra copying from + * window to pending_buf. + */ +local block_state deflate_stored(s, flush) + deflate_state *s; + int flush; +{ + /* Stored blocks are limited to 0xffff bytes, pending_buf is limited + * to pending_buf_size, and each stored block has a 5 byte header: + */ + ulg max_block_size = 0xffff; + ulg max_start; + + if (max_block_size > s->pending_buf_size - 5) { + max_block_size = s->pending_buf_size - 5; + } + + /* Copy as much as possible from input to output: */ + for (;;) { + /* Fill the window as much as possible: */ + if (s->lookahead <= 1) { + + Assert(s->strstart < s->w_size+MAX_DIST(s) || + s->block_start >= (long)s->w_size, "slide too late"); + + fill_window(s); + if (s->lookahead == 0 && flush == Z_NO_FLUSH) return need_more; + + if (s->lookahead == 0) break; /* flush the current block */ + } + Assert(s->block_start >= 0L, "block gone"); + + s->strstart += s->lookahead; + s->lookahead = 0; + + /* Emit a stored block if pending_buf will be full: */ + max_start = s->block_start + max_block_size; + if (s->strstart == 0 || (ulg)s->strstart >= max_start) { + /* strstart == 0 is possible when wraparound on 16-bit machine */ + s->lookahead = (uInt)(s->strstart - max_start); + s->strstart = (uInt)max_start; + FLUSH_BLOCK(s, 0); + } + /* Flush if we may have to slide, otherwise block_start may become + * negative and the data will be gone: + */ + if (s->strstart - (uInt)s->block_start >= MAX_DIST(s)) { + FLUSH_BLOCK(s, 0); + } + } + FLUSH_BLOCK(s, flush == Z_FINISH); + return flush == Z_FINISH ? finish_done : block_done; +} + +/* =========================================================================== + * Compress as much as possible from the input stream, return the current + * block state. + * This function does not perform lazy evaluation of matches and inserts + * new strings in the dictionary only for unmatched strings or for short + * matches. It is used only for the fast compression options. + */ +local block_state deflate_fast(s, flush) + deflate_state *s; + int flush; +{ + IPos hash_head; /* head of the hash chain */ + int bflush; /* set if current block must be flushed */ + + for (;;) { + /* Make sure that we always have enough lookahead, except + * at the end of the input file. We need MAX_MATCH bytes + * for the next match, plus MIN_MATCH bytes to insert the + * string following the next match. + */ + if (s->lookahead < MIN_LOOKAHEAD) { + fill_window(s); + if (s->lookahead < MIN_LOOKAHEAD && flush == Z_NO_FLUSH) { + return need_more; + } + if (s->lookahead == 0) break; /* flush the current block */ + } + + /* Insert the string window[strstart .. strstart+2] in the + * dictionary, and set hash_head to the head of the hash chain: + */ + hash_head = NIL; + if (s->lookahead >= MIN_MATCH) { + INSERT_STRING(s, s->strstart, hash_head); + } + + /* Find the longest match, discarding those <= prev_length. + * At this point we have always match_length < MIN_MATCH + */ + if (hash_head != NIL && s->strstart - hash_head <= MAX_DIST(s)) { + /* To simplify the code, we prevent matches with the string + * of window index 0 (in particular we have to avoid a match + * of the string with itself at the start of the input file). + */ + s->match_length = longest_match (s, hash_head); + /* longest_match() sets match_start */ + } + if (s->match_length >= MIN_MATCH) { + check_match(s, s->strstart, s->match_start, s->match_length); + + _tr_tally_dist(s, s->strstart - s->match_start, + s->match_length - MIN_MATCH, bflush); + + s->lookahead -= s->match_length; + + /* Insert new strings in the hash table only if the match length + * is not too large. This saves time but degrades compression. + */ +#ifndef FASTEST + if (s->match_length <= s->max_insert_length && + s->lookahead >= MIN_MATCH) { + s->match_length--; /* string at strstart already in table */ + do { + s->strstart++; + INSERT_STRING(s, s->strstart, hash_head); + /* strstart never exceeds WSIZE-MAX_MATCH, so there are + * always MIN_MATCH bytes ahead. + */ + } while (--s->match_length != 0); + s->strstart++; + } else +#endif + { + s->strstart += s->match_length; + s->match_length = 0; + s->ins_h = s->window[s->strstart]; + UPDATE_HASH(s, s->ins_h, s->window[s->strstart+1]); +#if MIN_MATCH != 3 + Call UPDATE_HASH() MIN_MATCH-3 more times +#endif + /* If lookahead < MIN_MATCH, ins_h is garbage, but it does not + * matter since it will be recomputed at next deflate call. + */ + } + } else { + /* No match, output a literal byte */ + Tracevv((stderr,"%c", s->window[s->strstart])); + _tr_tally_lit (s, s->window[s->strstart], bflush); + s->lookahead--; + s->strstart++; + } + if (bflush) FLUSH_BLOCK(s, 0); + } + FLUSH_BLOCK(s, flush == Z_FINISH); + return flush == Z_FINISH ? finish_done : block_done; +} + +#ifndef FASTEST +/* =========================================================================== + * Same as above, but achieves better compression. We use a lazy + * evaluation for matches: a match is finally adopted only if there is + * no better match at the next window position. + */ +local block_state deflate_slow(s, flush) + deflate_state *s; + int flush; +{ + IPos hash_head; /* head of hash chain */ + int bflush; /* set if current block must be flushed */ + + /* Process the input block. */ + for (;;) { + /* Make sure that we always have enough lookahead, except + * at the end of the input file. We need MAX_MATCH bytes + * for the next match, plus MIN_MATCH bytes to insert the + * string following the next match. + */ + if (s->lookahead < MIN_LOOKAHEAD) { + fill_window(s); + if (s->lookahead < MIN_LOOKAHEAD && flush == Z_NO_FLUSH) { + return need_more; + } + if (s->lookahead == 0) break; /* flush the current block */ + } + + /* Insert the string window[strstart .. strstart+2] in the + * dictionary, and set hash_head to the head of the hash chain: + */ + hash_head = NIL; + if (s->lookahead >= MIN_MATCH) { + INSERT_STRING(s, s->strstart, hash_head); + } + + /* Find the longest match, discarding those <= prev_length. + */ + s->prev_length = s->match_length, s->prev_match = s->match_start; + s->match_length = MIN_MATCH-1; + + if (hash_head != NIL && s->prev_length < s->max_lazy_match && + s->strstart - hash_head <= MAX_DIST(s)) { + /* To simplify the code, we prevent matches with the string + * of window index 0 (in particular we have to avoid a match + * of the string with itself at the start of the input file). + */ + s->match_length = longest_match (s, hash_head); + /* longest_match() sets match_start */ + + if (s->match_length <= 5 && (s->strategy == Z_FILTERED +#if TOO_FAR <= 32767 + || (s->match_length == MIN_MATCH && + s->strstart - s->match_start > TOO_FAR) +#endif + )) { + + /* If prev_match is also MIN_MATCH, match_start is garbage + * but we will ignore the current match anyway. + */ + s->match_length = MIN_MATCH-1; + } + } + /* If there was a match at the previous step and the current + * match is not better, output the previous match: + */ + if (s->prev_length >= MIN_MATCH && s->match_length <= s->prev_length) { + uInt max_insert = s->strstart + s->lookahead - MIN_MATCH; + /* Do not insert strings in hash table beyond this. */ + + check_match(s, s->strstart-1, s->prev_match, s->prev_length); + + _tr_tally_dist(s, s->strstart -1 - s->prev_match, + s->prev_length - MIN_MATCH, bflush); + + /* Insert in hash table all strings up to the end of the match. + * strstart-1 and strstart are already inserted. If there is not + * enough lookahead, the last two strings are not inserted in + * the hash table. + */ + s->lookahead -= s->prev_length-1; + s->prev_length -= 2; + do { + if (++s->strstart <= max_insert) { + INSERT_STRING(s, s->strstart, hash_head); + } + } while (--s->prev_length != 0); + s->match_available = 0; + s->match_length = MIN_MATCH-1; + s->strstart++; + + if (bflush) FLUSH_BLOCK(s, 0); + + } else if (s->match_available) { + /* If there was no match at the previous position, output a + * single literal. If there was a match but the current match + * is longer, truncate the previous match to a single literal. + */ + Tracevv((stderr,"%c", s->window[s->strstart-1])); + _tr_tally_lit(s, s->window[s->strstart-1], bflush); + if (bflush) { + FLUSH_BLOCK_ONLY(s, 0); + } + s->strstart++; + s->lookahead--; + if (s->strm->avail_out == 0) return need_more; + } else { + /* There is no previous match to compare with, wait for + * the next step to decide. + */ + s->match_available = 1; + s->strstart++; + s->lookahead--; + } + } + Assert (flush != Z_NO_FLUSH, "no flush?"); + if (s->match_available) { + Tracevv((stderr,"%c", s->window[s->strstart-1])); + _tr_tally_lit(s, s->window[s->strstart-1], bflush); + s->match_available = 0; + } + FLUSH_BLOCK(s, flush == Z_FINISH); + return flush == Z_FINISH ? finish_done : block_done; +} +#endif /* FASTEST */ + +/* =========================================================================== + * For Z_RLE, simply look for runs of bytes, generate matches only of distance + * one. Do not maintain a hash table. (It will be regenerated if this run of + * deflate switches away from Z_RLE.) + */ +local block_state deflate_rle(s, flush) + deflate_state *s; + int flush; +{ + int bflush; /* set if current block must be flushed */ + uInt prev; /* byte at distance one to match */ + Bytef *scan, *strend; /* scan goes up to strend for length of run */ + + for (;;) { + /* Make sure that we always have enough lookahead, except + * at the end of the input file. We need MAX_MATCH bytes + * for the longest encodable run. + */ + if (s->lookahead < MAX_MATCH) { + fill_window(s); + if (s->lookahead < MAX_MATCH && flush == Z_NO_FLUSH) { + return need_more; + } + if (s->lookahead == 0) break; /* flush the current block */ + } + + /* See how many times the previous byte repeats */ + s->match_length = 0; + if (s->lookahead >= MIN_MATCH && s->strstart > 0) { + scan = s->window + s->strstart - 1; + prev = *scan; + if (prev == *++scan && prev == *++scan && prev == *++scan) { + strend = s->window + s->strstart + MAX_MATCH; + do { + } while (prev == *++scan && prev == *++scan && + prev == *++scan && prev == *++scan && + prev == *++scan && prev == *++scan && + prev == *++scan && prev == *++scan && + scan < strend); + s->match_length = MAX_MATCH - (int)(strend - scan); + if (s->match_length > s->lookahead) + s->match_length = s->lookahead; + } + } + + /* Emit match if have run of MIN_MATCH or longer, else emit literal */ + if (s->match_length >= MIN_MATCH) { + check_match(s, s->strstart, s->strstart - 1, s->match_length); + + _tr_tally_dist(s, 1, s->match_length - MIN_MATCH, bflush); + + s->lookahead -= s->match_length; + s->strstart += s->match_length; + s->match_length = 0; + } else { + /* No match, output a literal byte */ + Tracevv((stderr,"%c", s->window[s->strstart])); + _tr_tally_lit (s, s->window[s->strstart], bflush); + s->lookahead--; + s->strstart++; + } + if (bflush) FLUSH_BLOCK(s, 0); + } + FLUSH_BLOCK(s, flush == Z_FINISH); + return flush == Z_FINISH ? finish_done : block_done; +} + +/* =========================================================================== + * For Z_HUFFMAN_ONLY, do not look for matches. Do not maintain a hash table. + * (It will be regenerated if this run of deflate switches away from Huffman.) + */ +local block_state deflate_huff(s, flush) + deflate_state *s; + int flush; +{ + int bflush; /* set if current block must be flushed */ + + for (;;) { + /* Make sure that we have a literal to write. */ + if (s->lookahead == 0) { + fill_window(s); + if (s->lookahead == 0) { + if (flush == Z_NO_FLUSH) + return need_more; + break; /* flush the current block */ + } + } + + /* Output a literal byte */ + s->match_length = 0; + Tracevv((stderr,"%c", s->window[s->strstart])); + _tr_tally_lit (s, s->window[s->strstart], bflush); + s->lookahead--; + s->strstart++; + if (bflush) FLUSH_BLOCK(s, 0); + } + FLUSH_BLOCK(s, flush == Z_FINISH); + return flush == Z_FINISH ? finish_done : block_done; +} diff --git a/mk/linux/mojosetup/zlib/deflate.h b/mk/linux/mojosetup/zlib/deflate.h new file mode 100644 index 00000000..f53deba8 --- /dev/null +++ b/mk/linux/mojosetup/zlib/deflate.h @@ -0,0 +1,342 @@ +/* deflate.h -- internal compression state + * Copyright (C) 1995-2009 Jean-loup Gailly + * For conditions of distribution and use, see copyright notice in zlib.h + */ + +/* WARNING: this file should *not* be used by applications. It is + part of the implementation of the compression library and is + subject to change. Applications should only use zlib.h. + */ + +/* @(#) $Id$ */ + +#ifndef DEFLATE_H +#define DEFLATE_H + +#include "zutil.h" + +/* define NO_GZIP when compiling if you want to disable gzip header and + trailer creation by deflate(). NO_GZIP would be used to avoid linking in + the crc code when it is not needed. For shared libraries, gzip encoding + should be left enabled. */ +#ifndef NO_GZIP +# define GZIP +#endif + +/* =========================================================================== + * Internal compression state. + */ + +#define LENGTH_CODES 29 +/* number of length codes, not counting the special END_BLOCK code */ + +#define LITERALS 256 +/* number of literal bytes 0..255 */ + +#define L_CODES (LITERALS+1+LENGTH_CODES) +/* number of Literal or Length codes, including the END_BLOCK code */ + +#define D_CODES 30 +/* number of distance codes */ + +#define BL_CODES 19 +/* number of codes used to transfer the bit lengths */ + +#define HEAP_SIZE (2*L_CODES+1) +/* maximum heap size */ + +#define MAX_BITS 15 +/* All codes must not exceed MAX_BITS bits */ + +#define INIT_STATE 42 +#define EXTRA_STATE 69 +#define NAME_STATE 73 +#define COMMENT_STATE 91 +#define HCRC_STATE 103 +#define BUSY_STATE 113 +#define FINISH_STATE 666 +/* Stream status */ + + +/* Data structure describing a single value and its code string. */ +typedef struct ct_data_s { + union { + ush freq; /* frequency count */ + ush code; /* bit string */ + } fc; + union { + ush dad; /* father node in Huffman tree */ + ush len; /* length of bit string */ + } dl; +} FAR ct_data; + +#define Freq fc.freq +#define Code fc.code +#define Dad dl.dad +#define Len dl.len + +typedef struct static_tree_desc_s static_tree_desc; + +typedef struct tree_desc_s { + ct_data *dyn_tree; /* the dynamic tree */ + int max_code; /* largest code with non zero frequency */ + static_tree_desc *stat_desc; /* the corresponding static tree */ +} FAR tree_desc; + +typedef ush Pos; +typedef Pos FAR Posf; +typedef unsigned IPos; + +/* A Pos is an index in the character window. We use short instead of int to + * save space in the various tables. IPos is used only for parameter passing. + */ + +typedef struct internal_state { + z_streamp strm; /* pointer back to this zlib stream */ + int status; /* as the name implies */ + Bytef *pending_buf; /* output still pending */ + ulg pending_buf_size; /* size of pending_buf */ + Bytef *pending_out; /* next pending byte to output to the stream */ + uInt pending; /* nb of bytes in the pending buffer */ + int wrap; /* bit 0 true for zlib, bit 1 true for gzip */ + gz_headerp gzhead; /* gzip header information to write */ + uInt gzindex; /* where in extra, name, or comment */ + Byte method; /* STORED (for zip only) or DEFLATED */ + int last_flush; /* value of flush param for previous deflate call */ + + /* used by deflate.c: */ + + uInt w_size; /* LZ77 window size (32K by default) */ + uInt w_bits; /* log2(w_size) (8..16) */ + uInt w_mask; /* w_size - 1 */ + + Bytef *window; + /* Sliding window. Input bytes are read into the second half of the window, + * and move to the first half later to keep a dictionary of at least wSize + * bytes. With this organization, matches are limited to a distance of + * wSize-MAX_MATCH bytes, but this ensures that IO is always + * performed with a length multiple of the block size. Also, it limits + * the window size to 64K, which is quite useful on MSDOS. + * To do: use the user input buffer as sliding window. + */ + + ulg window_size; + /* Actual size of window: 2*wSize, except when the user input buffer + * is directly used as sliding window. + */ + + Posf *prev; + /* Link to older string with same hash index. To limit the size of this + * array to 64K, this link is maintained only for the last 32K strings. + * An index in this array is thus a window index modulo 32K. + */ + + Posf *head; /* Heads of the hash chains or NIL. */ + + uInt ins_h; /* hash index of string to be inserted */ + uInt hash_size; /* number of elements in hash table */ + uInt hash_bits; /* log2(hash_size) */ + uInt hash_mask; /* hash_size-1 */ + + uInt hash_shift; + /* Number of bits by which ins_h must be shifted at each input + * step. It must be such that after MIN_MATCH steps, the oldest + * byte no longer takes part in the hash key, that is: + * hash_shift * MIN_MATCH >= hash_bits + */ + + long block_start; + /* Window position at the beginning of the current output block. Gets + * negative when the window is moved backwards. + */ + + uInt match_length; /* length of best match */ + IPos prev_match; /* previous match */ + int match_available; /* set if previous match exists */ + uInt strstart; /* start of string to insert */ + uInt match_start; /* start of matching string */ + uInt lookahead; /* number of valid bytes ahead in window */ + + uInt prev_length; + /* Length of the best match at previous step. Matches not greater than this + * are discarded. This is used in the lazy match evaluation. + */ + + uInt max_chain_length; + /* To speed up deflation, hash chains are never searched beyond this + * length. A higher limit improves compression ratio but degrades the + * speed. + */ + + uInt max_lazy_match; + /* Attempt to find a better match only when the current match is strictly + * smaller than this value. This mechanism is used only for compression + * levels >= 4. + */ +# define max_insert_length max_lazy_match + /* Insert new strings in the hash table only if the match length is not + * greater than this length. This saves time but degrades compression. + * max_insert_length is used only for compression levels <= 3. + */ + + int level; /* compression level (1..9) */ + int strategy; /* favor or force Huffman coding*/ + + uInt good_match; + /* Use a faster search when the previous match is longer than this */ + + int nice_match; /* Stop searching when current match exceeds this */ + + /* used by trees.c: */ + /* Didn't use ct_data typedef below to supress compiler warning */ + struct ct_data_s dyn_ltree[HEAP_SIZE]; /* literal and length tree */ + struct ct_data_s dyn_dtree[2*D_CODES+1]; /* distance tree */ + struct ct_data_s bl_tree[2*BL_CODES+1]; /* Huffman tree for bit lengths */ + + struct tree_desc_s l_desc; /* desc. for literal tree */ + struct tree_desc_s d_desc; /* desc. for distance tree */ + struct tree_desc_s bl_desc; /* desc. for bit length tree */ + + ush bl_count[MAX_BITS+1]; + /* number of codes at each bit length for an optimal tree */ + + int heap[2*L_CODES+1]; /* heap used to build the Huffman trees */ + int heap_len; /* number of elements in the heap */ + int heap_max; /* element of largest frequency */ + /* The sons of heap[n] are heap[2*n] and heap[2*n+1]. heap[0] is not used. + * The same heap array is used to build all trees. + */ + + uch depth[2*L_CODES+1]; + /* Depth of each subtree used as tie breaker for trees of equal frequency + */ + + uchf *l_buf; /* buffer for literals or lengths */ + + uInt lit_bufsize; + /* Size of match buffer for literals/lengths. There are 4 reasons for + * limiting lit_bufsize to 64K: + * - frequencies can be kept in 16 bit counters + * - if compression is not successful for the first block, all input + * data is still in the window so we can still emit a stored block even + * when input comes from standard input. (This can also be done for + * all blocks if lit_bufsize is not greater than 32K.) + * - if compression is not successful for a file smaller than 64K, we can + * even emit a stored file instead of a stored block (saving 5 bytes). + * This is applicable only for zip (not gzip or zlib). + * - creating new Huffman trees less frequently may not provide fast + * adaptation to changes in the input data statistics. (Take for + * example a binary file with poorly compressible code followed by + * a highly compressible string table.) Smaller buffer sizes give + * fast adaptation but have of course the overhead of transmitting + * trees more frequently. + * - I can't count above 4 + */ + + uInt last_lit; /* running index in l_buf */ + + ushf *d_buf; + /* Buffer for distances. To simplify the code, d_buf and l_buf have + * the same number of elements. To use different lengths, an extra flag + * array would be necessary. + */ + + ulg opt_len; /* bit length of current block with optimal trees */ + ulg static_len; /* bit length of current block with static trees */ + uInt matches; /* number of string matches in current block */ + int last_eob_len; /* bit length of EOB code for last block */ + +#ifdef DEBUG + ulg compressed_len; /* total bit length of compressed file mod 2^32 */ + ulg bits_sent; /* bit length of compressed data sent mod 2^32 */ +#endif + + ush bi_buf; + /* Output buffer. bits are inserted starting at the bottom (least + * significant bits). + */ + int bi_valid; + /* Number of valid bits in bi_buf. All bits above the last valid bit + * are always zero. + */ + + ulg high_water; + /* High water mark offset in window for initialized bytes -- bytes above + * this are set to zero in order to avoid memory check warnings when + * longest match routines access bytes past the input. This is then + * updated to the new high water mark. + */ + +} FAR deflate_state; + +/* Output a byte on the stream. + * IN assertion: there is enough room in pending_buf. + */ +#define put_byte(s, c) {s->pending_buf[s->pending++] = (c);} + + +#define MIN_LOOKAHEAD (MAX_MATCH+MIN_MATCH+1) +/* Minimum amount of lookahead, except at the end of the input file. + * See deflate.c for comments about the MIN_MATCH+1. + */ + +#define MAX_DIST(s) ((s)->w_size-MIN_LOOKAHEAD) +/* In order to simplify the code, particularly on 16 bit machines, match + * distances are limited to MAX_DIST instead of WSIZE. + */ + +#define WIN_INIT MAX_MATCH +/* Number of bytes after end of data in window to initialize in order to avoid + memory checker errors from longest match routines */ + + /* in trees.c */ +void _tr_init OF((deflate_state *s)); +int _tr_tally OF((deflate_state *s, unsigned dist, unsigned lc)); +void _tr_flush_block OF((deflate_state *s, charf *buf, ulg stored_len, + int last)); +void _tr_align OF((deflate_state *s)); +void _tr_stored_block OF((deflate_state *s, charf *buf, ulg stored_len, + int last)); + +#define d_code(dist) \ + ((dist) < 256 ? _dist_code[dist] : _dist_code[256+((dist)>>7)]) +/* Mapping from a distance to a distance code. dist is the distance - 1 and + * must not have side effects. _dist_code[256] and _dist_code[257] are never + * used. + */ + +#ifndef DEBUG +/* Inline versions of _tr_tally for speed: */ + +#if defined(GEN_TREES_H) || !defined(STDC) + extern uch _length_code[]; + extern uch _dist_code[]; +#else + extern const uch _length_code[]; + extern const uch _dist_code[]; +#endif + +# define _tr_tally_lit(s, c, flush) \ + { uch cc = (c); \ + s->d_buf[s->last_lit] = 0; \ + s->l_buf[s->last_lit++] = cc; \ + s->dyn_ltree[cc].Freq++; \ + flush = (s->last_lit == s->lit_bufsize-1); \ + } +# define _tr_tally_dist(s, distance, length, flush) \ + { uch len = (length); \ + ush dist = (distance); \ + s->d_buf[s->last_lit] = dist; \ + s->l_buf[s->last_lit++] = len; \ + dist--; \ + s->dyn_ltree[_length_code[len]+LITERALS+1].Freq++; \ + s->dyn_dtree[d_code(dist)].Freq++; \ + flush = (s->last_lit == s->lit_bufsize-1); \ + } +#else +# define _tr_tally_lit(s, c, flush) flush = _tr_tally(s, 0, c) +# define _tr_tally_dist(s, distance, length, flush) \ + flush = _tr_tally(s, distance, length) +#endif + +#endif /* DEFLATE_H */ diff --git a/mk/linux/mojosetup/zlib/infback.c b/mk/linux/mojosetup/zlib/infback.c new file mode 100644 index 00000000..af3a8c96 --- /dev/null +++ b/mk/linux/mojosetup/zlib/infback.c @@ -0,0 +1,632 @@ +/* infback.c -- inflate using a call-back interface + * Copyright (C) 1995-2009 Mark Adler + * For conditions of distribution and use, see copyright notice in zlib.h + */ + +/* + This code is largely copied from inflate.c. Normally either infback.o or + inflate.o would be linked into an application--not both. The interface + with inffast.c is retained so that optimized assembler-coded versions of + inflate_fast() can be used with either inflate.c or infback.c. + */ + +#include "zutil.h" +#include "inftrees.h" +#include "inflate.h" +#include "inffast.h" + +/* function prototypes */ +local void fixedtables OF((struct inflate_state FAR *state)); + +/* + strm provides memory allocation functions in zalloc and zfree, or + Z_NULL to use the library memory allocation functions. + + windowBits is in the range 8..15, and window is a user-supplied + window and output buffer that is 2**windowBits bytes. + */ +int ZEXPORT inflateBackInit_(strm, windowBits, window, version, stream_size) +z_streamp strm; +int windowBits; +unsigned char FAR *window; +const char *version; +int stream_size; +{ + struct inflate_state FAR *state; + + if (version == Z_NULL || version[0] != ZLIB_VERSION[0] || + stream_size != (int)(sizeof(z_stream))) + return Z_VERSION_ERROR; + if (strm == Z_NULL || window == Z_NULL || + windowBits < 8 || windowBits > 15) + return Z_STREAM_ERROR; + strm->msg = Z_NULL; /* in case we return an error */ + if (strm->zalloc == (alloc_func)0) { + strm->zalloc = zcalloc; + strm->opaque = (voidpf)0; + } + if (strm->zfree == (free_func)0) strm->zfree = zcfree; + state = (struct inflate_state FAR *)ZALLOC(strm, 1, + sizeof(struct inflate_state)); + if (state == Z_NULL) return Z_MEM_ERROR; + Tracev((stderr, "inflate: allocated\n")); + strm->state = (struct internal_state FAR *)state; + state->dmax = 32768U; + state->wbits = windowBits; + state->wsize = 1U << windowBits; + state->window = window; + state->wnext = 0; + state->whave = 0; + return Z_OK; +} + +/* + Return state with length and distance decoding tables and index sizes set to + fixed code decoding. Normally this returns fixed tables from inffixed.h. + If BUILDFIXED is defined, then instead this routine builds the tables the + first time it's called, and returns those tables the first time and + thereafter. This reduces the size of the code by about 2K bytes, in + exchange for a little execution time. However, BUILDFIXED should not be + used for threaded applications, since the rewriting of the tables and virgin + may not be thread-safe. + */ +local void fixedtables(state) +struct inflate_state FAR *state; +{ +#ifdef BUILDFIXED + static int virgin = 1; + static code *lenfix, *distfix; + static code fixed[544]; + + /* build fixed huffman tables if first call (may not be thread safe) */ + if (virgin) { + unsigned sym, bits; + static code *next; + + /* literal/length table */ + sym = 0; + while (sym < 144) state->lens[sym++] = 8; + while (sym < 256) state->lens[sym++] = 9; + while (sym < 280) state->lens[sym++] = 7; + while (sym < 288) state->lens[sym++] = 8; + next = fixed; + lenfix = next; + bits = 9; + inflate_table(LENS, state->lens, 288, &(next), &(bits), state->work); + + /* distance table */ + sym = 0; + while (sym < 32) state->lens[sym++] = 5; + distfix = next; + bits = 5; + inflate_table(DISTS, state->lens, 32, &(next), &(bits), state->work); + + /* do this just once */ + virgin = 0; + } +#else /* !BUILDFIXED */ +# include "inffixed.h" +#endif /* BUILDFIXED */ + state->lencode = lenfix; + state->lenbits = 9; + state->distcode = distfix; + state->distbits = 5; +} + +/* Macros for inflateBack(): */ + +/* Load returned state from inflate_fast() */ +#define LOAD() \ + do { \ + put = strm->next_out; \ + left = strm->avail_out; \ + next = strm->next_in; \ + have = strm->avail_in; \ + hold = state->hold; \ + bits = state->bits; \ + } while (0) + +/* Set state from registers for inflate_fast() */ +#define RESTORE() \ + do { \ + strm->next_out = put; \ + strm->avail_out = left; \ + strm->next_in = next; \ + strm->avail_in = have; \ + state->hold = hold; \ + state->bits = bits; \ + } while (0) + +/* Clear the input bit accumulator */ +#define INITBITS() \ + do { \ + hold = 0; \ + bits = 0; \ + } while (0) + +/* Assure that some input is available. If input is requested, but denied, + then return a Z_BUF_ERROR from inflateBack(). */ +#define PULL() \ + do { \ + if (have == 0) { \ + have = in(in_desc, &next); \ + if (have == 0) { \ + next = Z_NULL; \ + ret = Z_BUF_ERROR; \ + goto inf_leave; \ + } \ + } \ + } while (0) + +/* Get a byte of input into the bit accumulator, or return from inflateBack() + with an error if there is no input available. */ +#define PULLBYTE() \ + do { \ + PULL(); \ + have--; \ + hold += (unsigned long)(*next++) << bits; \ + bits += 8; \ + } while (0) + +/* Assure that there are at least n bits in the bit accumulator. If there is + not enough available input to do that, then return from inflateBack() with + an error. */ +#define NEEDBITS(n) \ + do { \ + while (bits < (unsigned)(n)) \ + PULLBYTE(); \ + } while (0) + +/* Return the low n bits of the bit accumulator (n < 16) */ +#define BITS(n) \ + ((unsigned)hold & ((1U << (n)) - 1)) + +/* Remove n bits from the bit accumulator */ +#define DROPBITS(n) \ + do { \ + hold >>= (n); \ + bits -= (unsigned)(n); \ + } while (0) + +/* Remove zero to seven bits as needed to go to a byte boundary */ +#define BYTEBITS() \ + do { \ + hold >>= bits & 7; \ + bits -= bits & 7; \ + } while (0) + +/* Assure that some output space is available, by writing out the window + if it's full. If the write fails, return from inflateBack() with a + Z_BUF_ERROR. */ +#define ROOM() \ + do { \ + if (left == 0) { \ + put = state->window; \ + left = state->wsize; \ + state->whave = left; \ + if (out(out_desc, put, left)) { \ + ret = Z_BUF_ERROR; \ + goto inf_leave; \ + } \ + } \ + } while (0) + +/* + strm provides the memory allocation functions and window buffer on input, + and provides information on the unused input on return. For Z_DATA_ERROR + returns, strm will also provide an error message. + + in() and out() are the call-back input and output functions. When + inflateBack() needs more input, it calls in(). When inflateBack() has + filled the window with output, or when it completes with data in the + window, it calls out() to write out the data. The application must not + change the provided input until in() is called again or inflateBack() + returns. The application must not change the window/output buffer until + inflateBack() returns. + + in() and out() are called with a descriptor parameter provided in the + inflateBack() call. This parameter can be a structure that provides the + information required to do the read or write, as well as accumulated + information on the input and output such as totals and check values. + + in() should return zero on failure. out() should return non-zero on + failure. If either in() or out() fails, than inflateBack() returns a + Z_BUF_ERROR. strm->next_in can be checked for Z_NULL to see whether it + was in() or out() that caused in the error. Otherwise, inflateBack() + returns Z_STREAM_END on success, Z_DATA_ERROR for an deflate format + error, or Z_MEM_ERROR if it could not allocate memory for the state. + inflateBack() can also return Z_STREAM_ERROR if the input parameters + are not correct, i.e. strm is Z_NULL or the state was not initialized. + */ +int ZEXPORT inflateBack(strm, in, in_desc, out, out_desc) +z_streamp strm; +in_func in; +void FAR *in_desc; +out_func out; +void FAR *out_desc; +{ + struct inflate_state FAR *state; + unsigned char FAR *next; /* next input */ + unsigned char FAR *put; /* next output */ + unsigned have, left; /* available input and output */ + unsigned long hold; /* bit buffer */ + unsigned bits; /* bits in bit buffer */ + unsigned copy; /* number of stored or match bytes to copy */ + unsigned char FAR *from; /* where to copy match bytes from */ + code here; /* current decoding table entry */ + code last; /* parent table entry */ + unsigned len; /* length to copy for repeats, bits to drop */ + int ret; /* return code */ + static const unsigned short order[19] = /* permutation of code lengths */ + {16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15}; + + /* Check that the strm exists and that the state was initialized */ + if (strm == Z_NULL || strm->state == Z_NULL) + return Z_STREAM_ERROR; + state = (struct inflate_state FAR *)strm->state; + + /* Reset the state */ + strm->msg = Z_NULL; + state->mode = TYPE; + state->last = 0; + state->whave = 0; + next = strm->next_in; + have = next != Z_NULL ? strm->avail_in : 0; + hold = 0; + bits = 0; + put = state->window; + left = state->wsize; + + /* Inflate until end of block marked as last */ + for (;;) + switch (state->mode) { + case TYPE: + /* determine and dispatch block type */ + if (state->last) { + BYTEBITS(); + state->mode = DONE; + break; + } + NEEDBITS(3); + state->last = BITS(1); + DROPBITS(1); + switch (BITS(2)) { + case 0: /* stored block */ + Tracev((stderr, "inflate: stored block%s\n", + state->last ? " (last)" : "")); + state->mode = STORED; + break; + case 1: /* fixed block */ + fixedtables(state); + Tracev((stderr, "inflate: fixed codes block%s\n", + state->last ? " (last)" : "")); + state->mode = LEN; /* decode codes */ + break; + case 2: /* dynamic block */ + Tracev((stderr, "inflate: dynamic codes block%s\n", + state->last ? " (last)" : "")); + state->mode = TABLE; + break; + case 3: + strm->msg = (char *)"invalid block type"; + state->mode = BAD; + } + DROPBITS(2); + break; + + case STORED: + /* get and verify stored block length */ + BYTEBITS(); /* go to byte boundary */ + NEEDBITS(32); + if ((hold & 0xffff) != ((hold >> 16) ^ 0xffff)) { + strm->msg = (char *)"invalid stored block lengths"; + state->mode = BAD; + break; + } + state->length = (unsigned)hold & 0xffff; + Tracev((stderr, "inflate: stored length %u\n", + state->length)); + INITBITS(); + + /* copy stored block from input to output */ + while (state->length != 0) { + copy = state->length; + PULL(); + ROOM(); + if (copy > have) copy = have; + if (copy > left) copy = left; + zmemcpy(put, next, copy); + have -= copy; + next += copy; + left -= copy; + put += copy; + state->length -= copy; + } + Tracev((stderr, "inflate: stored end\n")); + state->mode = TYPE; + break; + + case TABLE: + /* get dynamic table entries descriptor */ + NEEDBITS(14); + state->nlen = BITS(5) + 257; + DROPBITS(5); + state->ndist = BITS(5) + 1; + DROPBITS(5); + state->ncode = BITS(4) + 4; + DROPBITS(4); +#ifndef PKZIP_BUG_WORKAROUND + if (state->nlen > 286 || state->ndist > 30) { + strm->msg = (char *)"too many length or distance symbols"; + state->mode = BAD; + break; + } +#endif + Tracev((stderr, "inflate: table sizes ok\n")); + + /* get code length code lengths (not a typo) */ + state->have = 0; + while (state->have < state->ncode) { + NEEDBITS(3); + state->lens[order[state->have++]] = (unsigned short)BITS(3); + DROPBITS(3); + } + while (state->have < 19) + state->lens[order[state->have++]] = 0; + state->next = state->codes; + state->lencode = (code const FAR *)(state->next); + state->lenbits = 7; + ret = inflate_table(CODES, state->lens, 19, &(state->next), + &(state->lenbits), state->work); + if (ret) { + strm->msg = (char *)"invalid code lengths set"; + state->mode = BAD; + break; + } + Tracev((stderr, "inflate: code lengths ok\n")); + + /* get length and distance code code lengths */ + state->have = 0; + while (state->have < state->nlen + state->ndist) { + for (;;) { + here = state->lencode[BITS(state->lenbits)]; + if ((unsigned)(here.bits) <= bits) break; + PULLBYTE(); + } + if (here.val < 16) { + NEEDBITS(here.bits); + DROPBITS(here.bits); + state->lens[state->have++] = here.val; + } + else { + if (here.val == 16) { + NEEDBITS(here.bits + 2); + DROPBITS(here.bits); + if (state->have == 0) { + strm->msg = (char *)"invalid bit length repeat"; + state->mode = BAD; + break; + } + len = (unsigned)(state->lens[state->have - 1]); + copy = 3 + BITS(2); + DROPBITS(2); + } + else if (here.val == 17) { + NEEDBITS(here.bits + 3); + DROPBITS(here.bits); + len = 0; + copy = 3 + BITS(3); + DROPBITS(3); + } + else { + NEEDBITS(here.bits + 7); + DROPBITS(here.bits); + len = 0; + copy = 11 + BITS(7); + DROPBITS(7); + } + if (state->have + copy > state->nlen + state->ndist) { + strm->msg = (char *)"invalid bit length repeat"; + state->mode = BAD; + break; + } + while (copy--) + state->lens[state->have++] = (unsigned short)len; + } + } + + /* handle error breaks in while */ + if (state->mode == BAD) break; + + /* check for end-of-block code (better have one) */ + if (state->lens[256] == 0) { + strm->msg = (char *)"invalid code -- missing end-of-block"; + state->mode = BAD; + break; + } + + /* build code tables -- note: do not change the lenbits or distbits + values here (9 and 6) without reading the comments in inftrees.h + concerning the ENOUGH constants, which depend on those values */ + state->next = state->codes; + state->lencode = (code const FAR *)(state->next); + state->lenbits = 9; + ret = inflate_table(LENS, state->lens, state->nlen, &(state->next), + &(state->lenbits), state->work); + if (ret) { + strm->msg = (char *)"invalid literal/lengths set"; + state->mode = BAD; + break; + } + state->distcode = (code const FAR *)(state->next); + state->distbits = 6; + ret = inflate_table(DISTS, state->lens + state->nlen, state->ndist, + &(state->next), &(state->distbits), state->work); + if (ret) { + strm->msg = (char *)"invalid distances set"; + state->mode = BAD; + break; + } + Tracev((stderr, "inflate: codes ok\n")); + state->mode = LEN; + + case LEN: + /* use inflate_fast() if we have enough input and output */ + if (have >= 6 && left >= 258) { + RESTORE(); + if (state->whave < state->wsize) + state->whave = state->wsize - left; + inflate_fast(strm, state->wsize); + LOAD(); + break; + } + + /* get a literal, length, or end-of-block code */ + for (;;) { + here = state->lencode[BITS(state->lenbits)]; + if ((unsigned)(here.bits) <= bits) break; + PULLBYTE(); + } + if (here.op && (here.op & 0xf0) == 0) { + last = here; + for (;;) { + here = state->lencode[last.val + + (BITS(last.bits + last.op) >> last.bits)]; + if ((unsigned)(last.bits + here.bits) <= bits) break; + PULLBYTE(); + } + DROPBITS(last.bits); + } + DROPBITS(here.bits); + state->length = (unsigned)here.val; + + /* process literal */ + if (here.op == 0) { + Tracevv((stderr, here.val >= 0x20 && here.val < 0x7f ? + "inflate: literal '%c'\n" : + "inflate: literal 0x%02x\n", here.val)); + ROOM(); + *put++ = (unsigned char)(state->length); + left--; + state->mode = LEN; + break; + } + + /* process end of block */ + if (here.op & 32) { + Tracevv((stderr, "inflate: end of block\n")); + state->mode = TYPE; + break; + } + + /* invalid code */ + if (here.op & 64) { + strm->msg = (char *)"invalid literal/length code"; + state->mode = BAD; + break; + } + + /* length code -- get extra bits, if any */ + state->extra = (unsigned)(here.op) & 15; + if (state->extra != 0) { + NEEDBITS(state->extra); + state->length += BITS(state->extra); + DROPBITS(state->extra); + } + Tracevv((stderr, "inflate: length %u\n", state->length)); + + /* get distance code */ + for (;;) { + here = state->distcode[BITS(state->distbits)]; + if ((unsigned)(here.bits) <= bits) break; + PULLBYTE(); + } + if ((here.op & 0xf0) == 0) { + last = here; + for (;;) { + here = state->distcode[last.val + + (BITS(last.bits + last.op) >> last.bits)]; + if ((unsigned)(last.bits + here.bits) <= bits) break; + PULLBYTE(); + } + DROPBITS(last.bits); + } + DROPBITS(here.bits); + if (here.op & 64) { + strm->msg = (char *)"invalid distance code"; + state->mode = BAD; + break; + } + state->offset = (unsigned)here.val; + + /* get distance extra bits, if any */ + state->extra = (unsigned)(here.op) & 15; + if (state->extra != 0) { + NEEDBITS(state->extra); + state->offset += BITS(state->extra); + DROPBITS(state->extra); + } + if (state->offset > state->wsize - (state->whave < state->wsize ? + left : 0)) { + strm->msg = (char *)"invalid distance too far back"; + state->mode = BAD; + break; + } + Tracevv((stderr, "inflate: distance %u\n", state->offset)); + + /* copy match from window to output */ + do { + ROOM(); + copy = state->wsize - state->offset; + if (copy < left) { + from = put + copy; + copy = left - copy; + } + else { + from = put - state->offset; + copy = left; + } + if (copy > state->length) copy = state->length; + state->length -= copy; + left -= copy; + do { + *put++ = *from++; + } while (--copy); + } while (state->length != 0); + break; + + case DONE: + /* inflate stream terminated properly -- write leftover output */ + ret = Z_STREAM_END; + if (left < state->wsize) { + if (out(out_desc, state->window, state->wsize - left)) + ret = Z_BUF_ERROR; + } + goto inf_leave; + + case BAD: + ret = Z_DATA_ERROR; + goto inf_leave; + + default: /* can't happen, but makes compilers happy */ + ret = Z_STREAM_ERROR; + goto inf_leave; + } + + /* Return unused input */ + inf_leave: + strm->next_in = next; + strm->avail_in = have; + return ret; +} + +int ZEXPORT inflateBackEnd(strm) +z_streamp strm; +{ + if (strm == Z_NULL || strm->state == Z_NULL || strm->zfree == (free_func)0) + return Z_STREAM_ERROR; + ZFREE(strm, strm->state); + strm->state = Z_NULL; + Tracev((stderr, "inflate: end\n")); + return Z_OK; +} diff --git a/mk/linux/mojosetup/zlib/inffast.c b/mk/linux/mojosetup/zlib/inffast.c new file mode 100644 index 00000000..0a0761f3 --- /dev/null +++ b/mk/linux/mojosetup/zlib/inffast.c @@ -0,0 +1,340 @@ +/* inffast.c -- fast decoding + * Copyright (C) 1995-2008 Mark Adler + * For conditions of distribution and use, see copyright notice in zlib.h + */ + +#include "zutil.h" +#include "inftrees.h" +#include "inflate.h" +#include "inffast.h" + +#ifndef ASMINF + +/* Allow machine dependent optimization for post-increment or pre-increment. + Based on testing to date, + Pre-increment preferred for: + - PowerPC G3 (Adler) + - MIPS R5000 (Randers-Pehrson) + Post-increment preferred for: + - none + No measurable difference: + - Pentium III (Anderson) + - M68060 (Nikl) + */ +#ifdef POSTINC +# define OFF 0 +# define PUP(a) *(a)++ +#else +# define OFF 1 +# define PUP(a) *++(a) +#endif + +/* + Decode literal, length, and distance codes and write out the resulting + literal and match bytes until either not enough input or output is + available, an end-of-block is encountered, or a data error is encountered. + When large enough input and output buffers are supplied to inflate(), for + example, a 16K input buffer and a 64K output buffer, more than 95% of the + inflate execution time is spent in this routine. + + Entry assumptions: + + state->mode == LEN + strm->avail_in >= 6 + strm->avail_out >= 258 + start >= strm->avail_out + state->bits < 8 + + On return, state->mode is one of: + + LEN -- ran out of enough output space or enough available input + TYPE -- reached end of block code, inflate() to interpret next block + BAD -- error in block data + + Notes: + + - The maximum input bits used by a length/distance pair is 15 bits for the + length code, 5 bits for the length extra, 15 bits for the distance code, + and 13 bits for the distance extra. This totals 48 bits, or six bytes. + Therefore if strm->avail_in >= 6, then there is enough input to avoid + checking for available input while decoding. + + - The maximum bytes that a single length/distance pair can output is 258 + bytes, which is the maximum length that can be coded. inflate_fast() + requires strm->avail_out >= 258 for each loop to avoid checking for + output space. + */ +void inflate_fast(strm, start) +z_streamp strm; +unsigned start; /* inflate()'s starting value for strm->avail_out */ +{ + struct inflate_state FAR *state; + unsigned char FAR *in; /* local strm->next_in */ + unsigned char FAR *last; /* while in < last, enough input available */ + unsigned char FAR *out; /* local strm->next_out */ + unsigned char FAR *beg; /* inflate()'s initial strm->next_out */ + unsigned char FAR *end; /* while out < end, enough space available */ +#ifdef INFLATE_STRICT + unsigned dmax; /* maximum distance from zlib header */ +#endif + unsigned wsize; /* window size or zero if not using window */ + unsigned whave; /* valid bytes in the window */ + unsigned wnext; /* window write index */ + unsigned char FAR *window; /* allocated sliding window, if wsize != 0 */ + unsigned long hold; /* local strm->hold */ + unsigned bits; /* local strm->bits */ + code const FAR *lcode; /* local strm->lencode */ + code const FAR *dcode; /* local strm->distcode */ + unsigned lmask; /* mask for first level of length codes */ + unsigned dmask; /* mask for first level of distance codes */ + code here; /* retrieved table entry */ + unsigned op; /* code bits, operation, extra bits, or */ + /* window position, window bytes to copy */ + unsigned len; /* match length, unused bytes */ + unsigned dist; /* match distance */ + unsigned char FAR *from; /* where to copy match from */ + + /* copy state to local variables */ + state = (struct inflate_state FAR *)strm->state; + in = strm->next_in - OFF; + last = in + (strm->avail_in - 5); + out = strm->next_out - OFF; + beg = out - (start - strm->avail_out); + end = out + (strm->avail_out - 257); +#ifdef INFLATE_STRICT + dmax = state->dmax; +#endif + wsize = state->wsize; + whave = state->whave; + wnext = state->wnext; + window = state->window; + hold = state->hold; + bits = state->bits; + lcode = state->lencode; + dcode = state->distcode; + lmask = (1U << state->lenbits) - 1; + dmask = (1U << state->distbits) - 1; + + /* decode literals and length/distances until end-of-block or not enough + input data or output space */ + do { + if (bits < 15) { + hold += (unsigned long)(PUP(in)) << bits; + bits += 8; + hold += (unsigned long)(PUP(in)) << bits; + bits += 8; + } + here = lcode[hold & lmask]; + dolen: + op = (unsigned)(here.bits); + hold >>= op; + bits -= op; + op = (unsigned)(here.op); + if (op == 0) { /* literal */ + Tracevv((stderr, here.val >= 0x20 && here.val < 0x7f ? + "inflate: literal '%c'\n" : + "inflate: literal 0x%02x\n", here.val)); + PUP(out) = (unsigned char)(here.val); + } + else if (op & 16) { /* length base */ + len = (unsigned)(here.val); + op &= 15; /* number of extra bits */ + if (op) { + if (bits < op) { + hold += (unsigned long)(PUP(in)) << bits; + bits += 8; + } + len += (unsigned)hold & ((1U << op) - 1); + hold >>= op; + bits -= op; + } + Tracevv((stderr, "inflate: length %u\n", len)); + if (bits < 15) { + hold += (unsigned long)(PUP(in)) << bits; + bits += 8; + hold += (unsigned long)(PUP(in)) << bits; + bits += 8; + } + here = dcode[hold & dmask]; + dodist: + op = (unsigned)(here.bits); + hold >>= op; + bits -= op; + op = (unsigned)(here.op); + if (op & 16) { /* distance base */ + dist = (unsigned)(here.val); + op &= 15; /* number of extra bits */ + if (bits < op) { + hold += (unsigned long)(PUP(in)) << bits; + bits += 8; + if (bits < op) { + hold += (unsigned long)(PUP(in)) << bits; + bits += 8; + } + } + dist += (unsigned)hold & ((1U << op) - 1); +#ifdef INFLATE_STRICT + if (dist > dmax) { + strm->msg = (char *)"invalid distance too far back"; + state->mode = BAD; + break; + } +#endif + hold >>= op; + bits -= op; + Tracevv((stderr, "inflate: distance %u\n", dist)); + op = (unsigned)(out - beg); /* max distance in output */ + if (dist > op) { /* see if copy from window */ + op = dist - op; /* distance back in window */ + if (op > whave) { + if (state->sane) { + strm->msg = + (char *)"invalid distance too far back"; + state->mode = BAD; + break; + } +#ifdef INFLATE_ALLOW_INVALID_DISTANCE_TOOFAR_ARRR + if (len <= op - whave) { + do { + PUP(out) = 0; + } while (--len); + continue; + } + len -= op - whave; + do { + PUP(out) = 0; + } while (--op > whave); + if (op == 0) { + from = out - dist; + do { + PUP(out) = PUP(from); + } while (--len); + continue; + } +#endif + } + from = window - OFF; + if (wnext == 0) { /* very common case */ + from += wsize - op; + if (op < len) { /* some from window */ + len -= op; + do { + PUP(out) = PUP(from); + } while (--op); + from = out - dist; /* rest from output */ + } + } + else if (wnext < op) { /* wrap around window */ + from += wsize + wnext - op; + op -= wnext; + if (op < len) { /* some from end of window */ + len -= op; + do { + PUP(out) = PUP(from); + } while (--op); + from = window - OFF; + if (wnext < len) { /* some from start of window */ + op = wnext; + len -= op; + do { + PUP(out) = PUP(from); + } while (--op); + from = out - dist; /* rest from output */ + } + } + } + else { /* contiguous in window */ + from += wnext - op; + if (op < len) { /* some from window */ + len -= op; + do { + PUP(out) = PUP(from); + } while (--op); + from = out - dist; /* rest from output */ + } + } + while (len > 2) { + PUP(out) = PUP(from); + PUP(out) = PUP(from); + PUP(out) = PUP(from); + len -= 3; + } + if (len) { + PUP(out) = PUP(from); + if (len > 1) + PUP(out) = PUP(from); + } + } + else { + from = out - dist; /* copy direct from output */ + do { /* minimum length is three */ + PUP(out) = PUP(from); + PUP(out) = PUP(from); + PUP(out) = PUP(from); + len -= 3; + } while (len > 2); + if (len) { + PUP(out) = PUP(from); + if (len > 1) + PUP(out) = PUP(from); + } + } + } + else if ((op & 64) == 0) { /* 2nd level distance code */ + here = dcode[here.val + (hold & ((1U << op) - 1))]; + goto dodist; + } + else { + strm->msg = (char *)"invalid distance code"; + state->mode = BAD; + break; + } + } + else if ((op & 64) == 0) { /* 2nd level length code */ + here = lcode[here.val + (hold & ((1U << op) - 1))]; + goto dolen; + } + else if (op & 32) { /* end-of-block */ + Tracevv((stderr, "inflate: end of block\n")); + state->mode = TYPE; + break; + } + else { + strm->msg = (char *)"invalid literal/length code"; + state->mode = BAD; + break; + } + } while (in < last && out < end); + + /* return unused bytes (on entry, bits < 8, so in won't go too far back) */ + len = bits >> 3; + in -= len; + bits -= len << 3; + hold &= (1U << bits) - 1; + + /* update state and return */ + strm->next_in = in + OFF; + strm->next_out = out + OFF; + strm->avail_in = (unsigned)(in < last ? 5 + (last - in) : 5 - (in - last)); + strm->avail_out = (unsigned)(out < end ? + 257 + (end - out) : 257 - (out - end)); + state->hold = hold; + state->bits = bits; + return; +} + +/* + inflate_fast() speedups that turned out slower (on a PowerPC G3 750CXe): + - Using bit fields for code structure + - Different op definition to avoid & for extra bits (do & for table bits) + - Three separate decoding do-loops for direct, window, and wnext == 0 + - Special case for distance > 1 copies to do overlapped load and store copy + - Explicit branch predictions (based on measured branch probabilities) + - Deferring match copy and interspersed it with decoding subsequent codes + - Swapping literal/length else + - Swapping window/direct else + - Larger unrolled copy loops (three is about right) + - Moving len -= 3 statement into middle of loop + */ + +#endif /* !ASMINF */ diff --git a/mk/linux/mojosetup/zlib/inffast.h b/mk/linux/mojosetup/zlib/inffast.h new file mode 100644 index 00000000..1e88d2d9 --- /dev/null +++ b/mk/linux/mojosetup/zlib/inffast.h @@ -0,0 +1,11 @@ +/* inffast.h -- header to use inffast.c + * Copyright (C) 1995-2003 Mark Adler + * For conditions of distribution and use, see copyright notice in zlib.h + */ + +/* WARNING: this file should *not* be used by applications. It is + part of the implementation of the compression library and is + subject to change. Applications should only use zlib.h. + */ + +void inflate_fast OF((z_streamp strm, unsigned start)); diff --git a/mk/linux/mojosetup/zlib/inffixed.h b/mk/linux/mojosetup/zlib/inffixed.h new file mode 100644 index 00000000..75ed4b59 --- /dev/null +++ b/mk/linux/mojosetup/zlib/inffixed.h @@ -0,0 +1,94 @@ + /* inffixed.h -- table for decoding fixed codes + * Generated automatically by makefixed(). + */ + + /* WARNING: this file should *not* be used by applications. It + is part of the implementation of the compression library and + is subject to change. Applications should only use zlib.h. + */ + + static const code lenfix[512] = { + {96,7,0},{0,8,80},{0,8,16},{20,8,115},{18,7,31},{0,8,112},{0,8,48}, + {0,9,192},{16,7,10},{0,8,96},{0,8,32},{0,9,160},{0,8,0},{0,8,128}, + {0,8,64},{0,9,224},{16,7,6},{0,8,88},{0,8,24},{0,9,144},{19,7,59}, + {0,8,120},{0,8,56},{0,9,208},{17,7,17},{0,8,104},{0,8,40},{0,9,176}, + {0,8,8},{0,8,136},{0,8,72},{0,9,240},{16,7,4},{0,8,84},{0,8,20}, + {21,8,227},{19,7,43},{0,8,116},{0,8,52},{0,9,200},{17,7,13},{0,8,100}, + {0,8,36},{0,9,168},{0,8,4},{0,8,132},{0,8,68},{0,9,232},{16,7,8}, + {0,8,92},{0,8,28},{0,9,152},{20,7,83},{0,8,124},{0,8,60},{0,9,216}, + {18,7,23},{0,8,108},{0,8,44},{0,9,184},{0,8,12},{0,8,140},{0,8,76}, + {0,9,248},{16,7,3},{0,8,82},{0,8,18},{21,8,163},{19,7,35},{0,8,114}, + {0,8,50},{0,9,196},{17,7,11},{0,8,98},{0,8,34},{0,9,164},{0,8,2}, + {0,8,130},{0,8,66},{0,9,228},{16,7,7},{0,8,90},{0,8,26},{0,9,148}, + {20,7,67},{0,8,122},{0,8,58},{0,9,212},{18,7,19},{0,8,106},{0,8,42}, + {0,9,180},{0,8,10},{0,8,138},{0,8,74},{0,9,244},{16,7,5},{0,8,86}, + {0,8,22},{64,8,0},{19,7,51},{0,8,118},{0,8,54},{0,9,204},{17,7,15}, + {0,8,102},{0,8,38},{0,9,172},{0,8,6},{0,8,134},{0,8,70},{0,9,236}, + {16,7,9},{0,8,94},{0,8,30},{0,9,156},{20,7,99},{0,8,126},{0,8,62}, + {0,9,220},{18,7,27},{0,8,110},{0,8,46},{0,9,188},{0,8,14},{0,8,142}, + {0,8,78},{0,9,252},{96,7,0},{0,8,81},{0,8,17},{21,8,131},{18,7,31}, + {0,8,113},{0,8,49},{0,9,194},{16,7,10},{0,8,97},{0,8,33},{0,9,162}, + {0,8,1},{0,8,129},{0,8,65},{0,9,226},{16,7,6},{0,8,89},{0,8,25}, + {0,9,146},{19,7,59},{0,8,121},{0,8,57},{0,9,210},{17,7,17},{0,8,105}, + {0,8,41},{0,9,178},{0,8,9},{0,8,137},{0,8,73},{0,9,242},{16,7,4}, + {0,8,85},{0,8,21},{16,8,258},{19,7,43},{0,8,117},{0,8,53},{0,9,202}, + {17,7,13},{0,8,101},{0,8,37},{0,9,170},{0,8,5},{0,8,133},{0,8,69}, + {0,9,234},{16,7,8},{0,8,93},{0,8,29},{0,9,154},{20,7,83},{0,8,125}, + {0,8,61},{0,9,218},{18,7,23},{0,8,109},{0,8,45},{0,9,186},{0,8,13}, + {0,8,141},{0,8,77},{0,9,250},{16,7,3},{0,8,83},{0,8,19},{21,8,195}, + {19,7,35},{0,8,115},{0,8,51},{0,9,198},{17,7,11},{0,8,99},{0,8,35}, + {0,9,166},{0,8,3},{0,8,131},{0,8,67},{0,9,230},{16,7,7},{0,8,91}, + {0,8,27},{0,9,150},{20,7,67},{0,8,123},{0,8,59},{0,9,214},{18,7,19}, + {0,8,107},{0,8,43},{0,9,182},{0,8,11},{0,8,139},{0,8,75},{0,9,246}, + {16,7,5},{0,8,87},{0,8,23},{64,8,0},{19,7,51},{0,8,119},{0,8,55}, + {0,9,206},{17,7,15},{0,8,103},{0,8,39},{0,9,174},{0,8,7},{0,8,135}, + {0,8,71},{0,9,238},{16,7,9},{0,8,95},{0,8,31},{0,9,158},{20,7,99}, + {0,8,127},{0,8,63},{0,9,222},{18,7,27},{0,8,111},{0,8,47},{0,9,190}, + {0,8,15},{0,8,143},{0,8,79},{0,9,254},{96,7,0},{0,8,80},{0,8,16}, + {20,8,115},{18,7,31},{0,8,112},{0,8,48},{0,9,193},{16,7,10},{0,8,96}, + {0,8,32},{0,9,161},{0,8,0},{0,8,128},{0,8,64},{0,9,225},{16,7,6}, + {0,8,88},{0,8,24},{0,9,145},{19,7,59},{0,8,120},{0,8,56},{0,9,209}, + {17,7,17},{0,8,104},{0,8,40},{0,9,177},{0,8,8},{0,8,136},{0,8,72}, + {0,9,241},{16,7,4},{0,8,84},{0,8,20},{21,8,227},{19,7,43},{0,8,116}, + {0,8,52},{0,9,201},{17,7,13},{0,8,100},{0,8,36},{0,9,169},{0,8,4}, + {0,8,132},{0,8,68},{0,9,233},{16,7,8},{0,8,92},{0,8,28},{0,9,153}, + {20,7,83},{0,8,124},{0,8,60},{0,9,217},{18,7,23},{0,8,108},{0,8,44}, + {0,9,185},{0,8,12},{0,8,140},{0,8,76},{0,9,249},{16,7,3},{0,8,82}, + {0,8,18},{21,8,163},{19,7,35},{0,8,114},{0,8,50},{0,9,197},{17,7,11}, + {0,8,98},{0,8,34},{0,9,165},{0,8,2},{0,8,130},{0,8,66},{0,9,229}, + {16,7,7},{0,8,90},{0,8,26},{0,9,149},{20,7,67},{0,8,122},{0,8,58}, + {0,9,213},{18,7,19},{0,8,106},{0,8,42},{0,9,181},{0,8,10},{0,8,138}, + {0,8,74},{0,9,245},{16,7,5},{0,8,86},{0,8,22},{64,8,0},{19,7,51}, + {0,8,118},{0,8,54},{0,9,205},{17,7,15},{0,8,102},{0,8,38},{0,9,173}, + {0,8,6},{0,8,134},{0,8,70},{0,9,237},{16,7,9},{0,8,94},{0,8,30}, + {0,9,157},{20,7,99},{0,8,126},{0,8,62},{0,9,221},{18,7,27},{0,8,110}, + {0,8,46},{0,9,189},{0,8,14},{0,8,142},{0,8,78},{0,9,253},{96,7,0}, + {0,8,81},{0,8,17},{21,8,131},{18,7,31},{0,8,113},{0,8,49},{0,9,195}, + {16,7,10},{0,8,97},{0,8,33},{0,9,163},{0,8,1},{0,8,129},{0,8,65}, + {0,9,227},{16,7,6},{0,8,89},{0,8,25},{0,9,147},{19,7,59},{0,8,121}, + {0,8,57},{0,9,211},{17,7,17},{0,8,105},{0,8,41},{0,9,179},{0,8,9}, + {0,8,137},{0,8,73},{0,9,243},{16,7,4},{0,8,85},{0,8,21},{16,8,258}, + {19,7,43},{0,8,117},{0,8,53},{0,9,203},{17,7,13},{0,8,101},{0,8,37}, + {0,9,171},{0,8,5},{0,8,133},{0,8,69},{0,9,235},{16,7,8},{0,8,93}, + {0,8,29},{0,9,155},{20,7,83},{0,8,125},{0,8,61},{0,9,219},{18,7,23}, + {0,8,109},{0,8,45},{0,9,187},{0,8,13},{0,8,141},{0,8,77},{0,9,251}, + {16,7,3},{0,8,83},{0,8,19},{21,8,195},{19,7,35},{0,8,115},{0,8,51}, + {0,9,199},{17,7,11},{0,8,99},{0,8,35},{0,9,167},{0,8,3},{0,8,131}, + {0,8,67},{0,9,231},{16,7,7},{0,8,91},{0,8,27},{0,9,151},{20,7,67}, + {0,8,123},{0,8,59},{0,9,215},{18,7,19},{0,8,107},{0,8,43},{0,9,183}, + {0,8,11},{0,8,139},{0,8,75},{0,9,247},{16,7,5},{0,8,87},{0,8,23}, + {64,8,0},{19,7,51},{0,8,119},{0,8,55},{0,9,207},{17,7,15},{0,8,103}, + {0,8,39},{0,9,175},{0,8,7},{0,8,135},{0,8,71},{0,9,239},{16,7,9}, + {0,8,95},{0,8,31},{0,9,159},{20,7,99},{0,8,127},{0,8,63},{0,9,223}, + {18,7,27},{0,8,111},{0,8,47},{0,9,191},{0,8,15},{0,8,143},{0,8,79}, + {0,9,255} + }; + + static const code distfix[32] = { + {16,5,1},{23,5,257},{19,5,17},{27,5,4097},{17,5,5},{25,5,1025}, + {21,5,65},{29,5,16385},{16,5,3},{24,5,513},{20,5,33},{28,5,8193}, + {18,5,9},{26,5,2049},{22,5,129},{64,5,0},{16,5,2},{23,5,385}, + {19,5,25},{27,5,6145},{17,5,7},{25,5,1537},{21,5,97},{29,5,24577}, + {16,5,4},{24,5,769},{20,5,49},{28,5,12289},{18,5,13},{26,5,3073}, + {22,5,193},{64,5,0} + }; diff --git a/mk/linux/mojosetup/zlib/inflate.c b/mk/linux/mojosetup/zlib/inflate.c new file mode 100644 index 00000000..a8431abe --- /dev/null +++ b/mk/linux/mojosetup/zlib/inflate.c @@ -0,0 +1,1480 @@ +/* inflate.c -- zlib decompression + * Copyright (C) 1995-2010 Mark Adler + * For conditions of distribution and use, see copyright notice in zlib.h + */ + +/* + * Change history: + * + * 1.2.beta0 24 Nov 2002 + * - First version -- complete rewrite of inflate to simplify code, avoid + * creation of window when not needed, minimize use of window when it is + * needed, make inffast.c even faster, implement gzip decoding, and to + * improve code readability and style over the previous zlib inflate code + * + * 1.2.beta1 25 Nov 2002 + * - Use pointers for available input and output checking in inffast.c + * - Remove input and output counters in inffast.c + * - Change inffast.c entry and loop from avail_in >= 7 to >= 6 + * - Remove unnecessary second byte pull from length extra in inffast.c + * - Unroll direct copy to three copies per loop in inffast.c + * + * 1.2.beta2 4 Dec 2002 + * - Change external routine names to reduce potential conflicts + * - Correct filename to inffixed.h for fixed tables in inflate.c + * - Make hbuf[] unsigned char to match parameter type in inflate.c + * - Change strm->next_out[-state->offset] to *(strm->next_out - state->offset) + * to avoid negation problem on Alphas (64 bit) in inflate.c + * + * 1.2.beta3 22 Dec 2002 + * - Add comments on state->bits assertion in inffast.c + * - Add comments on op field in inftrees.h + * - Fix bug in reuse of allocated window after inflateReset() + * - Remove bit fields--back to byte structure for speed + * - Remove distance extra == 0 check in inflate_fast()--only helps for lengths + * - Change post-increments to pre-increments in inflate_fast(), PPC biased? + * - Add compile time option, POSTINC, to use post-increments instead (Intel?) + * - Make MATCH copy in inflate() much faster for when inflate_fast() not used + * - Use local copies of stream next and avail values, as well as local bit + * buffer and bit count in inflate()--for speed when inflate_fast() not used + * + * 1.2.beta4 1 Jan 2003 + * - Split ptr - 257 statements in inflate_table() to avoid compiler warnings + * - Move a comment on output buffer sizes from inffast.c to inflate.c + * - Add comments in inffast.c to introduce the inflate_fast() routine + * - Rearrange window copies in inflate_fast() for speed and simplification + * - Unroll last copy for window match in inflate_fast() + * - Use local copies of window variables in inflate_fast() for speed + * - Pull out common wnext == 0 case for speed in inflate_fast() + * - Make op and len in inflate_fast() unsigned for consistency + * - Add FAR to lcode and dcode declarations in inflate_fast() + * - Simplified bad distance check in inflate_fast() + * - Added inflateBackInit(), inflateBack(), and inflateBackEnd() in new + * source file infback.c to provide a call-back interface to inflate for + * programs like gzip and unzip -- uses window as output buffer to avoid + * window copying + * + * 1.2.beta5 1 Jan 2003 + * - Improved inflateBack() interface to allow the caller to provide initial + * input in strm. + * - Fixed stored blocks bug in inflateBack() + * + * 1.2.beta6 4 Jan 2003 + * - Added comments in inffast.c on effectiveness of POSTINC + * - Typecasting all around to reduce compiler warnings + * - Changed loops from while (1) or do {} while (1) to for (;;), again to + * make compilers happy + * - Changed type of window in inflateBackInit() to unsigned char * + * + * 1.2.beta7 27 Jan 2003 + * - Changed many types to unsigned or unsigned short to avoid warnings + * - Added inflateCopy() function + * + * 1.2.0 9 Mar 2003 + * - Changed inflateBack() interface to provide separate opaque descriptors + * for the in() and out() functions + * - Changed inflateBack() argument and in_func typedef to swap the length + * and buffer address return values for the input function + * - Check next_in and next_out for Z_NULL on entry to inflate() + * + * The history for versions after 1.2.0 are in ChangeLog in zlib distribution. + */ + +#include "zutil.h" +#include "inftrees.h" +#include "inflate.h" +#include "inffast.h" + +#ifdef MAKEFIXED +# ifndef BUILDFIXED +# define BUILDFIXED +# endif +#endif + +/* function prototypes */ +local void fixedtables OF((struct inflate_state FAR *state)); +local int updatewindow OF((z_streamp strm, unsigned out)); +#ifdef BUILDFIXED + void makefixed OF((void)); +#endif +local unsigned syncsearch OF((unsigned FAR *have, unsigned char FAR *buf, + unsigned len)); + +int ZEXPORT inflateReset(strm) +z_streamp strm; +{ + struct inflate_state FAR *state; + + if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR; + state = (struct inflate_state FAR *)strm->state; + strm->total_in = strm->total_out = state->total = 0; + strm->msg = Z_NULL; + strm->adler = 1; /* to support ill-conceived Java test suite */ + state->mode = HEAD; + state->last = 0; + state->havedict = 0; + state->dmax = 32768U; + state->head = Z_NULL; + state->wsize = 0; + state->whave = 0; + state->wnext = 0; + state->hold = 0; + state->bits = 0; + state->lencode = state->distcode = state->next = state->codes; + state->sane = 1; + state->back = -1; + Tracev((stderr, "inflate: reset\n")); + return Z_OK; +} + +int ZEXPORT inflateReset2(strm, windowBits) +z_streamp strm; +int windowBits; +{ + int wrap; + struct inflate_state FAR *state; + + /* get the state */ + if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR; + state = (struct inflate_state FAR *)strm->state; + + /* extract wrap request from windowBits parameter */ + if (windowBits < 0) { + wrap = 0; + windowBits = -windowBits; + } + else { + wrap = (windowBits >> 4) + 1; +#ifdef GUNZIP + if (windowBits < 48) + windowBits &= 15; +#endif + } + + /* set number of window bits, free window if different */ + if (windowBits && (windowBits < 8 || windowBits > 15)) + return Z_STREAM_ERROR; + if (state->window != Z_NULL && state->wbits != (unsigned)windowBits) { + ZFREE(strm, state->window); + state->window = Z_NULL; + } + + /* update state and reset the rest of it */ + state->wrap = wrap; + state->wbits = (unsigned)windowBits; + return inflateReset(strm); +} + +int ZEXPORT inflateInit2_(strm, windowBits, version, stream_size) +z_streamp strm; +int windowBits; +const char *version; +int stream_size; +{ + int ret; + struct inflate_state FAR *state; + + if (version == Z_NULL || version[0] != ZLIB_VERSION[0] || + stream_size != (int)(sizeof(z_stream))) + return Z_VERSION_ERROR; + if (strm == Z_NULL) return Z_STREAM_ERROR; + strm->msg = Z_NULL; /* in case we return an error */ + if (strm->zalloc == (alloc_func)0) { + strm->zalloc = zcalloc; + strm->opaque = (voidpf)0; + } + if (strm->zfree == (free_func)0) strm->zfree = zcfree; + state = (struct inflate_state FAR *) + ZALLOC(strm, 1, sizeof(struct inflate_state)); + if (state == Z_NULL) return Z_MEM_ERROR; + Tracev((stderr, "inflate: allocated\n")); + strm->state = (struct internal_state FAR *)state; + state->window = Z_NULL; + ret = inflateReset2(strm, windowBits); + if (ret != Z_OK) { + ZFREE(strm, state); + strm->state = Z_NULL; + } + return ret; +} + +int ZEXPORT inflateInit_(strm, version, stream_size) +z_streamp strm; +const char *version; +int stream_size; +{ + return inflateInit2_(strm, DEF_WBITS, version, stream_size); +} + +int ZEXPORT inflatePrime(strm, bits, value) +z_streamp strm; +int bits; +int value; +{ + struct inflate_state FAR *state; + + if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR; + state = (struct inflate_state FAR *)strm->state; + if (bits < 0) { + state->hold = 0; + state->bits = 0; + return Z_OK; + } + if (bits > 16 || state->bits + bits > 32) return Z_STREAM_ERROR; + value &= (1L << bits) - 1; + state->hold += value << state->bits; + state->bits += bits; + return Z_OK; +} + +/* + Return state with length and distance decoding tables and index sizes set to + fixed code decoding. Normally this returns fixed tables from inffixed.h. + If BUILDFIXED is defined, then instead this routine builds the tables the + first time it's called, and returns those tables the first time and + thereafter. This reduces the size of the code by about 2K bytes, in + exchange for a little execution time. However, BUILDFIXED should not be + used for threaded applications, since the rewriting of the tables and virgin + may not be thread-safe. + */ +local void fixedtables(state) +struct inflate_state FAR *state; +{ +#ifdef BUILDFIXED + static int virgin = 1; + static code *lenfix, *distfix; + static code fixed[544]; + + /* build fixed huffman tables if first call (may not be thread safe) */ + if (virgin) { + unsigned sym, bits; + static code *next; + + /* literal/length table */ + sym = 0; + while (sym < 144) state->lens[sym++] = 8; + while (sym < 256) state->lens[sym++] = 9; + while (sym < 280) state->lens[sym++] = 7; + while (sym < 288) state->lens[sym++] = 8; + next = fixed; + lenfix = next; + bits = 9; + inflate_table(LENS, state->lens, 288, &(next), &(bits), state->work); + + /* distance table */ + sym = 0; + while (sym < 32) state->lens[sym++] = 5; + distfix = next; + bits = 5; + inflate_table(DISTS, state->lens, 32, &(next), &(bits), state->work); + + /* do this just once */ + virgin = 0; + } +#else /* !BUILDFIXED */ +# include "inffixed.h" +#endif /* BUILDFIXED */ + state->lencode = lenfix; + state->lenbits = 9; + state->distcode = distfix; + state->distbits = 5; +} + +#ifdef MAKEFIXED +#include + +/* + Write out the inffixed.h that is #include'd above. Defining MAKEFIXED also + defines BUILDFIXED, so the tables are built on the fly. makefixed() writes + those tables to stdout, which would be piped to inffixed.h. A small program + can simply call makefixed to do this: + + void makefixed(void); + + int main(void) + { + makefixed(); + return 0; + } + + Then that can be linked with zlib built with MAKEFIXED defined and run: + + a.out > inffixed.h + */ +void makefixed() +{ + unsigned low, size; + struct inflate_state state; + + fixedtables(&state); + puts(" /* inffixed.h -- table for decoding fixed codes"); + puts(" * Generated automatically by makefixed()."); + puts(" */"); + puts(""); + puts(" /* WARNING: this file should *not* be used by applications."); + puts(" It is part of the implementation of this library and is"); + puts(" subject to change. Applications should only use zlib.h."); + puts(" */"); + puts(""); + size = 1U << 9; + printf(" static const code lenfix[%u] = {", size); + low = 0; + for (;;) { + if ((low % 7) == 0) printf("\n "); + printf("{%u,%u,%d}", state.lencode[low].op, state.lencode[low].bits, + state.lencode[low].val); + if (++low == size) break; + putchar(','); + } + puts("\n };"); + size = 1U << 5; + printf("\n static const code distfix[%u] = {", size); + low = 0; + for (;;) { + if ((low % 6) == 0) printf("\n "); + printf("{%u,%u,%d}", state.distcode[low].op, state.distcode[low].bits, + state.distcode[low].val); + if (++low == size) break; + putchar(','); + } + puts("\n };"); +} +#endif /* MAKEFIXED */ + +/* + Update the window with the last wsize (normally 32K) bytes written before + returning. If window does not exist yet, create it. This is only called + when a window is already in use, or when output has been written during this + inflate call, but the end of the deflate stream has not been reached yet. + It is also called to create a window for dictionary data when a dictionary + is loaded. + + Providing output buffers larger than 32K to inflate() should provide a speed + advantage, since only the last 32K of output is copied to the sliding window + upon return from inflate(), and since all distances after the first 32K of + output will fall in the output data, making match copies simpler and faster. + The advantage may be dependent on the size of the processor's data caches. + */ +local int updatewindow(strm, out) +z_streamp strm; +unsigned out; +{ + struct inflate_state FAR *state; + unsigned copy, dist; + + state = (struct inflate_state FAR *)strm->state; + + /* if it hasn't been done already, allocate space for the window */ + if (state->window == Z_NULL) { + state->window = (unsigned char FAR *) + ZALLOC(strm, 1U << state->wbits, + sizeof(unsigned char)); + if (state->window == Z_NULL) return 1; + } + + /* if window not in use yet, initialize */ + if (state->wsize == 0) { + state->wsize = 1U << state->wbits; + state->wnext = 0; + state->whave = 0; + } + + /* copy state->wsize or less output bytes into the circular window */ + copy = out - strm->avail_out; + if (copy >= state->wsize) { + zmemcpy(state->window, strm->next_out - state->wsize, state->wsize); + state->wnext = 0; + state->whave = state->wsize; + } + else { + dist = state->wsize - state->wnext; + if (dist > copy) dist = copy; + zmemcpy(state->window + state->wnext, strm->next_out - copy, dist); + copy -= dist; + if (copy) { + zmemcpy(state->window, strm->next_out - copy, copy); + state->wnext = copy; + state->whave = state->wsize; + } + else { + state->wnext += dist; + if (state->wnext == state->wsize) state->wnext = 0; + if (state->whave < state->wsize) state->whave += dist; + } + } + return 0; +} + +/* Macros for inflate(): */ + +/* check function to use adler32() for zlib or crc32() for gzip */ +#ifdef GUNZIP +# define UPDATE(check, buf, len) \ + (state->flags ? crc32(check, buf, len) : adler32(check, buf, len)) +#else +# define UPDATE(check, buf, len) adler32(check, buf, len) +#endif + +/* check macros for header crc */ +#ifdef GUNZIP +# define CRC2(check, word) \ + do { \ + hbuf[0] = (unsigned char)(word); \ + hbuf[1] = (unsigned char)((word) >> 8); \ + check = crc32(check, hbuf, 2); \ + } while (0) + +# define CRC4(check, word) \ + do { \ + hbuf[0] = (unsigned char)(word); \ + hbuf[1] = (unsigned char)((word) >> 8); \ + hbuf[2] = (unsigned char)((word) >> 16); \ + hbuf[3] = (unsigned char)((word) >> 24); \ + check = crc32(check, hbuf, 4); \ + } while (0) +#endif + +/* Load registers with state in inflate() for speed */ +#define LOAD() \ + do { \ + put = strm->next_out; \ + left = strm->avail_out; \ + next = strm->next_in; \ + have = strm->avail_in; \ + hold = state->hold; \ + bits = state->bits; \ + } while (0) + +/* Restore state from registers in inflate() */ +#define RESTORE() \ + do { \ + strm->next_out = put; \ + strm->avail_out = left; \ + strm->next_in = next; \ + strm->avail_in = have; \ + state->hold = hold; \ + state->bits = bits; \ + } while (0) + +/* Clear the input bit accumulator */ +#define INITBITS() \ + do { \ + hold = 0; \ + bits = 0; \ + } while (0) + +/* Get a byte of input into the bit accumulator, or return from inflate() + if there is no input available. */ +#define PULLBYTE() \ + do { \ + if (have == 0) goto inf_leave; \ + have--; \ + hold += (unsigned long)(*next++) << bits; \ + bits += 8; \ + } while (0) + +/* Assure that there are at least n bits in the bit accumulator. If there is + not enough available input to do that, then return from inflate(). */ +#define NEEDBITS(n) \ + do { \ + while (bits < (unsigned)(n)) \ + PULLBYTE(); \ + } while (0) + +/* Return the low n bits of the bit accumulator (n < 16) */ +#define BITS(n) \ + ((unsigned)hold & ((1U << (n)) - 1)) + +/* Remove n bits from the bit accumulator */ +#define DROPBITS(n) \ + do { \ + hold >>= (n); \ + bits -= (unsigned)(n); \ + } while (0) + +/* Remove zero to seven bits as needed to go to a byte boundary */ +#define BYTEBITS() \ + do { \ + hold >>= bits & 7; \ + bits -= bits & 7; \ + } while (0) + +/* Reverse the bytes in a 32-bit value */ +#define REVERSE(q) \ + ((((q) >> 24) & 0xff) + (((q) >> 8) & 0xff00) + \ + (((q) & 0xff00) << 8) + (((q) & 0xff) << 24)) + +/* + inflate() uses a state machine to process as much input data and generate as + much output data as possible before returning. The state machine is + structured roughly as follows: + + for (;;) switch (state) { + ... + case STATEn: + if (not enough input data or output space to make progress) + return; + ... make progress ... + state = STATEm; + break; + ... + } + + so when inflate() is called again, the same case is attempted again, and + if the appropriate resources are provided, the machine proceeds to the + next state. The NEEDBITS() macro is usually the way the state evaluates + whether it can proceed or should return. NEEDBITS() does the return if + the requested bits are not available. The typical use of the BITS macros + is: + + NEEDBITS(n); + ... do something with BITS(n) ... + DROPBITS(n); + + where NEEDBITS(n) either returns from inflate() if there isn't enough + input left to load n bits into the accumulator, or it continues. BITS(n) + gives the low n bits in the accumulator. When done, DROPBITS(n) drops + the low n bits off the accumulator. INITBITS() clears the accumulator + and sets the number of available bits to zero. BYTEBITS() discards just + enough bits to put the accumulator on a byte boundary. After BYTEBITS() + and a NEEDBITS(8), then BITS(8) would return the next byte in the stream. + + NEEDBITS(n) uses PULLBYTE() to get an available byte of input, or to return + if there is no input available. The decoding of variable length codes uses + PULLBYTE() directly in order to pull just enough bytes to decode the next + code, and no more. + + Some states loop until they get enough input, making sure that enough + state information is maintained to continue the loop where it left off + if NEEDBITS() returns in the loop. For example, want, need, and keep + would all have to actually be part of the saved state in case NEEDBITS() + returns: + + case STATEw: + while (want < need) { + NEEDBITS(n); + keep[want++] = BITS(n); + DROPBITS(n); + } + state = STATEx; + case STATEx: + + As shown above, if the next state is also the next case, then the break + is omitted. + + A state may also return if there is not enough output space available to + complete that state. Those states are copying stored data, writing a + literal byte, and copying a matching string. + + When returning, a "goto inf_leave" is used to update the total counters, + update the check value, and determine whether any progress has been made + during that inflate() call in order to return the proper return code. + Progress is defined as a change in either strm->avail_in or strm->avail_out. + When there is a window, goto inf_leave will update the window with the last + output written. If a goto inf_leave occurs in the middle of decompression + and there is no window currently, goto inf_leave will create one and copy + output to the window for the next call of inflate(). + + In this implementation, the flush parameter of inflate() only affects the + return code (per zlib.h). inflate() always writes as much as possible to + strm->next_out, given the space available and the provided input--the effect + documented in zlib.h of Z_SYNC_FLUSH. Furthermore, inflate() always defers + the allocation of and copying into a sliding window until necessary, which + provides the effect documented in zlib.h for Z_FINISH when the entire input + stream available. So the only thing the flush parameter actually does is: + when flush is set to Z_FINISH, inflate() cannot return Z_OK. Instead it + will return Z_BUF_ERROR if it has not reached the end of the stream. + */ + +int ZEXPORT inflate(strm, flush) +z_streamp strm; +int flush; +{ + struct inflate_state FAR *state; + unsigned char FAR *next; /* next input */ + unsigned char FAR *put; /* next output */ + unsigned have, left; /* available input and output */ + unsigned long hold; /* bit buffer */ + unsigned bits; /* bits in bit buffer */ + unsigned in, out; /* save starting available input and output */ + unsigned copy; /* number of stored or match bytes to copy */ + unsigned char FAR *from; /* where to copy match bytes from */ + code here; /* current decoding table entry */ + code last; /* parent table entry */ + unsigned len; /* length to copy for repeats, bits to drop */ + int ret; /* return code */ +#ifdef GUNZIP + unsigned char hbuf[4]; /* buffer for gzip header crc calculation */ +#endif + static const unsigned short order[19] = /* permutation of code lengths */ + {16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15}; + + if (strm == Z_NULL || strm->state == Z_NULL || strm->next_out == Z_NULL || + (strm->next_in == Z_NULL && strm->avail_in != 0)) + return Z_STREAM_ERROR; + + state = (struct inflate_state FAR *)strm->state; + if (state->mode == TYPE) state->mode = TYPEDO; /* skip check */ + LOAD(); + in = have; + out = left; + ret = Z_OK; + for (;;) + switch (state->mode) { + case HEAD: + if (state->wrap == 0) { + state->mode = TYPEDO; + break; + } + NEEDBITS(16); +#ifdef GUNZIP + if ((state->wrap & 2) && hold == 0x8b1f) { /* gzip header */ + state->check = crc32(0L, Z_NULL, 0); + CRC2(state->check, hold); + INITBITS(); + state->mode = FLAGS; + break; + } + state->flags = 0; /* expect zlib header */ + if (state->head != Z_NULL) + state->head->done = -1; + if (!(state->wrap & 1) || /* check if zlib header allowed */ +#else + if ( +#endif + ((BITS(8) << 8) + (hold >> 8)) % 31) { + strm->msg = (char *)"incorrect header check"; + state->mode = BAD; + break; + } + if (BITS(4) != Z_DEFLATED) { + strm->msg = (char *)"unknown compression method"; + state->mode = BAD; + break; + } + DROPBITS(4); + len = BITS(4) + 8; + if (state->wbits == 0) + state->wbits = len; + else if (len > state->wbits) { + strm->msg = (char *)"invalid window size"; + state->mode = BAD; + break; + } + state->dmax = 1U << len; + Tracev((stderr, "inflate: zlib header ok\n")); + strm->adler = state->check = adler32(0L, Z_NULL, 0); + state->mode = hold & 0x200 ? DICTID : TYPE; + INITBITS(); + break; +#ifdef GUNZIP + case FLAGS: + NEEDBITS(16); + state->flags = (int)(hold); + if ((state->flags & 0xff) != Z_DEFLATED) { + strm->msg = (char *)"unknown compression method"; + state->mode = BAD; + break; + } + if (state->flags & 0xe000) { + strm->msg = (char *)"unknown header flags set"; + state->mode = BAD; + break; + } + if (state->head != Z_NULL) + state->head->text = (int)((hold >> 8) & 1); + if (state->flags & 0x0200) CRC2(state->check, hold); + INITBITS(); + state->mode = TIME; + case TIME: + NEEDBITS(32); + if (state->head != Z_NULL) + state->head->time = hold; + if (state->flags & 0x0200) CRC4(state->check, hold); + INITBITS(); + state->mode = OS; + case OS: + NEEDBITS(16); + if (state->head != Z_NULL) { + state->head->xflags = (int)(hold & 0xff); + state->head->os = (int)(hold >> 8); + } + if (state->flags & 0x0200) CRC2(state->check, hold); + INITBITS(); + state->mode = EXLEN; + case EXLEN: + if (state->flags & 0x0400) { + NEEDBITS(16); + state->length = (unsigned)(hold); + if (state->head != Z_NULL) + state->head->extra_len = (unsigned)hold; + if (state->flags & 0x0200) CRC2(state->check, hold); + INITBITS(); + } + else if (state->head != Z_NULL) + state->head->extra = Z_NULL; + state->mode = EXTRA; + case EXTRA: + if (state->flags & 0x0400) { + copy = state->length; + if (copy > have) copy = have; + if (copy) { + if (state->head != Z_NULL && + state->head->extra != Z_NULL) { + len = state->head->extra_len - state->length; + zmemcpy(state->head->extra + len, next, + len + copy > state->head->extra_max ? + state->head->extra_max - len : copy); + } + if (state->flags & 0x0200) + state->check = crc32(state->check, next, copy); + have -= copy; + next += copy; + state->length -= copy; + } + if (state->length) goto inf_leave; + } + state->length = 0; + state->mode = NAME; + case NAME: + if (state->flags & 0x0800) { + if (have == 0) goto inf_leave; + copy = 0; + do { + len = (unsigned)(next[copy++]); + if (state->head != Z_NULL && + state->head->name != Z_NULL && + state->length < state->head->name_max) + state->head->name[state->length++] = len; + } while (len && copy < have); + if (state->flags & 0x0200) + state->check = crc32(state->check, next, copy); + have -= copy; + next += copy; + if (len) goto inf_leave; + } + else if (state->head != Z_NULL) + state->head->name = Z_NULL; + state->length = 0; + state->mode = COMMENT; + case COMMENT: + if (state->flags & 0x1000) { + if (have == 0) goto inf_leave; + copy = 0; + do { + len = (unsigned)(next[copy++]); + if (state->head != Z_NULL && + state->head->comment != Z_NULL && + state->length < state->head->comm_max) + state->head->comment[state->length++] = len; + } while (len && copy < have); + if (state->flags & 0x0200) + state->check = crc32(state->check, next, copy); + have -= copy; + next += copy; + if (len) goto inf_leave; + } + else if (state->head != Z_NULL) + state->head->comment = Z_NULL; + state->mode = HCRC; + case HCRC: + if (state->flags & 0x0200) { + NEEDBITS(16); + if (hold != (state->check & 0xffff)) { + strm->msg = (char *)"header crc mismatch"; + state->mode = BAD; + break; + } + INITBITS(); + } + if (state->head != Z_NULL) { + state->head->hcrc = (int)((state->flags >> 9) & 1); + state->head->done = 1; + } + strm->adler = state->check = crc32(0L, Z_NULL, 0); + state->mode = TYPE; + break; +#endif + case DICTID: + NEEDBITS(32); + strm->adler = state->check = REVERSE(hold); + INITBITS(); + state->mode = DICT; + case DICT: + if (state->havedict == 0) { + RESTORE(); + return Z_NEED_DICT; + } + strm->adler = state->check = adler32(0L, Z_NULL, 0); + state->mode = TYPE; + case TYPE: + if (flush == Z_BLOCK || flush == Z_TREES) goto inf_leave; + case TYPEDO: + if (state->last) { + BYTEBITS(); + state->mode = CHECK; + break; + } + NEEDBITS(3); + state->last = BITS(1); + DROPBITS(1); + switch (BITS(2)) { + case 0: /* stored block */ + Tracev((stderr, "inflate: stored block%s\n", + state->last ? " (last)" : "")); + state->mode = STORED; + break; + case 1: /* fixed block */ + fixedtables(state); + Tracev((stderr, "inflate: fixed codes block%s\n", + state->last ? " (last)" : "")); + state->mode = LEN_; /* decode codes */ + if (flush == Z_TREES) { + DROPBITS(2); + goto inf_leave; + } + break; + case 2: /* dynamic block */ + Tracev((stderr, "inflate: dynamic codes block%s\n", + state->last ? " (last)" : "")); + state->mode = TABLE; + break; + case 3: + strm->msg = (char *)"invalid block type"; + state->mode = BAD; + } + DROPBITS(2); + break; + case STORED: + BYTEBITS(); /* go to byte boundary */ + NEEDBITS(32); + if ((hold & 0xffff) != ((hold >> 16) ^ 0xffff)) { + strm->msg = (char *)"invalid stored block lengths"; + state->mode = BAD; + break; + } + state->length = (unsigned)hold & 0xffff; + Tracev((stderr, "inflate: stored length %u\n", + state->length)); + INITBITS(); + state->mode = COPY_; + if (flush == Z_TREES) goto inf_leave; + case COPY_: + state->mode = COPY; + case COPY: + copy = state->length; + if (copy) { + if (copy > have) copy = have; + if (copy > left) copy = left; + if (copy == 0) goto inf_leave; + zmemcpy(put, next, copy); + have -= copy; + next += copy; + left -= copy; + put += copy; + state->length -= copy; + break; + } + Tracev((stderr, "inflate: stored end\n")); + state->mode = TYPE; + break; + case TABLE: + NEEDBITS(14); + state->nlen = BITS(5) + 257; + DROPBITS(5); + state->ndist = BITS(5) + 1; + DROPBITS(5); + state->ncode = BITS(4) + 4; + DROPBITS(4); +#ifndef PKZIP_BUG_WORKAROUND + if (state->nlen > 286 || state->ndist > 30) { + strm->msg = (char *)"too many length or distance symbols"; + state->mode = BAD; + break; + } +#endif + Tracev((stderr, "inflate: table sizes ok\n")); + state->have = 0; + state->mode = LENLENS; + case LENLENS: + while (state->have < state->ncode) { + NEEDBITS(3); + state->lens[order[state->have++]] = (unsigned short)BITS(3); + DROPBITS(3); + } + while (state->have < 19) + state->lens[order[state->have++]] = 0; + state->next = state->codes; + state->lencode = (code const FAR *)(state->next); + state->lenbits = 7; + ret = inflate_table(CODES, state->lens, 19, &(state->next), + &(state->lenbits), state->work); + if (ret) { + strm->msg = (char *)"invalid code lengths set"; + state->mode = BAD; + break; + } + Tracev((stderr, "inflate: code lengths ok\n")); + state->have = 0; + state->mode = CODELENS; + case CODELENS: + while (state->have < state->nlen + state->ndist) { + for (;;) { + here = state->lencode[BITS(state->lenbits)]; + if ((unsigned)(here.bits) <= bits) break; + PULLBYTE(); + } + if (here.val < 16) { + NEEDBITS(here.bits); + DROPBITS(here.bits); + state->lens[state->have++] = here.val; + } + else { + if (here.val == 16) { + NEEDBITS(here.bits + 2); + DROPBITS(here.bits); + if (state->have == 0) { + strm->msg = (char *)"invalid bit length repeat"; + state->mode = BAD; + break; + } + len = state->lens[state->have - 1]; + copy = 3 + BITS(2); + DROPBITS(2); + } + else if (here.val == 17) { + NEEDBITS(here.bits + 3); + DROPBITS(here.bits); + len = 0; + copy = 3 + BITS(3); + DROPBITS(3); + } + else { + NEEDBITS(here.bits + 7); + DROPBITS(here.bits); + len = 0; + copy = 11 + BITS(7); + DROPBITS(7); + } + if (state->have + copy > state->nlen + state->ndist) { + strm->msg = (char *)"invalid bit length repeat"; + state->mode = BAD; + break; + } + while (copy--) + state->lens[state->have++] = (unsigned short)len; + } + } + + /* handle error breaks in while */ + if (state->mode == BAD) break; + + /* check for end-of-block code (better have one) */ + if (state->lens[256] == 0) { + strm->msg = (char *)"invalid code -- missing end-of-block"; + state->mode = BAD; + break; + } + + /* build code tables -- note: do not change the lenbits or distbits + values here (9 and 6) without reading the comments in inftrees.h + concerning the ENOUGH constants, which depend on those values */ + state->next = state->codes; + state->lencode = (code const FAR *)(state->next); + state->lenbits = 9; + ret = inflate_table(LENS, state->lens, state->nlen, &(state->next), + &(state->lenbits), state->work); + if (ret) { + strm->msg = (char *)"invalid literal/lengths set"; + state->mode = BAD; + break; + } + state->distcode = (code const FAR *)(state->next); + state->distbits = 6; + ret = inflate_table(DISTS, state->lens + state->nlen, state->ndist, + &(state->next), &(state->distbits), state->work); + if (ret) { + strm->msg = (char *)"invalid distances set"; + state->mode = BAD; + break; + } + Tracev((stderr, "inflate: codes ok\n")); + state->mode = LEN_; + if (flush == Z_TREES) goto inf_leave; + case LEN_: + state->mode = LEN; + case LEN: + if (have >= 6 && left >= 258) { + RESTORE(); + inflate_fast(strm, out); + LOAD(); + if (state->mode == TYPE) + state->back = -1; + break; + } + state->back = 0; + for (;;) { + here = state->lencode[BITS(state->lenbits)]; + if ((unsigned)(here.bits) <= bits) break; + PULLBYTE(); + } + if (here.op && (here.op & 0xf0) == 0) { + last = here; + for (;;) { + here = state->lencode[last.val + + (BITS(last.bits + last.op) >> last.bits)]; + if ((unsigned)(last.bits + here.bits) <= bits) break; + PULLBYTE(); + } + DROPBITS(last.bits); + state->back += last.bits; + } + DROPBITS(here.bits); + state->back += here.bits; + state->length = (unsigned)here.val; + if ((int)(here.op) == 0) { + Tracevv((stderr, here.val >= 0x20 && here.val < 0x7f ? + "inflate: literal '%c'\n" : + "inflate: literal 0x%02x\n", here.val)); + state->mode = LIT; + break; + } + if (here.op & 32) { + Tracevv((stderr, "inflate: end of block\n")); + state->back = -1; + state->mode = TYPE; + break; + } + if (here.op & 64) { + strm->msg = (char *)"invalid literal/length code"; + state->mode = BAD; + break; + } + state->extra = (unsigned)(here.op) & 15; + state->mode = LENEXT; + case LENEXT: + if (state->extra) { + NEEDBITS(state->extra); + state->length += BITS(state->extra); + DROPBITS(state->extra); + state->back += state->extra; + } + Tracevv((stderr, "inflate: length %u\n", state->length)); + state->was = state->length; + state->mode = DIST; + case DIST: + for (;;) { + here = state->distcode[BITS(state->distbits)]; + if ((unsigned)(here.bits) <= bits) break; + PULLBYTE(); + } + if ((here.op & 0xf0) == 0) { + last = here; + for (;;) { + here = state->distcode[last.val + + (BITS(last.bits + last.op) >> last.bits)]; + if ((unsigned)(last.bits + here.bits) <= bits) break; + PULLBYTE(); + } + DROPBITS(last.bits); + state->back += last.bits; + } + DROPBITS(here.bits); + state->back += here.bits; + if (here.op & 64) { + strm->msg = (char *)"invalid distance code"; + state->mode = BAD; + break; + } + state->offset = (unsigned)here.val; + state->extra = (unsigned)(here.op) & 15; + state->mode = DISTEXT; + case DISTEXT: + if (state->extra) { + NEEDBITS(state->extra); + state->offset += BITS(state->extra); + DROPBITS(state->extra); + state->back += state->extra; + } +#ifdef INFLATE_STRICT + if (state->offset > state->dmax) { + strm->msg = (char *)"invalid distance too far back"; + state->mode = BAD; + break; + } +#endif + Tracevv((stderr, "inflate: distance %u\n", state->offset)); + state->mode = MATCH; + case MATCH: + if (left == 0) goto inf_leave; + copy = out - left; + if (state->offset > copy) { /* copy from window */ + copy = state->offset - copy; + if (copy > state->whave) { + if (state->sane) { + strm->msg = (char *)"invalid distance too far back"; + state->mode = BAD; + break; + } +#ifdef INFLATE_ALLOW_INVALID_DISTANCE_TOOFAR_ARRR + Trace((stderr, "inflate.c too far\n")); + copy -= state->whave; + if (copy > state->length) copy = state->length; + if (copy > left) copy = left; + left -= copy; + state->length -= copy; + do { + *put++ = 0; + } while (--copy); + if (state->length == 0) state->mode = LEN; + break; +#endif + } + if (copy > state->wnext) { + copy -= state->wnext; + from = state->window + (state->wsize - copy); + } + else + from = state->window + (state->wnext - copy); + if (copy > state->length) copy = state->length; + } + else { /* copy from output */ + from = put - state->offset; + copy = state->length; + } + if (copy > left) copy = left; + left -= copy; + state->length -= copy; + do { + *put++ = *from++; + } while (--copy); + if (state->length == 0) state->mode = LEN; + break; + case LIT: + if (left == 0) goto inf_leave; + *put++ = (unsigned char)(state->length); + left--; + state->mode = LEN; + break; + case CHECK: + if (state->wrap) { + NEEDBITS(32); + out -= left; + strm->total_out += out; + state->total += out; + if (out) + strm->adler = state->check = + UPDATE(state->check, put - out, out); + out = left; + if (( +#ifdef GUNZIP + state->flags ? hold : +#endif + REVERSE(hold)) != state->check) { + strm->msg = (char *)"incorrect data check"; + state->mode = BAD; + break; + } + INITBITS(); + Tracev((stderr, "inflate: check matches trailer\n")); + } +#ifdef GUNZIP + state->mode = LENGTH; + case LENGTH: + if (state->wrap && state->flags) { + NEEDBITS(32); + if (hold != (state->total & 0xffffffffUL)) { + strm->msg = (char *)"incorrect length check"; + state->mode = BAD; + break; + } + INITBITS(); + Tracev((stderr, "inflate: length matches trailer\n")); + } +#endif + state->mode = DONE; + case DONE: + ret = Z_STREAM_END; + goto inf_leave; + case BAD: + ret = Z_DATA_ERROR; + goto inf_leave; + case MEM: + return Z_MEM_ERROR; + case SYNC: + default: + return Z_STREAM_ERROR; + } + + /* + Return from inflate(), updating the total counts and the check value. + If there was no progress during the inflate() call, return a buffer + error. Call updatewindow() to create and/or update the window state. + Note: a memory error from inflate() is non-recoverable. + */ + inf_leave: + RESTORE(); + if (state->wsize || (state->mode < CHECK && out != strm->avail_out)) + if (updatewindow(strm, out)) { + state->mode = MEM; + return Z_MEM_ERROR; + } + in -= strm->avail_in; + out -= strm->avail_out; + strm->total_in += in; + strm->total_out += out; + state->total += out; + if (state->wrap && out) + strm->adler = state->check = + UPDATE(state->check, strm->next_out - out, out); + strm->data_type = state->bits + (state->last ? 64 : 0) + + (state->mode == TYPE ? 128 : 0) + + (state->mode == LEN_ || state->mode == COPY_ ? 256 : 0); + if (((in == 0 && out == 0) || flush == Z_FINISH) && ret == Z_OK) + ret = Z_BUF_ERROR; + return ret; +} + +int ZEXPORT inflateEnd(strm) +z_streamp strm; +{ + struct inflate_state FAR *state; + if (strm == Z_NULL || strm->state == Z_NULL || strm->zfree == (free_func)0) + return Z_STREAM_ERROR; + state = (struct inflate_state FAR *)strm->state; + if (state->window != Z_NULL) ZFREE(strm, state->window); + ZFREE(strm, strm->state); + strm->state = Z_NULL; + Tracev((stderr, "inflate: end\n")); + return Z_OK; +} + +int ZEXPORT inflateSetDictionary(strm, dictionary, dictLength) +z_streamp strm; +const Bytef *dictionary; +uInt dictLength; +{ + struct inflate_state FAR *state; + unsigned long id; + + /* check state */ + if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR; + state = (struct inflate_state FAR *)strm->state; + if (state->wrap != 0 && state->mode != DICT) + return Z_STREAM_ERROR; + + /* check for correct dictionary id */ + if (state->mode == DICT) { + id = adler32(0L, Z_NULL, 0); + id = adler32(id, dictionary, dictLength); + if (id != state->check) + return Z_DATA_ERROR; + } + + /* copy dictionary to window */ + if (updatewindow(strm, strm->avail_out)) { + state->mode = MEM; + return Z_MEM_ERROR; + } + if (dictLength > state->wsize) { + zmemcpy(state->window, dictionary + dictLength - state->wsize, + state->wsize); + state->whave = state->wsize; + } + else { + zmemcpy(state->window + state->wsize - dictLength, dictionary, + dictLength); + state->whave = dictLength; + } + state->havedict = 1; + Tracev((stderr, "inflate: dictionary set\n")); + return Z_OK; +} + +int ZEXPORT inflateGetHeader(strm, head) +z_streamp strm; +gz_headerp head; +{ + struct inflate_state FAR *state; + + /* check state */ + if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR; + state = (struct inflate_state FAR *)strm->state; + if ((state->wrap & 2) == 0) return Z_STREAM_ERROR; + + /* save header structure */ + state->head = head; + head->done = 0; + return Z_OK; +} + +/* + Search buf[0..len-1] for the pattern: 0, 0, 0xff, 0xff. Return when found + or when out of input. When called, *have is the number of pattern bytes + found in order so far, in 0..3. On return *have is updated to the new + state. If on return *have equals four, then the pattern was found and the + return value is how many bytes were read including the last byte of the + pattern. If *have is less than four, then the pattern has not been found + yet and the return value is len. In the latter case, syncsearch() can be + called again with more data and the *have state. *have is initialized to + zero for the first call. + */ +local unsigned syncsearch(have, buf, len) +unsigned FAR *have; +unsigned char FAR *buf; +unsigned len; +{ + unsigned got; + unsigned next; + + got = *have; + next = 0; + while (next < len && got < 4) { + if ((int)(buf[next]) == (got < 2 ? 0 : 0xff)) + got++; + else if (buf[next]) + got = 0; + else + got = 4 - got; + next++; + } + *have = got; + return next; +} + +int ZEXPORT inflateSync(strm) +z_streamp strm; +{ + unsigned len; /* number of bytes to look at or looked at */ + unsigned long in, out; /* temporary to save total_in and total_out */ + unsigned char buf[4]; /* to restore bit buffer to byte string */ + struct inflate_state FAR *state; + + /* check parameters */ + if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR; + state = (struct inflate_state FAR *)strm->state; + if (strm->avail_in == 0 && state->bits < 8) return Z_BUF_ERROR; + + /* if first time, start search in bit buffer */ + if (state->mode != SYNC) { + state->mode = SYNC; + state->hold <<= state->bits & 7; + state->bits -= state->bits & 7; + len = 0; + while (state->bits >= 8) { + buf[len++] = (unsigned char)(state->hold); + state->hold >>= 8; + state->bits -= 8; + } + state->have = 0; + syncsearch(&(state->have), buf, len); + } + + /* search available input */ + len = syncsearch(&(state->have), strm->next_in, strm->avail_in); + strm->avail_in -= len; + strm->next_in += len; + strm->total_in += len; + + /* return no joy or set up to restart inflate() on a new block */ + if (state->have != 4) return Z_DATA_ERROR; + in = strm->total_in; out = strm->total_out; + inflateReset(strm); + strm->total_in = in; strm->total_out = out; + state->mode = TYPE; + return Z_OK; +} + +/* + Returns true if inflate is currently at the end of a block generated by + Z_SYNC_FLUSH or Z_FULL_FLUSH. This function is used by one PPP + implementation to provide an additional safety check. PPP uses + Z_SYNC_FLUSH but removes the length bytes of the resulting empty stored + block. When decompressing, PPP checks that at the end of input packet, + inflate is waiting for these length bytes. + */ +int ZEXPORT inflateSyncPoint(strm) +z_streamp strm; +{ + struct inflate_state FAR *state; + + if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR; + state = (struct inflate_state FAR *)strm->state; + return state->mode == STORED && state->bits == 0; +} + +int ZEXPORT inflateCopy(dest, source) +z_streamp dest; +z_streamp source; +{ + struct inflate_state FAR *state; + struct inflate_state FAR *copy; + unsigned char FAR *window; + unsigned wsize; + + /* check input */ + if (dest == Z_NULL || source == Z_NULL || source->state == Z_NULL || + source->zalloc == (alloc_func)0 || source->zfree == (free_func)0) + return Z_STREAM_ERROR; + state = (struct inflate_state FAR *)source->state; + + /* allocate space */ + copy = (struct inflate_state FAR *) + ZALLOC(source, 1, sizeof(struct inflate_state)); + if (copy == Z_NULL) return Z_MEM_ERROR; + window = Z_NULL; + if (state->window != Z_NULL) { + window = (unsigned char FAR *) + ZALLOC(source, 1U << state->wbits, sizeof(unsigned char)); + if (window == Z_NULL) { + ZFREE(source, copy); + return Z_MEM_ERROR; + } + } + + /* copy state */ + zmemcpy(dest, source, sizeof(z_stream)); + zmemcpy(copy, state, sizeof(struct inflate_state)); + if (state->lencode >= state->codes && + state->lencode <= state->codes + ENOUGH - 1) { + copy->lencode = copy->codes + (state->lencode - state->codes); + copy->distcode = copy->codes + (state->distcode - state->codes); + } + copy->next = copy->codes + (state->next - state->codes); + if (window != Z_NULL) { + wsize = 1U << state->wbits; + zmemcpy(window, state->window, wsize); + } + copy->window = window; + dest->state = (struct internal_state FAR *)copy; + return Z_OK; +} + +int ZEXPORT inflateUndermine(strm, subvert) +z_streamp strm; +int subvert; +{ + struct inflate_state FAR *state; + + if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR; + state = (struct inflate_state FAR *)strm->state; + state->sane = !subvert; +#ifdef INFLATE_ALLOW_INVALID_DISTANCE_TOOFAR_ARRR + return Z_OK; +#else + state->sane = 1; + return Z_DATA_ERROR; +#endif +} + +long ZEXPORT inflateMark(strm) +z_streamp strm; +{ + struct inflate_state FAR *state; + + if (strm == Z_NULL || strm->state == Z_NULL) return -1L << 16; + state = (struct inflate_state FAR *)strm->state; + return ((long)(state->back) << 16) + + (state->mode == COPY ? state->length : + (state->mode == MATCH ? state->was - state->length : 0)); +} diff --git a/mk/linux/mojosetup/zlib/inflate.h b/mk/linux/mojosetup/zlib/inflate.h new file mode 100644 index 00000000..95f4986d --- /dev/null +++ b/mk/linux/mojosetup/zlib/inflate.h @@ -0,0 +1,122 @@ +/* inflate.h -- internal inflate state definition + * Copyright (C) 1995-2009 Mark Adler + * For conditions of distribution and use, see copyright notice in zlib.h + */ + +/* WARNING: this file should *not* be used by applications. It is + part of the implementation of the compression library and is + subject to change. Applications should only use zlib.h. + */ + +/* define NO_GZIP when compiling if you want to disable gzip header and + trailer decoding by inflate(). NO_GZIP would be used to avoid linking in + the crc code when it is not needed. For shared libraries, gzip decoding + should be left enabled. */ +#ifndef NO_GZIP +# define GUNZIP +#endif + +/* Possible inflate modes between inflate() calls */ +typedef enum { + HEAD, /* i: waiting for magic header */ + FLAGS, /* i: waiting for method and flags (gzip) */ + TIME, /* i: waiting for modification time (gzip) */ + OS, /* i: waiting for extra flags and operating system (gzip) */ + EXLEN, /* i: waiting for extra length (gzip) */ + EXTRA, /* i: waiting for extra bytes (gzip) */ + NAME, /* i: waiting for end of file name (gzip) */ + COMMENT, /* i: waiting for end of comment (gzip) */ + HCRC, /* i: waiting for header crc (gzip) */ + DICTID, /* i: waiting for dictionary check value */ + DICT, /* waiting for inflateSetDictionary() call */ + TYPE, /* i: waiting for type bits, including last-flag bit */ + TYPEDO, /* i: same, but skip check to exit inflate on new block */ + STORED, /* i: waiting for stored size (length and complement) */ + COPY_, /* i/o: same as COPY below, but only first time in */ + COPY, /* i/o: waiting for input or output to copy stored block */ + TABLE, /* i: waiting for dynamic block table lengths */ + LENLENS, /* i: waiting for code length code lengths */ + CODELENS, /* i: waiting for length/lit and distance code lengths */ + LEN_, /* i: same as LEN below, but only first time in */ + LEN, /* i: waiting for length/lit/eob code */ + LENEXT, /* i: waiting for length extra bits */ + DIST, /* i: waiting for distance code */ + DISTEXT, /* i: waiting for distance extra bits */ + MATCH, /* o: waiting for output space to copy string */ + LIT, /* o: waiting for output space to write literal */ + CHECK, /* i: waiting for 32-bit check value */ + LENGTH, /* i: waiting for 32-bit length (gzip) */ + DONE, /* finished check, done -- remain here until reset */ + BAD, /* got a data error -- remain here until reset */ + MEM, /* got an inflate() memory error -- remain here until reset */ + SYNC /* looking for synchronization bytes to restart inflate() */ +} inflate_mode; + +/* + State transitions between above modes - + + (most modes can go to BAD or MEM on error -- not shown for clarity) + + Process header: + HEAD -> (gzip) or (zlib) or (raw) + (gzip) -> FLAGS -> TIME -> OS -> EXLEN -> EXTRA -> NAME -> COMMENT -> + HCRC -> TYPE + (zlib) -> DICTID or TYPE + DICTID -> DICT -> TYPE + (raw) -> TYPEDO + Read deflate blocks: + TYPE -> TYPEDO -> STORED or TABLE or LEN_ or CHECK + STORED -> COPY_ -> COPY -> TYPE + TABLE -> LENLENS -> CODELENS -> LEN_ + LEN_ -> LEN + Read deflate codes in fixed or dynamic block: + LEN -> LENEXT or LIT or TYPE + LENEXT -> DIST -> DISTEXT -> MATCH -> LEN + LIT -> LEN + Process trailer: + CHECK -> LENGTH -> DONE + */ + +/* state maintained between inflate() calls. Approximately 10K bytes. */ +struct inflate_state { + inflate_mode mode; /* current inflate mode */ + int last; /* true if processing last block */ + int wrap; /* bit 0 true for zlib, bit 1 true for gzip */ + int havedict; /* true if dictionary provided */ + int flags; /* gzip header method and flags (0 if zlib) */ + unsigned dmax; /* zlib header max distance (INFLATE_STRICT) */ + unsigned long check; /* protected copy of check value */ + unsigned long total; /* protected copy of output count */ + gz_headerp head; /* where to save gzip header information */ + /* sliding window */ + unsigned wbits; /* log base 2 of requested window size */ + unsigned wsize; /* window size or zero if not using window */ + unsigned whave; /* valid bytes in the window */ + unsigned wnext; /* window write index */ + unsigned char FAR *window; /* allocated sliding window, if needed */ + /* bit accumulator */ + unsigned long hold; /* input bit accumulator */ + unsigned bits; /* number of bits in "in" */ + /* for string and stored block copying */ + unsigned length; /* literal or length of data to copy */ + unsigned offset; /* distance back to copy string from */ + /* for table and code decoding */ + unsigned extra; /* extra bits needed */ + /* fixed and dynamic code tables */ + code const FAR *lencode; /* starting table for length/literal codes */ + code const FAR *distcode; /* starting table for distance codes */ + unsigned lenbits; /* index bits for lencode */ + unsigned distbits; /* index bits for distcode */ + /* dynamic table building */ + unsigned ncode; /* number of code length code lengths */ + unsigned nlen; /* number of length code lengths */ + unsigned ndist; /* number of distance code lengths */ + unsigned have; /* number of code lengths in lens[] */ + code FAR *next; /* next available space in codes[] */ + unsigned short lens[320]; /* temporary storage for code lengths */ + unsigned short work[288]; /* work area for code table building */ + code codes[ENOUGH]; /* space for code tables */ + int sane; /* if false, allow invalid distance too far */ + int back; /* bits back of last unprocessed length/lit */ + unsigned was; /* initial length of match */ +}; diff --git a/mk/linux/mojosetup/zlib/inftrees.c b/mk/linux/mojosetup/zlib/inftrees.c new file mode 100644 index 00000000..ccf7fa96 --- /dev/null +++ b/mk/linux/mojosetup/zlib/inftrees.c @@ -0,0 +1,330 @@ +/* inftrees.c -- generate Huffman trees for efficient decoding + * Copyright (C) 1995-2010 Mark Adler + * For conditions of distribution and use, see copyright notice in zlib.h + */ + +#include "zutil.h" +#include "inftrees.h" + +#define MAXBITS 15 + +const char inflate_copyright[] = + " inflate 1.2.4 Copyright 1995-2010 Mark Adler "; +/* + If you use the zlib library in a product, an acknowledgment is welcome + in the documentation of your product. If for some reason you cannot + include such an acknowledgment, I would appreciate that you keep this + copyright string in the executable of your product. + */ + +/* + Build a set of tables to decode the provided canonical Huffman code. + The code lengths are lens[0..codes-1]. The result starts at *table, + whose indices are 0..2^bits-1. work is a writable array of at least + lens shorts, which is used as a work area. type is the type of code + to be generated, CODES, LENS, or DISTS. On return, zero is success, + -1 is an invalid code, and +1 means that ENOUGH isn't enough. table + on return points to the next available entry's address. bits is the + requested root table index bits, and on return it is the actual root + table index bits. It will differ if the request is greater than the + longest code or if it is less than the shortest code. + */ +int inflate_table(type, lens, codes, table, bits, work) +codetype type; +unsigned short FAR *lens; +unsigned codes; +code FAR * FAR *table; +unsigned FAR *bits; +unsigned short FAR *work; +{ + unsigned len; /* a code's length in bits */ + unsigned sym; /* index of code symbols */ + unsigned min, max; /* minimum and maximum code lengths */ + unsigned root; /* number of index bits for root table */ + unsigned curr; /* number of index bits for current table */ + unsigned drop; /* code bits to drop for sub-table */ + int left; /* number of prefix codes available */ + unsigned used; /* code entries in table used */ + unsigned huff; /* Huffman code */ + unsigned incr; /* for incrementing code, index */ + unsigned fill; /* index for replicating entries */ + unsigned low; /* low bits for current root entry */ + unsigned mask; /* mask for low root bits */ + code here; /* table entry for duplication */ + code FAR *next; /* next available space in table */ + const unsigned short FAR *base; /* base value table to use */ + const unsigned short FAR *extra; /* extra bits table to use */ + int end; /* use base and extra for symbol > end */ + unsigned short count[MAXBITS+1]; /* number of codes of each length */ + unsigned short offs[MAXBITS+1]; /* offsets in table for each length */ + static const unsigned short lbase[31] = { /* Length codes 257..285 base */ + 3, 4, 5, 6, 7, 8, 9, 10, 11, 13, 15, 17, 19, 23, 27, 31, + 35, 43, 51, 59, 67, 83, 99, 115, 131, 163, 195, 227, 258, 0, 0}; + static const unsigned short lext[31] = { /* Length codes 257..285 extra */ + 16, 16, 16, 16, 16, 16, 16, 16, 17, 17, 17, 17, 18, 18, 18, 18, + 19, 19, 19, 19, 20, 20, 20, 20, 21, 21, 21, 21, 16, 64, 195}; + static const unsigned short dbase[32] = { /* Distance codes 0..29 base */ + 1, 2, 3, 4, 5, 7, 9, 13, 17, 25, 33, 49, 65, 97, 129, 193, + 257, 385, 513, 769, 1025, 1537, 2049, 3073, 4097, 6145, + 8193, 12289, 16385, 24577, 0, 0}; + static const unsigned short dext[32] = { /* Distance codes 0..29 extra */ + 16, 16, 16, 16, 17, 17, 18, 18, 19, 19, 20, 20, 21, 21, 22, 22, + 23, 23, 24, 24, 25, 25, 26, 26, 27, 27, + 28, 28, 29, 29, 64, 64}; + + /* + Process a set of code lengths to create a canonical Huffman code. The + code lengths are lens[0..codes-1]. Each length corresponds to the + symbols 0..codes-1. The Huffman code is generated by first sorting the + symbols by length from short to long, and retaining the symbol order + for codes with equal lengths. Then the code starts with all zero bits + for the first code of the shortest length, and the codes are integer + increments for the same length, and zeros are appended as the length + increases. For the deflate format, these bits are stored backwards + from their more natural integer increment ordering, and so when the + decoding tables are built in the large loop below, the integer codes + are incremented backwards. + + This routine assumes, but does not check, that all of the entries in + lens[] are in the range 0..MAXBITS. The caller must assure this. + 1..MAXBITS is interpreted as that code length. zero means that that + symbol does not occur in this code. + + The codes are sorted by computing a count of codes for each length, + creating from that a table of starting indices for each length in the + sorted table, and then entering the symbols in order in the sorted + table. The sorted table is work[], with that space being provided by + the caller. + + The length counts are used for other purposes as well, i.e. finding + the minimum and maximum length codes, determining if there are any + codes at all, checking for a valid set of lengths, and looking ahead + at length counts to determine sub-table sizes when building the + decoding tables. + */ + + /* accumulate lengths for codes (assumes lens[] all in 0..MAXBITS) */ + for (len = 0; len <= MAXBITS; len++) + count[len] = 0; + for (sym = 0; sym < codes; sym++) + count[lens[sym]]++; + + /* bound code lengths, force root to be within code lengths */ + root = *bits; + for (max = MAXBITS; max >= 1; max--) + if (count[max] != 0) break; + if (root > max) root = max; + if (max == 0) { /* no symbols to code at all */ + here.op = (unsigned char)64; /* invalid code marker */ + here.bits = (unsigned char)1; + here.val = (unsigned short)0; + *(*table)++ = here; /* make a table to force an error */ + *(*table)++ = here; + *bits = 1; + return 0; /* no symbols, but wait for decoding to report error */ + } + for (min = 1; min < max; min++) + if (count[min] != 0) break; + if (root < min) root = min; + + /* check for an over-subscribed or incomplete set of lengths */ + left = 1; + for (len = 1; len <= MAXBITS; len++) { + left <<= 1; + left -= count[len]; + if (left < 0) return -1; /* over-subscribed */ + } + if (left > 0 && (type == CODES || max != 1)) + return -1; /* incomplete set */ + + /* generate offsets into symbol table for each length for sorting */ + offs[1] = 0; + for (len = 1; len < MAXBITS; len++) + offs[len + 1] = offs[len] + count[len]; + + /* sort symbols by length, by symbol order within each length */ + for (sym = 0; sym < codes; sym++) + if (lens[sym] != 0) work[offs[lens[sym]]++] = (unsigned short)sym; + + /* + Create and fill in decoding tables. In this loop, the table being + filled is at next and has curr index bits. The code being used is huff + with length len. That code is converted to an index by dropping drop + bits off of the bottom. For codes where len is less than drop + curr, + those top drop + curr - len bits are incremented through all values to + fill the table with replicated entries. + + root is the number of index bits for the root table. When len exceeds + root, sub-tables are created pointed to by the root entry with an index + of the low root bits of huff. This is saved in low to check for when a + new sub-table should be started. drop is zero when the root table is + being filled, and drop is root when sub-tables are being filled. + + When a new sub-table is needed, it is necessary to look ahead in the + code lengths to determine what size sub-table is needed. The length + counts are used for this, and so count[] is decremented as codes are + entered in the tables. + + used keeps track of how many table entries have been allocated from the + provided *table space. It is checked for LENS and DIST tables against + the constants ENOUGH_LENS and ENOUGH_DISTS to guard against changes in + the initial root table size constants. See the comments in inftrees.h + for more information. + + sym increments through all symbols, and the loop terminates when + all codes of length max, i.e. all codes, have been processed. This + routine permits incomplete codes, so another loop after this one fills + in the rest of the decoding tables with invalid code markers. + */ + + /* set up for code type */ + switch (type) { + case CODES: + base = extra = work; /* dummy value--not used */ + end = 19; + break; + case LENS: + base = lbase; + base -= 257; + extra = lext; + extra -= 257; + end = 256; + break; + default: /* DISTS */ + base = dbase; + extra = dext; + end = -1; + } + + /* initialize state for loop */ + huff = 0; /* starting code */ + sym = 0; /* starting code symbol */ + len = min; /* starting code length */ + next = *table; /* current table to fill in */ + curr = root; /* current table index bits */ + drop = 0; /* current bits to drop from code for index */ + low = (unsigned)(-1); /* trigger new sub-table when len > root */ + used = 1U << root; /* use root table entries */ + mask = used - 1; /* mask for comparing low */ + + /* check available table space */ + if ((type == LENS && used >= ENOUGH_LENS) || + (type == DISTS && used >= ENOUGH_DISTS)) + return 1; + + /* process all codes and make table entries */ + for (;;) { + /* create table entry */ + here.bits = (unsigned char)(len - drop); + if ((int)(work[sym]) < end) { + here.op = (unsigned char)0; + here.val = work[sym]; + } + else if ((int)(work[sym]) > end) { + here.op = (unsigned char)(extra[work[sym]]); + here.val = base[work[sym]]; + } + else { + here.op = (unsigned char)(32 + 64); /* end of block */ + here.val = 0; + } + + /* replicate for those indices with low len bits equal to huff */ + incr = 1U << (len - drop); + fill = 1U << curr; + min = fill; /* save offset to next table */ + do { + fill -= incr; + next[(huff >> drop) + fill] = here; + } while (fill != 0); + + /* backwards increment the len-bit code huff */ + incr = 1U << (len - 1); + while (huff & incr) + incr >>= 1; + if (incr != 0) { + huff &= incr - 1; + huff += incr; + } + else + huff = 0; + + /* go to next symbol, update count, len */ + sym++; + if (--(count[len]) == 0) { + if (len == max) break; + len = lens[work[sym]]; + } + + /* create new sub-table if needed */ + if (len > root && (huff & mask) != low) { + /* if first time, transition to sub-tables */ + if (drop == 0) + drop = root; + + /* increment past last table */ + next += min; /* here min is 1 << curr */ + + /* determine length of next table */ + curr = len - drop; + left = (int)(1 << curr); + while (curr + drop < max) { + left -= count[curr + drop]; + if (left <= 0) break; + curr++; + left <<= 1; + } + + /* check for enough space */ + used += 1U << curr; + if ((type == LENS && used >= ENOUGH_LENS) || + (type == DISTS && used >= ENOUGH_DISTS)) + return 1; + + /* point entry in root table to sub-table */ + low = huff & mask; + (*table)[low].op = (unsigned char)curr; + (*table)[low].bits = (unsigned char)root; + (*table)[low].val = (unsigned short)(next - *table); + } + } + + /* + Fill in rest of table for incomplete codes. This loop is similar to the + loop above in incrementing huff for table indices. It is assumed that + len is equal to curr + drop, so there is no loop needed to increment + through high index bits. When the current sub-table is filled, the loop + drops back to the root table to fill in any remaining entries there. + */ + here.op = (unsigned char)64; /* invalid code marker */ + here.bits = (unsigned char)(len - drop); + here.val = (unsigned short)0; + while (huff != 0) { + /* when done with sub-table, drop back to root table */ + if (drop != 0 && (huff & mask) != low) { + drop = 0; + len = root; + next = *table; + here.bits = (unsigned char)len; + } + + /* put invalid code marker in table */ + next[huff >> drop] = here; + + /* backwards increment the len-bit code huff */ + incr = 1U << (len - 1); + while (huff & incr) + incr >>= 1; + if (incr != 0) { + huff &= incr - 1; + huff += incr; + } + else + huff = 0; + } + + /* set return parameters */ + *table += used; + *bits = root; + return 0; +} diff --git a/mk/linux/mojosetup/zlib/inftrees.h b/mk/linux/mojosetup/zlib/inftrees.h new file mode 100644 index 00000000..67461da0 --- /dev/null +++ b/mk/linux/mojosetup/zlib/inftrees.h @@ -0,0 +1,62 @@ +/* inftrees.h -- header to use inftrees.c + * Copyright (C) 1995-2005 Mark Adler + * For conditions of distribution and use, see copyright notice in zlib.h + */ + +/* WARNING: this file should *not* be used by applications. It is + part of the implementation of the compression library and is + subject to change. Applications should only use zlib.h. + */ + +/* Structure for decoding tables. Each entry provides either the + information needed to do the operation requested by the code that + indexed that table entry, or it provides a pointer to another + table that indexes more bits of the code. op indicates whether + the entry is a pointer to another table, a literal, a length or + distance, an end-of-block, or an invalid code. For a table + pointer, the low four bits of op is the number of index bits of + that table. For a length or distance, the low four bits of op + is the number of extra bits to get after the code. bits is + the number of bits in this code or part of the code to drop off + of the bit buffer. val is the actual byte to output in the case + of a literal, the base length or distance, or the offset from + the current table to the next table. Each entry is four bytes. */ +typedef struct { + unsigned char op; /* operation, extra bits, table bits */ + unsigned char bits; /* bits in this part of the code */ + unsigned short val; /* offset in table or code value */ +} code; + +/* op values as set by inflate_table(): + 00000000 - literal + 0000tttt - table link, tttt != 0 is the number of table index bits + 0001eeee - length or distance, eeee is the number of extra bits + 01100000 - end of block + 01000000 - invalid code + */ + +/* Maximum size of the dynamic table. The maximum number of code structures is + 1444, which is the sum of 852 for literal/length codes and 592 for distance + codes. These values were found by exhaustive searches using the program + examples/enough.c found in the zlib distribtution. The arguments to that + program are the number of symbols, the initial root table size, and the + maximum bit length of a code. "enough 286 9 15" for literal/length codes + returns returns 852, and "enough 30 6 15" for distance codes returns 592. + The initial root table size (9 or 6) is found in the fifth argument of the + inflate_table() calls in inflate.c and infback.c. If the root table size is + changed, then these maximum sizes would be need to be recalculated and + updated. */ +#define ENOUGH_LENS 852 +#define ENOUGH_DISTS 592 +#define ENOUGH (ENOUGH_LENS+ENOUGH_DISTS) + +/* Type of code to build for inflate_table() */ +typedef enum { + CODES, + LENS, + DISTS +} codetype; + +extern int inflate_table OF((codetype type, unsigned short FAR *lens, + unsigned codes, code FAR * FAR *table, + unsigned FAR *bits, unsigned short FAR *work)); diff --git a/mk/linux/mojosetup/zlib/trees.c b/mk/linux/mojosetup/zlib/trees.c new file mode 100644 index 00000000..1a6e997a --- /dev/null +++ b/mk/linux/mojosetup/zlib/trees.c @@ -0,0 +1,1243 @@ +/* trees.c -- output deflated data using Huffman coding + * Copyright (C) 1995-2009 Jean-loup Gailly + * detect_data_type() function provided freely by Cosmin Truta, 2006 + * For conditions of distribution and use, see copyright notice in zlib.h + */ + +/* + * ALGORITHM + * + * The "deflation" process uses several Huffman trees. The more + * common source values are represented by shorter bit sequences. + * + * Each code tree is stored in a compressed form which is itself + * a Huffman encoding of the lengths of all the code strings (in + * ascending order by source values). The actual code strings are + * reconstructed from the lengths in the inflate process, as described + * in the deflate specification. + * + * REFERENCES + * + * Deutsch, L.P.,"'Deflate' Compressed Data Format Specification". + * Available in ftp.uu.net:/pub/archiving/zip/doc/deflate-1.1.doc + * + * Storer, James A. + * Data Compression: Methods and Theory, pp. 49-50. + * Computer Science Press, 1988. ISBN 0-7167-8156-5. + * + * Sedgewick, R. + * Algorithms, p290. + * Addison-Wesley, 1983. ISBN 0-201-06672-6. + */ + +/* @(#) $Id$ */ + +/* #define GEN_TREES_H */ + +#include "deflate.h" + +#ifdef DEBUG +# include +#endif + +/* =========================================================================== + * Constants + */ + +#define MAX_BL_BITS 7 +/* Bit length codes must not exceed MAX_BL_BITS bits */ + +#define END_BLOCK 256 +/* end of block literal code */ + +#define REP_3_6 16 +/* repeat previous bit length 3-6 times (2 bits of repeat count) */ + +#define REPZ_3_10 17 +/* repeat a zero length 3-10 times (3 bits of repeat count) */ + +#define REPZ_11_138 18 +/* repeat a zero length 11-138 times (7 bits of repeat count) */ + +local const int extra_lbits[LENGTH_CODES] /* extra bits for each length code */ + = {0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0}; + +local const int extra_dbits[D_CODES] /* extra bits for each distance code */ + = {0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13}; + +local const int extra_blbits[BL_CODES]/* extra bits for each bit length code */ + = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7}; + +local const uch bl_order[BL_CODES] + = {16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15}; +/* The lengths of the bit length codes are sent in order of decreasing + * probability, to avoid transmitting the lengths for unused bit length codes. + */ + +#define Buf_size (8 * 2*sizeof(char)) +/* Number of bits used within bi_buf. (bi_buf might be implemented on + * more than 16 bits on some systems.) + */ + +/* =========================================================================== + * Local data. These are initialized only once. + */ + +#define DIST_CODE_LEN 512 /* see definition of array dist_code below */ + +#if defined(GEN_TREES_H) || !defined(STDC) +/* non ANSI compilers may not accept trees.h */ + +local ct_data static_ltree[L_CODES+2]; +/* The static literal tree. Since the bit lengths are imposed, there is no + * need for the L_CODES extra codes used during heap construction. However + * The codes 286 and 287 are needed to build a canonical tree (see _tr_init + * below). + */ + +local ct_data static_dtree[D_CODES]; +/* The static distance tree. (Actually a trivial tree since all codes use + * 5 bits.) + */ + +uch _dist_code[DIST_CODE_LEN]; +/* Distance codes. The first 256 values correspond to the distances + * 3 .. 258, the last 256 values correspond to the top 8 bits of + * the 15 bit distances. + */ + +uch _length_code[MAX_MATCH-MIN_MATCH+1]; +/* length code for each normalized match length (0 == MIN_MATCH) */ + +local int base_length[LENGTH_CODES]; +/* First normalized length for each code (0 = MIN_MATCH) */ + +local int base_dist[D_CODES]; +/* First normalized distance for each code (0 = distance of 1) */ + +#else +# include "trees.h" +#endif /* GEN_TREES_H */ + +struct static_tree_desc_s { + const ct_data *static_tree; /* static tree or NULL */ + const intf *extra_bits; /* extra bits for each code or NULL */ + int extra_base; /* base index for extra_bits */ + int elems; /* max number of elements in the tree */ + int max_length; /* max bit length for the codes */ +}; + +local static_tree_desc static_l_desc = +{static_ltree, extra_lbits, LITERALS+1, L_CODES, MAX_BITS}; + +local static_tree_desc static_d_desc = +{static_dtree, extra_dbits, 0, D_CODES, MAX_BITS}; + +local static_tree_desc static_bl_desc = +{(const ct_data *)0, extra_blbits, 0, BL_CODES, MAX_BL_BITS}; + +/* =========================================================================== + * Local (static) routines in this file. + */ + +local void tr_static_init OF((void)); +local void init_block OF((deflate_state *s)); +local void pqdownheap OF((deflate_state *s, ct_data *tree, int k)); +local void gen_bitlen OF((deflate_state *s, tree_desc *desc)); +local void gen_codes OF((ct_data *tree, int max_code, ushf *bl_count)); +local void build_tree OF((deflate_state *s, tree_desc *desc)); +local void scan_tree OF((deflate_state *s, ct_data *tree, int max_code)); +local void send_tree OF((deflate_state *s, ct_data *tree, int max_code)); +local int build_bl_tree OF((deflate_state *s)); +local void send_all_trees OF((deflate_state *s, int lcodes, int dcodes, + int blcodes)); +local void compress_block OF((deflate_state *s, ct_data *ltree, + ct_data *dtree)); +local int detect_data_type OF((deflate_state *s)); +local unsigned bi_reverse OF((unsigned value, int length)); +local void bi_windup OF((deflate_state *s)); +local void bi_flush OF((deflate_state *s)); +local void copy_block OF((deflate_state *s, charf *buf, unsigned len, + int header)); + +#ifdef GEN_TREES_H +local void gen_trees_header OF((void)); +#endif + +#ifndef DEBUG +# define send_code(s, c, tree) send_bits(s, tree[c].Code, tree[c].Len) + /* Send a code of the given tree. c and tree must not have side effects */ + +#else /* DEBUG */ +# define send_code(s, c, tree) \ + { if (z_verbose>2) fprintf(stderr,"\ncd %3d ",(c)); \ + send_bits(s, tree[c].Code, tree[c].Len); } +#endif + +/* =========================================================================== + * Output a short LSB first on the stream. + * IN assertion: there is enough room in pendingBuf. + */ +#define put_short(s, w) { \ + put_byte(s, (uch)((w) & 0xff)); \ + put_byte(s, (uch)((ush)(w) >> 8)); \ +} + +/* =========================================================================== + * Send a value on a given number of bits. + * IN assertion: length <= 16 and value fits in length bits. + */ +#ifdef DEBUG +local void send_bits OF((deflate_state *s, int value, int length)); + +local void send_bits(s, value, length) + deflate_state *s; + int value; /* value to send */ + int length; /* number of bits */ +{ + Tracevv((stderr," l %2d v %4x ", length, value)); + Assert(length > 0 && length <= 15, "invalid length"); + s->bits_sent += (ulg)length; + + /* If not enough room in bi_buf, use (valid) bits from bi_buf and + * (16 - bi_valid) bits from value, leaving (width - (16-bi_valid)) + * unused bits in value. + */ + if (s->bi_valid > (int)Buf_size - length) { + s->bi_buf |= (ush)value << s->bi_valid; + put_short(s, s->bi_buf); + s->bi_buf = (ush)value >> (Buf_size - s->bi_valid); + s->bi_valid += length - Buf_size; + } else { + s->bi_buf |= (ush)value << s->bi_valid; + s->bi_valid += length; + } +} +#else /* !DEBUG */ + +#define send_bits(s, value, length) \ +{ int len = length;\ + if (s->bi_valid > (int)Buf_size - len) {\ + int val = value;\ + s->bi_buf |= (ush)val << s->bi_valid;\ + put_short(s, s->bi_buf);\ + s->bi_buf = (ush)val >> (Buf_size - s->bi_valid);\ + s->bi_valid += len - Buf_size;\ + } else {\ + s->bi_buf |= (ush)(value) << s->bi_valid;\ + s->bi_valid += len;\ + }\ +} +#endif /* DEBUG */ + + +/* the arguments must not have side effects */ + +/* =========================================================================== + * Initialize the various 'constant' tables. + */ +local void tr_static_init() +{ +#if defined(GEN_TREES_H) || !defined(STDC) + static int static_init_done = 0; + int n; /* iterates over tree elements */ + int bits; /* bit counter */ + int length; /* length value */ + int code; /* code value */ + int dist; /* distance index */ + ush bl_count[MAX_BITS+1]; + /* number of codes at each bit length for an optimal tree */ + + if (static_init_done) return; + + /* For some embedded targets, global variables are not initialized: */ +#ifdef NO_INIT_GLOBAL_POINTERS + static_l_desc.static_tree = static_ltree; + static_l_desc.extra_bits = extra_lbits; + static_d_desc.static_tree = static_dtree; + static_d_desc.extra_bits = extra_dbits; + static_bl_desc.extra_bits = extra_blbits; +#endif + + /* Initialize the mapping length (0..255) -> length code (0..28) */ + length = 0; + for (code = 0; code < LENGTH_CODES-1; code++) { + base_length[code] = length; + for (n = 0; n < (1< dist code (0..29) */ + dist = 0; + for (code = 0 ; code < 16; code++) { + base_dist[code] = dist; + for (n = 0; n < (1<>= 7; /* from now on, all distances are divided by 128 */ + for ( ; code < D_CODES; code++) { + base_dist[code] = dist << 7; + for (n = 0; n < (1<<(extra_dbits[code]-7)); n++) { + _dist_code[256 + dist++] = (uch)code; + } + } + Assert (dist == 256, "tr_static_init: 256+dist != 512"); + + /* Construct the codes of the static literal tree */ + for (bits = 0; bits <= MAX_BITS; bits++) bl_count[bits] = 0; + n = 0; + while (n <= 143) static_ltree[n++].Len = 8, bl_count[8]++; + while (n <= 255) static_ltree[n++].Len = 9, bl_count[9]++; + while (n <= 279) static_ltree[n++].Len = 7, bl_count[7]++; + while (n <= 287) static_ltree[n++].Len = 8, bl_count[8]++; + /* Codes 286 and 287 do not exist, but we must include them in the + * tree construction to get a canonical Huffman tree (longest code + * all ones) + */ + gen_codes((ct_data *)static_ltree, L_CODES+1, bl_count); + + /* The static distance tree is trivial: */ + for (n = 0; n < D_CODES; n++) { + static_dtree[n].Len = 5; + static_dtree[n].Code = bi_reverse((unsigned)n, 5); + } + static_init_done = 1; + +# ifdef GEN_TREES_H + gen_trees_header(); +# endif +#endif /* defined(GEN_TREES_H) || !defined(STDC) */ +} + +/* =========================================================================== + * Genererate the file trees.h describing the static trees. + */ +#ifdef GEN_TREES_H +# ifndef DEBUG +# include +# endif + +# define SEPARATOR(i, last, width) \ + ((i) == (last)? "\n};\n\n" : \ + ((i) % (width) == (width)-1 ? ",\n" : ", ")) + +void gen_trees_header() +{ + FILE *header = fopen("trees.h", "w"); + int i; + + Assert (header != NULL, "Can't open trees.h"); + fprintf(header, + "/* header created automatically with -DGEN_TREES_H */\n\n"); + + fprintf(header, "local const ct_data static_ltree[L_CODES+2] = {\n"); + for (i = 0; i < L_CODES+2; i++) { + fprintf(header, "{{%3u},{%3u}}%s", static_ltree[i].Code, + static_ltree[i].Len, SEPARATOR(i, L_CODES+1, 5)); + } + + fprintf(header, "local const ct_data static_dtree[D_CODES] = {\n"); + for (i = 0; i < D_CODES; i++) { + fprintf(header, "{{%2u},{%2u}}%s", static_dtree[i].Code, + static_dtree[i].Len, SEPARATOR(i, D_CODES-1, 5)); + } + + fprintf(header, "const uch _dist_code[DIST_CODE_LEN] = {\n"); + for (i = 0; i < DIST_CODE_LEN; i++) { + fprintf(header, "%2u%s", _dist_code[i], + SEPARATOR(i, DIST_CODE_LEN-1, 20)); + } + + fprintf(header, "const uch _length_code[MAX_MATCH-MIN_MATCH+1]= {\n"); + for (i = 0; i < MAX_MATCH-MIN_MATCH+1; i++) { + fprintf(header, "%2u%s", _length_code[i], + SEPARATOR(i, MAX_MATCH-MIN_MATCH, 20)); + } + + fprintf(header, "local const int base_length[LENGTH_CODES] = {\n"); + for (i = 0; i < LENGTH_CODES; i++) { + fprintf(header, "%1u%s", base_length[i], + SEPARATOR(i, LENGTH_CODES-1, 20)); + } + + fprintf(header, "local const int base_dist[D_CODES] = {\n"); + for (i = 0; i < D_CODES; i++) { + fprintf(header, "%5u%s", base_dist[i], + SEPARATOR(i, D_CODES-1, 10)); + } + + fclose(header); +} +#endif /* GEN_TREES_H */ + +/* =========================================================================== + * Initialize the tree data structures for a new zlib stream. + */ +void _tr_init(s) + deflate_state *s; +{ + tr_static_init(); + + s->l_desc.dyn_tree = s->dyn_ltree; + s->l_desc.stat_desc = &static_l_desc; + + s->d_desc.dyn_tree = s->dyn_dtree; + s->d_desc.stat_desc = &static_d_desc; + + s->bl_desc.dyn_tree = s->bl_tree; + s->bl_desc.stat_desc = &static_bl_desc; + + s->bi_buf = 0; + s->bi_valid = 0; + s->last_eob_len = 8; /* enough lookahead for inflate */ +#ifdef DEBUG + s->compressed_len = 0L; + s->bits_sent = 0L; +#endif + + /* Initialize the first block of the first file: */ + init_block(s); +} + +/* =========================================================================== + * Initialize a new block. + */ +local void init_block(s) + deflate_state *s; +{ + int n; /* iterates over tree elements */ + + /* Initialize the trees. */ + for (n = 0; n < L_CODES; n++) s->dyn_ltree[n].Freq = 0; + for (n = 0; n < D_CODES; n++) s->dyn_dtree[n].Freq = 0; + for (n = 0; n < BL_CODES; n++) s->bl_tree[n].Freq = 0; + + s->dyn_ltree[END_BLOCK].Freq = 1; + s->opt_len = s->static_len = 0L; + s->last_lit = s->matches = 0; +} + +#define SMALLEST 1 +/* Index within the heap array of least frequent node in the Huffman tree */ + + +/* =========================================================================== + * Remove the smallest element from the heap and recreate the heap with + * one less element. Updates heap and heap_len. + */ +#define pqremove(s, tree, top) \ +{\ + top = s->heap[SMALLEST]; \ + s->heap[SMALLEST] = s->heap[s->heap_len--]; \ + pqdownheap(s, tree, SMALLEST); \ +} + +/* =========================================================================== + * Compares to subtrees, using the tree depth as tie breaker when + * the subtrees have equal frequency. This minimizes the worst case length. + */ +#define smaller(tree, n, m, depth) \ + (tree[n].Freq < tree[m].Freq || \ + (tree[n].Freq == tree[m].Freq && depth[n] <= depth[m])) + +/* =========================================================================== + * Restore the heap property by moving down the tree starting at node k, + * exchanging a node with the smallest of its two sons if necessary, stopping + * when the heap property is re-established (each father smaller than its + * two sons). + */ +local void pqdownheap(s, tree, k) + deflate_state *s; + ct_data *tree; /* the tree to restore */ + int k; /* node to move down */ +{ + int v = s->heap[k]; + int j = k << 1; /* left son of k */ + while (j <= s->heap_len) { + /* Set j to the smallest of the two sons: */ + if (j < s->heap_len && + smaller(tree, s->heap[j+1], s->heap[j], s->depth)) { + j++; + } + /* Exit if v is smaller than both sons */ + if (smaller(tree, v, s->heap[j], s->depth)) break; + + /* Exchange v with the smallest son */ + s->heap[k] = s->heap[j]; k = j; + + /* And continue down the tree, setting j to the left son of k */ + j <<= 1; + } + s->heap[k] = v; +} + +/* =========================================================================== + * Compute the optimal bit lengths for a tree and update the total bit length + * for the current block. + * IN assertion: the fields freq and dad are set, heap[heap_max] and + * above are the tree nodes sorted by increasing frequency. + * OUT assertions: the field len is set to the optimal bit length, the + * array bl_count contains the frequencies for each bit length. + * The length opt_len is updated; static_len is also updated if stree is + * not null. + */ +local void gen_bitlen(s, desc) + deflate_state *s; + tree_desc *desc; /* the tree descriptor */ +{ + ct_data *tree = desc->dyn_tree; + int max_code = desc->max_code; + const ct_data *stree = desc->stat_desc->static_tree; + const intf *extra = desc->stat_desc->extra_bits; + int base = desc->stat_desc->extra_base; + int max_length = desc->stat_desc->max_length; + int h; /* heap index */ + int n, m; /* iterate over the tree elements */ + int bits; /* bit length */ + int xbits; /* extra bits */ + ush f; /* frequency */ + int overflow = 0; /* number of elements with bit length too large */ + + for (bits = 0; bits <= MAX_BITS; bits++) s->bl_count[bits] = 0; + + /* In a first pass, compute the optimal bit lengths (which may + * overflow in the case of the bit length tree). + */ + tree[s->heap[s->heap_max]].Len = 0; /* root of the heap */ + + for (h = s->heap_max+1; h < HEAP_SIZE; h++) { + n = s->heap[h]; + bits = tree[tree[n].Dad].Len + 1; + if (bits > max_length) bits = max_length, overflow++; + tree[n].Len = (ush)bits; + /* We overwrite tree[n].Dad which is no longer needed */ + + if (n > max_code) continue; /* not a leaf node */ + + s->bl_count[bits]++; + xbits = 0; + if (n >= base) xbits = extra[n-base]; + f = tree[n].Freq; + s->opt_len += (ulg)f * (bits + xbits); + if (stree) s->static_len += (ulg)f * (stree[n].Len + xbits); + } + if (overflow == 0) return; + + Trace((stderr,"\nbit length overflow\n")); + /* This happens for example on obj2 and pic of the Calgary corpus */ + + /* Find the first bit length which could increase: */ + do { + bits = max_length-1; + while (s->bl_count[bits] == 0) bits--; + s->bl_count[bits]--; /* move one leaf down the tree */ + s->bl_count[bits+1] += 2; /* move one overflow item as its brother */ + s->bl_count[max_length]--; + /* The brother of the overflow item also moves one step up, + * but this does not affect bl_count[max_length] + */ + overflow -= 2; + } while (overflow > 0); + + /* Now recompute all bit lengths, scanning in increasing frequency. + * h is still equal to HEAP_SIZE. (It is simpler to reconstruct all + * lengths instead of fixing only the wrong ones. This idea is taken + * from 'ar' written by Haruhiko Okumura.) + */ + for (bits = max_length; bits != 0; bits--) { + n = s->bl_count[bits]; + while (n != 0) { + m = s->heap[--h]; + if (m > max_code) continue; + if ((unsigned) tree[m].Len != (unsigned) bits) { + Trace((stderr,"code %d bits %d->%d\n", m, tree[m].Len, bits)); + s->opt_len += ((long)bits - (long)tree[m].Len) + *(long)tree[m].Freq; + tree[m].Len = (ush)bits; + } + n--; + } + } +} + +/* =========================================================================== + * Generate the codes for a given tree and bit counts (which need not be + * optimal). + * IN assertion: the array bl_count contains the bit length statistics for + * the given tree and the field len is set for all tree elements. + * OUT assertion: the field code is set for all tree elements of non + * zero code length. + */ +local void gen_codes (tree, max_code, bl_count) + ct_data *tree; /* the tree to decorate */ + int max_code; /* largest code with non zero frequency */ + ushf *bl_count; /* number of codes at each bit length */ +{ + ush next_code[MAX_BITS+1]; /* next code value for each bit length */ + ush code = 0; /* running code value */ + int bits; /* bit index */ + int n; /* code index */ + + /* The distribution counts are first used to generate the code values + * without bit reversal. + */ + for (bits = 1; bits <= MAX_BITS; bits++) { + next_code[bits] = code = (code + bl_count[bits-1]) << 1; + } + /* Check that the bit counts in bl_count are consistent. The last code + * must be all ones. + */ + Assert (code + bl_count[MAX_BITS]-1 == (1<dyn_tree; + const ct_data *stree = desc->stat_desc->static_tree; + int elems = desc->stat_desc->elems; + int n, m; /* iterate over heap elements */ + int max_code = -1; /* largest code with non zero frequency */ + int node; /* new node being created */ + + /* Construct the initial heap, with least frequent element in + * heap[SMALLEST]. The sons of heap[n] are heap[2*n] and heap[2*n+1]. + * heap[0] is not used. + */ + s->heap_len = 0, s->heap_max = HEAP_SIZE; + + for (n = 0; n < elems; n++) { + if (tree[n].Freq != 0) { + s->heap[++(s->heap_len)] = max_code = n; + s->depth[n] = 0; + } else { + tree[n].Len = 0; + } + } + + /* The pkzip format requires that at least one distance code exists, + * and that at least one bit should be sent even if there is only one + * possible code. So to avoid special checks later on we force at least + * two codes of non zero frequency. + */ + while (s->heap_len < 2) { + node = s->heap[++(s->heap_len)] = (max_code < 2 ? ++max_code : 0); + tree[node].Freq = 1; + s->depth[node] = 0; + s->opt_len--; if (stree) s->static_len -= stree[node].Len; + /* node is 0 or 1 so it does not have extra bits */ + } + desc->max_code = max_code; + + /* The elements heap[heap_len/2+1 .. heap_len] are leaves of the tree, + * establish sub-heaps of increasing lengths: + */ + for (n = s->heap_len/2; n >= 1; n--) pqdownheap(s, tree, n); + + /* Construct the Huffman tree by repeatedly combining the least two + * frequent nodes. + */ + node = elems; /* next internal node of the tree */ + do { + pqremove(s, tree, n); /* n = node of least frequency */ + m = s->heap[SMALLEST]; /* m = node of next least frequency */ + + s->heap[--(s->heap_max)] = n; /* keep the nodes sorted by frequency */ + s->heap[--(s->heap_max)] = m; + + /* Create a new node father of n and m */ + tree[node].Freq = tree[n].Freq + tree[m].Freq; + s->depth[node] = (uch)((s->depth[n] >= s->depth[m] ? + s->depth[n] : s->depth[m]) + 1); + tree[n].Dad = tree[m].Dad = (ush)node; +#ifdef DUMP_BL_TREE + if (tree == s->bl_tree) { + fprintf(stderr,"\nnode %d(%d), sons %d(%d) %d(%d)", + node, tree[node].Freq, n, tree[n].Freq, m, tree[m].Freq); + } +#endif + /* and insert the new node in the heap */ + s->heap[SMALLEST] = node++; + pqdownheap(s, tree, SMALLEST); + + } while (s->heap_len >= 2); + + s->heap[--(s->heap_max)] = s->heap[SMALLEST]; + + /* At this point, the fields freq and dad are set. We can now + * generate the bit lengths. + */ + gen_bitlen(s, (tree_desc *)desc); + + /* The field len is now set, we can generate the bit codes */ + gen_codes ((ct_data *)tree, max_code, s->bl_count); +} + +/* =========================================================================== + * Scan a literal or distance tree to determine the frequencies of the codes + * in the bit length tree. + */ +local void scan_tree (s, tree, max_code) + deflate_state *s; + ct_data *tree; /* the tree to be scanned */ + int max_code; /* and its largest code of non zero frequency */ +{ + int n; /* iterates over all tree elements */ + int prevlen = -1; /* last emitted length */ + int curlen; /* length of current code */ + int nextlen = tree[0].Len; /* length of next code */ + int count = 0; /* repeat count of the current code */ + int max_count = 7; /* max repeat count */ + int min_count = 4; /* min repeat count */ + + if (nextlen == 0) max_count = 138, min_count = 3; + tree[max_code+1].Len = (ush)0xffff; /* guard */ + + for (n = 0; n <= max_code; n++) { + curlen = nextlen; nextlen = tree[n+1].Len; + if (++count < max_count && curlen == nextlen) { + continue; + } else if (count < min_count) { + s->bl_tree[curlen].Freq += count; + } else if (curlen != 0) { + if (curlen != prevlen) s->bl_tree[curlen].Freq++; + s->bl_tree[REP_3_6].Freq++; + } else if (count <= 10) { + s->bl_tree[REPZ_3_10].Freq++; + } else { + s->bl_tree[REPZ_11_138].Freq++; + } + count = 0; prevlen = curlen; + if (nextlen == 0) { + max_count = 138, min_count = 3; + } else if (curlen == nextlen) { + max_count = 6, min_count = 3; + } else { + max_count = 7, min_count = 4; + } + } +} + +/* =========================================================================== + * Send a literal or distance tree in compressed form, using the codes in + * bl_tree. + */ +local void send_tree (s, tree, max_code) + deflate_state *s; + ct_data *tree; /* the tree to be scanned */ + int max_code; /* and its largest code of non zero frequency */ +{ + int n; /* iterates over all tree elements */ + int prevlen = -1; /* last emitted length */ + int curlen; /* length of current code */ + int nextlen = tree[0].Len; /* length of next code */ + int count = 0; /* repeat count of the current code */ + int max_count = 7; /* max repeat count */ + int min_count = 4; /* min repeat count */ + + /* tree[max_code+1].Len = -1; */ /* guard already set */ + if (nextlen == 0) max_count = 138, min_count = 3; + + for (n = 0; n <= max_code; n++) { + curlen = nextlen; nextlen = tree[n+1].Len; + if (++count < max_count && curlen == nextlen) { + continue; + } else if (count < min_count) { + do { send_code(s, curlen, s->bl_tree); } while (--count != 0); + + } else if (curlen != 0) { + if (curlen != prevlen) { + send_code(s, curlen, s->bl_tree); count--; + } + Assert(count >= 3 && count <= 6, " 3_6?"); + send_code(s, REP_3_6, s->bl_tree); send_bits(s, count-3, 2); + + } else if (count <= 10) { + send_code(s, REPZ_3_10, s->bl_tree); send_bits(s, count-3, 3); + + } else { + send_code(s, REPZ_11_138, s->bl_tree); send_bits(s, count-11, 7); + } + count = 0; prevlen = curlen; + if (nextlen == 0) { + max_count = 138, min_count = 3; + } else if (curlen == nextlen) { + max_count = 6, min_count = 3; + } else { + max_count = 7, min_count = 4; + } + } +} + +/* =========================================================================== + * Construct the Huffman tree for the bit lengths and return the index in + * bl_order of the last bit length code to send. + */ +local int build_bl_tree(s) + deflate_state *s; +{ + int max_blindex; /* index of last bit length code of non zero freq */ + + /* Determine the bit length frequencies for literal and distance trees */ + scan_tree(s, (ct_data *)s->dyn_ltree, s->l_desc.max_code); + scan_tree(s, (ct_data *)s->dyn_dtree, s->d_desc.max_code); + + /* Build the bit length tree: */ + build_tree(s, (tree_desc *)(&(s->bl_desc))); + /* opt_len now includes the length of the tree representations, except + * the lengths of the bit lengths codes and the 5+5+4 bits for the counts. + */ + + /* Determine the number of bit length codes to send. The pkzip format + * requires that at least 4 bit length codes be sent. (appnote.txt says + * 3 but the actual value used is 4.) + */ + for (max_blindex = BL_CODES-1; max_blindex >= 3; max_blindex--) { + if (s->bl_tree[bl_order[max_blindex]].Len != 0) break; + } + /* Update opt_len to include the bit length tree and counts */ + s->opt_len += 3*(max_blindex+1) + 5+5+4; + Tracev((stderr, "\ndyn trees: dyn %ld, stat %ld", + s->opt_len, s->static_len)); + + return max_blindex; +} + +/* =========================================================================== + * Send the header for a block using dynamic Huffman trees: the counts, the + * lengths of the bit length codes, the literal tree and the distance tree. + * IN assertion: lcodes >= 257, dcodes >= 1, blcodes >= 4. + */ +local void send_all_trees(s, lcodes, dcodes, blcodes) + deflate_state *s; + int lcodes, dcodes, blcodes; /* number of codes for each tree */ +{ + int rank; /* index in bl_order */ + + Assert (lcodes >= 257 && dcodes >= 1 && blcodes >= 4, "not enough codes"); + Assert (lcodes <= L_CODES && dcodes <= D_CODES && blcodes <= BL_CODES, + "too many codes"); + Tracev((stderr, "\nbl counts: ")); + send_bits(s, lcodes-257, 5); /* not +255 as stated in appnote.txt */ + send_bits(s, dcodes-1, 5); + send_bits(s, blcodes-4, 4); /* not -3 as stated in appnote.txt */ + for (rank = 0; rank < blcodes; rank++) { + Tracev((stderr, "\nbl code %2d ", bl_order[rank])); + send_bits(s, s->bl_tree[bl_order[rank]].Len, 3); + } + Tracev((stderr, "\nbl tree: sent %ld", s->bits_sent)); + + send_tree(s, (ct_data *)s->dyn_ltree, lcodes-1); /* literal tree */ + Tracev((stderr, "\nlit tree: sent %ld", s->bits_sent)); + + send_tree(s, (ct_data *)s->dyn_dtree, dcodes-1); /* distance tree */ + Tracev((stderr, "\ndist tree: sent %ld", s->bits_sent)); +} + +/* =========================================================================== + * Send a stored block + */ +void _tr_stored_block(s, buf, stored_len, last) + deflate_state *s; + charf *buf; /* input block */ + ulg stored_len; /* length of input block */ + int last; /* one if this is the last block for a file */ +{ + send_bits(s, (STORED_BLOCK<<1)+last, 3); /* send block type */ +#ifdef DEBUG + s->compressed_len = (s->compressed_len + 3 + 7) & (ulg)~7L; + s->compressed_len += (stored_len + 4) << 3; +#endif + copy_block(s, buf, (unsigned)stored_len, 1); /* with header */ +} + +/* =========================================================================== + * Send one empty static block to give enough lookahead for inflate. + * This takes 10 bits, of which 7 may remain in the bit buffer. + * The current inflate code requires 9 bits of lookahead. If the + * last two codes for the previous block (real code plus EOB) were coded + * on 5 bits or less, inflate may have only 5+3 bits of lookahead to decode + * the last real code. In this case we send two empty static blocks instead + * of one. (There are no problems if the previous block is stored or fixed.) + * To simplify the code, we assume the worst case of last real code encoded + * on one bit only. + */ +void _tr_align(s) + deflate_state *s; +{ + send_bits(s, STATIC_TREES<<1, 3); + send_code(s, END_BLOCK, static_ltree); +#ifdef DEBUG + s->compressed_len += 10L; /* 3 for block type, 7 for EOB */ +#endif + bi_flush(s); + /* Of the 10 bits for the empty block, we have already sent + * (10 - bi_valid) bits. The lookahead for the last real code (before + * the EOB of the previous block) was thus at least one plus the length + * of the EOB plus what we have just sent of the empty static block. + */ + if (1 + s->last_eob_len + 10 - s->bi_valid < 9) { + send_bits(s, STATIC_TREES<<1, 3); + send_code(s, END_BLOCK, static_ltree); +#ifdef DEBUG + s->compressed_len += 10L; +#endif + bi_flush(s); + } + s->last_eob_len = 7; +} + +/* =========================================================================== + * Determine the best encoding for the current block: dynamic trees, static + * trees or store, and output the encoded block to the zip file. + */ +void _tr_flush_block(s, buf, stored_len, last) + deflate_state *s; + charf *buf; /* input block, or NULL if too old */ + ulg stored_len; /* length of input block */ + int last; /* one if this is the last block for a file */ +{ + ulg opt_lenb, static_lenb; /* opt_len and static_len in bytes */ + int max_blindex = 0; /* index of last bit length code of non zero freq */ + + /* Build the Huffman trees unless a stored block is forced */ + if (s->level > 0) { + + /* Check if the file is binary or text */ + if (s->strm->data_type == Z_UNKNOWN) + s->strm->data_type = detect_data_type(s); + + /* Construct the literal and distance trees */ + build_tree(s, (tree_desc *)(&(s->l_desc))); + Tracev((stderr, "\nlit data: dyn %ld, stat %ld", s->opt_len, + s->static_len)); + + build_tree(s, (tree_desc *)(&(s->d_desc))); + Tracev((stderr, "\ndist data: dyn %ld, stat %ld", s->opt_len, + s->static_len)); + /* At this point, opt_len and static_len are the total bit lengths of + * the compressed block data, excluding the tree representations. + */ + + /* Build the bit length tree for the above two trees, and get the index + * in bl_order of the last bit length code to send. + */ + max_blindex = build_bl_tree(s); + + /* Determine the best encoding. Compute the block lengths in bytes. */ + opt_lenb = (s->opt_len+3+7)>>3; + static_lenb = (s->static_len+3+7)>>3; + + Tracev((stderr, "\nopt %lu(%lu) stat %lu(%lu) stored %lu lit %u ", + opt_lenb, s->opt_len, static_lenb, s->static_len, stored_len, + s->last_lit)); + + if (static_lenb <= opt_lenb) opt_lenb = static_lenb; + + } else { + Assert(buf != (char*)0, "lost buf"); + opt_lenb = static_lenb = stored_len + 5; /* force a stored block */ + } + +#ifdef FORCE_STORED + if (buf != (char*)0) { /* force stored block */ +#else + if (stored_len+4 <= opt_lenb && buf != (char*)0) { + /* 4: two words for the lengths */ +#endif + /* The test buf != NULL is only necessary if LIT_BUFSIZE > WSIZE. + * Otherwise we can't have processed more than WSIZE input bytes since + * the last block flush, because compression would have been + * successful. If LIT_BUFSIZE <= WSIZE, it is never too late to + * transform a block into a stored block. + */ + _tr_stored_block(s, buf, stored_len, last); + +#ifdef FORCE_STATIC + } else if (static_lenb >= 0) { /* force static trees */ +#else + } else if (s->strategy == Z_FIXED || static_lenb == opt_lenb) { +#endif + send_bits(s, (STATIC_TREES<<1)+last, 3); + compress_block(s, (ct_data *)static_ltree, (ct_data *)static_dtree); +#ifdef DEBUG + s->compressed_len += 3 + s->static_len; +#endif + } else { + send_bits(s, (DYN_TREES<<1)+last, 3); + send_all_trees(s, s->l_desc.max_code+1, s->d_desc.max_code+1, + max_blindex+1); + compress_block(s, (ct_data *)s->dyn_ltree, (ct_data *)s->dyn_dtree); +#ifdef DEBUG + s->compressed_len += 3 + s->opt_len; +#endif + } + Assert (s->compressed_len == s->bits_sent, "bad compressed size"); + /* The above check is made mod 2^32, for files larger than 512 MB + * and uLong implemented on 32 bits. + */ + init_block(s); + + if (last) { + bi_windup(s); +#ifdef DEBUG + s->compressed_len += 7; /* align on byte boundary */ +#endif + } + Tracev((stderr,"\ncomprlen %lu(%lu) ", s->compressed_len>>3, + s->compressed_len-7*last)); +} + +/* =========================================================================== + * Save the match info and tally the frequency counts. Return true if + * the current block must be flushed. + */ +int _tr_tally (s, dist, lc) + deflate_state *s; + unsigned dist; /* distance of matched string */ + unsigned lc; /* match length-MIN_MATCH or unmatched char (if dist==0) */ +{ + s->d_buf[s->last_lit] = (ush)dist; + s->l_buf[s->last_lit++] = (uch)lc; + if (dist == 0) { + /* lc is the unmatched char */ + s->dyn_ltree[lc].Freq++; + } else { + s->matches++; + /* Here, lc is the match length - MIN_MATCH */ + dist--; /* dist = match distance - 1 */ + Assert((ush)dist < (ush)MAX_DIST(s) && + (ush)lc <= (ush)(MAX_MATCH-MIN_MATCH) && + (ush)d_code(dist) < (ush)D_CODES, "_tr_tally: bad match"); + + s->dyn_ltree[_length_code[lc]+LITERALS+1].Freq++; + s->dyn_dtree[d_code(dist)].Freq++; + } + +#ifdef TRUNCATE_BLOCK + /* Try to guess if it is profitable to stop the current block here */ + if ((s->last_lit & 0x1fff) == 0 && s->level > 2) { + /* Compute an upper bound for the compressed length */ + ulg out_length = (ulg)s->last_lit*8L; + ulg in_length = (ulg)((long)s->strstart - s->block_start); + int dcode; + for (dcode = 0; dcode < D_CODES; dcode++) { + out_length += (ulg)s->dyn_dtree[dcode].Freq * + (5L+extra_dbits[dcode]); + } + out_length >>= 3; + Tracev((stderr,"\nlast_lit %u, in %ld, out ~%ld(%ld%%) ", + s->last_lit, in_length, out_length, + 100L - out_length*100L/in_length)); + if (s->matches < s->last_lit/2 && out_length < in_length/2) return 1; + } +#endif + return (s->last_lit == s->lit_bufsize-1); + /* We avoid equality with lit_bufsize because of wraparound at 64K + * on 16 bit machines and because stored blocks are restricted to + * 64K-1 bytes. + */ +} + +/* =========================================================================== + * Send the block data compressed using the given Huffman trees + */ +local void compress_block(s, ltree, dtree) + deflate_state *s; + ct_data *ltree; /* literal tree */ + ct_data *dtree; /* distance tree */ +{ + unsigned dist; /* distance of matched string */ + int lc; /* match length or unmatched char (if dist == 0) */ + unsigned lx = 0; /* running index in l_buf */ + unsigned code; /* the code to send */ + int extra; /* number of extra bits to send */ + + if (s->last_lit != 0) do { + dist = s->d_buf[lx]; + lc = s->l_buf[lx++]; + if (dist == 0) { + send_code(s, lc, ltree); /* send a literal byte */ + Tracecv(isgraph(lc), (stderr," '%c' ", lc)); + } else { + /* Here, lc is the match length - MIN_MATCH */ + code = _length_code[lc]; + send_code(s, code+LITERALS+1, ltree); /* send the length code */ + extra = extra_lbits[code]; + if (extra != 0) { + lc -= base_length[code]; + send_bits(s, lc, extra); /* send the extra length bits */ + } + dist--; /* dist is now the match distance - 1 */ + code = d_code(dist); + Assert (code < D_CODES, "bad d_code"); + + send_code(s, code, dtree); /* send the distance code */ + extra = extra_dbits[code]; + if (extra != 0) { + dist -= base_dist[code]; + send_bits(s, dist, extra); /* send the extra distance bits */ + } + } /* literal or match pair ? */ + + /* Check that the overlay between pending_buf and d_buf+l_buf is ok: */ + Assert((uInt)(s->pending) < s->lit_bufsize + 2*lx, + "pendingBuf overflow"); + + } while (lx < s->last_lit); + + send_code(s, END_BLOCK, ltree); + s->last_eob_len = ltree[END_BLOCK].Len; +} + +/* =========================================================================== + * Check if the data type is TEXT or BINARY, using the following algorithm: + * - TEXT if the two conditions below are satisfied: + * a) There are no non-portable control characters belonging to the + * "black list" (0..6, 14..25, 28..31). + * b) There is at least one printable character belonging to the + * "white list" (9 {TAB}, 10 {LF}, 13 {CR}, 32..255). + * - BINARY otherwise. + * - The following partially-portable control characters form a + * "gray list" that is ignored in this detection algorithm: + * (7 {BEL}, 8 {BS}, 11 {VT}, 12 {FF}, 26 {SUB}, 27 {ESC}). + * IN assertion: the fields Freq of dyn_ltree are set. + */ +local int detect_data_type(s) + deflate_state *s; +{ + /* black_mask is the bit mask of black-listed bytes + * set bits 0..6, 14..25, and 28..31 + * 0xf3ffc07f = binary 11110011111111111100000001111111 + */ + unsigned long black_mask = 0xf3ffc07fUL; + int n; + + /* Check for non-textual ("black-listed") bytes. */ + for (n = 0; n <= 31; n++, black_mask >>= 1) + if ((black_mask & 1) && (s->dyn_ltree[n].Freq != 0)) + return Z_BINARY; + + /* Check for textual ("white-listed") bytes. */ + if (s->dyn_ltree[9].Freq != 0 || s->dyn_ltree[10].Freq != 0 + || s->dyn_ltree[13].Freq != 0) + return Z_TEXT; + for (n = 32; n < LITERALS; n++) + if (s->dyn_ltree[n].Freq != 0) + return Z_TEXT; + + /* There are no "black-listed" or "white-listed" bytes: + * this stream either is empty or has tolerated ("gray-listed") bytes only. + */ + return Z_BINARY; +} + +/* =========================================================================== + * Reverse the first len bits of a code, using straightforward code (a faster + * method would use a table) + * IN assertion: 1 <= len <= 15 + */ +local unsigned bi_reverse(code, len) + unsigned code; /* the value to invert */ + int len; /* its bit length */ +{ + register unsigned res = 0; + do { + res |= code & 1; + code >>= 1, res <<= 1; + } while (--len > 0); + return res >> 1; +} + +/* =========================================================================== + * Flush the bit buffer, keeping at most 7 bits in it. + */ +local void bi_flush(s) + deflate_state *s; +{ + if (s->bi_valid == 16) { + put_short(s, s->bi_buf); + s->bi_buf = 0; + s->bi_valid = 0; + } else if (s->bi_valid >= 8) { + put_byte(s, (Byte)s->bi_buf); + s->bi_buf >>= 8; + s->bi_valid -= 8; + } +} + +/* =========================================================================== + * Flush the bit buffer and align the output on a byte boundary + */ +local void bi_windup(s) + deflate_state *s; +{ + if (s->bi_valid > 8) { + put_short(s, s->bi_buf); + } else if (s->bi_valid > 0) { + put_byte(s, (Byte)s->bi_buf); + } + s->bi_buf = 0; + s->bi_valid = 0; +#ifdef DEBUG + s->bits_sent = (s->bits_sent+7) & ~7; +#endif +} + +/* =========================================================================== + * Copy a stored block, storing first the length and its + * one's complement if requested. + */ +local void copy_block(s, buf, len, header) + deflate_state *s; + charf *buf; /* the input data */ + unsigned len; /* its length */ + int header; /* true if block header must be written */ +{ + bi_windup(s); /* align on byte boundary */ + s->last_eob_len = 8; /* enough lookahead for inflate */ + + if (header) { + put_short(s, (ush)len); + put_short(s, (ush)~len); +#ifdef DEBUG + s->bits_sent += 2*16; +#endif + } +#ifdef DEBUG + s->bits_sent += (ulg)len<<3; +#endif + while (len--) { + put_byte(s, *buf++); + } +} diff --git a/mk/linux/mojosetup/zlib/trees.h b/mk/linux/mojosetup/zlib/trees.h new file mode 100644 index 00000000..72facf90 --- /dev/null +++ b/mk/linux/mojosetup/zlib/trees.h @@ -0,0 +1,128 @@ +/* header created automatically with -DGEN_TREES_H */ + +local const ct_data static_ltree[L_CODES+2] = { +{{ 12},{ 8}}, {{140},{ 8}}, {{ 76},{ 8}}, {{204},{ 8}}, {{ 44},{ 8}}, +{{172},{ 8}}, {{108},{ 8}}, {{236},{ 8}}, {{ 28},{ 8}}, {{156},{ 8}}, +{{ 92},{ 8}}, {{220},{ 8}}, {{ 60},{ 8}}, {{188},{ 8}}, {{124},{ 8}}, +{{252},{ 8}}, {{ 2},{ 8}}, {{130},{ 8}}, {{ 66},{ 8}}, {{194},{ 8}}, +{{ 34},{ 8}}, {{162},{ 8}}, {{ 98},{ 8}}, {{226},{ 8}}, {{ 18},{ 8}}, +{{146},{ 8}}, {{ 82},{ 8}}, {{210},{ 8}}, {{ 50},{ 8}}, {{178},{ 8}}, +{{114},{ 8}}, {{242},{ 8}}, {{ 10},{ 8}}, {{138},{ 8}}, {{ 74},{ 8}}, +{{202},{ 8}}, {{ 42},{ 8}}, {{170},{ 8}}, {{106},{ 8}}, {{234},{ 8}}, +{{ 26},{ 8}}, {{154},{ 8}}, {{ 90},{ 8}}, {{218},{ 8}}, {{ 58},{ 8}}, +{{186},{ 8}}, {{122},{ 8}}, {{250},{ 8}}, {{ 6},{ 8}}, {{134},{ 8}}, +{{ 70},{ 8}}, {{198},{ 8}}, {{ 38},{ 8}}, {{166},{ 8}}, {{102},{ 8}}, +{{230},{ 8}}, {{ 22},{ 8}}, {{150},{ 8}}, {{ 86},{ 8}}, {{214},{ 8}}, +{{ 54},{ 8}}, {{182},{ 8}}, {{118},{ 8}}, {{246},{ 8}}, {{ 14},{ 8}}, +{{142},{ 8}}, {{ 78},{ 8}}, {{206},{ 8}}, {{ 46},{ 8}}, {{174},{ 8}}, +{{110},{ 8}}, {{238},{ 8}}, {{ 30},{ 8}}, {{158},{ 8}}, {{ 94},{ 8}}, +{{222},{ 8}}, {{ 62},{ 8}}, {{190},{ 8}}, {{126},{ 8}}, {{254},{ 8}}, +{{ 1},{ 8}}, {{129},{ 8}}, {{ 65},{ 8}}, {{193},{ 8}}, {{ 33},{ 8}}, +{{161},{ 8}}, {{ 97},{ 8}}, {{225},{ 8}}, {{ 17},{ 8}}, {{145},{ 8}}, +{{ 81},{ 8}}, {{209},{ 8}}, {{ 49},{ 8}}, {{177},{ 8}}, {{113},{ 8}}, +{{241},{ 8}}, {{ 9},{ 8}}, {{137},{ 8}}, {{ 73},{ 8}}, {{201},{ 8}}, +{{ 41},{ 8}}, {{169},{ 8}}, {{105},{ 8}}, {{233},{ 8}}, {{ 25},{ 8}}, +{{153},{ 8}}, {{ 89},{ 8}}, {{217},{ 8}}, {{ 57},{ 8}}, {{185},{ 8}}, +{{121},{ 8}}, {{249},{ 8}}, {{ 5},{ 8}}, {{133},{ 8}}, {{ 69},{ 8}}, +{{197},{ 8}}, {{ 37},{ 8}}, {{165},{ 8}}, {{101},{ 8}}, {{229},{ 8}}, +{{ 21},{ 8}}, {{149},{ 8}}, {{ 85},{ 8}}, {{213},{ 8}}, {{ 53},{ 8}}, +{{181},{ 8}}, {{117},{ 8}}, {{245},{ 8}}, {{ 13},{ 8}}, {{141},{ 8}}, +{{ 77},{ 8}}, {{205},{ 8}}, {{ 45},{ 8}}, {{173},{ 8}}, {{109},{ 8}}, +{{237},{ 8}}, {{ 29},{ 8}}, {{157},{ 8}}, {{ 93},{ 8}}, {{221},{ 8}}, +{{ 61},{ 8}}, {{189},{ 8}}, {{125},{ 8}}, {{253},{ 8}}, {{ 19},{ 9}}, +{{275},{ 9}}, {{147},{ 9}}, {{403},{ 9}}, {{ 83},{ 9}}, {{339},{ 9}}, +{{211},{ 9}}, {{467},{ 9}}, {{ 51},{ 9}}, {{307},{ 9}}, {{179},{ 9}}, +{{435},{ 9}}, {{115},{ 9}}, {{371},{ 9}}, {{243},{ 9}}, {{499},{ 9}}, +{{ 11},{ 9}}, {{267},{ 9}}, {{139},{ 9}}, {{395},{ 9}}, {{ 75},{ 9}}, +{{331},{ 9}}, {{203},{ 9}}, {{459},{ 9}}, {{ 43},{ 9}}, {{299},{ 9}}, +{{171},{ 9}}, {{427},{ 9}}, {{107},{ 9}}, {{363},{ 9}}, {{235},{ 9}}, +{{491},{ 9}}, {{ 27},{ 9}}, {{283},{ 9}}, {{155},{ 9}}, {{411},{ 9}}, +{{ 91},{ 9}}, {{347},{ 9}}, {{219},{ 9}}, {{475},{ 9}}, {{ 59},{ 9}}, +{{315},{ 9}}, {{187},{ 9}}, {{443},{ 9}}, {{123},{ 9}}, {{379},{ 9}}, +{{251},{ 9}}, {{507},{ 9}}, {{ 7},{ 9}}, {{263},{ 9}}, {{135},{ 9}}, +{{391},{ 9}}, {{ 71},{ 9}}, {{327},{ 9}}, {{199},{ 9}}, {{455},{ 9}}, +{{ 39},{ 9}}, {{295},{ 9}}, {{167},{ 9}}, {{423},{ 9}}, {{103},{ 9}}, +{{359},{ 9}}, {{231},{ 9}}, {{487},{ 9}}, {{ 23},{ 9}}, {{279},{ 9}}, +{{151},{ 9}}, {{407},{ 9}}, {{ 87},{ 9}}, {{343},{ 9}}, {{215},{ 9}}, +{{471},{ 9}}, {{ 55},{ 9}}, {{311},{ 9}}, {{183},{ 9}}, {{439},{ 9}}, +{{119},{ 9}}, {{375},{ 9}}, {{247},{ 9}}, {{503},{ 9}}, {{ 15},{ 9}}, +{{271},{ 9}}, {{143},{ 9}}, {{399},{ 9}}, {{ 79},{ 9}}, {{335},{ 9}}, +{{207},{ 9}}, {{463},{ 9}}, {{ 47},{ 9}}, {{303},{ 9}}, {{175},{ 9}}, +{{431},{ 9}}, {{111},{ 9}}, {{367},{ 9}}, {{239},{ 9}}, {{495},{ 9}}, +{{ 31},{ 9}}, {{287},{ 9}}, {{159},{ 9}}, {{415},{ 9}}, {{ 95},{ 9}}, +{{351},{ 9}}, {{223},{ 9}}, {{479},{ 9}}, {{ 63},{ 9}}, {{319},{ 9}}, +{{191},{ 9}}, {{447},{ 9}}, {{127},{ 9}}, {{383},{ 9}}, {{255},{ 9}}, +{{511},{ 9}}, {{ 0},{ 7}}, {{ 64},{ 7}}, {{ 32},{ 7}}, {{ 96},{ 7}}, +{{ 16},{ 7}}, {{ 80},{ 7}}, {{ 48},{ 7}}, {{112},{ 7}}, {{ 8},{ 7}}, +{{ 72},{ 7}}, {{ 40},{ 7}}, {{104},{ 7}}, {{ 24},{ 7}}, {{ 88},{ 7}}, +{{ 56},{ 7}}, {{120},{ 7}}, {{ 4},{ 7}}, {{ 68},{ 7}}, {{ 36},{ 7}}, +{{100},{ 7}}, {{ 20},{ 7}}, {{ 84},{ 7}}, {{ 52},{ 7}}, {{116},{ 7}}, +{{ 3},{ 8}}, {{131},{ 8}}, {{ 67},{ 8}}, {{195},{ 8}}, {{ 35},{ 8}}, +{{163},{ 8}}, {{ 99},{ 8}}, {{227},{ 8}} +}; + +local const ct_data static_dtree[D_CODES] = { +{{ 0},{ 5}}, {{16},{ 5}}, {{ 8},{ 5}}, {{24},{ 5}}, {{ 4},{ 5}}, +{{20},{ 5}}, {{12},{ 5}}, {{28},{ 5}}, {{ 2},{ 5}}, {{18},{ 5}}, +{{10},{ 5}}, {{26},{ 5}}, {{ 6},{ 5}}, {{22},{ 5}}, {{14},{ 5}}, +{{30},{ 5}}, {{ 1},{ 5}}, {{17},{ 5}}, {{ 9},{ 5}}, {{25},{ 5}}, +{{ 5},{ 5}}, {{21},{ 5}}, {{13},{ 5}}, {{29},{ 5}}, {{ 3},{ 5}}, +{{19},{ 5}}, {{11},{ 5}}, {{27},{ 5}}, {{ 7},{ 5}}, {{23},{ 5}} +}; + +const uch _dist_code[DIST_CODE_LEN] = { + 0, 1, 2, 3, 4, 4, 5, 5, 6, 6, 6, 6, 7, 7, 7, 7, 8, 8, 8, 8, + 8, 8, 8, 8, 9, 9, 9, 9, 9, 9, 9, 9, 10, 10, 10, 10, 10, 10, 10, 10, +10, 10, 10, 10, 10, 10, 10, 10, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, +11, 11, 11, 11, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, +12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 13, 13, 13, 13, +13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, +13, 13, 13, 13, 13, 13, 13, 13, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, +14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, +14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, +14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 15, 15, 15, 15, 15, 15, 15, 15, +15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, +15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, +15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 0, 0, 16, 17, +18, 18, 19, 19, 20, 20, 20, 20, 21, 21, 21, 21, 22, 22, 22, 22, 22, 22, 22, 22, +23, 23, 23, 23, 23, 23, 23, 23, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, +24, 24, 24, 24, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, +26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, +26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 27, 27, 27, 27, 27, 27, 27, 27, +27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, +27, 27, 27, 27, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, +28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, +28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, +28, 28, 28, 28, 28, 28, 28, 28, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, +29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, +29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, +29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29 +}; + +const uch _length_code[MAX_MATCH-MIN_MATCH+1]= { + 0, 1, 2, 3, 4, 5, 6, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 12, 12, +13, 13, 13, 13, 14, 14, 14, 14, 15, 15, 15, 15, 16, 16, 16, 16, 16, 16, 16, 16, +17, 17, 17, 17, 17, 17, 17, 17, 18, 18, 18, 18, 18, 18, 18, 18, 19, 19, 19, 19, +19, 19, 19, 19, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, +21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 22, 22, 22, 22, +22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 23, 23, 23, 23, 23, 23, 23, 23, +23, 23, 23, 23, 23, 23, 23, 23, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, +24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, +25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, +25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 26, 26, 26, 26, 26, 26, 26, 26, +26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, +26, 26, 26, 26, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, +27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 28 +}; + +local const int base_length[LENGTH_CODES] = { +0, 1, 2, 3, 4, 5, 6, 7, 8, 10, 12, 14, 16, 20, 24, 28, 32, 40, 48, 56, +64, 80, 96, 112, 128, 160, 192, 224, 0 +}; + +local const int base_dist[D_CODES] = { + 0, 1, 2, 3, 4, 6, 8, 12, 16, 24, + 32, 48, 64, 96, 128, 192, 256, 384, 512, 768, + 1024, 1536, 2048, 3072, 4096, 6144, 8192, 12288, 16384, 24576 +}; + diff --git a/mk/linux/mojosetup/zlib/uncompr.c b/mk/linux/mojosetup/zlib/uncompr.c new file mode 100644 index 00000000..ad98be3a --- /dev/null +++ b/mk/linux/mojosetup/zlib/uncompr.c @@ -0,0 +1,59 @@ +/* uncompr.c -- decompress a memory buffer + * Copyright (C) 1995-2003, 2010 Jean-loup Gailly. + * For conditions of distribution and use, see copyright notice in zlib.h + */ + +/* @(#) $Id$ */ + +#define ZLIB_INTERNAL +#include "zlib.h" + +/* =========================================================================== + Decompresses the source buffer into the destination buffer. sourceLen is + the byte length of the source buffer. Upon entry, destLen is the total + size of the destination buffer, which must be large enough to hold the + entire uncompressed data. (The size of the uncompressed data must have + been saved previously by the compressor and transmitted to the decompressor + by some mechanism outside the scope of this compression library.) + Upon exit, destLen is the actual size of the compressed buffer. + + uncompress returns Z_OK if success, Z_MEM_ERROR if there was not + enough memory, Z_BUF_ERROR if there was not enough room in the output + buffer, or Z_DATA_ERROR if the input data was corrupted. +*/ +int ZEXPORT uncompress (dest, destLen, source, sourceLen) + Bytef *dest; + uLongf *destLen; + const Bytef *source; + uLong sourceLen; +{ + z_stream stream; + int err; + + stream.next_in = (Bytef*)source; + stream.avail_in = (uInt)sourceLen; + /* Check for source > 64K on 16-bit machine: */ + if ((uLong)stream.avail_in != sourceLen) return Z_BUF_ERROR; + + stream.next_out = dest; + stream.avail_out = (uInt)*destLen; + if ((uLong)stream.avail_out != *destLen) return Z_BUF_ERROR; + + stream.zalloc = (alloc_func)0; + stream.zfree = (free_func)0; + + err = inflateInit(&stream); + if (err != Z_OK) return err; + + err = inflate(&stream, Z_FINISH); + if (err != Z_STREAM_END) { + inflateEnd(&stream); + if (err == Z_NEED_DICT || (err == Z_BUF_ERROR && stream.avail_in == 0)) + return Z_DATA_ERROR; + return err; + } + *destLen = stream.total_out; + + err = inflateEnd(&stream); + return err; +} diff --git a/mk/linux/mojosetup/zlib/version.txt b/mk/linux/mojosetup/zlib/version.txt new file mode 100644 index 00000000..5c5d8f26 --- /dev/null +++ b/mk/linux/mojosetup/zlib/version.txt @@ -0,0 +1 @@ +zlib-1.2.4 diff --git a/mk/linux/mojosetup/zlib/zconf.h b/mk/linux/mojosetup/zlib/zconf.h new file mode 100644 index 00000000..58880245 --- /dev/null +++ b/mk/linux/mojosetup/zlib/zconf.h @@ -0,0 +1,416 @@ +/* zconf.h -- configuration of the zlib compression library + * Copyright (C) 1995-2010 Jean-loup Gailly. + * For conditions of distribution and use, see copyright notice in zlib.h + */ + +/* @(#) $Id$ */ + +#ifndef ZCONF_H +#define ZCONF_H + +/* + * If you *really* need a unique prefix for all types and library functions, + * compile with -DZ_PREFIX. The "standard" zlib should be compiled without it. + * Even better than compiling with -DZ_PREFIX would be to use configure to set + * this permanently in zconf.h using "./configure --zprefix". + */ +#ifdef Z_PREFIX /* may be set to #if 1 by ./configure */ + +/* all linked symbols */ +# define _dist_code z__dist_code +# define _length_code z__length_code +# define _tr_align z__tr_align +# define _tr_flush_block z__tr_flush_block +# define _tr_init z__tr_init +# define _tr_stored_block z__tr_stored_block +# define _tr_tally z__tr_tally +# define adler32 z_adler32 +# define adler32_combine z_adler32_combine +# define adler32_combine64 z_adler32_combine64 +# define compress z_compress +# define compress2 z_compress2 +# define compressBound z_compressBound +# define crc32 z_crc32 +# define crc32_combine z_crc32_combine +# define crc32_combine64 z_crc32_combine64 +# define deflate z_deflate +# define deflateBound z_deflateBound +# define deflateCopy z_deflateCopy +# define deflateEnd z_deflateEnd +# define deflateInit2_ z_deflateInit2_ +# define deflateInit_ z_deflateInit_ +# define deflateParams z_deflateParams +# define deflatePrime z_deflatePrime +# define deflateReset z_deflateReset +# define deflateSetDictionary z_deflateSetDictionary +# define deflateSetHeader z_deflateSetHeader +# define deflateTune z_deflateTune +# define deflate_copyright z_deflate_copyright +# define get_crc_table z_get_crc_table +# define gz_error z_gz_error +# define gz_intmax z_gz_intmax +# define gz_strwinerror z_gz_strwinerror +# define gzbuffer z_gzbuffer +# define gzclearerr z_gzclearerr +# define gzclose z_gzclose +# define gzclose_r z_gzclose_r +# define gzclose_w z_gzclose_w +# define gzdirect z_gzdirect +# define gzdopen z_gzdopen +# define gzeof z_gzeof +# define gzerror z_gzerror +# define gzflush z_gzflush +# define gzgetc z_gzgetc +# define gzgets z_gzgets +# define gzoffset z_gzoffset +# define gzoffset64 z_gzoffset64 +# define gzopen z_gzopen +# define gzopen64 z_gzopen64 +# define gzprintf z_gzprintf +# define gzputc z_gzputc +# define gzputs z_gzputs +# define gzread z_gzread +# define gzrewind z_gzrewind +# define gzseek z_gzseek +# define gzseek64 z_gzseek64 +# define gzsetparams z_gzsetparams +# define gztell z_gztell +# define gztell64 z_gztell64 +# define gzungetc z_gzungetc +# define gzwrite z_gzwrite +# define inflate z_inflate +# define inflateBack z_inflateBack +# define inflateBackEnd z_inflateBackEnd +# define inflateBackInit_ z_inflateBackInit_ +# define inflateCopy z_inflateCopy +# define inflateEnd z_inflateEnd +# define inflateGetHeader z_inflateGetHeader +# define inflateInit2_ z_inflateInit2_ +# define inflateInit_ z_inflateInit_ +# define inflateMark z_inflateMark +# define inflatePrime z_inflatePrime +# define inflateReset z_inflateReset +# define inflateReset2 z_inflateReset2 +# define inflateSetDictionary z_inflateSetDictionary +# define inflateSync z_inflateSync +# define inflateSyncPoint z_inflateSyncPoint +# define inflateUndermine z_inflateUndermine +# define inflate_copyright z_inflate_copyright +# define inflate_fast z_inflate_fast +# define inflate_table z_inflate_table +# define uncompress z_uncompress +# define zError z_zError +# define zcalloc z_zcalloc +# define zcfree z_zcfree +# define zlibCompileFlags z_zlibCompileFlags +# define zlibVersion z_zlibVersion + +/* all zlib typedefs in zlib.h and zconf.h */ +# define Byte z_Byte +# define Bytef z_Bytef +# define alloc_func z_alloc_func +# define charf z_charf +# define free_func z_free_func +# define gzFile z_gzFile +# define gz_header z_gz_header +# define gz_headerp z_gz_headerp +# define in_func z_in_func +# define intf z_intf +# define out_func z_out_func +# define uInt z_uInt +# define uIntf z_uIntf +# define uLong z_uLong +# define uLongf z_uLongf +# define voidp z_voidp +# define voidpc z_voidpc +# define voidpf z_voidpf + +/* all zlib structs in zlib.h and zconf.h */ +# define gz_header_s z_gz_header_s +# define internal_state z_internal_state + +#endif + +#if defined(__MSDOS__) && !defined(MSDOS) +# define MSDOS +#endif +#if (defined(OS_2) || defined(__OS2__)) && !defined(OS2) +# define OS2 +#endif +#if defined(_WINDOWS) && !defined(WINDOWS) +# define WINDOWS +#endif +#if defined(_WIN32) || defined(_WIN32_WCE) || defined(__WIN32__) +# ifndef WIN32 +# define WIN32 +# endif +#endif +#if (defined(MSDOS) || defined(OS2) || defined(WINDOWS)) && !defined(WIN32) +# if !defined(__GNUC__) && !defined(__FLAT__) && !defined(__386__) +# ifndef SYS16BIT +# define SYS16BIT +# endif +# endif +#endif + +/* + * Compile with -DMAXSEG_64K if the alloc function cannot allocate more + * than 64k bytes at a time (needed on systems with 16-bit int). + */ +#ifdef SYS16BIT +# define MAXSEG_64K +#endif +#ifdef MSDOS +# define UNALIGNED_OK +#endif + +#ifdef __STDC_VERSION__ +# ifndef STDC +# define STDC +# endif +# if __STDC_VERSION__ >= 199901L +# ifndef STDC99 +# define STDC99 +# endif +# endif +#endif +#if !defined(STDC) && (defined(__STDC__) || defined(__cplusplus)) +# define STDC +#endif +#if !defined(STDC) && (defined(__GNUC__) || defined(__BORLANDC__)) +# define STDC +#endif +#if !defined(STDC) && (defined(MSDOS) || defined(WINDOWS) || defined(WIN32)) +# define STDC +#endif +#if !defined(STDC) && (defined(OS2) || defined(__HOS_AIX__)) +# define STDC +#endif + +#if defined(__OS400__) && !defined(STDC) /* iSeries (formerly AS/400). */ +# define STDC +#endif + +#ifndef STDC +# ifndef const /* cannot use !defined(STDC) && !defined(const) on Mac */ +# define const /* note: need a more gentle solution here */ +# endif +#endif + +/* Some Mac compilers merge all .h files incorrectly: */ +#if defined(__MWERKS__)||defined(applec)||defined(THINK_C)||defined(__SC__) +# define NO_DUMMY_DECL +#endif + +/* Maximum value for memLevel in deflateInit2 */ +#ifndef MAX_MEM_LEVEL +# ifdef MAXSEG_64K +# define MAX_MEM_LEVEL 8 +# else +# define MAX_MEM_LEVEL 9 +# endif +#endif + +/* Maximum value for windowBits in deflateInit2 and inflateInit2. + * WARNING: reducing MAX_WBITS makes minigzip unable to extract .gz files + * created by gzip. (Files created by minigzip can still be extracted by + * gzip.) + */ +#ifndef MAX_WBITS +# define MAX_WBITS 15 /* 32K LZ77 window */ +#endif + +/* The memory requirements for deflate are (in bytes): + (1 << (windowBits+2)) + (1 << (memLevel+9)) + that is: 128K for windowBits=15 + 128K for memLevel = 8 (default values) + plus a few kilobytes for small objects. For example, if you want to reduce + the default memory requirements from 256K to 128K, compile with + make CFLAGS="-O -DMAX_WBITS=14 -DMAX_MEM_LEVEL=7" + Of course this will generally degrade compression (there's no free lunch). + + The memory requirements for inflate are (in bytes) 1 << windowBits + that is, 32K for windowBits=15 (default value) plus a few kilobytes + for small objects. +*/ + + /* Type declarations */ + +#ifndef OF /* function prototypes */ +# ifdef STDC +# define OF(args) args +# else +# define OF(args) () +# endif +#endif + +/* The following definitions for FAR are needed only for MSDOS mixed + * model programming (small or medium model with some far allocations). + * This was tested only with MSC; for other MSDOS compilers you may have + * to define NO_MEMCPY in zutil.h. If you don't need the mixed model, + * just define FAR to be empty. + */ +#ifdef SYS16BIT +# if defined(M_I86SM) || defined(M_I86MM) + /* MSC small or medium model */ +# define SMALL_MEDIUM +# ifdef _MSC_VER +# define FAR _far +# else +# define FAR far +# endif +# endif +# if (defined(__SMALL__) || defined(__MEDIUM__)) + /* Turbo C small or medium model */ +# define SMALL_MEDIUM +# ifdef __BORLANDC__ +# define FAR _far +# else +# define FAR far +# endif +# endif +#endif + +#if defined(WINDOWS) || defined(WIN32) + /* If building or using zlib as a DLL, define ZLIB_DLL. + * This is not mandatory, but it offers a little performance increase. + */ +# ifdef ZLIB_DLL +# if defined(WIN32) && (!defined(__BORLANDC__) || (__BORLANDC__ >= 0x500)) +# ifdef ZLIB_INTERNAL +# define ZEXTERN extern __declspec(dllexport) +# else +# define ZEXTERN extern __declspec(dllimport) +# endif +# endif +# endif /* ZLIB_DLL */ + /* If building or using zlib with the WINAPI/WINAPIV calling convention, + * define ZLIB_WINAPI. + * Caution: the standard ZLIB1.DLL is NOT compiled using ZLIB_WINAPI. + */ +# ifdef ZLIB_WINAPI +# ifdef FAR +# undef FAR +# endif +# include + /* No need for _export, use ZLIB.DEF instead. */ + /* For complete Windows compatibility, use WINAPI, not __stdcall. */ +# define ZEXPORT WINAPI +# ifdef WIN32 +# define ZEXPORTVA WINAPIV +# else +# define ZEXPORTVA FAR CDECL +# endif +# endif +#endif + +#if defined (__BEOS__) +# ifdef ZLIB_DLL +# ifdef ZLIB_INTERNAL +# define ZEXPORT __declspec(dllexport) +# define ZEXPORTVA __declspec(dllexport) +# else +# define ZEXPORT __declspec(dllimport) +# define ZEXPORTVA __declspec(dllimport) +# endif +# endif +#endif + +#ifdef HAVE_VISIBILITY_PRAGMA +# define ZEXTERN __attribute__((visibility ("default"))) extern +#endif + +#ifndef ZEXTERN +# define ZEXTERN extern +#endif +#ifndef ZEXPORT +# define ZEXPORT +#endif +#ifndef ZEXPORTVA +# define ZEXPORTVA +#endif + +#ifndef FAR +# define FAR +#endif + +#if !defined(__MACTYPES__) +typedef unsigned char Byte; /* 8 bits */ +#endif +typedef unsigned int uInt; /* 16 bits or more */ +typedef unsigned long uLong; /* 32 bits or more */ + +#ifdef SMALL_MEDIUM + /* Borland C/C++ and some old MSC versions ignore FAR inside typedef */ +# define Bytef Byte FAR +#else + typedef Byte FAR Bytef; +#endif +typedef char FAR charf; +typedef int FAR intf; +typedef uInt FAR uIntf; +typedef uLong FAR uLongf; + +#ifdef STDC + typedef void const *voidpc; + typedef void FAR *voidpf; + typedef void *voidp; +#else + typedef Byte const *voidpc; + typedef Byte FAR *voidpf; + typedef Byte *voidp; +#endif + +#ifdef HAVE_UNISTD_H /* may be set to #if 1 by ./configure */ +# define Z_HAVE_UNISTD_H +#endif + +#ifdef Z_HAVE_UNISTD_H +# include /* for off_t */ +# include /* for SEEK_* and off_t */ +# ifdef VMS +# include /* for off_t */ +# endif +# ifndef z_off_t +# define z_off_t off_t +# endif +#endif + +#ifdef _LARGEFILE64_SOURCE +# include +#endif + +#ifndef SEEK_SET +# define SEEK_SET 0 /* Seek from beginning of file. */ +# define SEEK_CUR 1 /* Seek from current position. */ +# define SEEK_END 2 /* Set file pointer to EOF plus "offset" */ +#endif +#ifndef z_off_t +# define z_off_t long +#endif + +#if defined(__OS400__) +# define NO_vsnprintf +#endif + +#if defined(__MVS__) +# define NO_vsnprintf +#endif + +/* MVS linker does not support external names larger than 8 bytes */ +#if defined(__MVS__) + #pragma map(deflateInit_,"DEIN") + #pragma map(deflateInit2_,"DEIN2") + #pragma map(deflateEnd,"DEEND") + #pragma map(deflateBound,"DEBND") + #pragma map(inflateInit_,"ININ") + #pragma map(inflateInit2_,"ININ2") + #pragma map(inflateEnd,"INEND") + #pragma map(inflateSync,"INSY") + #pragma map(inflateSetDictionary,"INSEDI") + #pragma map(compressBound,"CMBND") + #pragma map(inflate_table,"INTABL") + #pragma map(inflate_fast,"INFA") + #pragma map(inflate_copyright,"INCOPY") +#endif + +#endif /* ZCONF_H */ diff --git a/mk/linux/mojosetup/zlib/zlib.h b/mk/linux/mojosetup/zlib/zlib.h new file mode 100644 index 00000000..f5785be7 --- /dev/null +++ b/mk/linux/mojosetup/zlib/zlib.h @@ -0,0 +1,1605 @@ +/* zlib.h -- interface of the 'zlib' general purpose compression library + version 1.2.4, Mar 14th, 2010 + + Copyright (C) 1995-2010 Jean-loup Gailly and Mark Adler + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. + + Jean-loup Gailly Mark Adler + jloup@gzip.org madler@alumni.caltech.edu + + + The data format used by the zlib library is described by RFCs (Request for + Comments) 1950 to 1952 in the files http://www.ietf.org/rfc/rfc1950.txt + (zlib format), rfc1951.txt (deflate format) and rfc1952.txt (gzip format). +*/ + +#ifndef ZLIB_H +#define ZLIB_H + +#include "zconf.h" + +#ifdef __cplusplus +extern "C" { +#endif + +#define ZLIB_VERSION "1.2.4" +#define ZLIB_VERNUM 0x1240 +#define ZLIB_VER_MAJOR 1 +#define ZLIB_VER_MINOR 2 +#define ZLIB_VER_REVISION 4 +#define ZLIB_VER_SUBREVISION 0 + +/* + The 'zlib' compression library provides in-memory compression and + decompression functions, including integrity checks of the uncompressed data. + This version of the library supports only one compression method (deflation) + but other algorithms will be added later and will have the same stream + interface. + + Compression can be done in a single step if the buffers are large enough, + or can be done by repeated calls of the compression function. In the latter + case, the application must provide more input and/or consume the output + (providing more output space) before each call. + + The compressed data format used by default by the in-memory functions is + the zlib format, which is a zlib wrapper documented in RFC 1950, wrapped + around a deflate stream, which is itself documented in RFC 1951. + + The library also supports reading and writing files in gzip (.gz) format + with an interface similar to that of stdio using the functions that start + with "gz". The gzip format is different from the zlib format. gzip is a + gzip wrapper, documented in RFC 1952, wrapped around a deflate stream. + + This library can optionally read and write gzip streams in memory as well. + + The zlib format was designed to be compact and fast for use in memory + and on communications channels. The gzip format was designed for single- + file compression on file systems, has a larger header than zlib to maintain + directory information, and uses a different, slower check method than zlib. + + The library does not install any signal handler. The decoder checks + the consistency of the compressed data, so the library should never crash + even in case of corrupted input. +*/ + +typedef voidpf (*alloc_func) OF((voidpf opaque, uInt items, uInt size)); +typedef void (*free_func) OF((voidpf opaque, voidpf address)); + +struct internal_state; + +typedef struct z_stream_s { + Bytef *next_in; /* next input byte */ + uInt avail_in; /* number of bytes available at next_in */ + uLong total_in; /* total nb of input bytes read so far */ + + Bytef *next_out; /* next output byte should be put there */ + uInt avail_out; /* remaining free space at next_out */ + uLong total_out; /* total nb of bytes output so far */ + + char *msg; /* last error message, NULL if no error */ + struct internal_state FAR *state; /* not visible by applications */ + + alloc_func zalloc; /* used to allocate the internal state */ + free_func zfree; /* used to free the internal state */ + voidpf opaque; /* private data object passed to zalloc and zfree */ + + int data_type; /* best guess about the data type: binary or text */ + uLong adler; /* adler32 value of the uncompressed data */ + uLong reserved; /* reserved for future use */ +} z_stream; + +typedef z_stream FAR *z_streamp; + +/* + gzip header information passed to and from zlib routines. See RFC 1952 + for more details on the meanings of these fields. +*/ +typedef struct gz_header_s { + int text; /* true if compressed data believed to be text */ + uLong time; /* modification time */ + int xflags; /* extra flags (not used when writing a gzip file) */ + int os; /* operating system */ + Bytef *extra; /* pointer to extra field or Z_NULL if none */ + uInt extra_len; /* extra field length (valid if extra != Z_NULL) */ + uInt extra_max; /* space at extra (only when reading header) */ + Bytef *name; /* pointer to zero-terminated file name or Z_NULL */ + uInt name_max; /* space at name (only when reading header) */ + Bytef *comment; /* pointer to zero-terminated comment or Z_NULL */ + uInt comm_max; /* space at comment (only when reading header) */ + int hcrc; /* true if there was or will be a header crc */ + int done; /* true when done reading gzip header (not used + when writing a gzip file) */ +} gz_header; + +typedef gz_header FAR *gz_headerp; + +/* + The application must update next_in and avail_in when avail_in has dropped + to zero. It must update next_out and avail_out when avail_out has dropped + to zero. The application must initialize zalloc, zfree and opaque before + calling the init function. All other fields are set by the compression + library and must not be updated by the application. + + The opaque value provided by the application will be passed as the first + parameter for calls of zalloc and zfree. This can be useful for custom + memory management. The compression library attaches no meaning to the + opaque value. + + zalloc must return Z_NULL if there is not enough memory for the object. + If zlib is used in a multi-threaded application, zalloc and zfree must be + thread safe. + + On 16-bit systems, the functions zalloc and zfree must be able to allocate + exactly 65536 bytes, but will not be required to allocate more than this if + the symbol MAXSEG_64K is defined (see zconf.h). WARNING: On MSDOS, pointers + returned by zalloc for objects of exactly 65536 bytes *must* have their + offset normalized to zero. The default allocation function provided by this + library ensures this (see zutil.c). To reduce memory requirements and avoid + any allocation of 64K objects, at the expense of compression ratio, compile + the library with -DMAX_WBITS=14 (see zconf.h). + + The fields total_in and total_out can be used for statistics or progress + reports. After compression, total_in holds the total size of the + uncompressed data and may be saved for use in the decompressor (particularly + if the decompressor wants to decompress everything in a single step). +*/ + + /* constants */ + +#define Z_NO_FLUSH 0 +#define Z_PARTIAL_FLUSH 1 +#define Z_SYNC_FLUSH 2 +#define Z_FULL_FLUSH 3 +#define Z_FINISH 4 +#define Z_BLOCK 5 +#define Z_TREES 6 +/* Allowed flush values; see deflate() and inflate() below for details */ + +#define Z_OK 0 +#define Z_STREAM_END 1 +#define Z_NEED_DICT 2 +#define Z_ERRNO (-1) +#define Z_STREAM_ERROR (-2) +#define Z_DATA_ERROR (-3) +#define Z_MEM_ERROR (-4) +#define Z_BUF_ERROR (-5) +#define Z_VERSION_ERROR (-6) +/* Return codes for the compression/decompression functions. Negative values + * are errors, positive values are used for special but normal events. + */ + +#define Z_NO_COMPRESSION 0 +#define Z_BEST_SPEED 1 +#define Z_BEST_COMPRESSION 9 +#define Z_DEFAULT_COMPRESSION (-1) +/* compression levels */ + +#define Z_FILTERED 1 +#define Z_HUFFMAN_ONLY 2 +#define Z_RLE 3 +#define Z_FIXED 4 +#define Z_DEFAULT_STRATEGY 0 +/* compression strategy; see deflateInit2() below for details */ + +#define Z_BINARY 0 +#define Z_TEXT 1 +#define Z_ASCII Z_TEXT /* for compatibility with 1.2.2 and earlier */ +#define Z_UNKNOWN 2 +/* Possible values of the data_type field (though see inflate()) */ + +#define Z_DEFLATED 8 +/* The deflate compression method (the only one supported in this version) */ + +#define Z_NULL 0 /* for initializing zalloc, zfree, opaque */ + +#define zlib_version zlibVersion() +/* for compatibility with versions < 1.0.2 */ + + + /* basic functions */ + +ZEXTERN const char * ZEXPORT zlibVersion OF((void)); +/* The application can compare zlibVersion and ZLIB_VERSION for consistency. + If the first character differs, the library code actually used is not + compatible with the zlib.h header file used by the application. This check + is automatically made by deflateInit and inflateInit. + */ + +/* +ZEXTERN int ZEXPORT deflateInit OF((z_streamp strm, int level)); + + Initializes the internal stream state for compression. The fields + zalloc, zfree and opaque must be initialized before by the caller. If + zalloc and zfree are set to Z_NULL, deflateInit updates them to use default + allocation functions. + + The compression level must be Z_DEFAULT_COMPRESSION, or between 0 and 9: + 1 gives best speed, 9 gives best compression, 0 gives no compression at all + (the input data is simply copied a block at a time). Z_DEFAULT_COMPRESSION + requests a default compromise between speed and compression (currently + equivalent to level 6). + + deflateInit returns Z_OK if success, Z_MEM_ERROR if there was not enough + memory, Z_STREAM_ERROR if level is not a valid compression level, or + Z_VERSION_ERROR if the zlib library version (zlib_version) is incompatible + with the version assumed by the caller (ZLIB_VERSION). msg is set to null + if there is no error message. deflateInit does not perform any compression: + this will be done by deflate(). +*/ + + +ZEXTERN int ZEXPORT deflate OF((z_streamp strm, int flush)); +/* + deflate compresses as much data as possible, and stops when the input + buffer becomes empty or the output buffer becomes full. It may introduce + some output latency (reading input without producing any output) except when + forced to flush. + + The detailed semantics are as follows. deflate performs one or both of the + following actions: + + - Compress more input starting at next_in and update next_in and avail_in + accordingly. If not all input can be processed (because there is not + enough room in the output buffer), next_in and avail_in are updated and + processing will resume at this point for the next call of deflate(). + + - Provide more output starting at next_out and update next_out and avail_out + accordingly. This action is forced if the parameter flush is non zero. + Forcing flush frequently degrades the compression ratio, so this parameter + should be set only when necessary (in interactive applications). Some + output may be provided even if flush is not set. + + Before the call of deflate(), the application should ensure that at least + one of the actions is possible, by providing more input and/or consuming more + output, and updating avail_in or avail_out accordingly; avail_out should + never be zero before the call. The application can consume the compressed + output when it wants, for example when the output buffer is full (avail_out + == 0), or after each call of deflate(). If deflate returns Z_OK and with + zero avail_out, it must be called again after making room in the output + buffer because there might be more output pending. + + Normally the parameter flush is set to Z_NO_FLUSH, which allows deflate to + decide how much data to accumulate before producing output, in order to + maximize compression. + + If the parameter flush is set to Z_SYNC_FLUSH, all pending output is + flushed to the output buffer and the output is aligned on a byte boundary, so + that the decompressor can get all input data available so far. (In + particular avail_in is zero after the call if enough output space has been + provided before the call.) Flushing may degrade compression for some + compression algorithms and so it should be used only when necessary. This + completes the current deflate block and follows it with an empty stored block + that is three bits plus filler bits to the next byte, followed by four bytes + (00 00 ff ff). + + If flush is set to Z_PARTIAL_FLUSH, all pending output is flushed to the + output buffer, but the output is not aligned to a byte boundary. All of the + input data so far will be available to the decompressor, as for Z_SYNC_FLUSH. + This completes the current deflate block and follows it with an empty fixed + codes block that is 10 bits long. This assures that enough bytes are output + in order for the decompressor to finish the block before the empty fixed code + block. + + If flush is set to Z_BLOCK, a deflate block is completed and emitted, as + for Z_SYNC_FLUSH, but the output is not aligned on a byte boundary, and up to + seven bits of the current block are held to be written as the next byte after + the next deflate block is completed. In this case, the decompressor may not + be provided enough bits at this point in order to complete decompression of + the data provided so far to the compressor. It may need to wait for the next + block to be emitted. This is for advanced applications that need to control + the emission of deflate blocks. + + If flush is set to Z_FULL_FLUSH, all output is flushed as with + Z_SYNC_FLUSH, and the compression state is reset so that decompression can + restart from this point if previous compressed data has been damaged or if + random access is desired. Using Z_FULL_FLUSH too often can seriously degrade + compression. + + If deflate returns with avail_out == 0, this function must be called again + with the same value of the flush parameter and more output space (updated + avail_out), until the flush is complete (deflate returns with non-zero + avail_out). In the case of a Z_FULL_FLUSH or Z_SYNC_FLUSH, make sure that + avail_out is greater than six to avoid repeated flush markers due to + avail_out == 0 on return. + + If the parameter flush is set to Z_FINISH, pending input is processed, + pending output is flushed and deflate returns with Z_STREAM_END if there was + enough output space; if deflate returns with Z_OK, this function must be + called again with Z_FINISH and more output space (updated avail_out) but no + more input data, until it returns with Z_STREAM_END or an error. After + deflate has returned Z_STREAM_END, the only possible operations on the stream + are deflateReset or deflateEnd. + + Z_FINISH can be used immediately after deflateInit if all the compression + is to be done in a single step. In this case, avail_out must be at least the + value returned by deflateBound (see below). If deflate does not return + Z_STREAM_END, then it must be called again as described above. + + deflate() sets strm->adler to the adler32 checksum of all input read + so far (that is, total_in bytes). + + deflate() may update strm->data_type if it can make a good guess about + the input data type (Z_BINARY or Z_TEXT). In doubt, the data is considered + binary. This field is only for information purposes and does not affect the + compression algorithm in any manner. + + deflate() returns Z_OK if some progress has been made (more input + processed or more output produced), Z_STREAM_END if all input has been + consumed and all output has been produced (only when flush is set to + Z_FINISH), Z_STREAM_ERROR if the stream state was inconsistent (for example + if next_in or next_out was Z_NULL), Z_BUF_ERROR if no progress is possible + (for example avail_in or avail_out was zero). Note that Z_BUF_ERROR is not + fatal, and deflate() can be called again with more input and more output + space to continue compressing. +*/ + + +ZEXTERN int ZEXPORT deflateEnd OF((z_streamp strm)); +/* + All dynamically allocated data structures for this stream are freed. + This function discards any unprocessed input and does not flush any pending + output. + + deflateEnd returns Z_OK if success, Z_STREAM_ERROR if the + stream state was inconsistent, Z_DATA_ERROR if the stream was freed + prematurely (some input or output was discarded). In the error case, msg + may be set but then points to a static string (which must not be + deallocated). +*/ + + +/* +ZEXTERN int ZEXPORT inflateInit OF((z_streamp strm)); + + Initializes the internal stream state for decompression. The fields + next_in, avail_in, zalloc, zfree and opaque must be initialized before by + the caller. If next_in is not Z_NULL and avail_in is large enough (the + exact value depends on the compression method), inflateInit determines the + compression method from the zlib header and allocates all data structures + accordingly; otherwise the allocation will be deferred to the first call of + inflate. If zalloc and zfree are set to Z_NULL, inflateInit updates them to + use default allocation functions. + + inflateInit returns Z_OK if success, Z_MEM_ERROR if there was not enough + memory, Z_VERSION_ERROR if the zlib library version is incompatible with the + version assumed by the caller, or Z_STREAM_ERROR if the parameters are + invalid, such as a null pointer to the structure. msg is set to null if + there is no error message. inflateInit does not perform any decompression + apart from possibly reading the zlib header if present: actual decompression + will be done by inflate(). (So next_in and avail_in may be modified, but + next_out and avail_out are unused and unchanged.) The current implementation + of inflateInit() does not process any header information -- that is deferred + until inflate() is called. +*/ + + +ZEXTERN int ZEXPORT inflate OF((z_streamp strm, int flush)); +/* + inflate decompresses as much data as possible, and stops when the input + buffer becomes empty or the output buffer becomes full. It may introduce + some output latency (reading input without producing any output) except when + forced to flush. + + The detailed semantics are as follows. inflate performs one or both of the + following actions: + + - Decompress more input starting at next_in and update next_in and avail_in + accordingly. If not all input can be processed (because there is not + enough room in the output buffer), next_in is updated and processing will + resume at this point for the next call of inflate(). + + - Provide more output starting at next_out and update next_out and avail_out + accordingly. inflate() provides as much output as possible, until there is + no more input data or no more space in the output buffer (see below about + the flush parameter). + + Before the call of inflate(), the application should ensure that at least + one of the actions is possible, by providing more input and/or consuming more + output, and updating the next_* and avail_* values accordingly. The + application can consume the uncompressed output when it wants, for example + when the output buffer is full (avail_out == 0), or after each call of + inflate(). If inflate returns Z_OK and with zero avail_out, it must be + called again after making room in the output buffer because there might be + more output pending. + + The flush parameter of inflate() can be Z_NO_FLUSH, Z_SYNC_FLUSH, Z_FINISH, + Z_BLOCK, or Z_TREES. Z_SYNC_FLUSH requests that inflate() flush as much + output as possible to the output buffer. Z_BLOCK requests that inflate() + stop if and when it gets to the next deflate block boundary. When decoding + the zlib or gzip format, this will cause inflate() to return immediately + after the header and before the first block. When doing a raw inflate, + inflate() will go ahead and process the first block, and will return when it + gets to the end of that block, or when it runs out of data. + + The Z_BLOCK option assists in appending to or combining deflate streams. + Also to assist in this, on return inflate() will set strm->data_type to the + number of unused bits in the last byte taken from strm->next_in, plus 64 if + inflate() is currently decoding the last block in the deflate stream, plus + 128 if inflate() returned immediately after decoding an end-of-block code or + decoding the complete header up to just before the first byte of the deflate + stream. The end-of-block will not be indicated until all of the uncompressed + data from that block has been written to strm->next_out. The number of + unused bits may in general be greater than seven, except when bit 7 of + data_type is set, in which case the number of unused bits will be less than + eight. data_type is set as noted here every time inflate() returns for all + flush options, and so can be used to determine the amount of currently + consumed input in bits. + + The Z_TREES option behaves as Z_BLOCK does, but it also returns when the + end of each deflate block header is reached, before any actual data in that + block is decoded. This allows the caller to determine the length of the + deflate block header for later use in random access within a deflate block. + 256 is added to the value of strm->data_type when inflate() returns + immediately after reaching the end of the deflate block header. + + inflate() should normally be called until it returns Z_STREAM_END or an + error. However if all decompression is to be performed in a single step (a + single call of inflate), the parameter flush should be set to Z_FINISH. In + this case all pending input is processed and all pending output is flushed; + avail_out must be large enough to hold all the uncompressed data. (The size + of the uncompressed data may have been saved by the compressor for this + purpose.) The next operation on this stream must be inflateEnd to deallocate + the decompression state. The use of Z_FINISH is never required, but can be + used to inform inflate that a faster approach may be used for the single + inflate() call. + + In this implementation, inflate() always flushes as much output as + possible to the output buffer, and always uses the faster approach on the + first call. So the only effect of the flush parameter in this implementation + is on the return value of inflate(), as noted below, or when it returns early + because Z_BLOCK or Z_TREES is used. + + If a preset dictionary is needed after this call (see inflateSetDictionary + below), inflate sets strm->adler to the adler32 checksum of the dictionary + chosen by the compressor and returns Z_NEED_DICT; otherwise it sets + strm->adler to the adler32 checksum of all output produced so far (that is, + total_out bytes) and returns Z_OK, Z_STREAM_END or an error code as described + below. At the end of the stream, inflate() checks that its computed adler32 + checksum is equal to that saved by the compressor and returns Z_STREAM_END + only if the checksum is correct. + + inflate() can decompress and check either zlib-wrapped or gzip-wrapped + deflate data. The header type is detected automatically, if requested when + initializing with inflateInit2(). Any information contained in the gzip + header is not retained, so applications that need that information should + instead use raw inflate, see inflateInit2() below, or inflateBack() and + perform their own processing of the gzip header and trailer. + + inflate() returns Z_OK if some progress has been made (more input processed + or more output produced), Z_STREAM_END if the end of the compressed data has + been reached and all uncompressed output has been produced, Z_NEED_DICT if a + preset dictionary is needed at this point, Z_DATA_ERROR if the input data was + corrupted (input stream not conforming to the zlib format or incorrect check + value), Z_STREAM_ERROR if the stream structure was inconsistent (for example + next_in or next_out was Z_NULL), Z_MEM_ERROR if there was not enough memory, + Z_BUF_ERROR if no progress is possible or if there was not enough room in the + output buffer when Z_FINISH is used. Note that Z_BUF_ERROR is not fatal, and + inflate() can be called again with more input and more output space to + continue decompressing. If Z_DATA_ERROR is returned, the application may + then call inflateSync() to look for a good compression block if a partial + recovery of the data is desired. +*/ + + +ZEXTERN int ZEXPORT inflateEnd OF((z_streamp strm)); +/* + All dynamically allocated data structures for this stream are freed. + This function discards any unprocessed input and does not flush any pending + output. + + inflateEnd returns Z_OK if success, Z_STREAM_ERROR if the stream state + was inconsistent. In the error case, msg may be set but then points to a + static string (which must not be deallocated). +*/ + + + /* Advanced functions */ + +/* + The following functions are needed only in some special applications. +*/ + +/* +ZEXTERN int ZEXPORT deflateInit2 OF((z_streamp strm, + int level, + int method, + int windowBits, + int memLevel, + int strategy)); + + This is another version of deflateInit with more compression options. The + fields next_in, zalloc, zfree and opaque must be initialized before by the + caller. + + The method parameter is the compression method. It must be Z_DEFLATED in + this version of the library. + + The windowBits parameter is the base two logarithm of the window size + (the size of the history buffer). It should be in the range 8..15 for this + version of the library. Larger values of this parameter result in better + compression at the expense of memory usage. The default value is 15 if + deflateInit is used instead. + + windowBits can also be -8..-15 for raw deflate. In this case, -windowBits + determines the window size. deflate() will then generate raw deflate data + with no zlib header or trailer, and will not compute an adler32 check value. + + windowBits can also be greater than 15 for optional gzip encoding. Add + 16 to windowBits to write a simple gzip header and trailer around the + compressed data instead of a zlib wrapper. The gzip header will have no + file name, no extra data, no comment, no modification time (set to zero), no + header crc, and the operating system will be set to 255 (unknown). If a + gzip stream is being written, strm->adler is a crc32 instead of an adler32. + + The memLevel parameter specifies how much memory should be allocated + for the internal compression state. memLevel=1 uses minimum memory but is + slow and reduces compression ratio; memLevel=9 uses maximum memory for + optimal speed. The default value is 8. See zconf.h for total memory usage + as a function of windowBits and memLevel. + + The strategy parameter is used to tune the compression algorithm. Use the + value Z_DEFAULT_STRATEGY for normal data, Z_FILTERED for data produced by a + filter (or predictor), Z_HUFFMAN_ONLY to force Huffman encoding only (no + string match), or Z_RLE to limit match distances to one (run-length + encoding). Filtered data consists mostly of small values with a somewhat + random distribution. In this case, the compression algorithm is tuned to + compress them better. The effect of Z_FILTERED is to force more Huffman + coding and less string matching; it is somewhat intermediate between + Z_DEFAULT_STRATEGY and Z_HUFFMAN_ONLY. Z_RLE is designed to be almost as + fast as Z_HUFFMAN_ONLY, but give better compression for PNG image data. The + strategy parameter only affects the compression ratio but not the + correctness of the compressed output even if it is not set appropriately. + Z_FIXED prevents the use of dynamic Huffman codes, allowing for a simpler + decoder for special applications. + + deflateInit2 returns Z_OK if success, Z_MEM_ERROR if there was not enough + memory, Z_STREAM_ERROR if any parameter is invalid (such as an invalid + method), or Z_VERSION_ERROR if the zlib library version (zlib_version) is + incompatible with the version assumed by the caller (ZLIB_VERSION). msg is + set to null if there is no error message. deflateInit2 does not perform any + compression: this will be done by deflate(). +*/ + +ZEXTERN int ZEXPORT deflateSetDictionary OF((z_streamp strm, + const Bytef *dictionary, + uInt dictLength)); +/* + Initializes the compression dictionary from the given byte sequence + without producing any compressed output. This function must be called + immediately after deflateInit, deflateInit2 or deflateReset, before any call + of deflate. The compressor and decompressor must use exactly the same + dictionary (see inflateSetDictionary). + + The dictionary should consist of strings (byte sequences) that are likely + to be encountered later in the data to be compressed, with the most commonly + used strings preferably put towards the end of the dictionary. Using a + dictionary is most useful when the data to be compressed is short and can be + predicted with good accuracy; the data can then be compressed better than + with the default empty dictionary. + + Depending on the size of the compression data structures selected by + deflateInit or deflateInit2, a part of the dictionary may in effect be + discarded, for example if the dictionary is larger than the window size + provided in deflateInit or deflateInit2. Thus the strings most likely to be + useful should be put at the end of the dictionary, not at the front. In + addition, the current implementation of deflate will use at most the window + size minus 262 bytes of the provided dictionary. + + Upon return of this function, strm->adler is set to the adler32 value + of the dictionary; the decompressor may later use this value to determine + which dictionary has been used by the compressor. (The adler32 value + applies to the whole dictionary even if only a subset of the dictionary is + actually used by the compressor.) If a raw deflate was requested, then the + adler32 value is not computed and strm->adler is not set. + + deflateSetDictionary returns Z_OK if success, or Z_STREAM_ERROR if a + parameter is invalid (e.g. dictionary being Z_NULL) or the stream state is + inconsistent (for example if deflate has already been called for this stream + or if the compression method is bsort). deflateSetDictionary does not + perform any compression: this will be done by deflate(). +*/ + +ZEXTERN int ZEXPORT deflateCopy OF((z_streamp dest, + z_streamp source)); +/* + Sets the destination stream as a complete copy of the source stream. + + This function can be useful when several compression strategies will be + tried, for example when there are several ways of pre-processing the input + data with a filter. The streams that will be discarded should then be freed + by calling deflateEnd. Note that deflateCopy duplicates the internal + compression state which can be quite large, so this strategy is slow and can + consume lots of memory. + + deflateCopy returns Z_OK if success, Z_MEM_ERROR if there was not + enough memory, Z_STREAM_ERROR if the source stream state was inconsistent + (such as zalloc being Z_NULL). msg is left unchanged in both source and + destination. +*/ + +ZEXTERN int ZEXPORT deflateReset OF((z_streamp strm)); +/* + This function is equivalent to deflateEnd followed by deflateInit, + but does not free and reallocate all the internal compression state. The + stream will keep the same compression level and any other attributes that + may have been set by deflateInit2. + + deflateReset returns Z_OK if success, or Z_STREAM_ERROR if the source + stream state was inconsistent (such as zalloc or state being Z_NULL). +*/ + +ZEXTERN int ZEXPORT deflateParams OF((z_streamp strm, + int level, + int strategy)); +/* + Dynamically update the compression level and compression strategy. The + interpretation of level and strategy is as in deflateInit2. This can be + used to switch between compression and straight copy of the input data, or + to switch to a different kind of input data requiring a different strategy. + If the compression level is changed, the input available so far is + compressed with the old level (and may be flushed); the new level will take + effect only at the next call of deflate(). + + Before the call of deflateParams, the stream state must be set as for + a call of deflate(), since the currently available input may have to be + compressed and flushed. In particular, strm->avail_out must be non-zero. + + deflateParams returns Z_OK if success, Z_STREAM_ERROR if the source + stream state was inconsistent or if a parameter was invalid, Z_BUF_ERROR if + strm->avail_out was zero. +*/ + +ZEXTERN int ZEXPORT deflateTune OF((z_streamp strm, + int good_length, + int max_lazy, + int nice_length, + int max_chain)); +/* + Fine tune deflate's internal compression parameters. This should only be + used by someone who understands the algorithm used by zlib's deflate for + searching for the best matching string, and even then only by the most + fanatic optimizer trying to squeeze out the last compressed bit for their + specific input data. Read the deflate.c source code for the meaning of the + max_lazy, good_length, nice_length, and max_chain parameters. + + deflateTune() can be called after deflateInit() or deflateInit2(), and + returns Z_OK on success, or Z_STREAM_ERROR for an invalid deflate stream. + */ + +ZEXTERN uLong ZEXPORT deflateBound OF((z_streamp strm, + uLong sourceLen)); +/* + deflateBound() returns an upper bound on the compressed size after + deflation of sourceLen bytes. It must be called after deflateInit() or + deflateInit2(), and after deflateSetHeader(), if used. This would be used + to allocate an output buffer for deflation in a single pass, and so would be + called before deflate(). +*/ + +ZEXTERN int ZEXPORT deflatePrime OF((z_streamp strm, + int bits, + int value)); +/* + deflatePrime() inserts bits in the deflate output stream. The intent + is that this function is used to start off the deflate output with the bits + leftover from a previous deflate stream when appending to it. As such, this + function can only be used for raw deflate, and must be used before the first + deflate() call after a deflateInit2() or deflateReset(). bits must be less + than or equal to 16, and that many of the least significant bits of value + will be inserted in the output. + + deflatePrime returns Z_OK if success, or Z_STREAM_ERROR if the source + stream state was inconsistent. +*/ + +ZEXTERN int ZEXPORT deflateSetHeader OF((z_streamp strm, + gz_headerp head)); +/* + deflateSetHeader() provides gzip header information for when a gzip + stream is requested by deflateInit2(). deflateSetHeader() may be called + after deflateInit2() or deflateReset() and before the first call of + deflate(). The text, time, os, extra field, name, and comment information + in the provided gz_header structure are written to the gzip header (xflag is + ignored -- the extra flags are set according to the compression level). The + caller must assure that, if not Z_NULL, name and comment are terminated with + a zero byte, and that if extra is not Z_NULL, that extra_len bytes are + available there. If hcrc is true, a gzip header crc is included. Note that + the current versions of the command-line version of gzip (up through version + 1.3.x) do not support header crc's, and will report that it is a "multi-part + gzip file" and give up. + + If deflateSetHeader is not used, the default gzip header has text false, + the time set to zero, and os set to 255, with no extra, name, or comment + fields. The gzip header is returned to the default state by deflateReset(). + + deflateSetHeader returns Z_OK if success, or Z_STREAM_ERROR if the source + stream state was inconsistent. +*/ + +/* +ZEXTERN int ZEXPORT inflateInit2 OF((z_streamp strm, + int windowBits)); + + This is another version of inflateInit with an extra parameter. The + fields next_in, avail_in, zalloc, zfree and opaque must be initialized + before by the caller. + + The windowBits parameter is the base two logarithm of the maximum window + size (the size of the history buffer). It should be in the range 8..15 for + this version of the library. The default value is 15 if inflateInit is used + instead. windowBits must be greater than or equal to the windowBits value + provided to deflateInit2() while compressing, or it must be equal to 15 if + deflateInit2() was not used. If a compressed stream with a larger window + size is given as input, inflate() will return with the error code + Z_DATA_ERROR instead of trying to allocate a larger window. + + windowBits can also be zero to request that inflate use the window size in + the zlib header of the compressed stream. + + windowBits can also be -8..-15 for raw inflate. In this case, -windowBits + determines the window size. inflate() will then process raw deflate data, + not looking for a zlib or gzip header, not generating a check value, and not + looking for any check values for comparison at the end of the stream. This + is for use with other formats that use the deflate compressed data format + such as zip. Those formats provide their own check values. If a custom + format is developed using the raw deflate format for compressed data, it is + recommended that a check value such as an adler32 or a crc32 be applied to + the uncompressed data as is done in the zlib, gzip, and zip formats. For + most applications, the zlib format should be used as is. Note that comments + above on the use in deflateInit2() applies to the magnitude of windowBits. + + windowBits can also be greater than 15 for optional gzip decoding. Add + 32 to windowBits to enable zlib and gzip decoding with automatic header + detection, or add 16 to decode only the gzip format (the zlib format will + return a Z_DATA_ERROR). If a gzip stream is being decoded, strm->adler is a + crc32 instead of an adler32. + + inflateInit2 returns Z_OK if success, Z_MEM_ERROR if there was not enough + memory, Z_VERSION_ERROR if the zlib library version is incompatible with the + version assumed by the caller, or Z_STREAM_ERROR if the parameters are + invalid, such as a null pointer to the structure. msg is set to null if + there is no error message. inflateInit2 does not perform any decompression + apart from possibly reading the zlib header if present: actual decompression + will be done by inflate(). (So next_in and avail_in may be modified, but + next_out and avail_out are unused and unchanged.) The current implementation + of inflateInit2() does not process any header information -- that is + deferred until inflate() is called. +*/ + +ZEXTERN int ZEXPORT inflateSetDictionary OF((z_streamp strm, + const Bytef *dictionary, + uInt dictLength)); +/* + Initializes the decompression dictionary from the given uncompressed byte + sequence. This function must be called immediately after a call of inflate, + if that call returned Z_NEED_DICT. The dictionary chosen by the compressor + can be determined from the adler32 value returned by that call of inflate. + The compressor and decompressor must use exactly the same dictionary (see + deflateSetDictionary). For raw inflate, this function can be called + immediately after inflateInit2() or inflateReset() and before any call of + inflate() to set the dictionary. The application must insure that the + dictionary that was used for compression is provided. + + inflateSetDictionary returns Z_OK if success, Z_STREAM_ERROR if a + parameter is invalid (e.g. dictionary being Z_NULL) or the stream state is + inconsistent, Z_DATA_ERROR if the given dictionary doesn't match the + expected one (incorrect adler32 value). inflateSetDictionary does not + perform any decompression: this will be done by subsequent calls of + inflate(). +*/ + +ZEXTERN int ZEXPORT inflateSync OF((z_streamp strm)); +/* + Skips invalid compressed data until a full flush point (see above the + description of deflate with Z_FULL_FLUSH) can be found, or until all + available input is skipped. No output is provided. + + inflateSync returns Z_OK if a full flush point has been found, Z_BUF_ERROR + if no more input was provided, Z_DATA_ERROR if no flush point has been + found, or Z_STREAM_ERROR if the stream structure was inconsistent. In the + success case, the application may save the current current value of total_in + which indicates where valid compressed data was found. In the error case, + the application may repeatedly call inflateSync, providing more input each + time, until success or end of the input data. +*/ + +ZEXTERN int ZEXPORT inflateCopy OF((z_streamp dest, + z_streamp source)); +/* + Sets the destination stream as a complete copy of the source stream. + + This function can be useful when randomly accessing a large stream. The + first pass through the stream can periodically record the inflate state, + allowing restarting inflate at those points when randomly accessing the + stream. + + inflateCopy returns Z_OK if success, Z_MEM_ERROR if there was not + enough memory, Z_STREAM_ERROR if the source stream state was inconsistent + (such as zalloc being Z_NULL). msg is left unchanged in both source and + destination. +*/ + +ZEXTERN int ZEXPORT inflateReset OF((z_streamp strm)); +/* + This function is equivalent to inflateEnd followed by inflateInit, + but does not free and reallocate all the internal decompression state. The + stream will keep attributes that may have been set by inflateInit2. + + inflateReset returns Z_OK if success, or Z_STREAM_ERROR if the source + stream state was inconsistent (such as zalloc or state being Z_NULL). +*/ + +ZEXTERN int ZEXPORT inflateReset2 OF((z_streamp strm, + int windowBits)); +/* + This function is the same as inflateReset, but it also permits changing + the wrap and window size requests. The windowBits parameter is interpreted + the same as it is for inflateInit2. + + inflateReset2 returns Z_OK if success, or Z_STREAM_ERROR if the source + stream state was inconsistent (such as zalloc or state being Z_NULL), or if + the windowBits parameter is invalid. +*/ + +ZEXTERN int ZEXPORT inflatePrime OF((z_streamp strm, + int bits, + int value)); +/* + This function inserts bits in the inflate input stream. The intent is + that this function is used to start inflating at a bit position in the + middle of a byte. The provided bits will be used before any bytes are used + from next_in. This function should only be used with raw inflate, and + should be used before the first inflate() call after inflateInit2() or + inflateReset(). bits must be less than or equal to 16, and that many of the + least significant bits of value will be inserted in the input. + + If bits is negative, then the input stream bit buffer is emptied. Then + inflatePrime() can be called again to put bits in the buffer. This is used + to clear out bits leftover after feeding inflate a block description prior + to feeding inflate codes. + + inflatePrime returns Z_OK if success, or Z_STREAM_ERROR if the source + stream state was inconsistent. +*/ + +ZEXTERN long ZEXPORT inflateMark OF((z_streamp strm)); +/* + This function returns two values, one in the lower 16 bits of the return + value, and the other in the remaining upper bits, obtained by shifting the + return value down 16 bits. If the upper value is -1 and the lower value is + zero, then inflate() is currently decoding information outside of a block. + If the upper value is -1 and the lower value is non-zero, then inflate is in + the middle of a stored block, with the lower value equaling the number of + bytes from the input remaining to copy. If the upper value is not -1, then + it is the number of bits back from the current bit position in the input of + the code (literal or length/distance pair) currently being processed. In + that case the lower value is the number of bytes already emitted for that + code. + + A code is being processed if inflate is waiting for more input to complete + decoding of the code, or if it has completed decoding but is waiting for + more output space to write the literal or match data. + + inflateMark() is used to mark locations in the input data for random + access, which may be at bit positions, and to note those cases where the + output of a code may span boundaries of random access blocks. The current + location in the input stream can be determined from avail_in and data_type + as noted in the description for the Z_BLOCK flush parameter for inflate. + + inflateMark returns the value noted above or -1 << 16 if the provided + source stream state was inconsistent. +*/ + +ZEXTERN int ZEXPORT inflateGetHeader OF((z_streamp strm, + gz_headerp head)); +/* + inflateGetHeader() requests that gzip header information be stored in the + provided gz_header structure. inflateGetHeader() may be called after + inflateInit2() or inflateReset(), and before the first call of inflate(). + As inflate() processes the gzip stream, head->done is zero until the header + is completed, at which time head->done is set to one. If a zlib stream is + being decoded, then head->done is set to -1 to indicate that there will be + no gzip header information forthcoming. Note that Z_BLOCK or Z_TREES can be + used to force inflate() to return immediately after header processing is + complete and before any actual data is decompressed. + + The text, time, xflags, and os fields are filled in with the gzip header + contents. hcrc is set to true if there is a header CRC. (The header CRC + was valid if done is set to one.) If extra is not Z_NULL, then extra_max + contains the maximum number of bytes to write to extra. Once done is true, + extra_len contains the actual extra field length, and extra contains the + extra field, or that field truncated if extra_max is less than extra_len. + If name is not Z_NULL, then up to name_max characters are written there, + terminated with a zero unless the length is greater than name_max. If + comment is not Z_NULL, then up to comm_max characters are written there, + terminated with a zero unless the length is greater than comm_max. When any + of extra, name, or comment are not Z_NULL and the respective field is not + present in the header, then that field is set to Z_NULL to signal its + absence. This allows the use of deflateSetHeader() with the returned + structure to duplicate the header. However if those fields are set to + allocated memory, then the application will need to save those pointers + elsewhere so that they can be eventually freed. + + If inflateGetHeader is not used, then the header information is simply + discarded. The header is always checked for validity, including the header + CRC if present. inflateReset() will reset the process to discard the header + information. The application would need to call inflateGetHeader() again to + retrieve the header from the next gzip stream. + + inflateGetHeader returns Z_OK if success, or Z_STREAM_ERROR if the source + stream state was inconsistent. +*/ + +/* +ZEXTERN int ZEXPORT inflateBackInit OF((z_streamp strm, int windowBits, + unsigned char FAR *window)); + + Initialize the internal stream state for decompression using inflateBack() + calls. The fields zalloc, zfree and opaque in strm must be initialized + before the call. If zalloc and zfree are Z_NULL, then the default library- + derived memory allocation routines are used. windowBits is the base two + logarithm of the window size, in the range 8..15. window is a caller + supplied buffer of that size. Except for special applications where it is + assured that deflate was used with small window sizes, windowBits must be 15 + and a 32K byte window must be supplied to be able to decompress general + deflate streams. + + See inflateBack() for the usage of these routines. + + inflateBackInit will return Z_OK on success, Z_STREAM_ERROR if any of + the paramaters are invalid, Z_MEM_ERROR if the internal state could not be + allocated, or Z_VERSION_ERROR if the version of the library does not match + the version of the header file. +*/ + +typedef unsigned (*in_func) OF((void FAR *, unsigned char FAR * FAR *)); +typedef int (*out_func) OF((void FAR *, unsigned char FAR *, unsigned)); + +ZEXTERN int ZEXPORT inflateBack OF((z_streamp strm, + in_func in, void FAR *in_desc, + out_func out, void FAR *out_desc)); +/* + inflateBack() does a raw inflate with a single call using a call-back + interface for input and output. This is more efficient than inflate() for + file i/o applications in that it avoids copying between the output and the + sliding window by simply making the window itself the output buffer. This + function trusts the application to not change the output buffer passed by + the output function, at least until inflateBack() returns. + + inflateBackInit() must be called first to allocate the internal state + and to initialize the state with the user-provided window buffer. + inflateBack() may then be used multiple times to inflate a complete, raw + deflate stream with each call. inflateBackEnd() is then called to free the + allocated state. + + A raw deflate stream is one with no zlib or gzip header or trailer. + This routine would normally be used in a utility that reads zip or gzip + files and writes out uncompressed files. The utility would decode the + header and process the trailer on its own, hence this routine expects only + the raw deflate stream to decompress. This is different from the normal + behavior of inflate(), which expects either a zlib or gzip header and + trailer around the deflate stream. + + inflateBack() uses two subroutines supplied by the caller that are then + called by inflateBack() for input and output. inflateBack() calls those + routines until it reads a complete deflate stream and writes out all of the + uncompressed data, or until it encounters an error. The function's + parameters and return types are defined above in the in_func and out_func + typedefs. inflateBack() will call in(in_desc, &buf) which should return the + number of bytes of provided input, and a pointer to that input in buf. If + there is no input available, in() must return zero--buf is ignored in that + case--and inflateBack() will return a buffer error. inflateBack() will call + out(out_desc, buf, len) to write the uncompressed data buf[0..len-1]. out() + should return zero on success, or non-zero on failure. If out() returns + non-zero, inflateBack() will return with an error. Neither in() nor out() + are permitted to change the contents of the window provided to + inflateBackInit(), which is also the buffer that out() uses to write from. + The length written by out() will be at most the window size. Any non-zero + amount of input may be provided by in(). + + For convenience, inflateBack() can be provided input on the first call by + setting strm->next_in and strm->avail_in. If that input is exhausted, then + in() will be called. Therefore strm->next_in must be initialized before + calling inflateBack(). If strm->next_in is Z_NULL, then in() will be called + immediately for input. If strm->next_in is not Z_NULL, then strm->avail_in + must also be initialized, and then if strm->avail_in is not zero, input will + initially be taken from strm->next_in[0 .. strm->avail_in - 1]. + + The in_desc and out_desc parameters of inflateBack() is passed as the + first parameter of in() and out() respectively when they are called. These + descriptors can be optionally used to pass any information that the caller- + supplied in() and out() functions need to do their job. + + On return, inflateBack() will set strm->next_in and strm->avail_in to + pass back any unused input that was provided by the last in() call. The + return values of inflateBack() can be Z_STREAM_END on success, Z_BUF_ERROR + if in() or out() returned an error, Z_DATA_ERROR if there was a format error + in the deflate stream (in which case strm->msg is set to indicate the nature + of the error), or Z_STREAM_ERROR if the stream was not properly initialized. + In the case of Z_BUF_ERROR, an input or output error can be distinguished + using strm->next_in which will be Z_NULL only if in() returned an error. If + strm->next_in is not Z_NULL, then the Z_BUF_ERROR was due to out() returning + non-zero. (in() will always be called before out(), so strm->next_in is + assured to be defined if out() returns non-zero.) Note that inflateBack() + cannot return Z_OK. +*/ + +ZEXTERN int ZEXPORT inflateBackEnd OF((z_streamp strm)); +/* + All memory allocated by inflateBackInit() is freed. + + inflateBackEnd() returns Z_OK on success, or Z_STREAM_ERROR if the stream + state was inconsistent. +*/ + +ZEXTERN uLong ZEXPORT zlibCompileFlags OF((void)); +/* Return flags indicating compile-time options. + + Type sizes, two bits each, 00 = 16 bits, 01 = 32, 10 = 64, 11 = other: + 1.0: size of uInt + 3.2: size of uLong + 5.4: size of voidpf (pointer) + 7.6: size of z_off_t + + Compiler, assembler, and debug options: + 8: DEBUG + 9: ASMV or ASMINF -- use ASM code + 10: ZLIB_WINAPI -- exported functions use the WINAPI calling convention + 11: 0 (reserved) + + One-time table building (smaller code, but not thread-safe if true): + 12: BUILDFIXED -- build static block decoding tables when needed + 13: DYNAMIC_CRC_TABLE -- build CRC calculation tables when needed + 14,15: 0 (reserved) + + Library content (indicates missing functionality): + 16: NO_GZCOMPRESS -- gz* functions cannot compress (to avoid linking + deflate code when not needed) + 17: NO_GZIP -- deflate can't write gzip streams, and inflate can't detect + and decode gzip streams (to avoid linking crc code) + 18-19: 0 (reserved) + + Operation variations (changes in library functionality): + 20: PKZIP_BUG_WORKAROUND -- slightly more permissive inflate + 21: FASTEST -- deflate algorithm with only one, lowest compression level + 22,23: 0 (reserved) + + The sprintf variant used by gzprintf (zero is best): + 24: 0 = vs*, 1 = s* -- 1 means limited to 20 arguments after the format + 25: 0 = *nprintf, 1 = *printf -- 1 means gzprintf() not secure! + 26: 0 = returns value, 1 = void -- 1 means inferred string length returned + + Remainder: + 27-31: 0 (reserved) + */ + + + /* utility functions */ + +/* + The following utility functions are implemented on top of the basic + stream-oriented functions. To simplify the interface, some default options + are assumed (compression level and memory usage, standard memory allocation + functions). The source code of these utility functions can be modified if + you need special options. +*/ + +ZEXTERN int ZEXPORT compress OF((Bytef *dest, uLongf *destLen, + const Bytef *source, uLong sourceLen)); +/* + Compresses the source buffer into the destination buffer. sourceLen is + the byte length of the source buffer. Upon entry, destLen is the total size + of the destination buffer, which must be at least the value returned by + compressBound(sourceLen). Upon exit, destLen is the actual size of the + compressed buffer. + + compress returns Z_OK if success, Z_MEM_ERROR if there was not + enough memory, Z_BUF_ERROR if there was not enough room in the output + buffer. +*/ + +ZEXTERN int ZEXPORT compress2 OF((Bytef *dest, uLongf *destLen, + const Bytef *source, uLong sourceLen, + int level)); +/* + Compresses the source buffer into the destination buffer. The level + parameter has the same meaning as in deflateInit. sourceLen is the byte + length of the source buffer. Upon entry, destLen is the total size of the + destination buffer, which must be at least the value returned by + compressBound(sourceLen). Upon exit, destLen is the actual size of the + compressed buffer. + + compress2 returns Z_OK if success, Z_MEM_ERROR if there was not enough + memory, Z_BUF_ERROR if there was not enough room in the output buffer, + Z_STREAM_ERROR if the level parameter is invalid. +*/ + +ZEXTERN uLong ZEXPORT compressBound OF((uLong sourceLen)); +/* + compressBound() returns an upper bound on the compressed size after + compress() or compress2() on sourceLen bytes. It would be used before a + compress() or compress2() call to allocate the destination buffer. +*/ + +ZEXTERN int ZEXPORT uncompress OF((Bytef *dest, uLongf *destLen, + const Bytef *source, uLong sourceLen)); +/* + Decompresses the source buffer into the destination buffer. sourceLen is + the byte length of the source buffer. Upon entry, destLen is the total size + of the destination buffer, which must be large enough to hold the entire + uncompressed data. (The size of the uncompressed data must have been saved + previously by the compressor and transmitted to the decompressor by some + mechanism outside the scope of this compression library.) Upon exit, destLen + is the actual size of the uncompressed buffer. + + uncompress returns Z_OK if success, Z_MEM_ERROR if there was not + enough memory, Z_BUF_ERROR if there was not enough room in the output + buffer, or Z_DATA_ERROR if the input data was corrupted or incomplete. +*/ + + + /* gzip file access functions */ + +/* + This library supports reading and writing files in gzip (.gz) format with + an interface similar to that of stdio, using the functions that start with + "gz". The gzip format is different from the zlib format. gzip is a gzip + wrapper, documented in RFC 1952, wrapped around a deflate stream. +*/ + +typedef voidp gzFile; /* opaque gzip file descriptor */ + +/* +ZEXTERN gzFile ZEXPORT gzopen OF((const char *path, const char *mode)); + + Opens a gzip (.gz) file for reading or writing. The mode parameter is as + in fopen ("rb" or "wb") but can also include a compression level ("wb9") or + a strategy: 'f' for filtered data as in "wb6f", 'h' for Huffman-only + compression as in "wb1h", 'R' for run-length encoding as in "wb1R", or 'F' + for fixed code compression as in "wb9F". (See the description of + deflateInit2 for more information about the strategy parameter.) Also "a" + can be used instead of "w" to request that the gzip stream that will be + written be appended to the file. "+" will result in an error, since reading + and writing to the same gzip file is not supported. + + gzopen can be used to read a file which is not in gzip format; in this + case gzread will directly read from the file without decompression. + + gzopen returns NULL if the file could not be opened, if there was + insufficient memory to allocate the gzFile state, or if an invalid mode was + specified (an 'r', 'w', or 'a' was not provided, or '+' was provided). + errno can be checked to determine if the reason gzopen failed was that the + file could not be opened. +*/ + +ZEXTERN gzFile ZEXPORT gzdopen OF((int fd, const char *mode)); +/* + gzdopen associates a gzFile with the file descriptor fd. File descriptors + are obtained from calls like open, dup, creat, pipe or fileno (if the file + has been previously opened with fopen). The mode parameter is as in gzopen. + + The next call of gzclose on the returned gzFile will also close the file + descriptor fd, just like fclose(fdopen(fd, mode)) closes the file descriptor + fd. If you want to keep fd open, use fd = dup(fd_keep); gz = gzdopen(fd, + mode);. The duplicated descriptor should be saved to avoid a leak, since + gzdopen does not close fd if it fails. + + gzdopen returns NULL if there was insufficient memory to allocate the + gzFile state, if an invalid mode was specified (an 'r', 'w', or 'a' was not + provided, or '+' was provided), or if fd is -1. The file descriptor is not + used until the next gz* read, write, seek, or close operation, so gzdopen + will not detect if fd is invalid (unless fd is -1). +*/ + +ZEXTERN int ZEXPORT gzbuffer OF((gzFile file, unsigned size)); +/* + Set the internal buffer size used by this library's functions. The + default buffer size is 8192 bytes. This function must be called after + gzopen() or gzdopen(), and before any other calls that read or write the + file. The buffer memory allocation is always deferred to the first read or + write. Two buffers are allocated, either both of the specified size when + writing, or one of the specified size and the other twice that size when + reading. A larger buffer size of, for example, 64K or 128K bytes will + noticeably increase the speed of decompression (reading). + + The new buffer size also affects the maximum length for gzprintf(). + + gzbuffer() returns 0 on success, or -1 on failure, such as being called + too late. +*/ + +ZEXTERN int ZEXPORT gzsetparams OF((gzFile file, int level, int strategy)); +/* + Dynamically update the compression level or strategy. See the description + of deflateInit2 for the meaning of these parameters. + + gzsetparams returns Z_OK if success, or Z_STREAM_ERROR if the file was not + opened for writing. +*/ + +ZEXTERN int ZEXPORT gzread OF((gzFile file, voidp buf, unsigned len)); +/* + Reads the given number of uncompressed bytes from the compressed file. If + the input file was not in gzip format, gzread copies the given number of + bytes into the buffer. + + After reaching the end of a gzip stream in the input, gzread will continue + to read, looking for another gzip stream, or failing that, reading the rest + of the input file directly without decompression. The entire input file + will be read if gzread is called until it returns less than the requested + len. + + gzread returns the number of uncompressed bytes actually read, less than + len for end of file, or -1 for error. +*/ + +ZEXTERN int ZEXPORT gzwrite OF((gzFile file, + voidpc buf, unsigned len)); +/* + Writes the given number of uncompressed bytes into the compressed file. + gzwrite returns the number of uncompressed bytes written or 0 in case of + error. +*/ + +ZEXTERN int ZEXPORTVA gzprintf OF((gzFile file, const char *format, ...)); +/* + Converts, formats, and writes the arguments to the compressed file under + control of the format string, as in fprintf. gzprintf returns the number of + uncompressed bytes actually written, or 0 in case of error. The number of + uncompressed bytes written is limited to 8191, or one less than the buffer + size given to gzbuffer(). The caller should assure that this limit is not + exceeded. If it is exceeded, then gzprintf() will return an error (0) with + nothing written. In this case, there may also be a buffer overflow with + unpredictable consequences, which is possible only if zlib was compiled with + the insecure functions sprintf() or vsprintf() because the secure snprintf() + or vsnprintf() functions were not available. This can be determined using + zlibCompileFlags(). +*/ + +ZEXTERN int ZEXPORT gzputs OF((gzFile file, const char *s)); +/* + Writes the given null-terminated string to the compressed file, excluding + the terminating null character. + + gzputs returns the number of characters written, or -1 in case of error. +*/ + +ZEXTERN char * ZEXPORT gzgets OF((gzFile file, char *buf, int len)); +/* + Reads bytes from the compressed file until len-1 characters are read, or a + newline character is read and transferred to buf, or an end-of-file + condition is encountered. If any characters are read or if len == 1, the + string is terminated with a null character. If no characters are read due + to an end-of-file or len < 1, then the buffer is left untouched. + + gzgets returns buf which is a null-terminated string, or it returns NULL + for end-of-file or in case of error. If there was an error, the contents at + buf are indeterminate. +*/ + +ZEXTERN int ZEXPORT gzputc OF((gzFile file, int c)); +/* + Writes c, converted to an unsigned char, into the compressed file. gzputc + returns the value that was written, or -1 in case of error. +*/ + +ZEXTERN int ZEXPORT gzgetc OF((gzFile file)); +/* + Reads one byte from the compressed file. gzgetc returns this byte or -1 + in case of end of file or error. +*/ + +ZEXTERN int ZEXPORT gzungetc OF((int c, gzFile file)); +/* + Push one character back onto the stream to be read as the first character + on the next read. At least one character of push-back is allowed. + gzungetc() returns the character pushed, or -1 on failure. gzungetc() will + fail if c is -1, and may fail if a character has been pushed but not read + yet. If gzungetc is used immediately after gzopen or gzdopen, at least the + output buffer size of pushed characters is allowed. (See gzbuffer above.) + The pushed character will be discarded if the stream is repositioned with + gzseek() or gzrewind(). +*/ + +ZEXTERN int ZEXPORT gzflush OF((gzFile file, int flush)); +/* + Flushes all pending output into the compressed file. The parameter flush + is as in the deflate() function. The return value is the zlib error number + (see function gzerror below). gzflush is only permitted when writing. + + If the flush parameter is Z_FINISH, the remaining data is written and the + gzip stream is completed in the output. If gzwrite() is called again, a new + gzip stream will be started in the output. gzread() is able to read such + concatented gzip streams. + + gzflush should be called only when strictly necessary because it will + degrade compression if called too often. +*/ + +/* +ZEXTERN z_off_t ZEXPORT gzseek OF((gzFile file, + z_off_t offset, int whence)); + + Sets the starting position for the next gzread or gzwrite on the given + compressed file. The offset represents a number of bytes in the + uncompressed data stream. The whence parameter is defined as in lseek(2); + the value SEEK_END is not supported. + + If the file is opened for reading, this function is emulated but can be + extremely slow. If the file is opened for writing, only forward seeks are + supported; gzseek then compresses a sequence of zeroes up to the new + starting position. + + gzseek returns the resulting offset location as measured in bytes from + the beginning of the uncompressed stream, or -1 in case of error, in + particular if the file is opened for writing and the new starting position + would be before the current position. +*/ + +ZEXTERN int ZEXPORT gzrewind OF((gzFile file)); +/* + Rewinds the given file. This function is supported only for reading. + + gzrewind(file) is equivalent to (int)gzseek(file, 0L, SEEK_SET) +*/ + +/* +ZEXTERN z_off_t ZEXPORT gztell OF((gzFile file)); + + Returns the starting position for the next gzread or gzwrite on the given + compressed file. This position represents a number of bytes in the + uncompressed data stream, and is zero when starting, even if appending or + reading a gzip stream from the middle of a file using gzdopen(). + + gztell(file) is equivalent to gzseek(file, 0L, SEEK_CUR) +*/ + +/* +ZEXTERN z_off_t ZEXPORT gzoffset OF((gzFile file)); + + Returns the current offset in the file being read or written. This offset + includes the count of bytes that precede the gzip stream, for example when + appending or when using gzdopen() for reading. When reading, the offset + does not include as yet unused buffered input. This information can be used + for a progress indicator. On error, gzoffset() returns -1. +*/ + +ZEXTERN int ZEXPORT gzeof OF((gzFile file)); +/* + Returns true (1) if the end-of-file indicator has been set while reading, + false (0) otherwise. Note that the end-of-file indicator is set only if the + read tried to go past the end of the input, but came up short. Therefore, + just like feof(), gzeof() may return false even if there is no more data to + read, in the event that the last read request was for the exact number of + bytes remaining in the input file. This will happen if the input file size + is an exact multiple of the buffer size. + + If gzeof() returns true, then the read functions will return no more data, + unless the end-of-file indicator is reset by gzclearerr() and the input file + has grown since the previous end of file was detected. +*/ + +ZEXTERN int ZEXPORT gzdirect OF((gzFile file)); +/* + Returns true (1) if file is being copied directly while reading, or false + (0) if file is a gzip stream being decompressed. This state can change from + false to true while reading the input file if the end of a gzip stream is + reached, but is followed by data that is not another gzip stream. + + If the input file is empty, gzdirect() will return true, since the input + does not contain a gzip stream. + + If gzdirect() is used immediately after gzopen() or gzdopen() it will + cause buffers to be allocated to allow reading the file to determine if it + is a gzip file. Therefore if gzbuffer() is used, it should be called before + gzdirect(). +*/ + +ZEXTERN int ZEXPORT gzclose OF((gzFile file)); +/* + Flushes all pending output if necessary, closes the compressed file and + deallocates the (de)compression state. Note that once file is closed, you + cannot call gzerror with file, since its structures have been deallocated. + gzclose must not be called more than once on the same file, just as free + must not be called more than once on the same allocation. + + gzclose will return Z_STREAM_ERROR if file is not valid, Z_ERRNO on a + file operation error, or Z_OK on success. +*/ + +ZEXTERN int ZEXPORT gzclose_r OF((gzFile file)); +ZEXTERN int ZEXPORT gzclose_w OF((gzFile file)); +/* + Same as gzclose(), but gzclose_r() is only for use when reading, and + gzclose_w() is only for use when writing or appending. The advantage to + using these instead of gzclose() is that they avoid linking in zlib + compression or decompression code that is not used when only reading or only + writing respectively. If gzclose() is used, then both compression and + decompression code will be included the application when linking to a static + zlib library. +*/ + +ZEXTERN const char * ZEXPORT gzerror OF((gzFile file, int *errnum)); +/* + Returns the error message for the last error which occurred on the given + compressed file. errnum is set to zlib error number. If an error occurred + in the file system and not in the compression library, errnum is set to + Z_ERRNO and the application may consult errno to get the exact error code. + + The application must not modify the returned string. Future calls to + this function may invalidate the previously returned string. If file is + closed, then the string previously returned by gzerror will no longer be + available. + + gzerror() should be used to distinguish errors from end-of-file for those + functions above that do not distinguish those cases in their return values. +*/ + +ZEXTERN void ZEXPORT gzclearerr OF((gzFile file)); +/* + Clears the error and end-of-file flags for file. This is analogous to the + clearerr() function in stdio. This is useful for continuing to read a gzip + file that is being written concurrently. +*/ + + + /* checksum functions */ + +/* + These functions are not related to compression but are exported + anyway because they might be useful in applications using the compression + library. +*/ + +ZEXTERN uLong ZEXPORT adler32 OF((uLong adler, const Bytef *buf, uInt len)); +/* + Update a running Adler-32 checksum with the bytes buf[0..len-1] and + return the updated checksum. If buf is Z_NULL, this function returns the + required initial value for the checksum. + + An Adler-32 checksum is almost as reliable as a CRC32 but can be computed + much faster. + + Usage example: + + uLong adler = adler32(0L, Z_NULL, 0); + + while (read_buffer(buffer, length) != EOF) { + adler = adler32(adler, buffer, length); + } + if (adler != original_adler) error(); +*/ + +/* +ZEXTERN uLong ZEXPORT adler32_combine OF((uLong adler1, uLong adler2, + z_off_t len2)); + + Combine two Adler-32 checksums into one. For two sequences of bytes, seq1 + and seq2 with lengths len1 and len2, Adler-32 checksums were calculated for + each, adler1 and adler2. adler32_combine() returns the Adler-32 checksum of + seq1 and seq2 concatenated, requiring only adler1, adler2, and len2. +*/ + +ZEXTERN uLong ZEXPORT crc32 OF((uLong crc, const Bytef *buf, uInt len)); +/* + Update a running CRC-32 with the bytes buf[0..len-1] and return the + updated CRC-32. If buf is Z_NULL, this function returns the required + initial value for the for the crc. Pre- and post-conditioning (one's + complement) is performed within this function so it shouldn't be done by the + application. + + Usage example: + + uLong crc = crc32(0L, Z_NULL, 0); + + while (read_buffer(buffer, length) != EOF) { + crc = crc32(crc, buffer, length); + } + if (crc != original_crc) error(); +*/ + +/* +ZEXTERN uLong ZEXPORT crc32_combine OF((uLong crc1, uLong crc2, z_off_t len2)); + + Combine two CRC-32 check values into one. For two sequences of bytes, + seq1 and seq2 with lengths len1 and len2, CRC-32 check values were + calculated for each, crc1 and crc2. crc32_combine() returns the CRC-32 + check value of seq1 and seq2 concatenated, requiring only crc1, crc2, and + len2. +*/ + + + /* various hacks, don't look :) */ + +/* deflateInit and inflateInit are macros to allow checking the zlib version + * and the compiler's view of z_stream: + */ +ZEXTERN int ZEXPORT deflateInit_ OF((z_streamp strm, int level, + const char *version, int stream_size)); +ZEXTERN int ZEXPORT inflateInit_ OF((z_streamp strm, + const char *version, int stream_size)); +ZEXTERN int ZEXPORT deflateInit2_ OF((z_streamp strm, int level, int method, + int windowBits, int memLevel, + int strategy, const char *version, + int stream_size)); +ZEXTERN int ZEXPORT inflateInit2_ OF((z_streamp strm, int windowBits, + const char *version, int stream_size)); +ZEXTERN int ZEXPORT inflateBackInit_ OF((z_streamp strm, int windowBits, + unsigned char FAR *window, + const char *version, + int stream_size)); +#define deflateInit(strm, level) \ + deflateInit_((strm), (level), ZLIB_VERSION, sizeof(z_stream)) +#define inflateInit(strm) \ + inflateInit_((strm), ZLIB_VERSION, sizeof(z_stream)) +#define deflateInit2(strm, level, method, windowBits, memLevel, strategy) \ + deflateInit2_((strm),(level),(method),(windowBits),(memLevel),\ + (strategy), ZLIB_VERSION, sizeof(z_stream)) +#define inflateInit2(strm, windowBits) \ + inflateInit2_((strm), (windowBits), ZLIB_VERSION, sizeof(z_stream)) +#define inflateBackInit(strm, windowBits, window) \ + inflateBackInit_((strm), (windowBits), (window), \ + ZLIB_VERSION, sizeof(z_stream)) + +#ifdef _LARGEFILE64_SOURCE + ZEXTERN gzFile ZEXPORT gzopen64 OF((const char *, const char *)); + ZEXTERN off64_t ZEXPORT gzseek64 OF((gzFile, off64_t, int)); + ZEXTERN off64_t ZEXPORT gztell64 OF((gzFile)); + ZEXTERN off64_t ZEXPORT gzoffset64 OF((gzFile)); + ZEXTERN uLong ZEXPORT adler32_combine64 OF((uLong, uLong, off64_t)); + ZEXTERN uLong ZEXPORT crc32_combine64 OF((uLong, uLong, off64_t)); +#endif + +#if !defined(ZLIB_INTERNAL) && _FILE_OFFSET_BITS == 64 +# define gzopen gzopen64 +# define gzseek gzseek64 +# define gztell gztell64 +# define gzoffset gzoffset64 +# define adler32_combine adler32_combine64 +# define crc32_combine crc32_combine64 +# ifndef _LARGEFILE64_SOURCE + ZEXTERN gzFile ZEXPORT gzopen64 OF((const char *, const char *)); + ZEXTERN off_t ZEXPORT gzseek64 OF((gzFile, off_t, int)); + ZEXTERN off_t ZEXPORT gztell64 OF((gzFile)); + ZEXTERN off_t ZEXPORT gzoffset64 OF((gzFile)); + ZEXTERN uLong ZEXPORT adler32_combine64 OF((uLong, uLong, off_t)); + ZEXTERN uLong ZEXPORT crc32_combine64 OF((uLong, uLong, off_t)); +# endif +#else + ZEXTERN gzFile ZEXPORT gzopen OF((const char *, const char *)); + ZEXTERN z_off_t ZEXPORT gzseek OF((gzFile, z_off_t, int)); + ZEXTERN z_off_t ZEXPORT gztell OF((gzFile)); + ZEXTERN z_off_t ZEXPORT gzoffset OF((gzFile)); + ZEXTERN uLong ZEXPORT adler32_combine OF((uLong, uLong, z_off_t)); + ZEXTERN uLong ZEXPORT crc32_combine OF((uLong, uLong, z_off_t)); +#endif + +#if !defined(ZUTIL_H) && !defined(NO_DUMMY_DECL) + struct internal_state {int dummy;}; /* hack for buggy compilers */ +#endif + +ZEXTERN const char * ZEXPORT zError OF((int)); +ZEXTERN int ZEXPORT inflateSyncPoint OF((z_streamp)); +ZEXTERN const uLongf * ZEXPORT get_crc_table OF((void)); +ZEXTERN int ZEXPORT inflateUndermine OF((z_streamp, int)); + +#ifdef __cplusplus +} +#endif + +#endif /* ZLIB_H */ diff --git a/mk/linux/mojosetup/zlib/zutil.c b/mk/linux/mojosetup/zlib/zutil.c new file mode 100644 index 00000000..98a55a88 --- /dev/null +++ b/mk/linux/mojosetup/zlib/zutil.c @@ -0,0 +1,318 @@ +/* zutil.c -- target dependent utility functions for the compression library + * Copyright (C) 1995-2005 Jean-loup Gailly. + * For conditions of distribution and use, see copyright notice in zlib.h + */ + +/* @(#) $Id$ */ + +#include "zutil.h" + +#ifndef NO_DUMMY_DECL +struct internal_state {int dummy;}; /* for buggy compilers */ +#endif + +const char * const z_errmsg[10] = { +"need dictionary", /* Z_NEED_DICT 2 */ +"stream end", /* Z_STREAM_END 1 */ +"", /* Z_OK 0 */ +"file error", /* Z_ERRNO (-1) */ +"stream error", /* Z_STREAM_ERROR (-2) */ +"data error", /* Z_DATA_ERROR (-3) */ +"insufficient memory", /* Z_MEM_ERROR (-4) */ +"buffer error", /* Z_BUF_ERROR (-5) */ +"incompatible version",/* Z_VERSION_ERROR (-6) */ +""}; + + +const char * ZEXPORT zlibVersion() +{ + return ZLIB_VERSION; +} + +uLong ZEXPORT zlibCompileFlags() +{ + uLong flags; + + flags = 0; + switch ((int)(sizeof(uInt))) { + case 2: break; + case 4: flags += 1; break; + case 8: flags += 2; break; + default: flags += 3; + } + switch ((int)(sizeof(uLong))) { + case 2: break; + case 4: flags += 1 << 2; break; + case 8: flags += 2 << 2; break; + default: flags += 3 << 2; + } + switch ((int)(sizeof(voidpf))) { + case 2: break; + case 4: flags += 1 << 4; break; + case 8: flags += 2 << 4; break; + default: flags += 3 << 4; + } + switch ((int)(sizeof(z_off_t))) { + case 2: break; + case 4: flags += 1 << 6; break; + case 8: flags += 2 << 6; break; + default: flags += 3 << 6; + } +#ifdef DEBUG + flags += 1 << 8; +#endif +#if defined(ASMV) || defined(ASMINF) + flags += 1 << 9; +#endif +#ifdef ZLIB_WINAPI + flags += 1 << 10; +#endif +#ifdef BUILDFIXED + flags += 1 << 12; +#endif +#ifdef DYNAMIC_CRC_TABLE + flags += 1 << 13; +#endif +#ifdef NO_GZCOMPRESS + flags += 1L << 16; +#endif +#ifdef NO_GZIP + flags += 1L << 17; +#endif +#ifdef PKZIP_BUG_WORKAROUND + flags += 1L << 20; +#endif +#ifdef FASTEST + flags += 1L << 21; +#endif +#ifdef STDC +# ifdef NO_vsnprintf + flags += 1L << 25; +# ifdef HAS_vsprintf_void + flags += 1L << 26; +# endif +# else +# ifdef HAS_vsnprintf_void + flags += 1L << 26; +# endif +# endif +#else + flags += 1L << 24; +# ifdef NO_snprintf + flags += 1L << 25; +# ifdef HAS_sprintf_void + flags += 1L << 26; +# endif +# else +# ifdef HAS_snprintf_void + flags += 1L << 26; +# endif +# endif +#endif + return flags; +} + +#ifdef DEBUG + +# ifndef verbose +# define verbose 0 +# endif +int z_verbose = verbose; + +void z_error (m) + char *m; +{ + fprintf(stderr, "%s\n", m); + exit(1); +} +#endif + +/* exported to allow conversion of error code to string for compress() and + * uncompress() + */ +const char * ZEXPORT zError(err) + int err; +{ + return ERR_MSG(err); +} + +#if defined(_WIN32_WCE) + /* The Microsoft C Run-Time Library for Windows CE doesn't have + * errno. We define it as a global variable to simplify porting. + * Its value is always 0 and should not be used. + */ + int errno = 0; +#endif + +#ifndef HAVE_MEMCPY + +void zmemcpy(dest, source, len) + Bytef* dest; + const Bytef* source; + uInt len; +{ + if (len == 0) return; + do { + *dest++ = *source++; /* ??? to be unrolled */ + } while (--len != 0); +} + +int zmemcmp(s1, s2, len) + const Bytef* s1; + const Bytef* s2; + uInt len; +{ + uInt j; + + for (j = 0; j < len; j++) { + if (s1[j] != s2[j]) return 2*(s1[j] > s2[j])-1; + } + return 0; +} + +void zmemzero(dest, len) + Bytef* dest; + uInt len; +{ + if (len == 0) return; + do { + *dest++ = 0; /* ??? to be unrolled */ + } while (--len != 0); +} +#endif + + +#ifdef SYS16BIT + +#ifdef __TURBOC__ +/* Turbo C in 16-bit mode */ + +# define MY_ZCALLOC + +/* Turbo C malloc() does not allow dynamic allocation of 64K bytes + * and farmalloc(64K) returns a pointer with an offset of 8, so we + * must fix the pointer. Warning: the pointer must be put back to its + * original form in order to free it, use zcfree(). + */ + +#define MAX_PTR 10 +/* 10*64K = 640K */ + +local int next_ptr = 0; + +typedef struct ptr_table_s { + voidpf org_ptr; + voidpf new_ptr; +} ptr_table; + +local ptr_table table[MAX_PTR]; +/* This table is used to remember the original form of pointers + * to large buffers (64K). Such pointers are normalized with a zero offset. + * Since MSDOS is not a preemptive multitasking OS, this table is not + * protected from concurrent access. This hack doesn't work anyway on + * a protected system like OS/2. Use Microsoft C instead. + */ + +voidpf zcalloc (voidpf opaque, unsigned items, unsigned size) +{ + voidpf buf = opaque; /* just to make some compilers happy */ + ulg bsize = (ulg)items*size; + + /* If we allocate less than 65520 bytes, we assume that farmalloc + * will return a usable pointer which doesn't have to be normalized. + */ + if (bsize < 65520L) { + buf = farmalloc(bsize); + if (*(ush*)&buf != 0) return buf; + } else { + buf = farmalloc(bsize + 16L); + } + if (buf == NULL || next_ptr >= MAX_PTR) return NULL; + table[next_ptr].org_ptr = buf; + + /* Normalize the pointer to seg:0 */ + *((ush*)&buf+1) += ((ush)((uch*)buf-0) + 15) >> 4; + *(ush*)&buf = 0; + table[next_ptr++].new_ptr = buf; + return buf; +} + +void zcfree (voidpf opaque, voidpf ptr) +{ + int n; + if (*(ush*)&ptr != 0) { /* object < 64K */ + farfree(ptr); + return; + } + /* Find the original pointer */ + for (n = 0; n < next_ptr; n++) { + if (ptr != table[n].new_ptr) continue; + + farfree(table[n].org_ptr); + while (++n < next_ptr) { + table[n-1] = table[n]; + } + next_ptr--; + return; + } + ptr = opaque; /* just to make some compilers happy */ + Assert(0, "zcfree: ptr not found"); +} + +#endif /* __TURBOC__ */ + + +#ifdef M_I86 +/* Microsoft C in 16-bit mode */ + +# define MY_ZCALLOC + +#if (!defined(_MSC_VER) || (_MSC_VER <= 600)) +# define _halloc halloc +# define _hfree hfree +#endif + +voidpf zcalloc (voidpf opaque, unsigned items, unsigned size) +{ + if (opaque) opaque = 0; /* to make compiler happy */ + return _halloc((long)items, size); +} + +void zcfree (voidpf opaque, voidpf ptr) +{ + if (opaque) opaque = 0; /* to make compiler happy */ + _hfree(ptr); +} + +#endif /* M_I86 */ + +#endif /* SYS16BIT */ + + +#ifndef MY_ZCALLOC /* Any system without a special alloc function */ + +#ifndef STDC +extern voidp malloc OF((uInt size)); +extern voidp calloc OF((uInt items, uInt size)); +extern void free OF((voidpf ptr)); +#endif + +voidpf zcalloc (opaque, items, size) + voidpf opaque; + unsigned items; + unsigned size; +{ + if (opaque) items += size - size; /* make compiler happy */ + return sizeof(uInt) > 2 ? (voidpf)malloc(items * size) : + (voidpf)calloc(items, size); +} + +void zcfree (opaque, ptr) + voidpf opaque; + voidpf ptr; +{ + free(ptr); + if (opaque) return; /* make compiler happy */ +} + +#endif /* MY_ZCALLOC */ diff --git a/mk/linux/mojosetup/zlib/zutil.h b/mk/linux/mojosetup/zlib/zutil.h new file mode 100644 index 00000000..025035db --- /dev/null +++ b/mk/linux/mojosetup/zlib/zutil.h @@ -0,0 +1,287 @@ +/* zutil.h -- internal interface and configuration of the compression library + * Copyright (C) 1995-2010 Jean-loup Gailly. + * For conditions of distribution and use, see copyright notice in zlib.h + */ + +/* WARNING: this file should *not* be used by applications. It is + part of the implementation of the compression library and is + subject to change. Applications should only use zlib.h. + */ + +/* @(#) $Id$ */ + +#ifndef ZUTIL_H +#define ZUTIL_H + +#define ZLIB_INTERNAL +#include "zlib.h" + +#ifdef STDC +# if !(defined(_WIN32_WCE) && defined(_MSC_VER)) +# include +# endif +# include +# include +#endif + +#if defined(UNDER_CE) && defined(NO_ERRNO_H) +# define zseterrno(ERR) SetLastError((DWORD)(ERR)) +# define zerrno() ((int)GetLastError()) +#else +# ifdef NO_ERRNO_H + extern int errno; +# else +# include +# endif +# define zseterrno(ERR) do { errno = (ERR); } while (0) +# define zerrno() errno +#endif + +#ifndef local +# define local static +#endif +/* compile with -Dlocal if your debugger can't find static symbols */ + +typedef unsigned char uch; +typedef uch FAR uchf; +typedef unsigned short ush; +typedef ush FAR ushf; +typedef unsigned long ulg; + +extern const char * const z_errmsg[10]; /* indexed by 2-zlib_error */ +/* (size given to avoid silly warnings with Visual C++) */ + +#define ERR_MSG(err) z_errmsg[Z_NEED_DICT-(err)] + +#define ERR_RETURN(strm,err) \ + return (strm->msg = (char*)ERR_MSG(err), (err)) +/* To be used only when the state is known to be valid */ + + /* common constants */ + +#ifndef DEF_WBITS +# define DEF_WBITS MAX_WBITS +#endif +/* default windowBits for decompression. MAX_WBITS is for compression only */ + +#if MAX_MEM_LEVEL >= 8 +# define DEF_MEM_LEVEL 8 +#else +# define DEF_MEM_LEVEL MAX_MEM_LEVEL +#endif +/* default memLevel */ + +#define STORED_BLOCK 0 +#define STATIC_TREES 1 +#define DYN_TREES 2 +/* The three kinds of block type */ + +#define MIN_MATCH 3 +#define MAX_MATCH 258 +/* The minimum and maximum match lengths */ + +#define PRESET_DICT 0x20 /* preset dictionary flag in zlib header */ + + /* target dependencies */ + +#if defined(MSDOS) || (defined(WINDOWS) && !defined(WIN32)) +# define OS_CODE 0x00 +# if defined(__TURBOC__) || defined(__BORLANDC__) +# if (__STDC__ == 1) && (defined(__LARGE__) || defined(__COMPACT__)) + /* Allow compilation with ANSI keywords only enabled */ + void _Cdecl farfree( void *block ); + void *_Cdecl farmalloc( unsigned long nbytes ); +# else +# include +# endif +# else /* MSC or DJGPP */ +# include +# endif +#endif + +#ifdef AMIGA +# define OS_CODE 0x01 +#endif + +#if defined(VAXC) || defined(VMS) +# define OS_CODE 0x02 +# define F_OPEN(name, mode) \ + fopen((name), (mode), "mbc=60", "ctx=stm", "rfm=fix", "mrs=512") +#endif + +#if defined(ATARI) || defined(atarist) +# define OS_CODE 0x05 +#endif + +#ifdef OS2 +# define OS_CODE 0x06 +# ifdef M_I86 +# include +# endif +#endif + +#if defined(MACOS) || defined(TARGET_OS_MAC) +# define OS_CODE 0x07 +# if defined(__MWERKS__) && __dest_os != __be_os && __dest_os != __win32_os +# include /* for fdopen */ +# else +# ifndef fdopen +# define fdopen(fd,mode) NULL /* No fdopen() */ +# endif +# endif +#endif + +#ifdef TOPS20 +# define OS_CODE 0x0a +#endif + +#ifdef WIN32 +# ifndef __CYGWIN__ /* Cygwin is Unix, not Win32 */ +# define OS_CODE 0x0b +# endif +#endif + +#ifdef __50SERIES /* Prime/PRIMOS */ +# define OS_CODE 0x0f +#endif + +#if defined(_BEOS_) || defined(RISCOS) +# define fdopen(fd,mode) NULL /* No fdopen() */ +#endif + +#if (defined(_MSC_VER) && (_MSC_VER > 600)) && !defined __INTERIX +# if defined(_WIN32_WCE) +# define fdopen(fd,mode) NULL /* No fdopen() */ +# ifndef _PTRDIFF_T_DEFINED + typedef int ptrdiff_t; +# define _PTRDIFF_T_DEFINED +# endif +# else +# define fdopen(fd,type) _fdopen(fd,type) +# endif +#endif + +#if defined(__BORLANDC__) + #pragma warn -8004 + #pragma warn -8008 + #pragma warn -8066 +#endif + +#ifdef _LARGEFILE64_SOURCE +# define z_off64_t off64_t +#else +# define z_off64_t z_off_t +#endif + + /* common defaults */ + +#ifndef OS_CODE +# define OS_CODE 0x03 /* assume Unix */ +#endif + +#ifndef F_OPEN +# define F_OPEN(name, mode) fopen((name), (mode)) +#endif + +#ifdef _LARGEFILE64_SOURCE +# define F_OPEN64(name, mode) fopen64((name), (mode)) +#else +# define F_OPEN64(name, mode) fopen((name), (mode)) +#endif + + /* functions */ + +#if defined(STDC99) || (defined(__TURBOC__) && __TURBOC__ >= 0x550) +# ifndef HAVE_VSNPRINTF +# define HAVE_VSNPRINTF +# endif +#endif +#if defined(__CYGWIN__) +# ifndef HAVE_VSNPRINTF +# define HAVE_VSNPRINTF +# endif +#endif +#ifndef HAVE_VSNPRINTF +# ifdef MSDOS + /* vsnprintf may exist on some MS-DOS compilers (DJGPP?), + but for now we just assume it doesn't. */ +# define NO_vsnprintf +# endif +# ifdef __TURBOC__ +# define NO_vsnprintf +# endif +# ifdef WIN32 + /* In Win32, vsnprintf is available as the "non-ANSI" _vsnprintf. */ +# if !defined(vsnprintf) && !defined(NO_vsnprintf) +# if !defined(_MSC_VER) || ( defined(_MSC_VER) && _MSC_VER < 1500 ) +# define vsnprintf _vsnprintf +# endif +# endif +# endif +# ifdef __SASC +# define NO_vsnprintf +# endif +#endif +#ifdef VMS +# define NO_vsnprintf +#endif + +#if defined(pyr) +# define NO_MEMCPY +#endif +#if defined(SMALL_MEDIUM) && !defined(_MSC_VER) && !defined(__SC__) + /* Use our own functions for small and medium model with MSC <= 5.0. + * You may have to use the same strategy for Borland C (untested). + * The __SC__ check is for Symantec. + */ +# define NO_MEMCPY +#endif +#if defined(STDC) && !defined(HAVE_MEMCPY) && !defined(NO_MEMCPY) +# define HAVE_MEMCPY +#endif +#ifdef HAVE_MEMCPY +# ifdef SMALL_MEDIUM /* MSDOS small or medium model */ +# define zmemcpy _fmemcpy +# define zmemcmp _fmemcmp +# define zmemzero(dest, len) _fmemset(dest, 0, len) +# else +# define zmemcpy memcpy +# define zmemcmp memcmp +# define zmemzero(dest, len) memset(dest, 0, len) +# endif +#else + extern void zmemcpy OF((Bytef* dest, const Bytef* source, uInt len)); + extern int zmemcmp OF((const Bytef* s1, const Bytef* s2, uInt len)); + extern void zmemzero OF((Bytef* dest, uInt len)); +#endif + +/* Diagnostic functions */ +#ifdef DEBUG +# include + extern int z_verbose; + extern void z_error OF((char *m)); +# define Assert(cond,msg) {if(!(cond)) z_error(msg);} +# define Trace(x) {if (z_verbose>=0) fprintf x ;} +# define Tracev(x) {if (z_verbose>0) fprintf x ;} +# define Tracevv(x) {if (z_verbose>1) fprintf x ;} +# define Tracec(c,x) {if (z_verbose>0 && (c)) fprintf x ;} +# define Tracecv(c,x) {if (z_verbose>1 && (c)) fprintf x ;} +#else +# define Assert(cond,msg) +# define Trace(x) +# define Tracev(x) +# define Tracevv(x) +# define Tracec(c,x) +# define Tracecv(c,x) +#endif + + +voidpf zcalloc OF((voidpf opaque, unsigned items, unsigned size)); +void zcfree OF((voidpf opaque, voidpf ptr)); + +#define ZALLOC(strm, items, size) \ + (*((strm)->zalloc))((strm)->opaque, (items), (size)) +#define ZFREE(strm, addr) (*((strm)->zfree))((strm)->opaque, (voidpf)(addr)) +#define TRY_FREE(s, p) {if (p) ZFREE(s, p);} + +#endif /* ZUTIL_H */