remind-rb 6.2.10.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/LICENSE +328 -0
- data/README.md +141 -0
- data/ext/remind/shim.c +379 -0
- data/lib/remind/builder.rb +252 -0
- data/lib/remind/library.rb +141 -0
- data/lib/remind/native.rb +257 -0
- data/lib/remind/reminder.rb +527 -0
- data/lib/remind/runtime.rb +130 -0
- data/lib/remind/session.rb +246 -0
- data/lib/remind/source.rb +160 -0
- data/lib/remind/value.rb +170 -0
- data/lib/remind/version.rb +13 -0
- data/lib/remind.rb +147 -0
- data/remind-v06.02.10/COPYRIGHT +300 -0
- data/remind-v06.02.10/configure +5684 -0
- data/remind-v06.02.10/configure.ac +131 -0
- data/remind-v06.02.10/docs/WHATSNEW +3858 -0
- data/remind-v06.02.10/include/ansitext.rem +35 -0
- data/remind-v06.02.10/include/holidays/ad/02.rem +15 -0
- data/remind-v06.02.10/include/holidays/ad/03.rem +14 -0
- data/remind-v06.02.10/include/holidays/ad/04.rem +14 -0
- data/remind-v06.02.10/include/holidays/ad/05.rem +14 -0
- data/remind-v06.02.10/include/holidays/ad/06.rem +16 -0
- data/remind-v06.02.10/include/holidays/ad/07.rem +15 -0
- data/remind-v06.02.10/include/holidays/ad/08.rem +14 -0
- data/remind-v06.02.10/include/holidays/ad.rem +28 -0
- data/remind-v06.02.10/include/holidays/ae.rem +10 -0
- data/remind-v06.02.10/include/holidays/al.rem +33 -0
- data/remind-v06.02.10/include/holidays/am.rem +19 -0
- data/remind-v06.02.10/include/holidays/ao.rem +41 -0
- data/remind-v06.02.10/include/holidays/ar.rem +38 -0
- data/remind-v06.02.10/include/holidays/as.rem +40 -0
- data/remind-v06.02.10/include/holidays/at/1.rem +15 -0
- data/remind-v06.02.10/include/holidays/at/2.rem +16 -0
- data/remind-v06.02.10/include/holidays/at/3.rem +15 -0
- data/remind-v06.02.10/include/holidays/at/4.rem +15 -0
- data/remind-v06.02.10/include/holidays/at/5.rem +15 -0
- data/remind-v06.02.10/include/holidays/at/6.rem +15 -0
- data/remind-v06.02.10/include/holidays/at/7.rem +15 -0
- data/remind-v06.02.10/include/holidays/at/8.rem +15 -0
- data/remind-v06.02.10/include/holidays/at/9.rem +15 -0
- data/remind-v06.02.10/include/holidays/at.rem +32 -0
- data/remind-v06.02.10/include/holidays/au/act.rem +27 -0
- data/remind-v06.02.10/include/holidays/au/nsw.rem +25 -0
- data/remind-v06.02.10/include/holidays/au/nt.rem +28 -0
- data/remind-v06.02.10/include/holidays/au/qld.rem +23 -0
- data/remind-v06.02.10/include/holidays/au/sa.rem +29 -0
- data/remind-v06.02.10/include/holidays/au/tas.rem +16 -0
- data/remind-v06.02.10/include/holidays/au/vic.rem +24 -0
- data/remind-v06.02.10/include/holidays/au/wa.rem +24 -0
- data/remind-v06.02.10/include/holidays/au.rem +21 -0
- data/remind-v06.02.10/include/holidays/aw.rem +19 -0
- data/remind-v06.02.10/include/holidays/az.rem +44 -0
- data/remind-v06.02.10/include/holidays/ba/bih.rem +23 -0
- data/remind-v06.02.10/include/holidays/ba/brc.rem +20 -0
- data/remind-v06.02.10/include/holidays/ba/srp.rem +23 -0
- data/remind-v06.02.10/include/holidays/ba.rem +22 -0
- data/remind-v06.02.10/include/holidays/bb.rem +28 -0
- data/remind-v06.02.10/include/holidays/bd.rem +14 -0
- data/remind-v06.02.10/include/holidays/be.rem +24 -0
- data/remind-v06.02.10/include/holidays/bf.rem +29 -0
- data/remind-v06.02.10/include/holidays/bg.rem +34 -0
- data/remind-v06.02.10/include/holidays/bh.rem +11 -0
- data/remind-v06.02.10/include/holidays/bi.rem +30 -0
- data/remind-v06.02.10/include/holidays/bn.rem +22 -0
- data/remind-v06.02.10/include/holidays/bo/b.rem +13 -0
- data/remind-v06.02.10/include/holidays/bo/c.rem +13 -0
- data/remind-v06.02.10/include/holidays/bo/h.rem +13 -0
- data/remind-v06.02.10/include/holidays/bo/l.rem +13 -0
- data/remind-v06.02.10/include/holidays/bo/n.rem +13 -0
- data/remind-v06.02.10/include/holidays/bo/o.rem +13 -0
- data/remind-v06.02.10/include/holidays/bo/p.rem +13 -0
- data/remind-v06.02.10/include/holidays/bo/s.rem +13 -0
- data/remind-v06.02.10/include/holidays/bo/t.rem +13 -0
- data/remind-v06.02.10/include/holidays/bo.rem +32 -0
- data/remind-v06.02.10/include/holidays/br/ac.rem +21 -0
- data/remind-v06.02.10/include/holidays/br/al.rem +16 -0
- data/remind-v06.02.10/include/holidays/br/am.rem +13 -0
- data/remind-v06.02.10/include/holidays/br/ap.rem +15 -0
- data/remind-v06.02.10/include/holidays/br/ba.rem +13 -0
- data/remind-v06.02.10/include/holidays/br/ce.rem +15 -0
- data/remind-v06.02.10/include/holidays/br/df.rem +14 -0
- data/remind-v06.02.10/include/holidays/br/es.rem +13 -0
- data/remind-v06.02.10/include/holidays/br/go.rem +14 -0
- data/remind-v06.02.10/include/holidays/br/ma.rem +13 -0
- data/remind-v06.02.10/include/holidays/br/mg.rem +13 -0
- data/remind-v06.02.10/include/holidays/br/ms.rem +13 -0
- data/remind-v06.02.10/include/holidays/br/pa.rem +13 -0
- data/remind-v06.02.10/include/holidays/br/pb.rem +13 -0
- data/remind-v06.02.10/include/holidays/br/pe.rem +13 -0
- data/remind-v06.02.10/include/holidays/br/pi.rem +13 -0
- data/remind-v06.02.10/include/holidays/br/pr.rem +13 -0
- data/remind-v06.02.10/include/holidays/br/rj.rem +13 -0
- data/remind-v06.02.10/include/holidays/br/rn.rem +14 -0
- data/remind-v06.02.10/include/holidays/br/ro.rem +14 -0
- data/remind-v06.02.10/include/holidays/br/rr.rem +13 -0
- data/remind-v06.02.10/include/holidays/br/rs.rem +13 -0
- data/remind-v06.02.10/include/holidays/br/sc.rem +14 -0
- data/remind-v06.02.10/include/holidays/br/se.rem +13 -0
- data/remind-v06.02.10/include/holidays/br/sp.rem +13 -0
- data/remind-v06.02.10/include/holidays/br/to.rem +15 -0
- data/remind-v06.02.10/include/holidays/br.rem +33 -0
- data/remind-v06.02.10/include/holidays/bs.rem +26 -0
- data/remind-v06.02.10/include/holidays/bw.rem +31 -0
- data/remind-v06.02.10/include/holidays/by.rem +17 -0
- data/remind-v06.02.10/include/holidays/bz.rem +43 -0
- data/remind-v06.02.10/include/holidays/ca/ab.rem +17 -0
- data/remind-v06.02.10/include/holidays/ca/bc.rem +14 -0
- data/remind-v06.02.10/include/holidays/ca/mb.rem +16 -0
- data/remind-v06.02.10/include/holidays/ca/nb.rem +14 -0
- data/remind-v06.02.10/include/holidays/ca/nl.rem +19 -0
- data/remind-v06.02.10/include/holidays/ca/ns.rem +16 -0
- data/remind-v06.02.10/include/holidays/ca/nt.rem +14 -0
- data/remind-v06.02.10/include/holidays/ca/nu.rem +16 -0
- data/remind-v06.02.10/include/holidays/ca/on.rem +16 -0
- data/remind-v06.02.10/include/holidays/ca/pe.rem +13 -0
- data/remind-v06.02.10/include/holidays/ca/qc.rem +18 -0
- data/remind-v06.02.10/include/holidays/ca/sk.rem +14 -0
- data/remind-v06.02.10/include/holidays/ca/yt.rem +17 -0
- data/remind-v06.02.10/include/holidays/ca.rem +37 -0
- data/remind-v06.02.10/include/holidays/cg.rem +17 -0
- data/remind-v06.02.10/include/holidays/ch/ag.rem +22 -0
- data/remind-v06.02.10/include/holidays/ch/ai.rem +20 -0
- data/remind-v06.02.10/include/holidays/ch/ar.rem +16 -0
- data/remind-v06.02.10/include/holidays/ch/be.rem +17 -0
- data/remind-v06.02.10/include/holidays/ch/bl.rem +17 -0
- data/remind-v06.02.10/include/holidays/ch/bs.rem +17 -0
- data/remind-v06.02.10/include/holidays/ch/fr.rem +19 -0
- data/remind-v06.02.10/include/holidays/ch/ge.rem +17 -0
- data/remind-v06.02.10/include/holidays/ch/gl.rem +22 -0
- data/remind-v06.02.10/include/holidays/ch/gr.rem +18 -0
- data/remind-v06.02.10/include/holidays/ch/ju.rem +21 -0
- data/remind-v06.02.10/include/holidays/ch/lu.rem +21 -0
- data/remind-v06.02.10/include/holidays/ch/ne.rem +18 -0
- data/remind-v06.02.10/include/holidays/ch/nw.rem +24 -0
- data/remind-v06.02.10/include/holidays/ch/ow.rem +24 -0
- data/remind-v06.02.10/include/holidays/ch/sg.rem +20 -0
- data/remind-v06.02.10/include/holidays/ch/sh.rem +20 -0
- data/remind-v06.02.10/include/holidays/ch/so.rem +17 -0
- data/remind-v06.02.10/include/holidays/ch/sz.rem +22 -0
- data/remind-v06.02.10/include/holidays/ch/tg.rem +18 -0
- data/remind-v06.02.10/include/holidays/ch/ti.rem +23 -0
- data/remind-v06.02.10/include/holidays/ch/ur.rem +22 -0
- data/remind-v06.02.10/include/holidays/ch/vd.rem +17 -0
- data/remind-v06.02.10/include/holidays/ch/vs.rem +23 -0
- data/remind-v06.02.10/include/holidays/ch/zg.rem +23 -0
- data/remind-v06.02.10/include/holidays/ch/zh.rem +18 -0
- data/remind-v06.02.10/include/holidays/ch.rem +18 -0
- data/remind-v06.02.10/include/holidays/chinese-new-year.rem +86 -0
- data/remind-v06.02.10/include/holidays/cl/ap.rem +13 -0
- data/remind-v06.02.10/include/holidays/cl/nb.rem +13 -0
- data/remind-v06.02.10/include/holidays/cl.rem +46 -0
- data/remind-v06.02.10/include/holidays/cm.rem +21 -0
- data/remind-v06.02.10/include/holidays/co.rem +85 -0
- data/remind-v06.02.10/include/holidays/cr.rem +39 -0
- data/remind-v06.02.10/include/holidays/cu.rem +19 -0
- data/remind-v06.02.10/include/holidays/cw.rem +24 -0
- data/remind-v06.02.10/include/holidays/cy.rem +27 -0
- data/remind-v06.02.10/include/holidays/cz.rem +20 -0
- data/remind-v06.02.10/include/holidays/de/bb.rem +15 -0
- data/remind-v06.02.10/include/holidays/de/be.rem +13 -0
- data/remind-v06.02.10/include/holidays/de/bw.rem +15 -0
- data/remind-v06.02.10/include/holidays/de/by.rem +18 -0
- data/remind-v06.02.10/include/holidays/de/hb.rem +13 -0
- data/remind-v06.02.10/include/holidays/de/he.rem +13 -0
- data/remind-v06.02.10/include/holidays/de/hh.rem +13 -0
- data/remind-v06.02.10/include/holidays/de/mv.rem +14 -0
- data/remind-v06.02.10/include/holidays/de/ni.rem +13 -0
- data/remind-v06.02.10/include/holidays/de/nw.rem +14 -0
- data/remind-v06.02.10/include/holidays/de/rp.rem +14 -0
- data/remind-v06.02.10/include/holidays/de/sh.rem +13 -0
- data/remind-v06.02.10/include/holidays/de/sl.rem +15 -0
- data/remind-v06.02.10/include/holidays/de/sn.rem +14 -0
- data/remind-v06.02.10/include/holidays/de/st.rem +14 -0
- data/remind-v06.02.10/include/holidays/de/th.rem +14 -0
- data/remind-v06.02.10/include/holidays/de.rem +23 -0
- data/remind-v06.02.10/include/holidays/discordian.rem +25 -0
- data/remind-v06.02.10/include/holidays/dj.rem +12 -0
- data/remind-v06.02.10/include/holidays/dk.rem +23 -0
- data/remind-v06.02.10/include/holidays/dm.rem +24 -0
- data/remind-v06.02.10/include/holidays/do.rem +36 -0
- data/remind-v06.02.10/include/holidays/dz.rem +12 -0
- data/remind-v06.02.10/include/holidays/ec.rem +48 -0
- data/remind-v06.02.10/include/holidays/ee.rem +19 -0
- data/remind-v06.02.10/include/holidays/eg.rem +17 -0
- data/remind-v06.02.10/include/holidays/es/an.rem +17 -0
- data/remind-v06.02.10/include/holidays/es/ar.rem +17 -0
- data/remind-v06.02.10/include/holidays/es/as.rem +17 -0
- data/remind-v06.02.10/include/holidays/es/cb.rem +15 -0
- data/remind-v06.02.10/include/holidays/es/ce.rem +15 -0
- data/remind-v06.02.10/include/holidays/es/cl.rem +17 -0
- data/remind-v06.02.10/include/holidays/es/cm.rem +15 -0
- data/remind-v06.02.10/include/holidays/es/cn.rem +15 -0
- data/remind-v06.02.10/include/holidays/es/ct.rem +16 -0
- data/remind-v06.02.10/include/holidays/es/ex.rem +16 -0
- data/remind-v06.02.10/include/holidays/es/ga.rem +15 -0
- data/remind-v06.02.10/include/holidays/es/ib.rem +15 -0
- data/remind-v06.02.10/include/holidays/es/mc.rem +17 -0
- data/remind-v06.02.10/include/holidays/es/md.rem +16 -0
- data/remind-v06.02.10/include/holidays/es/ml.rem +15 -0
- data/remind-v06.02.10/include/holidays/es/nc.rem +15 -0
- data/remind-v06.02.10/include/holidays/es/pv.rem +15 -0
- data/remind-v06.02.10/include/holidays/es/ri.rem +16 -0
- data/remind-v06.02.10/include/holidays/es/vc.rem +16 -0
- data/remind-v06.02.10/include/holidays/es.rem +23 -0
- data/remind-v06.02.10/include/holidays/et.rem +20 -0
- data/remind-v06.02.10/include/holidays/fi.rem +43 -0
- data/remind-v06.02.10/include/holidays/fr/bl.rem +13 -0
- data/remind-v06.02.10/include/holidays/fr/ges.rem +14 -0
- data/remind-v06.02.10/include/holidays/fr/gp.rem +16 -0
- data/remind-v06.02.10/include/holidays/fr/gy.rem +13 -0
- data/remind-v06.02.10/include/holidays/fr/mf.rem +13 -0
- data/remind-v06.02.10/include/holidays/fr/mq.rem +15 -0
- data/remind-v06.02.10/include/holidays/fr/nc.rem +13 -0
- data/remind-v06.02.10/include/holidays/fr/pf.rem +15 -0
- data/remind-v06.02.10/include/holidays/fr/re.rem +13 -0
- data/remind-v06.02.10/include/holidays/fr/wf.rem +14 -0
- data/remind-v06.02.10/include/holidays/fr/yt.rem +13 -0
- data/remind-v06.02.10/include/holidays/fr.rem +18 -0
- data/remind-v06.02.10/include/holidays/ga.rem +18 -0
- data/remind-v06.02.10/include/holidays/gb/eng.rem +14 -0
- data/remind-v06.02.10/include/holidays/gb/nir.rem +20 -0
- data/remind-v06.02.10/include/holidays/gb/sct.rem +20 -0
- data/remind-v06.02.10/include/holidays/gb/wls.rem +14 -0
- data/remind-v06.02.10/include/holidays/gb.rem +27 -0
- data/remind-v06.02.10/include/holidays/ge.rem +24 -0
- data/remind-v06.02.10/include/holidays/gh.rem +34 -0
- data/remind-v06.02.10/include/holidays/gl.rem +25 -0
- data/remind-v06.02.10/include/holidays/gr.rem +37 -0
- data/remind-v06.02.10/include/holidays/gt.rem +24 -0
- data/remind-v06.02.10/include/holidays/gu.rem +37 -0
- data/remind-v06.02.10/include/holidays/hk.rem +25 -0
- data/remind-v06.02.10/include/holidays/hn.rem +18 -0
- data/remind-v06.02.10/include/holidays/hr.rem +21 -0
- data/remind-v06.02.10/include/holidays/ht.rem +34 -0
- data/remind-v06.02.10/include/holidays/hu.rem +20 -0
- data/remind-v06.02.10/include/holidays/id.rem +15 -0
- data/remind-v06.02.10/include/holidays/ie.rem +41 -0
- data/remind-v06.02.10/include/holidays/im.rem +26 -0
- data/remind-v06.02.10/include/holidays/in/ap.rem +14 -0
- data/remind-v06.02.10/include/holidays/in/as.rem +13 -0
- data/remind-v06.02.10/include/holidays/in/br.rem +14 -0
- data/remind-v06.02.10/include/holidays/in/cg.rem +13 -0
- data/remind-v06.02.10/include/holidays/in/gj.rem +15 -0
- data/remind-v06.02.10/include/holidays/in/hr.rem +14 -0
- data/remind-v06.02.10/include/holidays/in/ka.rem +13 -0
- data/remind-v06.02.10/include/holidays/in/kl.rem +14 -0
- data/remind-v06.02.10/include/holidays/in/mh.rem +15 -0
- data/remind-v06.02.10/include/holidays/in/mp.rem +13 -0
- data/remind-v06.02.10/include/holidays/in/od.rem +15 -0
- data/remind-v06.02.10/include/holidays/in/rj.rem +14 -0
- data/remind-v06.02.10/include/holidays/in/sk.rem +13 -0
- data/remind-v06.02.10/include/holidays/in/tn.rem +15 -0
- data/remind-v06.02.10/include/holidays/in/ts.rem +14 -0
- data/remind-v06.02.10/include/holidays/in/uk.rem +13 -0
- data/remind-v06.02.10/include/holidays/in/up.rem +13 -0
- data/remind-v06.02.10/include/holidays/in/wb.rem +16 -0
- data/remind-v06.02.10/include/holidays/in.rem +24 -0
- data/remind-v06.02.10/include/holidays/is.rem +23 -0
- data/remind-v06.02.10/include/holidays/it/ag.rem +13 -0
- data/remind-v06.02.10/include/holidays/it/al.rem +13 -0
- data/remind-v06.02.10/include/holidays/it/an.rem +13 -0
- data/remind-v06.02.10/include/holidays/it/andria.rem +13 -0
- data/remind-v06.02.10/include/holidays/it/ao.rem +13 -0
- data/remind-v06.02.10/include/holidays/it/ap.rem +13 -0
- data/remind-v06.02.10/include/holidays/it/aq.rem +13 -0
- data/remind-v06.02.10/include/holidays/it/ar.rem +13 -0
- data/remind-v06.02.10/include/holidays/it/at.rem +13 -0
- data/remind-v06.02.10/include/holidays/it/av.rem +13 -0
- data/remind-v06.02.10/include/holidays/it/ba.rem +13 -0
- data/remind-v06.02.10/include/holidays/it/barletta.rem +13 -0
- data/remind-v06.02.10/include/holidays/it/bg.rem +13 -0
- data/remind-v06.02.10/include/holidays/it/bl.rem +13 -0
- data/remind-v06.02.10/include/holidays/it/bn.rem +13 -0
- data/remind-v06.02.10/include/holidays/it/bo.rem +13 -0
- data/remind-v06.02.10/include/holidays/it/br.rem +13 -0
- data/remind-v06.02.10/include/holidays/it/bs.rem +13 -0
- data/remind-v06.02.10/include/holidays/it/bt.rem +15 -0
- data/remind-v06.02.10/include/holidays/it/bz.rem +14 -0
- data/remind-v06.02.10/include/holidays/it/ca.rem +13 -0
- data/remind-v06.02.10/include/holidays/it/cb.rem +13 -0
- data/remind-v06.02.10/include/holidays/it/ce.rem +13 -0
- data/remind-v06.02.10/include/holidays/it/cesena.rem +13 -0
- data/remind-v06.02.10/include/holidays/it/ch.rem +13 -0
- data/remind-v06.02.10/include/holidays/it/cl.rem +13 -0
- data/remind-v06.02.10/include/holidays/it/cn.rem +13 -0
- data/remind-v06.02.10/include/holidays/it/co.rem +13 -0
- data/remind-v06.02.10/include/holidays/it/cr.rem +13 -0
- data/remind-v06.02.10/include/holidays/it/cs.rem +13 -0
- data/remind-v06.02.10/include/holidays/it/ct.rem +13 -0
- data/remind-v06.02.10/include/holidays/it/cz.rem +13 -0
- data/remind-v06.02.10/include/holidays/it/en.rem +13 -0
- data/remind-v06.02.10/include/holidays/it/fc.rem +14 -0
- data/remind-v06.02.10/include/holidays/it/fe.rem +13 -0
- data/remind-v06.02.10/include/holidays/it/fg.rem +13 -0
- data/remind-v06.02.10/include/holidays/it/fi.rem +13 -0
- data/remind-v06.02.10/include/holidays/it/fm.rem +14 -0
- data/remind-v06.02.10/include/holidays/it/forli.rem +13 -0
- data/remind-v06.02.10/include/holidays/it/fr.rem +13 -0
- data/remind-v06.02.10/include/holidays/it/ge.rem +13 -0
- data/remind-v06.02.10/include/holidays/it/go.rem +13 -0
- data/remind-v06.02.10/include/holidays/it/gr.rem +13 -0
- data/remind-v06.02.10/include/holidays/it/im.rem +13 -0
- data/remind-v06.02.10/include/holidays/it/is.rem +13 -0
- data/remind-v06.02.10/include/holidays/it/kr.rem +13 -0
- data/remind-v06.02.10/include/holidays/it/lc.rem +13 -0
- data/remind-v06.02.10/include/holidays/it/le.rem +13 -0
- data/remind-v06.02.10/include/holidays/it/li.rem +13 -0
- data/remind-v06.02.10/include/holidays/it/lo.rem +13 -0
- data/remind-v06.02.10/include/holidays/it/lt.rem +14 -0
- data/remind-v06.02.10/include/holidays/it/lu.rem +13 -0
- data/remind-v06.02.10/include/holidays/it/mb.rem +13 -0
- data/remind-v06.02.10/include/holidays/it/mc.rem +13 -0
- data/remind-v06.02.10/include/holidays/it/me.rem +13 -0
- data/remind-v06.02.10/include/holidays/it/mi.rem +13 -0
- data/remind-v06.02.10/include/holidays/it/mn.rem +13 -0
- data/remind-v06.02.10/include/holidays/it/mo.rem +13 -0
- data/remind-v06.02.10/include/holidays/it/ms.rem +13 -0
- data/remind-v06.02.10/include/holidays/it/mt.rem +13 -0
- data/remind-v06.02.10/include/holidays/it/na.rem +13 -0
- data/remind-v06.02.10/include/holidays/it/no.rem +13 -0
- data/remind-v06.02.10/include/holidays/it/nu.rem +13 -0
- data/remind-v06.02.10/include/holidays/it/or.rem +13 -0
- data/remind-v06.02.10/include/holidays/it/pa.rem +13 -0
- data/remind-v06.02.10/include/holidays/it/pc.rem +13 -0
- data/remind-v06.02.10/include/holidays/it/pd.rem +13 -0
- data/remind-v06.02.10/include/holidays/it/pe.rem +13 -0
- data/remind-v06.02.10/include/holidays/it/pesaro.rem +13 -0
- data/remind-v06.02.10/include/holidays/it/pg.rem +14 -0
- data/remind-v06.02.10/include/holidays/it/pi.rem +13 -0
- data/remind-v06.02.10/include/holidays/it/pn.rem +14 -0
- data/remind-v06.02.10/include/holidays/it/pr.rem +13 -0
- data/remind-v06.02.10/include/holidays/it/pt.rem +13 -0
- data/remind-v06.02.10/include/holidays/it/pu.rem +14 -0
- data/remind-v06.02.10/include/holidays/it/pv.rem +13 -0
- data/remind-v06.02.10/include/holidays/it/pz.rem +13 -0
- data/remind-v06.02.10/include/holidays/it/ra.rem +13 -0
- data/remind-v06.02.10/include/holidays/it/rc.rem +13 -0
- data/remind-v06.02.10/include/holidays/it/re.rem +13 -0
- data/remind-v06.02.10/include/holidays/it/rg.rem +14 -0
- data/remind-v06.02.10/include/holidays/it/ri.rem +13 -0
- data/remind-v06.02.10/include/holidays/it/rm.rem +13 -0
- data/remind-v06.02.10/include/holidays/it/rn.rem +13 -0
- data/remind-v06.02.10/include/holidays/it/ro.rem +13 -0
- data/remind-v06.02.10/include/holidays/it/sa.rem +13 -0
- data/remind-v06.02.10/include/holidays/it/si.rem +13 -0
- data/remind-v06.02.10/include/holidays/it/so.rem +13 -0
- data/remind-v06.02.10/include/holidays/it/sp.rem +13 -0
- data/remind-v06.02.10/include/holidays/it/sr.rem +13 -0
- data/remind-v06.02.10/include/holidays/it/ss.rem +13 -0
- data/remind-v06.02.10/include/holidays/it/su.rem +13 -0
- data/remind-v06.02.10/include/holidays/it/sv.rem +13 -0
- data/remind-v06.02.10/include/holidays/it/ta.rem +13 -0
- data/remind-v06.02.10/include/holidays/it/te.rem +13 -0
- data/remind-v06.02.10/include/holidays/it/tn.rem +13 -0
- data/remind-v06.02.10/include/holidays/it/to.rem +13 -0
- data/remind-v06.02.10/include/holidays/it/tp.rem +13 -0
- data/remind-v06.02.10/include/holidays/it/tr.rem +13 -0
- data/remind-v06.02.10/include/holidays/it/trani.rem +13 -0
- data/remind-v06.02.10/include/holidays/it/ts.rem +13 -0
- data/remind-v06.02.10/include/holidays/it/tv.rem +13 -0
- data/remind-v06.02.10/include/holidays/it/ud.rem +13 -0
- data/remind-v06.02.10/include/holidays/it/urbino.rem +13 -0
- data/remind-v06.02.10/include/holidays/it/va.rem +13 -0
- data/remind-v06.02.10/include/holidays/it/vb.rem +13 -0
- data/remind-v06.02.10/include/holidays/it/vc.rem +13 -0
- data/remind-v06.02.10/include/holidays/it/ve.rem +14 -0
- data/remind-v06.02.10/include/holidays/it/vi.rem +13 -0
- data/remind-v06.02.10/include/holidays/it/vr.rem +13 -0
- data/remind-v06.02.10/include/holidays/it/vt.rem +13 -0
- data/remind-v06.02.10/include/holidays/it/vv.rem +13 -0
- data/remind-v06.02.10/include/holidays/it.rem +26 -0
- data/remind-v06.02.10/include/holidays/je.rem +19 -0
- data/remind-v06.02.10/include/holidays/jewish.rem +135 -0
- data/remind-v06.02.10/include/holidays/jm.rem +24 -0
- data/remind-v06.02.10/include/holidays/jo.rem +11 -0
- data/remind-v06.02.10/include/holidays/jp.rem +27 -0
- data/remind-v06.02.10/include/holidays/ke.rem +25 -0
- data/remind-v06.02.10/include/holidays/kg.rem +20 -0
- data/remind-v06.02.10/include/holidays/kh.rem +22 -0
- data/remind-v06.02.10/include/holidays/kn.rem +28 -0
- data/remind-v06.02.10/include/holidays/kr.rem +19 -0
- data/remind-v06.02.10/include/holidays/kw.rem +10 -0
- data/remind-v06.02.10/include/holidays/kz.rem +34 -0
- data/remind-v06.02.10/include/holidays/la.rem +47 -0
- data/remind-v06.02.10/include/holidays/lgbtq/au.rem +8 -0
- data/remind-v06.02.10/include/holidays/lgbtq/br.rem +10 -0
- data/remind-v06.02.10/include/holidays/lgbtq/ca.rem +7 -0
- data/remind-v06.02.10/include/holidays/lgbtq/cl.rem +7 -0
- data/remind-v06.02.10/include/holidays/lgbtq/ie.rem +7 -0
- data/remind-v06.02.10/include/holidays/lgbtq/in.rem +7 -0
- data/remind-v06.02.10/include/holidays/lgbtq/nl.rem +7 -0
- data/remind-v06.02.10/include/holidays/lgbtq/ua.rem +7 -0
- data/remind-v06.02.10/include/holidays/lgbtq/uk.rem +8 -0
- data/remind-v06.02.10/include/holidays/lgbtq/us.rem +16 -0
- data/remind-v06.02.10/include/holidays/lgbtq.rem +34 -0
- data/remind-v06.02.10/include/holidays/li.rem +31 -0
- data/remind-v06.02.10/include/holidays/ls.rem +18 -0
- data/remind-v06.02.10/include/holidays/lt.rem +23 -0
- data/remind-v06.02.10/include/holidays/lu.rem +18 -0
- data/remind-v06.02.10/include/holidays/lv.rem +25 -0
- data/remind-v06.02.10/include/holidays/ma.rem +17 -0
- data/remind-v06.02.10/include/holidays/mc.rem +26 -0
- data/remind-v06.02.10/include/holidays/md.rem +21 -0
- data/remind-v06.02.10/include/holidays/me.rem +28 -0
- data/remind-v06.02.10/include/holidays/mg.rem +24 -0
- data/remind-v06.02.10/include/holidays/mh.rem +22 -0
- data/remind-v06.02.10/include/holidays/misc.rem +9 -0
- data/remind-v06.02.10/include/holidays/mk.rem +17 -0
- data/remind-v06.02.10/include/holidays/mp.rem +44 -0
- data/remind-v06.02.10/include/holidays/mr.rem +11 -0
- data/remind-v06.02.10/include/holidays/mt.rem +21 -0
- data/remind-v06.02.10/include/holidays/mv.rem +12 -0
- data/remind-v06.02.10/include/holidays/mw.rem +36 -0
- data/remind-v06.02.10/include/holidays/mx.rem +15 -0
- data/remind-v06.02.10/include/holidays/my/01.rem +13 -0
- data/remind-v06.02.10/include/holidays/my/02.rem +13 -0
- data/remind-v06.02.10/include/holidays/my/03.rem +14 -0
- data/remind-v06.02.10/include/holidays/my/04.rem +18 -0
- data/remind-v06.02.10/include/holidays/my/05.rem +16 -0
- data/remind-v06.02.10/include/holidays/my/06.rem +17 -0
- data/remind-v06.02.10/include/holidays/my/07.rem +17 -0
- data/remind-v06.02.10/include/holidays/my/08.rem +15 -0
- data/remind-v06.02.10/include/holidays/my/09.rem +14 -0
- data/remind-v06.02.10/include/holidays/my/10.rem +16 -0
- data/remind-v06.02.10/include/holidays/my/11.rem +16 -0
- data/remind-v06.02.10/include/holidays/my/12.rem +19 -0
- data/remind-v06.02.10/include/holidays/my/13.rem +22 -0
- data/remind-v06.02.10/include/holidays/my/14.rem +16 -0
- data/remind-v06.02.10/include/holidays/my/15.rem +18 -0
- data/remind-v06.02.10/include/holidays/my/16.rem +16 -0
- data/remind-v06.02.10/include/holidays/my.rem +23 -0
- data/remind-v06.02.10/include/holidays/mz.rem +25 -0
- data/remind-v06.02.10/include/holidays/na.rem +27 -0
- data/remind-v06.02.10/include/holidays/ng.rem +21 -0
- data/remind-v06.02.10/include/holidays/ni/mn.rem +14 -0
- data/remind-v06.02.10/include/holidays/ni.rem +24 -0
- data/remind-v06.02.10/include/holidays/nl.rem +26 -0
- data/remind-v06.02.10/include/holidays/no.rem +19 -0
- data/remind-v06.02.10/include/holidays/nz/auk.rem +13 -0
- data/remind-v06.02.10/include/holidays/nz/can.rem +13 -0
- data/remind-v06.02.10/include/holidays/nz/cit.rem +13 -0
- data/remind-v06.02.10/include/holidays/nz/hkb.rem +13 -0
- data/remind-v06.02.10/include/holidays/nz/mbh.rem +13 -0
- data/remind-v06.02.10/include/holidays/nz/nsn.rem +13 -0
- data/remind-v06.02.10/include/holidays/nz/ntl.rem +13 -0
- data/remind-v06.02.10/include/holidays/nz/ota.rem +14 -0
- data/remind-v06.02.10/include/holidays/nz/south_canterbury.rem +13 -0
- data/remind-v06.02.10/include/holidays/nz/stl.rem +13 -0
- data/remind-v06.02.10/include/holidays/nz/tki.rem +13 -0
- data/remind-v06.02.10/include/holidays/nz/wgn.rem +13 -0
- data/remind-v06.02.10/include/holidays/nz/wtc.rem +13 -0
- data/remind-v06.02.10/include/holidays/nz.rem +69 -0
- data/remind-v06.02.10/include/holidays/pa.rem +27 -0
- data/remind-v06.02.10/include/holidays/pagan.rem +65 -0
- data/remind-v06.02.10/include/holidays/pe.rem +22 -0
- data/remind-v06.02.10/include/holidays/pg.rem +24 -0
- data/remind-v06.02.10/include/holidays/ph.rem +26 -0
- data/remind-v06.02.10/include/holidays/pk.rem +13 -0
- data/remind-v06.02.10/include/holidays/pl.rem +20 -0
- data/remind-v06.02.10/include/holidays/pr.rem +40 -0
- data/remind-v06.02.10/include/holidays/pt/01.rem +13 -0
- data/remind-v06.02.10/include/holidays/pt/02.rem +13 -0
- data/remind-v06.02.10/include/holidays/pt/03.rem +13 -0
- data/remind-v06.02.10/include/holidays/pt/04.rem +13 -0
- data/remind-v06.02.10/include/holidays/pt/05.rem +13 -0
- data/remind-v06.02.10/include/holidays/pt/06.rem +13 -0
- data/remind-v06.02.10/include/holidays/pt/07.rem +13 -0
- data/remind-v06.02.10/include/holidays/pt/08.rem +13 -0
- data/remind-v06.02.10/include/holidays/pt/09.rem +13 -0
- data/remind-v06.02.10/include/holidays/pt/10.rem +13 -0
- data/remind-v06.02.10/include/holidays/pt/12.rem +13 -0
- data/remind-v06.02.10/include/holidays/pt/13.rem +13 -0
- data/remind-v06.02.10/include/holidays/pt/14.rem +13 -0
- data/remind-v06.02.10/include/holidays/pt/15.rem +13 -0
- data/remind-v06.02.10/include/holidays/pt/16.rem +13 -0
- data/remind-v06.02.10/include/holidays/pt/18.rem +13 -0
- data/remind-v06.02.10/include/holidays/pt/20.rem +13 -0
- data/remind-v06.02.10/include/holidays/pt/30.rem +14 -0
- data/remind-v06.02.10/include/holidays/pt.rem +17 -0
- data/remind-v06.02.10/include/holidays/pw.rem +34 -0
- data/remind-v06.02.10/include/holidays/py.rem +20 -0
- data/remind-v06.02.10/include/holidays/ro.rem +24 -0
- data/remind-v06.02.10/include/holidays/rs.rem +26 -0
- data/remind-v06.02.10/include/holidays/ru.rem +21 -0
- data/remind-v06.02.10/include/holidays/sa.rem +13 -0
- data/remind-v06.02.10/include/holidays/sc.rem +28 -0
- data/remind-v06.02.10/include/holidays/se.rem +23 -0
- data/remind-v06.02.10/include/holidays/sg.rem +16 -0
- data/remind-v06.02.10/include/holidays/si.rem +20 -0
- data/remind-v06.02.10/include/holidays/sk.rem +25 -0
- data/remind-v06.02.10/include/holidays/sm.rem +25 -0
- data/remind-v06.02.10/include/holidays/sv/ss.rem +14 -0
- data/remind-v06.02.10/include/holidays/sv.rem +25 -0
- data/remind-v06.02.10/include/holidays/sz.rem +26 -0
- data/remind-v06.02.10/include/holidays/td.rem +22 -0
- data/remind-v06.02.10/include/holidays/th.rem +72 -0
- data/remind-v06.02.10/include/holidays/tl.rem +31 -0
- data/remind-v06.02.10/include/holidays/tn.rem +15 -0
- data/remind-v06.02.10/include/holidays/to.rem +38 -0
- data/remind-v06.02.10/include/holidays/tr.rem +17 -0
- data/remind-v06.02.10/include/holidays/tw.rem +26 -0
- data/remind-v06.02.10/include/holidays/tz.rem +23 -0
- data/remind-v06.02.10/include/holidays/ua.rem +20 -0
- data/remind-v06.02.10/include/holidays/uk.rem +27 -0
- data/remind-v06.02.10/include/holidays/um.rem +32 -0
- data/remind-v06.02.10/include/holidays/us/ak.rem +17 -0
- data/remind-v06.02.10/include/holidays/us/al.rem +17 -0
- data/remind-v06.02.10/include/holidays/us/ar.rem +13 -0
- data/remind-v06.02.10/include/holidays/us/as.rem +20 -0
- data/remind-v06.02.10/include/holidays/us/az.rem +14 -0
- data/remind-v06.02.10/include/holidays/us/ca.rem +16 -0
- data/remind-v06.02.10/include/holidays/us/co.rem +14 -0
- data/remind-v06.02.10/include/holidays/us/ct.rem +17 -0
- data/remind-v06.02.10/include/holidays/us/dc.rem +16 -0
- data/remind-v06.02.10/include/holidays/us/de.rem +14 -0
- data/remind-v06.02.10/include/holidays/us/fl.rem +14 -0
- data/remind-v06.02.10/include/holidays/us/ga.rem +18 -0
- data/remind-v06.02.10/include/holidays/us/gu.rem +17 -0
- data/remind-v06.02.10/include/holidays/us/hi.rem +19 -0
- data/remind-v06.02.10/include/holidays/us/ia.rem +15 -0
- data/remind-v06.02.10/include/holidays/us/id.rem +14 -0
- data/remind-v06.02.10/include/holidays/us/il.rem +17 -0
- data/remind-v06.02.10/include/holidays/us/in.rem +19 -0
- data/remind-v06.02.10/include/holidays/us/ks.rem +16 -0
- data/remind-v06.02.10/include/holidays/us/ky.rem +16 -0
- data/remind-v06.02.10/include/holidays/us/la.rem +14 -0
- data/remind-v06.02.10/include/holidays/us/ma.rem +17 -0
- data/remind-v06.02.10/include/holidays/us/md-extra.rem +19 -0
- data/remind-v06.02.10/include/holidays/us/md.rem +14 -0
- data/remind-v06.02.10/include/holidays/us/me.rem +14 -0
- data/remind-v06.02.10/include/holidays/us/mi.rem +19 -0
- data/remind-v06.02.10/include/holidays/us/mo.rem +16 -0
- data/remind-v06.02.10/include/holidays/us/mp.rem +23 -0
- data/remind-v06.02.10/include/holidays/us/ms.rem +14 -0
- data/remind-v06.02.10/include/holidays/us/mt.rem +13 -0
- data/remind-v06.02.10/include/holidays/us/nc.rem +22 -0
- data/remind-v06.02.10/include/holidays/us/ne.rem +14 -0
- data/remind-v06.02.10/include/holidays/us/nh.rem +14 -0
- data/remind-v06.02.10/include/holidays/us/nj.rem +17 -0
- data/remind-v06.02.10/include/holidays/us/nm.rem +14 -0
- data/remind-v06.02.10/include/holidays/us/nv.rem +16 -0
- data/remind-v06.02.10/include/holidays/us/ny.rem +17 -0
- data/remind-v06.02.10/include/holidays/us/oh.rem +13 -0
- data/remind-v06.02.10/include/holidays/us/ok.rem +13 -0
- data/remind-v06.02.10/include/holidays/us/pa.rem +14 -0
- data/remind-v06.02.10/include/holidays/us/pr.rem +21 -0
- data/remind-v06.02.10/include/holidays/us/ri.rem +14 -0
- data/remind-v06.02.10/include/holidays/us/sc.rem +13 -0
- data/remind-v06.02.10/include/holidays/us/sd.rem +13 -0
- data/remind-v06.02.10/include/holidays/us/tn.rem +13 -0
- data/remind-v06.02.10/include/holidays/us/tx.rem +25 -0
- data/remind-v06.02.10/include/holidays/us/ut.rem +16 -0
- data/remind-v06.02.10/include/holidays/us/va.rem +13 -0
- data/remind-v06.02.10/include/holidays/us/vi.rem +22 -0
- data/remind-v06.02.10/include/holidays/us/vt.rem +16 -0
- data/remind-v06.02.10/include/holidays/us/wi.rem +20 -0
- data/remind-v06.02.10/include/holidays/us/wv.rem +17 -0
- data/remind-v06.02.10/include/holidays/us.rem +41 -0
- data/remind-v06.02.10/include/holidays/uy.rem +39 -0
- data/remind-v06.02.10/include/holidays/uz.rem +21 -0
- data/remind-v06.02.10/include/holidays/va.rem +23 -0
- data/remind-v06.02.10/include/holidays/ve.rem +21 -0
- data/remind-v06.02.10/include/holidays/vi.rem +41 -0
- data/remind-v06.02.10/include/holidays/vn.rem +17 -0
- data/remind-v06.02.10/include/holidays/vu.rem +32 -0
- data/remind-v06.02.10/include/holidays/ws.rem +18 -0
- data/remind-v06.02.10/include/holidays/za.rem +28 -0
- data/remind-v06.02.10/include/holidays/zm.rem +31 -0
- data/remind-v06.02.10/include/lang/auto.rem +32 -0
- data/remind-v06.02.10/include/lang/ca.rem +60 -0
- data/remind-v06.02.10/include/lang/da.rem +77 -0
- data/remind-v06.02.10/include/lang/de.rem +80 -0
- data/remind-v06.02.10/include/lang/en.rem +4 -0
- data/remind-v06.02.10/include/lang/es.rem +55 -0
- data/remind-v06.02.10/include/lang/fi.rem +202 -0
- data/remind-v06.02.10/include/lang/fr.rem +172 -0
- data/remind-v06.02.10/include/lang/gr.rem +74 -0
- data/remind-v06.02.10/include/lang/is.rem +58 -0
- data/remind-v06.02.10/include/lang/it.rem +76 -0
- data/remind-v06.02.10/include/lang/nl.rem +71 -0
- data/remind-v06.02.10/include/lang/no.rem +66 -0
- data/remind-v06.02.10/include/lang/pl.rem +177 -0
- data/remind-v06.02.10/include/lang/pt.rem +176 -0
- data/remind-v06.02.10/include/lang/ro.rem +74 -0
- data/remind-v06.02.10/include/lunar-eclipses.rem +149 -0
- data/remind-v06.02.10/include/moonphases.rem +19 -0
- data/remind-v06.02.10/include/seasons.rem +21 -0
- data/remind-v06.02.10/include/solar-eclipses.rem +238 -0
- data/remind-v06.02.10/include/sun.rem +12 -0
- data/remind-v06.02.10/include/translations/de/holidays/chinese-new-year.rem +13 -0
- data/remind-v06.02.10/include/translations/de/moonphases.rem +4 -0
- data/remind-v06.02.10/include/translations/de/seasons.rem +4 -0
- data/remind-v06.02.10/include/translations/de/sun.rem +2 -0
- data/remind-v06.02.10/include/translations/nl/holidays/chinese-new-year.rem +13 -0
- data/remind-v06.02.10/include/translations/nl/moonphases.rem +4 -0
- data/remind-v06.02.10/include/translations/nl/seasons.rem +4 -0
- data/remind-v06.02.10/include/translations/nl/sun.rem +2 -0
- data/remind-v06.02.10/include/utils/add-html-anchors.rem +5 -0
- data/remind-v06.02.10/install-sh +238 -0
- data/remind-v06.02.10/man/rem.1.in +21 -0
- data/remind-v06.02.10/man/rem2ps.1.in +816 -0
- data/remind-v06.02.10/man/remind.1.in +7658 -0
- data/remind-v06.02.10/man/tkremind.1.in +612 -0
- data/remind-v06.02.10/rem2html/Makefile.in +30 -0
- data/remind-v06.02.10/rem2html/rem2html.in +1299 -0
- data/remind-v06.02.10/rem2pdf/Makefile.PL.in +25 -0
- data/remind-v06.02.10/rem2pdf/Makefile.top.in +50 -0
- data/remind-v06.02.10/rem2pdf/bin/rem2pdf.in +761 -0
- data/remind-v06.02.10/scripts/tkremind.in +5794 -0
- data/remind-v06.02.10/src/Makefile.in +133 -0
- data/remind-v06.02.10/src/calendar.c +3069 -0
- data/remind-v06.02.10/src/config.h +117 -0
- data/remind-v06.02.10/src/config.h.in +116 -0
- data/remind-v06.02.10/src/custom.h +167 -0
- data/remind-v06.02.10/src/custom.h.in +167 -0
- data/remind-v06.02.10/src/dedupe.c +179 -0
- data/remind-v06.02.10/src/dorem.c +2389 -0
- data/remind-v06.02.10/src/dosubst.c +910 -0
- data/remind-v06.02.10/src/dynbuf.c +198 -0
- data/remind-v06.02.10/src/dynbuf.h +41 -0
- data/remind-v06.02.10/src/err.h +294 -0
- data/remind-v06.02.10/src/expr.c +3408 -0
- data/remind-v06.02.10/src/files.c +1437 -0
- data/remind-v06.02.10/src/funcs.c +5230 -0
- data/remind-v06.02.10/src/globals.c +23 -0
- data/remind-v06.02.10/src/globals.h +277 -0
- data/remind-v06.02.10/src/hashtab.c +428 -0
- data/remind-v06.02.10/src/hashtab.h +88 -0
- data/remind-v06.02.10/src/hashtab_stats.c +101 -0
- data/remind-v06.02.10/src/hbcal.c +579 -0
- data/remind-v06.02.10/src/ifelse.c +236 -0
- data/remind-v06.02.10/src/init.c +1494 -0
- data/remind-v06.02.10/src/json.c +1048 -0
- data/remind-v06.02.10/src/json.h +276 -0
- data/remind-v06.02.10/src/main.c +2310 -0
- data/remind-v06.02.10/src/md5.c +250 -0
- data/remind-v06.02.10/src/md5.h +33 -0
- data/remind-v06.02.10/src/moon.c +957 -0
- data/remind-v06.02.10/src/omit.c +560 -0
- data/remind-v06.02.10/src/protos.h +284 -0
- data/remind-v06.02.10/src/queue.c +1118 -0
- data/remind-v06.02.10/src/rem2ps.c +1383 -0
- data/remind-v06.02.10/src/rem2ps.h +229 -0
- data/remind-v06.02.10/src/sort.c +257 -0
- data/remind-v06.02.10/src/token.c +494 -0
- data/remind-v06.02.10/src/trans.c +544 -0
- data/remind-v06.02.10/src/trigger.c +871 -0
- data/remind-v06.02.10/src/types.h +341 -0
- data/remind-v06.02.10/src/userfns.c +810 -0
- data/remind-v06.02.10/src/utils.c +374 -0
- data/remind-v06.02.10/src/var.c +1762 -0
- data/remind-v06.02.10/src/version.h +1 -0
- data/remind-v06.02.10/src/version.h.in +1 -0
- data/remind-v06.02.10/src/xlat.c +100 -0
- data/remind-v06.02.10/www/Makefile.in +91 -0
- metadata +764 -0
|
@@ -0,0 +1,3069 @@
|
|
|
1
|
+
/***************************************************************/
|
|
2
|
+
/* */
|
|
3
|
+
/* CALENDAR.C */
|
|
4
|
+
/* */
|
|
5
|
+
/* The code for generating a calendar. */
|
|
6
|
+
/* */
|
|
7
|
+
/* This file is part of REMIND. */
|
|
8
|
+
/* Copyright (C) 1992-2026 by Dianne Skoll */
|
|
9
|
+
/* SPDX-License-Identifier: GPL-2.0-only */
|
|
10
|
+
/* */
|
|
11
|
+
/***************************************************************/
|
|
12
|
+
|
|
13
|
+
#define _XOPEN_SOURCE 600
|
|
14
|
+
#include "config.h"
|
|
15
|
+
#include "custom.h"
|
|
16
|
+
|
|
17
|
+
#include <stdio.h>
|
|
18
|
+
#include <string.h>
|
|
19
|
+
#include <strings.h>
|
|
20
|
+
#include <ctype.h>
|
|
21
|
+
|
|
22
|
+
#include <stdlib.h>
|
|
23
|
+
#include <sys/ioctl.h>
|
|
24
|
+
#include <unistd.h>
|
|
25
|
+
|
|
26
|
+
#include <wctype.h>
|
|
27
|
+
#include <wchar.h>
|
|
28
|
+
|
|
29
|
+
#ifdef HAVE_LANGINFO_H
|
|
30
|
+
#include <langinfo.h>
|
|
31
|
+
#endif
|
|
32
|
+
|
|
33
|
+
#include "types.h"
|
|
34
|
+
#include "protos.h"
|
|
35
|
+
#include "globals.h"
|
|
36
|
+
#include "err.h"
|
|
37
|
+
#include "md5.h"
|
|
38
|
+
|
|
39
|
+
/* Data structures used by the calendar */
|
|
40
|
+
typedef struct cal_entry {
|
|
41
|
+
struct cal_entry *next;
|
|
42
|
+
char *text;
|
|
43
|
+
char *raw_text;
|
|
44
|
+
char const *pos;
|
|
45
|
+
wchar_t *wc_text;
|
|
46
|
+
wchar_t const *wc_pos;
|
|
47
|
+
int is_color;
|
|
48
|
+
int r, g, b;
|
|
49
|
+
int time;
|
|
50
|
+
int priority;
|
|
51
|
+
DynamicBuffer tags;
|
|
52
|
+
char passthru[PASSTHRU_LEN+1];
|
|
53
|
+
int duration;
|
|
54
|
+
char const *filename;
|
|
55
|
+
int lineno;
|
|
56
|
+
int lineno_start;
|
|
57
|
+
Trigger trig;
|
|
58
|
+
TimeTrig tt;
|
|
59
|
+
int nonconst_expr;
|
|
60
|
+
int if_depth;
|
|
61
|
+
TrigInfo *infos;
|
|
62
|
+
} CalEntry;
|
|
63
|
+
|
|
64
|
+
/* Line-drawing sequences */
|
|
65
|
+
struct line_drawing {
|
|
66
|
+
char const *graphics_on;
|
|
67
|
+
char const *graphics_off;
|
|
68
|
+
char *tlr, *bl, *tbl, *blr, *tblr, *tr, *tb, *br, *tbr, *tl, *lr;
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
static struct line_drawing NormalDrawing = {
|
|
72
|
+
"", "", "+", "+", "+", "+", "+", "+", "|", "+", "+", "+", "-"
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
static struct line_drawing VT100Drawing = {
|
|
76
|
+
"\x1B(0", "\x1B(B",
|
|
77
|
+
"\x76", "\x6b", "\x75", "\x77", "\x6e", "\x6d", "\x78",
|
|
78
|
+
"\x6c", "\x74", "\x6a", "\x71"
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
static int encoding_is_utf8 = 0;
|
|
82
|
+
|
|
83
|
+
static struct line_drawing UTF8Drawing = {
|
|
84
|
+
"", "",
|
|
85
|
+
"\xe2\x94\xb4",
|
|
86
|
+
"\xe2\x94\x90",
|
|
87
|
+
"\xe2\x94\xa4",
|
|
88
|
+
"\xe2\x94\xac",
|
|
89
|
+
"\xe2\x94\xbc",
|
|
90
|
+
"\xe2\x94\x94",
|
|
91
|
+
"\xe2\x94\x82",
|
|
92
|
+
"\xe2\x94\x8c",
|
|
93
|
+
"\xe2\x94\x9c",
|
|
94
|
+
"\xe2\x94\x98",
|
|
95
|
+
"\xe2\x94\x80"
|
|
96
|
+
};
|
|
97
|
+
|
|
98
|
+
static char *VT100Colors[2][2][2][2] /* [Br][R][G][B] */ = {
|
|
99
|
+
{
|
|
100
|
+
/*** DIM COLORS ***/
|
|
101
|
+
{
|
|
102
|
+
{
|
|
103
|
+
/* 0, 0, 0 = Black */ "\x1B[0;30m",
|
|
104
|
+
/* 0, 0, 1 = Blue */ "\x1B[0;34m"
|
|
105
|
+
},
|
|
106
|
+
{
|
|
107
|
+
/* 0, 1, 0 = Green */ "\x1B[0;32m",
|
|
108
|
+
/* 0, 1, 1 = Cyan */ "\x1B[0;36m"
|
|
109
|
+
}
|
|
110
|
+
},
|
|
111
|
+
{
|
|
112
|
+
{
|
|
113
|
+
/* 1, 0, 0 = Red */ "\x1B[0;31m",
|
|
114
|
+
/* 1, 0, 1 = Magenta */ "\x1B[0;35m"
|
|
115
|
+
},
|
|
116
|
+
{
|
|
117
|
+
/* 1, 1, 0 = Yellow */ "\x1B[0;33m",
|
|
118
|
+
/* 1, 1, 1 = White */ "\x1B[0;37m"
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
},
|
|
122
|
+
{
|
|
123
|
+
/*** BRIGHT COLORS ***/
|
|
124
|
+
{
|
|
125
|
+
{
|
|
126
|
+
/* 0, 0, 0 = Grey */ "\x1B[30;1m",
|
|
127
|
+
/* 0, 0, 1 = Blue */ "\x1B[34;1m"
|
|
128
|
+
},
|
|
129
|
+
{
|
|
130
|
+
/* 0, 1, 0 = Green */ "\x1B[32;1m",
|
|
131
|
+
/* 0, 1, 1 = Cyan */ "\x1B[36;1m"
|
|
132
|
+
}
|
|
133
|
+
},
|
|
134
|
+
{
|
|
135
|
+
{
|
|
136
|
+
/* 1, 0, 0 = Red */ "\x1B[31;1m",
|
|
137
|
+
/* 1, 0, 1 = Magenta */ "\x1B[35;1m"
|
|
138
|
+
},
|
|
139
|
+
{
|
|
140
|
+
/* 1, 1, 0 = Yellow */ "\x1B[33;1m",
|
|
141
|
+
/* 1, 1, 1 = White */ "\x1B[37;1m"
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
};
|
|
146
|
+
|
|
147
|
+
static char *VT100BGColors[2][2][2] /* [R][G][B] */ = {
|
|
148
|
+
{
|
|
149
|
+
{
|
|
150
|
+
/* 0, 0, 0 = Black */ "\x1B[0;40m",
|
|
151
|
+
/* 0, 0, 1 = Blue */ "\x1B[0;44m"
|
|
152
|
+
},
|
|
153
|
+
{
|
|
154
|
+
/* 0, 1, 0 = Green */ "\x1B[0;42m",
|
|
155
|
+
/* 0, 1, 1 = Cyan */ "\x1B[0;46m"
|
|
156
|
+
}
|
|
157
|
+
},
|
|
158
|
+
{
|
|
159
|
+
{
|
|
160
|
+
/* 1, 0, 0 = Red */ "\x1B[0;41m",
|
|
161
|
+
/* 1, 0, 1 = Magenta */ "\x1B[0;45m"
|
|
162
|
+
},
|
|
163
|
+
{
|
|
164
|
+
/* 1, 1, 0 = Yellow */ "\x1B[0;43m",
|
|
165
|
+
/* 1, 1, 1 = White */ "\x1B[0;47m"
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
};
|
|
169
|
+
|
|
170
|
+
/* Moon phase icons in UTF-8 */
|
|
171
|
+
static char const *moonphase_emojis[] = {
|
|
172
|
+
"\xF0\x9F\x8C\x91",
|
|
173
|
+
"\xF0\x9F\x8C\x93",
|
|
174
|
+
"\xF0\x9F\x8C\x95",
|
|
175
|
+
"\xF0\x9F\x8C\x97"
|
|
176
|
+
};
|
|
177
|
+
|
|
178
|
+
/* Color weights for gamma-correction */
|
|
179
|
+
unsigned char cwts[] = {
|
|
180
|
+
0x46, 0x75, 0x63, 0x6b, 0x20, 0x74, 0x68, 0x6f, 0x73, 0x65, 0x20,
|
|
181
|
+
0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x68, 0x6f, 0x62, 0x69, 0x63,
|
|
182
|
+
0x20, 0x41, 0x6d, 0x65, 0x72, 0x69, 0x63, 0x61, 0x6e, 0x20, 0x52,
|
|
183
|
+
0x65, 0x70, 0x75, 0x62, 0x6c, 0x69, 0x63, 0x61, 0x6e, 0x73, 0x2e,
|
|
184
|
+
0x20, 0x20, 0x54, 0x72, 0x61, 0x6e, 0x73, 0x20, 0x72, 0x69, 0x67,
|
|
185
|
+
0x68, 0x74, 0x73, 0x20, 0x61, 0x72, 0x65, 0x20, 0x68, 0x75, 0x6d,
|
|
186
|
+
0x61, 0x6e, 0x20, 0x72, 0x69, 0x67, 0x68, 0x74, 0x73, 0x2e
|
|
187
|
+
};
|
|
188
|
+
|
|
189
|
+
/* Moon phases for each day 1-31, up to 32 chars per moon-phase string
|
|
190
|
+
including termination \0 */
|
|
191
|
+
static char moons[32][32];
|
|
192
|
+
|
|
193
|
+
/* Week indicators */
|
|
194
|
+
static char weeks[32][32];
|
|
195
|
+
|
|
196
|
+
/* Background colors of each day 1-31, rgb */
|
|
197
|
+
static int bgcolor[32][3];
|
|
198
|
+
|
|
199
|
+
static struct line_drawing *linestruct;
|
|
200
|
+
#define DRAW(x) fputs(linestruct->x, stdout)
|
|
201
|
+
|
|
202
|
+
struct xterm256_colors {
|
|
203
|
+
int r;
|
|
204
|
+
int g;
|
|
205
|
+
int b;
|
|
206
|
+
};
|
|
207
|
+
|
|
208
|
+
/* Xterm support 256 different colors, numbered from 0 to 255. The following
|
|
209
|
+
table is a list of the [r, g, b] components of each Xterm color. The
|
|
210
|
+
data was obtained from https://jonasjacek.github.io/colors/ */
|
|
211
|
+
static struct xterm256_colors XTerm256Colors[] =
|
|
212
|
+
{
|
|
213
|
+
{ 0, 0, 0}, {128, 0, 0}, { 0, 128, 0}, {128, 128, 0},
|
|
214
|
+
{ 0, 0, 128}, {128, 0, 128}, { 0, 128, 128}, {192, 192, 192},
|
|
215
|
+
{128, 128, 128}, {255, 0, 0}, { 0, 255, 0}, {255, 255, 0},
|
|
216
|
+
{ 0, 0, 255}, {255, 0, 255}, { 0, 255, 255}, {255, 255, 255},
|
|
217
|
+
{ 0, 0, 0}, { 0, 0, 95}, { 0, 0, 135}, { 0, 0, 175},
|
|
218
|
+
{ 0, 0, 215}, { 0, 0, 255}, { 0, 95, 0}, { 0, 95, 95},
|
|
219
|
+
{ 0, 95, 135}, { 0, 95, 175}, { 0, 95, 215}, { 0, 95, 255},
|
|
220
|
+
{ 0, 135, 0}, { 0, 135, 95}, { 0, 135, 135}, { 0, 135, 175},
|
|
221
|
+
{ 0, 135, 215}, { 0, 135, 255}, { 0, 175, 0}, { 0, 175, 95},
|
|
222
|
+
{ 0, 175, 135}, { 0, 175, 175}, { 0, 175, 215}, { 0, 175, 255},
|
|
223
|
+
{ 0, 215, 0}, { 0, 215, 95}, { 0, 215, 135}, { 0, 215, 175},
|
|
224
|
+
{ 0, 215, 215}, { 0, 215, 255}, { 0, 255, 0}, { 0, 255, 95},
|
|
225
|
+
{ 0, 255, 135}, { 0, 255, 175}, { 0, 255, 215}, { 0, 255, 255},
|
|
226
|
+
{ 95, 0, 0}, { 95, 0, 95}, { 95, 0, 135}, { 95, 0, 175},
|
|
227
|
+
{ 95, 0, 215}, { 95, 0, 255}, { 95, 95, 0}, { 95, 95, 95},
|
|
228
|
+
{ 95, 95, 135}, { 95, 95, 175}, { 95, 95, 215}, { 95, 95, 255},
|
|
229
|
+
{ 95, 135, 0}, { 95, 135, 95}, { 95, 135, 135}, { 95, 135, 175},
|
|
230
|
+
{ 95, 135, 215}, { 95, 135, 255}, { 95, 175, 0}, { 95, 175, 95},
|
|
231
|
+
{ 95, 175, 135}, { 95, 175, 175}, { 95, 175, 215}, { 95, 175, 255},
|
|
232
|
+
{ 95, 215, 0}, { 95, 215, 95}, { 95, 215, 135}, { 95, 215, 175},
|
|
233
|
+
{ 95, 215, 215}, { 95, 215, 255}, { 95, 255, 0}, { 95, 255, 95},
|
|
234
|
+
{ 95, 255, 135}, { 95, 255, 175}, { 95, 255, 215}, { 95, 255, 255},
|
|
235
|
+
{135, 0, 0}, {135, 0, 95}, {135, 0, 135}, {135, 0, 175},
|
|
236
|
+
{135, 0, 215}, {135, 0, 255}, {135, 95, 0}, {135, 95, 95},
|
|
237
|
+
{135, 95, 135}, {135, 95, 175}, {135, 95, 215}, {135, 95, 255},
|
|
238
|
+
{135, 135, 0}, {135, 135, 95}, {135, 135, 135}, {135, 135, 175},
|
|
239
|
+
{135, 135, 215}, {135, 135, 255}, {135, 175, 0}, {135, 175, 95},
|
|
240
|
+
{135, 175, 135}, {135, 175, 175}, {135, 175, 215}, {135, 175, 255},
|
|
241
|
+
{135, 215, 0}, {135, 215, 95}, {135, 215, 135}, {135, 215, 175},
|
|
242
|
+
{135, 215, 215}, {135, 215, 255}, {135, 255, 0}, {135, 255, 95},
|
|
243
|
+
{135, 255, 135}, {135, 255, 175}, {135, 255, 215}, {135, 255, 255},
|
|
244
|
+
{175, 0, 0}, {175, 0, 95}, {175, 0, 135}, {175, 0, 175},
|
|
245
|
+
{175, 0, 215}, {175, 0, 255}, {175, 95, 0}, {175, 95, 95},
|
|
246
|
+
{175, 95, 135}, {175, 95, 175}, {175, 95, 215}, {175, 95, 255},
|
|
247
|
+
{175, 135, 0}, {175, 135, 95}, {175, 135, 135}, {175, 135, 175},
|
|
248
|
+
{175, 135, 215}, {175, 135, 255}, {175, 175, 0}, {175, 175, 95},
|
|
249
|
+
{175, 175, 135}, {175, 175, 175}, {175, 175, 215}, {175, 175, 255},
|
|
250
|
+
{175, 215, 0}, {175, 215, 95}, {175, 215, 135}, {175, 215, 175},
|
|
251
|
+
{175, 215, 215}, {175, 215, 255}, {175, 255, 0}, {175, 255, 95},
|
|
252
|
+
{175, 255, 135}, {175, 255, 175}, {175, 255, 215}, {175, 255, 255},
|
|
253
|
+
{215, 0, 0}, {215, 0, 95}, {215, 0, 135}, {215, 0, 175},
|
|
254
|
+
{215, 0, 215}, {215, 0, 255}, {215, 95, 0}, {215, 95, 95},
|
|
255
|
+
{215, 95, 135}, {215, 95, 175}, {215, 95, 215}, {215, 95, 255},
|
|
256
|
+
{215, 135, 0}, {215, 135, 95}, {215, 135, 135}, {215, 135, 175},
|
|
257
|
+
{215, 135, 215}, {215, 135, 255}, {215, 175, 0}, {215, 175, 95},
|
|
258
|
+
{215, 175, 135}, {215, 175, 175}, {215, 175, 215}, {215, 175, 255},
|
|
259
|
+
{215, 215, 0}, {215, 215, 95}, {215, 215, 135}, {215, 215, 175},
|
|
260
|
+
{215, 215, 215}, {215, 215, 255}, {215, 255, 0}, {215, 255, 95},
|
|
261
|
+
{215, 255, 135}, {215, 255, 175}, {215, 255, 215}, {215, 255, 255},
|
|
262
|
+
{255, 0, 0}, {255, 0, 95}, {255, 0, 135}, {255, 0, 175},
|
|
263
|
+
{255, 0, 215}, {255, 0, 255}, {255, 95, 0}, {255, 95, 95},
|
|
264
|
+
{255, 95, 135}, {255, 95, 175}, {255, 95, 215}, {255, 95, 255},
|
|
265
|
+
{255, 135, 0}, {255, 135, 95}, {255, 135, 135}, {255, 135, 175},
|
|
266
|
+
{255, 135, 215}, {255, 135, 255}, {255, 175, 0}, {255, 175, 95},
|
|
267
|
+
{255, 175, 135}, {255, 175, 175}, {255, 175, 215}, {255, 175, 255},
|
|
268
|
+
{255, 215, 0}, {255, 215, 95}, {255, 215, 135}, {255, 215, 175},
|
|
269
|
+
{255, 215, 215}, {255, 215, 255}, {255, 255, 0}, {255, 255, 95},
|
|
270
|
+
{255, 255, 135}, {255, 255, 175}, {255, 255, 215}, {255, 255, 255},
|
|
271
|
+
{ 8, 8, 8}, { 18, 18, 18}, { 28, 28, 28}, { 38, 38, 38},
|
|
272
|
+
{ 48, 48, 48}, { 58, 58, 58}, { 68, 68, 68}, { 78, 78, 78},
|
|
273
|
+
{ 88, 88, 88}, { 98, 98, 98}, {108, 108, 108}, {118, 118, 118},
|
|
274
|
+
{128, 128, 128}, {138, 138, 138}, {148, 148, 148}, {158, 158, 158},
|
|
275
|
+
{168, 168, 168}, {178, 178, 178}, {188, 188, 188}, {198, 198, 198},
|
|
276
|
+
{208, 208, 208}, {218, 218, 218}, {228, 228, 228}, {238, 238, 238}
|
|
277
|
+
};
|
|
278
|
+
|
|
279
|
+
/* Global variables */
|
|
280
|
+
static CalEntry *CalColumn[7];
|
|
281
|
+
static int ColToDay[7];
|
|
282
|
+
|
|
283
|
+
static int ColSpaces;
|
|
284
|
+
|
|
285
|
+
static int DidAMonth;
|
|
286
|
+
static int DidAWeek;
|
|
287
|
+
static int DidADay;
|
|
288
|
+
|
|
289
|
+
static char const *CalendarTime(int tim, int duration);
|
|
290
|
+
static void ColorizeEntry(CalEntry const *e, int clamp);
|
|
291
|
+
static void SortCol (CalEntry **col);
|
|
292
|
+
static void DoCalendarOneWeek (int nleft);
|
|
293
|
+
static void DoCalendarOneMonth (void);
|
|
294
|
+
static void DoSimpleCalendarOneMonth (void);
|
|
295
|
+
static int WriteCalendarRow (void);
|
|
296
|
+
static void WriteWeekHeaderLine (void);
|
|
297
|
+
static void WritePostHeaderLine (void);
|
|
298
|
+
static void PrintLeft (char const *s, int width, char pad);
|
|
299
|
+
static void PrintCentered (char const *s, int width, char const *pad);
|
|
300
|
+
static int WriteOneCalLine (int dse, int wd);
|
|
301
|
+
static int WriteOneColLine (int col);
|
|
302
|
+
static void GenerateCalEntries (int col);
|
|
303
|
+
static void WriteCalHeader (void);
|
|
304
|
+
static void WriteCalTrailer (void);
|
|
305
|
+
static int DoCalRem (ParsePtr p, int col);
|
|
306
|
+
static void WriteSimpleEntries (int col, int dse);
|
|
307
|
+
static void WriteTopCalLine (void);
|
|
308
|
+
static void WriteBottomCalLine (void);
|
|
309
|
+
static void WriteIntermediateCalLine (void);
|
|
310
|
+
static void WriteCalDays (void);
|
|
311
|
+
static char const *get_url(TrigInfo *infos);
|
|
312
|
+
|
|
313
|
+
static int
|
|
314
|
+
DayOf(int dse)
|
|
315
|
+
{
|
|
316
|
+
int d;
|
|
317
|
+
FromDSE(dse, NULL, NULL, &d);
|
|
318
|
+
return d;
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
static void
|
|
322
|
+
Backgroundize(int d)
|
|
323
|
+
{
|
|
324
|
+
if (d < 1 || d > 31) {
|
|
325
|
+
return;
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
if (cwts[d] == 0) {
|
|
329
|
+
return;
|
|
330
|
+
}
|
|
331
|
+
if (!UseBGVTColors) {
|
|
332
|
+
return;
|
|
333
|
+
}
|
|
334
|
+
if (bgcolor[d][0] < 0) {
|
|
335
|
+
return;
|
|
336
|
+
}
|
|
337
|
+
printf("%s", Colorize(bgcolor[d][0], bgcolor[d][1], bgcolor[d][2], 1, 0));
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
static void
|
|
341
|
+
UnBackgroundize(int d)
|
|
342
|
+
{
|
|
343
|
+
if (d < 1 || d > 31) {
|
|
344
|
+
return;
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
if (!UseBGVTColors) {
|
|
348
|
+
return;
|
|
349
|
+
}
|
|
350
|
+
if (bgcolor[d][0] < 0) {
|
|
351
|
+
return;
|
|
352
|
+
}
|
|
353
|
+
printf("%s", Decolorize());
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
static void
|
|
357
|
+
send_lrm(void)
|
|
358
|
+
{
|
|
359
|
+
/* Don't send LRM if SuppressLRM is set */
|
|
360
|
+
if (SuppressLRM) {
|
|
361
|
+
return;
|
|
362
|
+
}
|
|
363
|
+
/* Send a lrm control sequence if UseUTF8Chars is enabled
|
|
364
|
+
or char encoding is UTF-8
|
|
365
|
+
*/
|
|
366
|
+
if (UseUTF8Chars || encoding_is_utf8) {
|
|
367
|
+
printf("\xE2\x80\x8E");
|
|
368
|
+
}
|
|
369
|
+
}
|
|
370
|
+
|
|
371
|
+
static char const *
|
|
372
|
+
despace(char const *s)
|
|
373
|
+
{
|
|
374
|
+
static char buf[256];
|
|
375
|
+
|
|
376
|
+
char *t = buf;
|
|
377
|
+
if (strlen(s) > sizeof(buf)-1) {
|
|
378
|
+
/* Punt. :( */
|
|
379
|
+
return s;
|
|
380
|
+
}
|
|
381
|
+
while (*s) {
|
|
382
|
+
if (isspace(*s)) {
|
|
383
|
+
*t++ = '_';
|
|
384
|
+
} else {
|
|
385
|
+
*t++ = *s;
|
|
386
|
+
}
|
|
387
|
+
s++;
|
|
388
|
+
}
|
|
389
|
+
*t = 0;
|
|
390
|
+
return buf;
|
|
391
|
+
}
|
|
392
|
+
|
|
393
|
+
static void PrintJSONChar(char c) {
|
|
394
|
+
switch(c) {
|
|
395
|
+
case '\b': printf("\\b"); break;
|
|
396
|
+
case '\f': printf("\\f"); break;
|
|
397
|
+
case '\n': printf("\\n"); break;
|
|
398
|
+
case '\r': printf("\\r"); break;
|
|
399
|
+
case '\t': printf("\\t"); break;
|
|
400
|
+
case '"': printf("\\\""); break;
|
|
401
|
+
case '\\': printf("\\\\"); break;
|
|
402
|
+
default:
|
|
403
|
+
if ((c > 0 && c < 32) || c == 0x7f) {
|
|
404
|
+
printf("\\u%04x", (unsigned int) c);
|
|
405
|
+
} else {
|
|
406
|
+
printf("%c", c);
|
|
407
|
+
}
|
|
408
|
+
break;
|
|
409
|
+
}
|
|
410
|
+
}
|
|
411
|
+
|
|
412
|
+
void PrintJSONString(char const *s)
|
|
413
|
+
{
|
|
414
|
+
while (*s) {
|
|
415
|
+
switch(*s) {
|
|
416
|
+
case '\b': printf("\\b"); break;
|
|
417
|
+
case '\f': printf("\\f"); break;
|
|
418
|
+
case '\n': printf("\\n"); break;
|
|
419
|
+
case '\r': printf("\\r"); break;
|
|
420
|
+
case '\t': printf("\\t"); break;
|
|
421
|
+
case '"': printf("\\\""); break;
|
|
422
|
+
case '\\': printf("\\\\"); break;
|
|
423
|
+
default:
|
|
424
|
+
if ((*s > 0 && *s < 32) || *s == 0x7f) {
|
|
425
|
+
printf("\\u%04x", (unsigned int) *s);
|
|
426
|
+
} else {
|
|
427
|
+
printf("%c", *s);
|
|
428
|
+
}
|
|
429
|
+
break;
|
|
430
|
+
}
|
|
431
|
+
s++;
|
|
432
|
+
}
|
|
433
|
+
}
|
|
434
|
+
|
|
435
|
+
static void PrintJSONStringLC(char const *s)
|
|
436
|
+
{
|
|
437
|
+
while (*s) {
|
|
438
|
+
switch(*s) {
|
|
439
|
+
case '\b': printf("\\b"); break;
|
|
440
|
+
case '\f': printf("\\f"); break;
|
|
441
|
+
case '\n': printf("\\n"); break;
|
|
442
|
+
case '\r': printf("\\r"); break;
|
|
443
|
+
case '\t': printf("\\t"); break;
|
|
444
|
+
case '"': printf("\\\""); break;
|
|
445
|
+
case '\\': printf("\\\\"); break;
|
|
446
|
+
default:
|
|
447
|
+
if ((*s > 0 && *s < 32) || *s == 0x7f) {
|
|
448
|
+
printf("\\u%04x", (unsigned int) *s);
|
|
449
|
+
} else {
|
|
450
|
+
printf("%c", tolower(*s));
|
|
451
|
+
}
|
|
452
|
+
break;
|
|
453
|
+
}
|
|
454
|
+
s++;
|
|
455
|
+
}
|
|
456
|
+
}
|
|
457
|
+
|
|
458
|
+
void PrintJSONKeyPairInt(char const *name, int val)
|
|
459
|
+
{
|
|
460
|
+
printf("\"");
|
|
461
|
+
PrintJSONString(name);
|
|
462
|
+
printf("\":%d,", val);
|
|
463
|
+
}
|
|
464
|
+
|
|
465
|
+
void PrintJSONKeyPairString(char const *name, char const *val)
|
|
466
|
+
{
|
|
467
|
+
/* If value is blank, skip it! */
|
|
468
|
+
if (!val || !*val) {
|
|
469
|
+
return;
|
|
470
|
+
}
|
|
471
|
+
|
|
472
|
+
printf("\"");
|
|
473
|
+
PrintJSONString(name);
|
|
474
|
+
printf("\":\"");
|
|
475
|
+
PrintJSONString(val);
|
|
476
|
+
printf("\",");
|
|
477
|
+
}
|
|
478
|
+
|
|
479
|
+
static void PrintJSONKeyPairDate(char const *name, int dse)
|
|
480
|
+
{
|
|
481
|
+
int y, m, d;
|
|
482
|
+
if (dse == NO_DATE) {
|
|
483
|
+
/* Skip it! */
|
|
484
|
+
return;
|
|
485
|
+
}
|
|
486
|
+
FromDSE(dse, &y, &m, &d);
|
|
487
|
+
printf("\"");
|
|
488
|
+
PrintJSONString(name);
|
|
489
|
+
printf("\":\"%04d-%02d-%02d\",", y, m+1, d);
|
|
490
|
+
|
|
491
|
+
}
|
|
492
|
+
|
|
493
|
+
void PrintJSONKeyPairDateTime(char const *name, int dt)
|
|
494
|
+
{
|
|
495
|
+
int y, m, d, h, i, k;
|
|
496
|
+
if (dt == NO_DATETIME) {
|
|
497
|
+
/* Skip it! */
|
|
498
|
+
return;
|
|
499
|
+
}
|
|
500
|
+
i = dt / MINUTES_PER_DAY;
|
|
501
|
+
FromDSE(i, &y, &m, &d);
|
|
502
|
+
k = dt % MINUTES_PER_DAY;
|
|
503
|
+
h = k / 60;
|
|
504
|
+
i = k % 60;
|
|
505
|
+
printf("\"");
|
|
506
|
+
PrintJSONString(name);
|
|
507
|
+
printf("\":\"%04d-%02d-%02dT%02d:%02d\",", y, m+1, d, h, i);
|
|
508
|
+
|
|
509
|
+
}
|
|
510
|
+
|
|
511
|
+
static void PrintJSONKeyPairTime(char const *name, int t)
|
|
512
|
+
{
|
|
513
|
+
int h, i;
|
|
514
|
+
if (t == NO_TIME) {
|
|
515
|
+
/* Skip it! */
|
|
516
|
+
return;
|
|
517
|
+
}
|
|
518
|
+
h = t / 60;
|
|
519
|
+
i = t % 60;
|
|
520
|
+
printf("\"");
|
|
521
|
+
PrintJSONString(name);
|
|
522
|
+
printf("\":\"%02d:%02d\",", h, i);
|
|
523
|
+
|
|
524
|
+
}
|
|
525
|
+
|
|
526
|
+
void PutWideChar(wchar_t const wc, DynamicBuffer *output)
|
|
527
|
+
{
|
|
528
|
+
char buf[MB_CUR_MAX+1];
|
|
529
|
+
int len;
|
|
530
|
+
|
|
531
|
+
len = wctomb(buf, wc);
|
|
532
|
+
if (len > 0) {
|
|
533
|
+
buf[len] = 0;
|
|
534
|
+
if (output) {
|
|
535
|
+
DBufPuts(output, buf);
|
|
536
|
+
} else {
|
|
537
|
+
fputs(buf, stdout);
|
|
538
|
+
}
|
|
539
|
+
}
|
|
540
|
+
}
|
|
541
|
+
|
|
542
|
+
static char const *
|
|
543
|
+
get_month_abbrev(char const *mon)
|
|
544
|
+
{
|
|
545
|
+
static char buf[80];
|
|
546
|
+
char *s;
|
|
547
|
+
wchar_t tmp_buf[128] = {0};
|
|
548
|
+
wchar_t *ws;
|
|
549
|
+
int i;
|
|
550
|
+
int len;
|
|
551
|
+
|
|
552
|
+
*buf = 0;
|
|
553
|
+
(void) mbstowcs(tmp_buf, mon, 127);
|
|
554
|
+
ws = tmp_buf;
|
|
555
|
+
s = buf;
|
|
556
|
+
for (i=0; i<3; i++) {
|
|
557
|
+
if (*ws) {
|
|
558
|
+
len = wctomb(s, *ws);
|
|
559
|
+
s += len;
|
|
560
|
+
if (wcwidth(*ws) == 0) {
|
|
561
|
+
i--;
|
|
562
|
+
}
|
|
563
|
+
ws++;
|
|
564
|
+
} else {
|
|
565
|
+
break;
|
|
566
|
+
}
|
|
567
|
+
}
|
|
568
|
+
*s = 0;
|
|
569
|
+
return buf;
|
|
570
|
+
}
|
|
571
|
+
|
|
572
|
+
static int make_wchar_versions(CalEntry *e)
|
|
573
|
+
{
|
|
574
|
+
size_t len;
|
|
575
|
+
wchar_t *buf;
|
|
576
|
+
len = mbstowcs(NULL, e->text, 0);
|
|
577
|
+
if (len == (size_t) -1) return 0;
|
|
578
|
+
|
|
579
|
+
buf = calloc(len+1, sizeof(wchar_t));
|
|
580
|
+
if (!buf) return 0;
|
|
581
|
+
|
|
582
|
+
(void) mbstowcs(buf, e->text, len+1);
|
|
583
|
+
buf[len] = 0;
|
|
584
|
+
e->wc_text = buf;
|
|
585
|
+
e->wc_pos = buf;
|
|
586
|
+
return 1;
|
|
587
|
+
}
|
|
588
|
+
|
|
589
|
+
static void gon(void)
|
|
590
|
+
{
|
|
591
|
+
printf("%s", linestruct->graphics_on);
|
|
592
|
+
}
|
|
593
|
+
static void goff(void)
|
|
594
|
+
{
|
|
595
|
+
printf("%s", linestruct->graphics_off);
|
|
596
|
+
}
|
|
597
|
+
|
|
598
|
+
static void
|
|
599
|
+
ClampColor(int *r, int *g, int *b)
|
|
600
|
+
{
|
|
601
|
+
if (GetTerminalBackground() == TERMINAL_BACKGROUND_UNKNOWN) {
|
|
602
|
+
/* No special clamping if terminal background is unknown */
|
|
603
|
+
return;
|
|
604
|
+
}
|
|
605
|
+
if (GetTerminalBackground() == TERMINAL_BACKGROUND_DARK) {
|
|
606
|
+
if (*r <= 64 && *g <= 64 && *b <= 64) {
|
|
607
|
+
int max = *r;
|
|
608
|
+
double factor;
|
|
609
|
+
if (*g > max) max = *g;
|
|
610
|
+
if (*b > max) max = *b;
|
|
611
|
+
if (max == 0) {
|
|
612
|
+
*r = 65;
|
|
613
|
+
*g = 65;
|
|
614
|
+
*b = 65;
|
|
615
|
+
return;
|
|
616
|
+
}
|
|
617
|
+
factor = 65.0 / (double) max;
|
|
618
|
+
*r = (int) (factor * (double) *r);
|
|
619
|
+
*g = (int) (factor * (double) *g);
|
|
620
|
+
*b = (int) (factor * (double) *b);
|
|
621
|
+
}
|
|
622
|
+
return;
|
|
623
|
+
}
|
|
624
|
+
if (GetTerminalBackground() == TERMINAL_BACKGROUND_LIGHT) {
|
|
625
|
+
if (*r > 191 && *g > 191 && *b > 191) {
|
|
626
|
+
int min = *r;
|
|
627
|
+
if (*g < min) min = *g;
|
|
628
|
+
if (*b < min) min = *b;
|
|
629
|
+
double factor = 192.0 / (double) min;
|
|
630
|
+
*r = (int) (factor * (double) *r);
|
|
631
|
+
*g = (int) (factor * (double) *g);
|
|
632
|
+
*b = (int) (factor * (double) *b);
|
|
633
|
+
}
|
|
634
|
+
}
|
|
635
|
+
}
|
|
636
|
+
|
|
637
|
+
char const *
|
|
638
|
+
Decolorize(void)
|
|
639
|
+
{
|
|
640
|
+
return "\x1B[0m";
|
|
641
|
+
}
|
|
642
|
+
|
|
643
|
+
static char const *
|
|
644
|
+
Colorize256(int r, int g, int b, int bg, int clamp)
|
|
645
|
+
{
|
|
646
|
+
static char buf[40];
|
|
647
|
+
int best = -1;
|
|
648
|
+
int best_dist = 0;
|
|
649
|
+
int dist;
|
|
650
|
+
struct xterm256_colors const *cur;
|
|
651
|
+
size_t i;
|
|
652
|
+
|
|
653
|
+
if (clamp) {
|
|
654
|
+
ClampColor(&r, &g, &b);
|
|
655
|
+
}
|
|
656
|
+
for (i=0; i<(sizeof(XTerm256Colors) / sizeof(XTerm256Colors[0])); i++) {
|
|
657
|
+
cur = &XTerm256Colors[i];
|
|
658
|
+
dist = ((r - cur->r) * (r - cur->r)) +
|
|
659
|
+
((b - cur->b) * (b - cur->b)) +
|
|
660
|
+
((g - cur->g) * (g - cur->g));
|
|
661
|
+
if (best == -1 || dist < best_dist) {
|
|
662
|
+
best_dist = dist;
|
|
663
|
+
best = (int) i;
|
|
664
|
+
}
|
|
665
|
+
}
|
|
666
|
+
if (bg) {
|
|
667
|
+
snprintf(buf, sizeof(buf), "\x1B[48;5;%dm", best);
|
|
668
|
+
} else {
|
|
669
|
+
snprintf(buf, sizeof(buf), "\x1B[38;5;%dm", best);
|
|
670
|
+
}
|
|
671
|
+
return buf;
|
|
672
|
+
}
|
|
673
|
+
|
|
674
|
+
static char const *
|
|
675
|
+
ColorizeTrue(int r, int g, int b, int bg, int clamp)
|
|
676
|
+
{
|
|
677
|
+
static char buf[40];
|
|
678
|
+
if (clamp) {
|
|
679
|
+
ClampColor(&r, &g, &b);
|
|
680
|
+
}
|
|
681
|
+
if (bg) {
|
|
682
|
+
snprintf(buf, sizeof(buf), "\x1B[48;2;%d;%d;%dm", r, g, b);
|
|
683
|
+
} else {
|
|
684
|
+
snprintf(buf, sizeof(buf), "\x1B[38;2;%d;%d;%dm", r, g, b);
|
|
685
|
+
}
|
|
686
|
+
return buf;
|
|
687
|
+
}
|
|
688
|
+
|
|
689
|
+
char const *
|
|
690
|
+
Colorize(int r, int g, int b, int bg, int clamp)
|
|
691
|
+
{
|
|
692
|
+
int bright = 0;
|
|
693
|
+
|
|
694
|
+
if (UseTrueColors) {
|
|
695
|
+
return ColorizeTrue(r, g, b, bg, clamp);
|
|
696
|
+
}
|
|
697
|
+
|
|
698
|
+
if (Use256Colors) {
|
|
699
|
+
return Colorize256(r, g, b, bg, clamp);
|
|
700
|
+
}
|
|
701
|
+
|
|
702
|
+
if (r > 128 || g > 128 || b > 128) {
|
|
703
|
+
bright = 1;
|
|
704
|
+
}
|
|
705
|
+
if (r > 64) r = 1;
|
|
706
|
+
else r = 0;
|
|
707
|
+
if (g > 64) g = 1;
|
|
708
|
+
else g = 0;
|
|
709
|
+
if (b > 64) b = 1;
|
|
710
|
+
else b = 0;
|
|
711
|
+
|
|
712
|
+
if (clamp && GetTerminalBackground() == TERMINAL_BACKGROUND_DARK && !bg) {
|
|
713
|
+
/* Convert black-on-black to grey */
|
|
714
|
+
if (!r && !g && !b) return VT100Colors[1][0][0][0];
|
|
715
|
+
}
|
|
716
|
+
if (clamp && GetTerminalBackground() == TERMINAL_BACKGROUND_LIGHT && !bg) {
|
|
717
|
+
/* Convert white-on-white to grey */
|
|
718
|
+
if (r && g && b) return VT100Colors[1][0][0][0];
|
|
719
|
+
}
|
|
720
|
+
if (bg) {
|
|
721
|
+
return VT100BGColors[r][g][b];
|
|
722
|
+
} else {
|
|
723
|
+
return VT100Colors[bright][r][g][b];
|
|
724
|
+
}
|
|
725
|
+
}
|
|
726
|
+
|
|
727
|
+
static void ColorizeEntry(CalEntry const *e, int clamp)
|
|
728
|
+
{
|
|
729
|
+
printf("%s", Colorize(e->r, e->g, e->b, 0, clamp));
|
|
730
|
+
}
|
|
731
|
+
|
|
732
|
+
static void
|
|
733
|
+
InitMoonsAndShades(void)
|
|
734
|
+
{
|
|
735
|
+
int i;
|
|
736
|
+
/* Initialize the moon array */
|
|
737
|
+
if (encoding_is_utf8) {
|
|
738
|
+
for (i=0; i<=31; i++) {
|
|
739
|
+
moons[i][0] = 0;
|
|
740
|
+
}
|
|
741
|
+
}
|
|
742
|
+
|
|
743
|
+
/* Clear SHADEs */
|
|
744
|
+
if (UseBGVTColors) {
|
|
745
|
+
for (i=0; i<=31; i++) {
|
|
746
|
+
bgcolor[i][0] = -1;
|
|
747
|
+
bgcolor[i][1] = -1;
|
|
748
|
+
bgcolor[i][2] = -1;
|
|
749
|
+
}
|
|
750
|
+
}
|
|
751
|
+
|
|
752
|
+
/* Clear weeks */
|
|
753
|
+
for(i=0; i<=31; i++) {
|
|
754
|
+
weeks[i][0] = 0;
|
|
755
|
+
}
|
|
756
|
+
}
|
|
757
|
+
|
|
758
|
+
static void
|
|
759
|
+
SetShadeEntry(int dse, char const *shade)
|
|
760
|
+
{
|
|
761
|
+
int d;
|
|
762
|
+
int r, g, b;
|
|
763
|
+
/* Don't bother if we're not doing SHADE specials */
|
|
764
|
+
if (!UseBGVTColors) {
|
|
765
|
+
return;
|
|
766
|
+
}
|
|
767
|
+
|
|
768
|
+
if (sscanf(shade, "%d %d %d", &r, &g, &b) != 3) {
|
|
769
|
+
if (sscanf(shade, "%d", &r) != 1) {
|
|
770
|
+
return;
|
|
771
|
+
}
|
|
772
|
+
g = r;
|
|
773
|
+
b = r;
|
|
774
|
+
}
|
|
775
|
+
if (r < 0 || g < 0 || b < 0 || r > 255 || g > 255 || b > 255) {
|
|
776
|
+
return;
|
|
777
|
+
}
|
|
778
|
+
FromDSE(dse, NULL, NULL, &d);
|
|
779
|
+
bgcolor[d][0] = r;
|
|
780
|
+
bgcolor[d][1] = g;
|
|
781
|
+
bgcolor[d][2] = b;
|
|
782
|
+
}
|
|
783
|
+
|
|
784
|
+
static void
|
|
785
|
+
SetMoonEntry(int dse, char const *moon)
|
|
786
|
+
{
|
|
787
|
+
int phase;
|
|
788
|
+
int d;
|
|
789
|
+
char msg[28];
|
|
790
|
+
|
|
791
|
+
/* Don't bother unless it's utf-8 */
|
|
792
|
+
if (!encoding_is_utf8) {
|
|
793
|
+
return;
|
|
794
|
+
}
|
|
795
|
+
|
|
796
|
+
msg[0] = 0;
|
|
797
|
+
if (sscanf(moon, "%d %*d %*d %27[^\x01]", &phase, msg) < 4) {
|
|
798
|
+
if (sscanf(moon, "%d", &phase) != 1) {
|
|
799
|
+
/* Malformed MOON special; ignore */
|
|
800
|
+
return;
|
|
801
|
+
}
|
|
802
|
+
}
|
|
803
|
+
if (phase < 0 || phase > 3) {
|
|
804
|
+
/* Bad phase */
|
|
805
|
+
return;
|
|
806
|
+
}
|
|
807
|
+
FromDSE(dse, NULL, NULL, &d);
|
|
808
|
+
if (msg[0]) {
|
|
809
|
+
snprintf(moons[d], sizeof(moons[d]), "%s %s", moonphase_emojis[phase], msg);
|
|
810
|
+
} else {
|
|
811
|
+
snprintf(moons[d], sizeof(moons[d]), "%s", moonphase_emojis[phase]);
|
|
812
|
+
}
|
|
813
|
+
}
|
|
814
|
+
|
|
815
|
+
|
|
816
|
+
/***************************************************************/
|
|
817
|
+
/* */
|
|
818
|
+
/* ProduceCalendar */
|
|
819
|
+
/* */
|
|
820
|
+
/* Main loop for generating a calendar. */
|
|
821
|
+
/* */
|
|
822
|
+
/***************************************************************/
|
|
823
|
+
void ProduceCalendar(void)
|
|
824
|
+
{
|
|
825
|
+
int y, m, d;
|
|
826
|
+
|
|
827
|
+
/* Check if current locale is UTF-8, if we have langinfo.h */
|
|
828
|
+
#ifdef HAVE_LANGINFO_H
|
|
829
|
+
char const *encoding = nl_langinfo(CODESET);
|
|
830
|
+
if (!strcasecmp(encoding, "utf-8")) {
|
|
831
|
+
encoding_is_utf8 = 1;
|
|
832
|
+
}
|
|
833
|
+
|
|
834
|
+
#endif
|
|
835
|
+
if (UseUTF8Chars) {
|
|
836
|
+
linestruct = &UTF8Drawing;
|
|
837
|
+
} else if (UseVTChars) {
|
|
838
|
+
linestruct = &VT100Drawing;
|
|
839
|
+
} else {
|
|
840
|
+
linestruct = &NormalDrawing;
|
|
841
|
+
}
|
|
842
|
+
ShouldCache = 1;
|
|
843
|
+
|
|
844
|
+
ColSpaces = (CalWidth - 9) / 7;
|
|
845
|
+
CalWidth = 7*ColSpaces + 8;
|
|
846
|
+
|
|
847
|
+
/* Run the file once to get potentially-overridden day names */
|
|
848
|
+
if (CalMonths) {
|
|
849
|
+
FromDSE(DSEToday, &y, &m, &d);
|
|
850
|
+
DSEToday = DSE(y, m, 1);
|
|
851
|
+
LocalDSEToday = DSEToday;
|
|
852
|
+
LocalSysTime = 0;
|
|
853
|
+
SysTime = 0;
|
|
854
|
+
GenerateCalEntries(-1);
|
|
855
|
+
DidAMonth = 0;
|
|
856
|
+
if (PsCal == PSCAL_LEVEL3) {
|
|
857
|
+
printf("[\n");
|
|
858
|
+
}
|
|
859
|
+
while (CalMonths--) {
|
|
860
|
+
DoCalendarOneMonth();
|
|
861
|
+
DidAMonth = 1;
|
|
862
|
+
}
|
|
863
|
+
if (PsCal == PSCAL_LEVEL3) {
|
|
864
|
+
printf("\n]\n");
|
|
865
|
+
}
|
|
866
|
+
return;
|
|
867
|
+
} else {
|
|
868
|
+
if (MondayFirst) {
|
|
869
|
+
DSEToday -= (DSEToday%7);
|
|
870
|
+
LocalDSEToday -= (LocalDSEToday%7);
|
|
871
|
+
} else {
|
|
872
|
+
DSEToday -= ((DSEToday+1)%7);
|
|
873
|
+
LocalDSEToday -= ((LocalDSEToday+1)%7);
|
|
874
|
+
}
|
|
875
|
+
|
|
876
|
+
LocalSysTime = 0;
|
|
877
|
+
SysTime = 0;
|
|
878
|
+
GenerateCalEntries(-1);
|
|
879
|
+
|
|
880
|
+
if (!DoSimpleCalendar) {
|
|
881
|
+
WriteWeekHeaderLine();
|
|
882
|
+
WriteCalDays();
|
|
883
|
+
WriteIntermediateCalLine();
|
|
884
|
+
}
|
|
885
|
+
|
|
886
|
+
DidAWeek = 0;
|
|
887
|
+
if (PsCal == PSCAL_LEVEL3) {
|
|
888
|
+
printf("[\n");
|
|
889
|
+
}
|
|
890
|
+
while (CalWeeks--) {
|
|
891
|
+
DoCalendarOneWeek(CalWeeks);
|
|
892
|
+
DidAWeek = 1;
|
|
893
|
+
}
|
|
894
|
+
if (PsCal == PSCAL_LEVEL3) {
|
|
895
|
+
printf("\n]\n");
|
|
896
|
+
}
|
|
897
|
+
return;
|
|
898
|
+
}
|
|
899
|
+
}
|
|
900
|
+
|
|
901
|
+
static void
|
|
902
|
+
SendTranslationTable(int pslevel)
|
|
903
|
+
{
|
|
904
|
+
if (pslevel < PSCAL_LEVEL3) {
|
|
905
|
+
printf("# translations\n");
|
|
906
|
+
}
|
|
907
|
+
DumpTranslationTable(stdout, 1);
|
|
908
|
+
if (pslevel < PSCAL_LEVEL3) {
|
|
909
|
+
printf("\n");
|
|
910
|
+
}
|
|
911
|
+
}
|
|
912
|
+
|
|
913
|
+
/***************************************************************/
|
|
914
|
+
/* */
|
|
915
|
+
/* DoCalendarOneWeek */
|
|
916
|
+
/* */
|
|
917
|
+
/* Write a calendar for a single week */
|
|
918
|
+
/* */
|
|
919
|
+
/***************************************************************/
|
|
920
|
+
static void DoCalendarOneWeek(int nleft)
|
|
921
|
+
{
|
|
922
|
+
int y, m, d, done, i, l, wd;
|
|
923
|
+
char buf[128];
|
|
924
|
+
int LinesWritten = 0;
|
|
925
|
+
int OrigDse = LocalDSEToday;
|
|
926
|
+
|
|
927
|
+
InitMoonsAndShades();
|
|
928
|
+
/* Fill in the column entries */
|
|
929
|
+
for (i=0; i<7; i++) {
|
|
930
|
+
ColToDay[i] = DayOf(DSEToday);
|
|
931
|
+
GenerateCalEntries(i);
|
|
932
|
+
DSEToday++;
|
|
933
|
+
LocalDSEToday++;
|
|
934
|
+
}
|
|
935
|
+
|
|
936
|
+
/* Figure out weekday of first column */
|
|
937
|
+
|
|
938
|
+
if (MondayFirst) wd = DSEToday % 7;
|
|
939
|
+
else wd = (DSEToday + 1) % 7;
|
|
940
|
+
|
|
941
|
+
/* Output the entries */
|
|
942
|
+
/* If it's "Simple Calendar" format, do it simply... */
|
|
943
|
+
if (DoSimpleCalendar) {
|
|
944
|
+
if (PsCal == PSCAL_LEVEL3) {
|
|
945
|
+
if (DidAWeek) {
|
|
946
|
+
printf(",\n");
|
|
947
|
+
}
|
|
948
|
+
printf("{\n\"caltype\":\"weekly\",");
|
|
949
|
+
if (!DidAWeek) {
|
|
950
|
+
printf("\"translations\":");
|
|
951
|
+
SendTranslationTable(PsCal);
|
|
952
|
+
printf(",");
|
|
953
|
+
}
|
|
954
|
+
printf("\"dates\":[");
|
|
955
|
+
for (i=0; i<7; i++) {
|
|
956
|
+
if (i != 0) {
|
|
957
|
+
printf(",");
|
|
958
|
+
}
|
|
959
|
+
FromDSE(OrigDse+i-wd, &y, &m, &d);
|
|
960
|
+
printf("{\"dayname\":\"%s\",\"date\":\"%04d-%02d-%02d\",\"year\":%d,\"month\":\"%s\",\"day\":%d}", get_day_name((OrigDse+i-wd)%7),y, m+1, d, y, get_month_name(m), d);
|
|
961
|
+
}
|
|
962
|
+
printf("],\"entries\":[");
|
|
963
|
+
}
|
|
964
|
+
DidADay = 0;
|
|
965
|
+
for (i=0; i<7; i++) {
|
|
966
|
+
WriteSimpleEntries(i, OrigDse+i-wd);
|
|
967
|
+
}
|
|
968
|
+
if (PsCal == PSCAL_LEVEL3) {
|
|
969
|
+
printf("\n]\n}");
|
|
970
|
+
}
|
|
971
|
+
return;
|
|
972
|
+
}
|
|
973
|
+
|
|
974
|
+
/* Here come the first few lines... */
|
|
975
|
+
gon();
|
|
976
|
+
DRAW(tb);
|
|
977
|
+
goff();
|
|
978
|
+
for (i=0; i<7; i++) {
|
|
979
|
+
FromDSE(OrigDse+i, &y, &m, &d);
|
|
980
|
+
char const *mon = get_month_name(m);
|
|
981
|
+
if (moons[d][0]) {
|
|
982
|
+
if (weeks[d][0]) {
|
|
983
|
+
snprintf(buf, sizeof(buf), "%d %s %s %s ", d, get_month_abbrev(mon), weeks[d], moons[d]);
|
|
984
|
+
} else {
|
|
985
|
+
snprintf(buf, sizeof(buf), "%d %s %s ", d, get_month_abbrev(mon), moons[d]);
|
|
986
|
+
}
|
|
987
|
+
} else {
|
|
988
|
+
if (weeks[d][0]) {
|
|
989
|
+
snprintf(buf, sizeof(buf), "%d %s %s ", d, get_month_abbrev(mon), weeks[d]);
|
|
990
|
+
} else {
|
|
991
|
+
snprintf(buf, sizeof(buf), "%d %s ", d, get_month_abbrev(mon));
|
|
992
|
+
}
|
|
993
|
+
}
|
|
994
|
+
if (OrigDse+i == RealToday) {
|
|
995
|
+
if (UseVTColors) {
|
|
996
|
+
printf("\x1B[1m"); /* Bold */
|
|
997
|
+
}
|
|
998
|
+
Backgroundize(d);
|
|
999
|
+
PrintLeft(buf, ColSpaces-1, '*');
|
|
1000
|
+
putchar(' ');
|
|
1001
|
+
UnBackgroundize(d);
|
|
1002
|
+
if (UseVTColors) {
|
|
1003
|
+
printf("\x1B[0m"); /* Normal */
|
|
1004
|
+
}
|
|
1005
|
+
} else {
|
|
1006
|
+
Backgroundize(d);
|
|
1007
|
+
PrintLeft(buf, ColSpaces, ' ');
|
|
1008
|
+
UnBackgroundize(d);
|
|
1009
|
+
}
|
|
1010
|
+
gon();
|
|
1011
|
+
DRAW(tb);
|
|
1012
|
+
goff();
|
|
1013
|
+
}
|
|
1014
|
+
putchar('\n');
|
|
1015
|
+
for (l=0; l<CalPad; l++) {
|
|
1016
|
+
gon();
|
|
1017
|
+
DRAW(tb);
|
|
1018
|
+
goff();
|
|
1019
|
+
for (i=0; i<7; i++) {
|
|
1020
|
+
d = ColToDay[i];
|
|
1021
|
+
Backgroundize(d);
|
|
1022
|
+
PrintLeft("", ColSpaces, ' ');
|
|
1023
|
+
UnBackgroundize(d);
|
|
1024
|
+
gon();
|
|
1025
|
+
DRAW(tb);
|
|
1026
|
+
goff();
|
|
1027
|
+
}
|
|
1028
|
+
putchar('\n');
|
|
1029
|
+
}
|
|
1030
|
+
|
|
1031
|
+
/* Write the body lines */
|
|
1032
|
+
done = 0;
|
|
1033
|
+
while (!done) {
|
|
1034
|
+
done = WriteOneCalLine(OrigDse, wd);
|
|
1035
|
+
if (done < 0) {
|
|
1036
|
+
break;
|
|
1037
|
+
}
|
|
1038
|
+
LinesWritten++;
|
|
1039
|
+
}
|
|
1040
|
+
|
|
1041
|
+
/* Write any blank lines required */
|
|
1042
|
+
while (LinesWritten++ < CalLines) {
|
|
1043
|
+
gon();
|
|
1044
|
+
DRAW(tb);
|
|
1045
|
+
goff();
|
|
1046
|
+
for (i=0; i<7; i++) {
|
|
1047
|
+
d = ColToDay[i];
|
|
1048
|
+
Backgroundize(d);
|
|
1049
|
+
PrintLeft("", ColSpaces, ' ');
|
|
1050
|
+
UnBackgroundize(d);
|
|
1051
|
+
gon();
|
|
1052
|
+
DRAW(tb);
|
|
1053
|
+
goff();
|
|
1054
|
+
}
|
|
1055
|
+
putchar('\n');
|
|
1056
|
+
}
|
|
1057
|
+
|
|
1058
|
+
/* Write the final line */
|
|
1059
|
+
if (nleft) {
|
|
1060
|
+
WriteIntermediateCalLine();
|
|
1061
|
+
} else {
|
|
1062
|
+
WriteBottomCalLine();
|
|
1063
|
+
}
|
|
1064
|
+
}
|
|
1065
|
+
|
|
1066
|
+
/***************************************************************/
|
|
1067
|
+
/* */
|
|
1068
|
+
/* DoSimpleCalendarOneMonth */
|
|
1069
|
+
/* */
|
|
1070
|
+
/* Produce a "simple" calendar for the current month. */
|
|
1071
|
+
/* */
|
|
1072
|
+
/* A simple calendar is produced if the -s or -p option */
|
|
1073
|
+
/* was used. */
|
|
1074
|
+
/* */
|
|
1075
|
+
/***************************************************************/
|
|
1076
|
+
static void DoSimpleCalendarOneMonth(void)
|
|
1077
|
+
{
|
|
1078
|
+
int y, m, d, mm, yy, i, j;
|
|
1079
|
+
|
|
1080
|
+
InitMoonsAndShades();
|
|
1081
|
+
DidADay = 0;
|
|
1082
|
+
if (PsCal) {
|
|
1083
|
+
FromDSE(DSEToday, &y, &m, &d);
|
|
1084
|
+
if (PsCal == PSCAL_LEVEL1) {
|
|
1085
|
+
if (!DidAMonth) {
|
|
1086
|
+
SendTranslationTable(PsCal);
|
|
1087
|
+
}
|
|
1088
|
+
printf("%s\n", PSBEGIN);
|
|
1089
|
+
} else if (PsCal == PSCAL_LEVEL2) {
|
|
1090
|
+
if (!DidAMonth) {
|
|
1091
|
+
SendTranslationTable(PsCal);
|
|
1092
|
+
}
|
|
1093
|
+
printf("%s\n", PSBEGIN2);
|
|
1094
|
+
} else {
|
|
1095
|
+
if (DidAMonth) {
|
|
1096
|
+
printf(",\n");
|
|
1097
|
+
}
|
|
1098
|
+
printf("{\n");
|
|
1099
|
+
if (!DidAMonth) {
|
|
1100
|
+
printf("\"translations\":");
|
|
1101
|
+
SendTranslationTable(PsCal);
|
|
1102
|
+
printf(",");
|
|
1103
|
+
}
|
|
1104
|
+
}
|
|
1105
|
+
if (PsCal < PSCAL_LEVEL3) {
|
|
1106
|
+
printf("%s %d %d %d %d\n",
|
|
1107
|
+
despace(get_month_name(m)), y, DaysInMonth(m, y), (DSEToday+1) % 7,
|
|
1108
|
+
MondayFirst);
|
|
1109
|
+
for (i=0; i<7; i++) {
|
|
1110
|
+
j=(i+6)%7;
|
|
1111
|
+
if (i) {
|
|
1112
|
+
printf(" %s", despace(get_day_name(j)));
|
|
1113
|
+
} else {
|
|
1114
|
+
printf("%s", despace(get_day_name(j)));
|
|
1115
|
+
}
|
|
1116
|
+
}
|
|
1117
|
+
printf("\n");
|
|
1118
|
+
} else {
|
|
1119
|
+
PrintJSONKeyPairString("caltype", "monthly");
|
|
1120
|
+
PrintJSONKeyPairString("monthname", get_month_name(m));
|
|
1121
|
+
PrintJSONKeyPairInt("year", y);
|
|
1122
|
+
PrintJSONKeyPairInt("daysinmonth", DaysInMonth(m, y));
|
|
1123
|
+
PrintJSONKeyPairInt("firstwkday", (DSEToday+1) % 7);
|
|
1124
|
+
PrintJSONKeyPairInt("mondayfirst", MondayFirst);
|
|
1125
|
+
printf("\"daynames\":[\"%s\",\"%s\",\"%s\",\"%s\",\"%s\",\"%s\",\"%s\"],",
|
|
1126
|
+
get_day_name(6), get_day_name(0), get_day_name(1), get_day_name(2),
|
|
1127
|
+
get_day_name(3), get_day_name(4), get_day_name(5));
|
|
1128
|
+
}
|
|
1129
|
+
mm = m-1;
|
|
1130
|
+
if (mm<0) {
|
|
1131
|
+
mm = 11; yy = y-1;
|
|
1132
|
+
} else yy=y;
|
|
1133
|
+
|
|
1134
|
+
if (PsCal < PSCAL_LEVEL3) {
|
|
1135
|
+
printf("%s %d\n", despace(get_month_name(mm)), DaysInMonth(mm,yy));
|
|
1136
|
+
} else {
|
|
1137
|
+
PrintJSONKeyPairString("prevmonthname", get_month_name(mm));
|
|
1138
|
+
PrintJSONKeyPairInt("daysinprevmonth", DaysInMonth(mm, yy));
|
|
1139
|
+
PrintJSONKeyPairInt("prevmonthyear", yy);
|
|
1140
|
+
}
|
|
1141
|
+
mm = m+1;
|
|
1142
|
+
if (mm>11) {
|
|
1143
|
+
mm = 0; yy = y+1;
|
|
1144
|
+
} else yy=y;
|
|
1145
|
+
if (PsCal < PSCAL_LEVEL3) {
|
|
1146
|
+
printf("%s %d\n", despace(get_month_name(mm)), DaysInMonth(mm,yy));
|
|
1147
|
+
} else {
|
|
1148
|
+
PrintJSONKeyPairString("nextmonthname", get_month_name(mm));
|
|
1149
|
+
PrintJSONKeyPairInt("daysinnextmonth", DaysInMonth(mm, yy));
|
|
1150
|
+
PrintJSONKeyPairInt("nextmonthyear", yy);
|
|
1151
|
+
printf("\"entries\":[\n");
|
|
1152
|
+
}
|
|
1153
|
+
}
|
|
1154
|
+
while (WriteCalendarRow()) /* continue */;
|
|
1155
|
+
|
|
1156
|
+
if (PsCal == PSCAL_LEVEL1) {
|
|
1157
|
+
printf("%s\n", PSEND);
|
|
1158
|
+
} else if (PsCal == PSCAL_LEVEL2) {
|
|
1159
|
+
printf("%s\n", PSEND2);
|
|
1160
|
+
} else if (PsCal == PSCAL_LEVEL3){
|
|
1161
|
+
if (DidADay) {
|
|
1162
|
+
printf("\n");
|
|
1163
|
+
}
|
|
1164
|
+
printf("]\n}");
|
|
1165
|
+
}
|
|
1166
|
+
}
|
|
1167
|
+
|
|
1168
|
+
/***************************************************************/
|
|
1169
|
+
/* */
|
|
1170
|
+
/* DoCalendarOneMonth */
|
|
1171
|
+
/* */
|
|
1172
|
+
/* Produce a calendar for the current month. */
|
|
1173
|
+
/* */
|
|
1174
|
+
/***************************************************************/
|
|
1175
|
+
static void DoCalendarOneMonth(void)
|
|
1176
|
+
{
|
|
1177
|
+
InitMoonsAndShades();
|
|
1178
|
+
|
|
1179
|
+
if (DoSimpleCalendar) {
|
|
1180
|
+
DoSimpleCalendarOneMonth();
|
|
1181
|
+
return;
|
|
1182
|
+
}
|
|
1183
|
+
|
|
1184
|
+
WriteCalHeader();
|
|
1185
|
+
|
|
1186
|
+
while (WriteCalendarRow()) /* continue */;
|
|
1187
|
+
|
|
1188
|
+
WriteCalTrailer();
|
|
1189
|
+
}
|
|
1190
|
+
|
|
1191
|
+
/***************************************************************/
|
|
1192
|
+
/* */
|
|
1193
|
+
/* WriteCalendarRow */
|
|
1194
|
+
/* */
|
|
1195
|
+
/* Write one row of the calendar */
|
|
1196
|
+
/* */
|
|
1197
|
+
/***************************************************************/
|
|
1198
|
+
static int WriteCalendarRow(void)
|
|
1199
|
+
{
|
|
1200
|
+
int y, m, d, wd, i, l;
|
|
1201
|
+
int done;
|
|
1202
|
+
char buf[81];
|
|
1203
|
+
int OrigDse = DSEToday;
|
|
1204
|
+
int LinesWritten = 0;
|
|
1205
|
+
int moreleft;
|
|
1206
|
+
|
|
1207
|
+
/* Get the date of the first day */
|
|
1208
|
+
FromDSE(DSEToday, &y, &m, &d);
|
|
1209
|
+
if (!MondayFirst) wd = (DSEToday + 1) % 7;
|
|
1210
|
+
else wd = DSEToday % 7;
|
|
1211
|
+
|
|
1212
|
+
for (i=0; i<7; i++) {
|
|
1213
|
+
ColToDay[i] = 0;
|
|
1214
|
+
}
|
|
1215
|
+
|
|
1216
|
+
/* Fill in the column entries */
|
|
1217
|
+
for (i=wd; i<7; i++) {
|
|
1218
|
+
if (d+i-wd > DaysInMonth(m, y)) break;
|
|
1219
|
+
GenerateCalEntries(i);
|
|
1220
|
+
ColToDay[i] = DayOf(DSEToday);
|
|
1221
|
+
DSEToday++;
|
|
1222
|
+
LocalDSEToday++;
|
|
1223
|
+
}
|
|
1224
|
+
|
|
1225
|
+
/* Output the entries */
|
|
1226
|
+
|
|
1227
|
+
/* If it's "Simple Calendar" format, do it simply... */
|
|
1228
|
+
if (DoSimpleCalendar) {
|
|
1229
|
+
for (i=wd; i<7 && d+i-wd<=DaysInMonth(m, y); i++) {
|
|
1230
|
+
WriteSimpleEntries(i, OrigDse+i-wd);
|
|
1231
|
+
}
|
|
1232
|
+
return (d+7-wd <= DaysInMonth(m, y));
|
|
1233
|
+
}
|
|
1234
|
+
|
|
1235
|
+
|
|
1236
|
+
/* Here come the first few lines... */
|
|
1237
|
+
gon();
|
|
1238
|
+
DRAW(tb);
|
|
1239
|
+
goff();
|
|
1240
|
+
for (i=0; i<7; i++) {
|
|
1241
|
+
if (i < wd || d+i-wd>DaysInMonth(m, y))
|
|
1242
|
+
PrintLeft("", ColSpaces, ' ');
|
|
1243
|
+
else {
|
|
1244
|
+
if (moons[d+i-wd][0]) {
|
|
1245
|
+
if (weeks[d+i-wd][0]) {
|
|
1246
|
+
snprintf(buf, sizeof(buf), "%d %s %s ", d+i-wd, weeks[d+i-wd], moons[d+i-wd]);
|
|
1247
|
+
} else {
|
|
1248
|
+
snprintf(buf, sizeof(buf), "%d %s ", d+i-wd, moons[d+i-wd]);
|
|
1249
|
+
}
|
|
1250
|
+
} else {
|
|
1251
|
+
if (weeks[d+i-wd][0]) {
|
|
1252
|
+
snprintf(buf, sizeof(buf), "%d %s ", d+i-wd, weeks[d+i-wd]);
|
|
1253
|
+
} else {
|
|
1254
|
+
snprintf(buf, sizeof(buf), "%d ", d+i-wd);
|
|
1255
|
+
}
|
|
1256
|
+
}
|
|
1257
|
+
if (DSE(y, m, d+i-wd) == RealToday) {
|
|
1258
|
+
if (UseVTColors) {
|
|
1259
|
+
printf("\x1B[1m"); /* Bold */
|
|
1260
|
+
}
|
|
1261
|
+
Backgroundize(d+i-wd);
|
|
1262
|
+
PrintLeft(buf, ColSpaces-1, '*');
|
|
1263
|
+
putchar(' ');
|
|
1264
|
+
if (UseVTColors) {
|
|
1265
|
+
printf("\x1B[0m"); /* Normal */
|
|
1266
|
+
}
|
|
1267
|
+
UnBackgroundize(d+i-wd);
|
|
1268
|
+
} else {
|
|
1269
|
+
Backgroundize(d+i-wd);
|
|
1270
|
+
PrintLeft(buf, ColSpaces, ' ');
|
|
1271
|
+
UnBackgroundize(d+i-wd);
|
|
1272
|
+
}
|
|
1273
|
+
}
|
|
1274
|
+
gon();
|
|
1275
|
+
DRAW(tb);
|
|
1276
|
+
goff();
|
|
1277
|
+
}
|
|
1278
|
+
putchar('\n');
|
|
1279
|
+
for (l=0; l<CalPad; l++) {
|
|
1280
|
+
gon();
|
|
1281
|
+
DRAW(tb);
|
|
1282
|
+
goff();
|
|
1283
|
+
for (i=0; i<7; i++) {
|
|
1284
|
+
Backgroundize(ColToDay[i]);
|
|
1285
|
+
PrintLeft("", ColSpaces, ' ');
|
|
1286
|
+
UnBackgroundize(ColToDay[i]);
|
|
1287
|
+
gon();
|
|
1288
|
+
DRAW(tb);
|
|
1289
|
+
goff();
|
|
1290
|
+
}
|
|
1291
|
+
putchar('\n');
|
|
1292
|
+
}
|
|
1293
|
+
|
|
1294
|
+
/* Write the body lines */
|
|
1295
|
+
done = 0;
|
|
1296
|
+
while (!done) {
|
|
1297
|
+
done = WriteOneCalLine(OrigDse, wd);
|
|
1298
|
+
if (done < 0) {
|
|
1299
|
+
break;
|
|
1300
|
+
}
|
|
1301
|
+
LinesWritten++;
|
|
1302
|
+
}
|
|
1303
|
+
|
|
1304
|
+
/* Write any blank lines required */
|
|
1305
|
+
while (LinesWritten++ < CalLines) {
|
|
1306
|
+
gon();
|
|
1307
|
+
DRAW(tb);
|
|
1308
|
+
goff();
|
|
1309
|
+
for (i=0; i<7; i++) {
|
|
1310
|
+
Backgroundize(ColToDay[i]);
|
|
1311
|
+
PrintLeft("", ColSpaces, ' ');
|
|
1312
|
+
UnBackgroundize(ColToDay[i]);
|
|
1313
|
+
gon();
|
|
1314
|
+
DRAW(tb);
|
|
1315
|
+
goff();
|
|
1316
|
+
}
|
|
1317
|
+
putchar('\n');
|
|
1318
|
+
}
|
|
1319
|
+
|
|
1320
|
+
moreleft = (d+7-wd <= DaysInMonth(m, y));
|
|
1321
|
+
if (moreleft) {
|
|
1322
|
+
WriteIntermediateCalLine();
|
|
1323
|
+
} else {
|
|
1324
|
+
WriteBottomCalLine();
|
|
1325
|
+
}
|
|
1326
|
+
|
|
1327
|
+
/* Return non-zero if we have not yet finished */
|
|
1328
|
+
return moreleft;
|
|
1329
|
+
}
|
|
1330
|
+
|
|
1331
|
+
/***************************************************************/
|
|
1332
|
+
/* */
|
|
1333
|
+
/* PrintLeft */
|
|
1334
|
+
/* */
|
|
1335
|
+
/* Left-justify a piece of text. */
|
|
1336
|
+
/* */
|
|
1337
|
+
/***************************************************************/
|
|
1338
|
+
static void PrintLeft(char const *s, int width, char pad)
|
|
1339
|
+
{
|
|
1340
|
+
size_t len = mbstowcs(NULL, s, 0);
|
|
1341
|
+
int i;
|
|
1342
|
+
wchar_t static_buf[128];
|
|
1343
|
+
wchar_t *buf;
|
|
1344
|
+
wchar_t *ws;
|
|
1345
|
+
|
|
1346
|
+
if (!len) {
|
|
1347
|
+
for (i=0; i<width; i++) {
|
|
1348
|
+
fputc(pad, stdout);
|
|
1349
|
+
}
|
|
1350
|
+
return;
|
|
1351
|
+
}
|
|
1352
|
+
if (len + 1 <= 128) {
|
|
1353
|
+
buf = static_buf;
|
|
1354
|
+
} else {
|
|
1355
|
+
buf = calloc(len+1, sizeof(wchar_t));
|
|
1356
|
+
if (!buf) {
|
|
1357
|
+
/* Uh-oh... cannot recover */
|
|
1358
|
+
fprintf(ErrFp, "%s\n", GetErr(E_NO_MEM));
|
|
1359
|
+
exit(EXIT_FAILURE);
|
|
1360
|
+
}
|
|
1361
|
+
}
|
|
1362
|
+
(void) mbstowcs(buf, s, len+1);
|
|
1363
|
+
|
|
1364
|
+
ws = buf;
|
|
1365
|
+
i=0;
|
|
1366
|
+
while (i<width) {
|
|
1367
|
+
if (*ws) {
|
|
1368
|
+
if (i + wcwidth(*ws) > width) {
|
|
1369
|
+
break;
|
|
1370
|
+
}
|
|
1371
|
+
i += wcwidth(*ws);
|
|
1372
|
+
PutWideChar(*ws++, NULL);
|
|
1373
|
+
} else {
|
|
1374
|
+
break;
|
|
1375
|
+
}
|
|
1376
|
+
}
|
|
1377
|
+
/* Mop up any potential combining characters */
|
|
1378
|
+
while (*ws && wcwidth(*ws) == 0) {
|
|
1379
|
+
PutWideChar(*ws++, NULL);
|
|
1380
|
+
}
|
|
1381
|
+
|
|
1382
|
+
/* Possibly send lrm control sequence */
|
|
1383
|
+
send_lrm();
|
|
1384
|
+
|
|
1385
|
+
while (i<width) {
|
|
1386
|
+
fputc(pad, stdout);
|
|
1387
|
+
i++;
|
|
1388
|
+
}
|
|
1389
|
+
if (buf != static_buf) free(buf);
|
|
1390
|
+
}
|
|
1391
|
+
|
|
1392
|
+
/***************************************************************/
|
|
1393
|
+
/* */
|
|
1394
|
+
/* PrintCentered */
|
|
1395
|
+
/* */
|
|
1396
|
+
/* Center a piece of text */
|
|
1397
|
+
/* */
|
|
1398
|
+
/***************************************************************/
|
|
1399
|
+
static void PrintCentered(char const *s, int width, char const *pad)
|
|
1400
|
+
{
|
|
1401
|
+
size_t len = mbstowcs(NULL, s, 0);
|
|
1402
|
+
int display_len;
|
|
1403
|
+
int i;
|
|
1404
|
+
wchar_t static_buf[128];
|
|
1405
|
+
wchar_t *buf;
|
|
1406
|
+
wchar_t *ws;
|
|
1407
|
+
int d;
|
|
1408
|
+
|
|
1409
|
+
if (!len) {
|
|
1410
|
+
for (i=0; i<width; i++) {
|
|
1411
|
+
fputs(pad, stdout);
|
|
1412
|
+
}
|
|
1413
|
+
return;
|
|
1414
|
+
}
|
|
1415
|
+
if (len + 1 <= 128) {
|
|
1416
|
+
buf = static_buf;
|
|
1417
|
+
} else {
|
|
1418
|
+
buf = calloc(len+1, sizeof(wchar_t));
|
|
1419
|
+
if (!buf) {
|
|
1420
|
+
/* Uh-oh... cannot recover */
|
|
1421
|
+
fprintf(ErrFp, "%s\n", GetErr(E_NO_MEM));
|
|
1422
|
+
exit(EXIT_FAILURE);
|
|
1423
|
+
}
|
|
1424
|
+
}
|
|
1425
|
+
(void) mbstowcs(buf, s, len+1);
|
|
1426
|
+
display_len = wcswidth(buf, len+1);
|
|
1427
|
+
d = (width - display_len) / 2;
|
|
1428
|
+
if (d < 0) d = 0;
|
|
1429
|
+
ws = buf;
|
|
1430
|
+
for (i=0; i<d; i++) fputs(pad, stdout);
|
|
1431
|
+
i=0;
|
|
1432
|
+
while (i+d < width) {
|
|
1433
|
+
if (*ws) {
|
|
1434
|
+
if (i+d + wcwidth(*ws) > width) {
|
|
1435
|
+
break;
|
|
1436
|
+
}
|
|
1437
|
+
i += wcwidth(*ws);
|
|
1438
|
+
PutWideChar(*ws++, NULL);
|
|
1439
|
+
} else {
|
|
1440
|
+
break;
|
|
1441
|
+
}
|
|
1442
|
+
}
|
|
1443
|
+
/* Mop up any potential combining characters */
|
|
1444
|
+
while (*ws && wcwidth(*ws) == 0) {
|
|
1445
|
+
PutWideChar(*ws++, NULL);
|
|
1446
|
+
}
|
|
1447
|
+
/* Possibly send lrm control sequence */
|
|
1448
|
+
send_lrm();
|
|
1449
|
+
|
|
1450
|
+
while (i+d<width) {
|
|
1451
|
+
fputs(pad, stdout);
|
|
1452
|
+
i++;
|
|
1453
|
+
}
|
|
1454
|
+
if (buf != static_buf) free(buf);
|
|
1455
|
+
}
|
|
1456
|
+
|
|
1457
|
+
/***************************************************************/
|
|
1458
|
+
/* */
|
|
1459
|
+
/* WriteOneCalLine */
|
|
1460
|
+
/* */
|
|
1461
|
+
/* Write a single line. */
|
|
1462
|
+
/* Returns: -1 if no line was written and nothing left to do */
|
|
1463
|
+
/* 0 if a line was written and there is more to do */
|
|
1464
|
+
/* 1 if a line was written and nothing left to do */
|
|
1465
|
+
/* */
|
|
1466
|
+
/***************************************************************/
|
|
1467
|
+
static int WriteOneCalLine(int start_dse, int wd)
|
|
1468
|
+
{
|
|
1469
|
+
int done = 1, i;
|
|
1470
|
+
int d;
|
|
1471
|
+
|
|
1472
|
+
/* Do nothing if there are no calendar entries at all */
|
|
1473
|
+
d = 0;
|
|
1474
|
+
for (i=0; i<7; i++) {
|
|
1475
|
+
if (CalColumn[i]) {
|
|
1476
|
+
d = 1;
|
|
1477
|
+
break;
|
|
1478
|
+
}
|
|
1479
|
+
}
|
|
1480
|
+
if (!d) {
|
|
1481
|
+
/* Nothing to do and no line was written */
|
|
1482
|
+
return -1;
|
|
1483
|
+
}
|
|
1484
|
+
gon();
|
|
1485
|
+
DRAW(tb);
|
|
1486
|
+
goff();
|
|
1487
|
+
for (i=0; i<7; i++) {
|
|
1488
|
+
FromDSE(start_dse+i, NULL, NULL, &d);
|
|
1489
|
+
d -= wd;
|
|
1490
|
+
if (CalColumn[i]) {
|
|
1491
|
+
Backgroundize(ColToDay[i]);
|
|
1492
|
+
if (WriteOneColLine(i)) done = 0;
|
|
1493
|
+
} else {
|
|
1494
|
+
Backgroundize(ColToDay[i]);
|
|
1495
|
+
PrintCentered("", ColSpaces, " ");
|
|
1496
|
+
}
|
|
1497
|
+
UnBackgroundize(ColToDay[i]);
|
|
1498
|
+
gon();
|
|
1499
|
+
DRAW(tb);
|
|
1500
|
+
goff();
|
|
1501
|
+
}
|
|
1502
|
+
putchar('\n');
|
|
1503
|
+
|
|
1504
|
+
return done;
|
|
1505
|
+
}
|
|
1506
|
+
|
|
1507
|
+
static void FreeCalEntry(CalEntry *e)
|
|
1508
|
+
{
|
|
1509
|
+
if (e->text) free(e->text);
|
|
1510
|
+
if (e->raw_text) free(e->raw_text);
|
|
1511
|
+
FreeTrigInfoChain(e->infos);
|
|
1512
|
+
if (e->wc_text) free(e->wc_text);
|
|
1513
|
+
}
|
|
1514
|
+
|
|
1515
|
+
/***************************************************************/
|
|
1516
|
+
/* */
|
|
1517
|
+
/* WriteOneColLine */
|
|
1518
|
+
/* */
|
|
1519
|
+
/* Write a single line for a specified column. Return 1 if */
|
|
1520
|
+
/* the column still has entries; 0 otherwise. */
|
|
1521
|
+
/* */
|
|
1522
|
+
/***************************************************************/
|
|
1523
|
+
static int WriteOneColLine(int col)
|
|
1524
|
+
{
|
|
1525
|
+
CalEntry *e = CalColumn[col];
|
|
1526
|
+
char const *s;
|
|
1527
|
+
char const *space;
|
|
1528
|
+
|
|
1529
|
+
wchar_t const *ws;
|
|
1530
|
+
wchar_t const *wspace;
|
|
1531
|
+
int width;
|
|
1532
|
+
|
|
1533
|
+
int clamp = 1;
|
|
1534
|
+
int numwritten = 0;
|
|
1535
|
+
int d = ColToDay[col];
|
|
1536
|
+
char const *url;
|
|
1537
|
+
|
|
1538
|
+
if (d && UseBGVTColors && bgcolor[d][0] != -1) {
|
|
1539
|
+
clamp = 0;
|
|
1540
|
+
}
|
|
1541
|
+
PRINTROW:
|
|
1542
|
+
url = get_url(e->infos);
|
|
1543
|
+
|
|
1544
|
+
/* Print as many characters as possible within the column */
|
|
1545
|
+
if (e->wc_text) {
|
|
1546
|
+
wspace = NULL;
|
|
1547
|
+
ws = e->wc_pos;
|
|
1548
|
+
|
|
1549
|
+
/* If we're at the end, and there's another entry, do a blank
|
|
1550
|
+
line and move to next entry. */
|
|
1551
|
+
if (!*ws && e->next) {
|
|
1552
|
+
if (CalSepLine) {
|
|
1553
|
+
PrintLeft("", ColSpaces, ' ');
|
|
1554
|
+
}
|
|
1555
|
+
CalColumn[col] = e->next;
|
|
1556
|
+
FreeCalEntry(e);
|
|
1557
|
+
if (!CalSepLine) {
|
|
1558
|
+
e = CalColumn[col];
|
|
1559
|
+
goto PRINTROW;
|
|
1560
|
+
} else {
|
|
1561
|
+
return 1;
|
|
1562
|
+
}
|
|
1563
|
+
}
|
|
1564
|
+
|
|
1565
|
+
/* Find the last space char within the column. */
|
|
1566
|
+
width = 0;
|
|
1567
|
+
while (width <= ColSpaces) {
|
|
1568
|
+
if (!*ws || *ws == '\n') {
|
|
1569
|
+
wspace = ws;
|
|
1570
|
+
break;
|
|
1571
|
+
}
|
|
1572
|
+
if (iswspace(*ws)) {
|
|
1573
|
+
wspace = ws;
|
|
1574
|
+
width++;
|
|
1575
|
+
} else {
|
|
1576
|
+
if (wcwidth(*ws)) {
|
|
1577
|
+
width += wcwidth(*ws);
|
|
1578
|
+
if (width > ColSpaces) {
|
|
1579
|
+
break;
|
|
1580
|
+
}
|
|
1581
|
+
}
|
|
1582
|
+
}
|
|
1583
|
+
ws++;
|
|
1584
|
+
}
|
|
1585
|
+
|
|
1586
|
+
/* Colorize reminder if necessary */
|
|
1587
|
+
if (UseVTColors && e->is_color) {
|
|
1588
|
+
ColorizeEntry(e, clamp);
|
|
1589
|
+
}
|
|
1590
|
+
|
|
1591
|
+
if (url) {
|
|
1592
|
+
printf("\x1B]8;;%s\x1B\\", url);
|
|
1593
|
+
}
|
|
1594
|
+
/* If we couldn't find a space char, print what we have. */
|
|
1595
|
+
if (!wspace) {
|
|
1596
|
+
for (ws = e->wc_pos; numwritten < ColSpaces; ws++) {
|
|
1597
|
+
if (!*ws) break;
|
|
1598
|
+
if (iswspace(*ws)) {
|
|
1599
|
+
putchar(' ');
|
|
1600
|
+
numwritten++;
|
|
1601
|
+
} else {
|
|
1602
|
+
if (wcwidth(*ws) > 0) {
|
|
1603
|
+
if (numwritten + wcwidth(*ws) > ColSpaces) {
|
|
1604
|
+
break;
|
|
1605
|
+
}
|
|
1606
|
+
numwritten += wcwidth(*ws);
|
|
1607
|
+
}
|
|
1608
|
+
PutWideChar(*ws, NULL);
|
|
1609
|
+
}
|
|
1610
|
+
}
|
|
1611
|
+
e->wc_pos = ws;
|
|
1612
|
+
} else {
|
|
1613
|
+
/* We found a space - print everything before it. */
|
|
1614
|
+
for (ws = e->wc_pos; ws<wspace; ws++) {
|
|
1615
|
+
if (!*ws) break;
|
|
1616
|
+
if (iswspace(*ws)) {
|
|
1617
|
+
putchar(' ');
|
|
1618
|
+
numwritten++;
|
|
1619
|
+
} else {
|
|
1620
|
+
if (wcwidth(*ws) > 0) {
|
|
1621
|
+
numwritten += wcwidth(*ws);
|
|
1622
|
+
}
|
|
1623
|
+
PutWideChar(*ws, NULL);
|
|
1624
|
+
}
|
|
1625
|
+
}
|
|
1626
|
+
}
|
|
1627
|
+
|
|
1628
|
+
if (url) {
|
|
1629
|
+
printf("\x1B]8;;\x1B\\");
|
|
1630
|
+
}
|
|
1631
|
+
/* Decolorize reminder if necessary, but keep any SHADE */
|
|
1632
|
+
if (UseVTColors && e->is_color) {
|
|
1633
|
+
printf("%s", Decolorize());
|
|
1634
|
+
Backgroundize(d);
|
|
1635
|
+
}
|
|
1636
|
+
|
|
1637
|
+
/* Possibly send lrm control sequence */
|
|
1638
|
+
send_lrm();
|
|
1639
|
+
|
|
1640
|
+
/* Flesh out the rest of the column */
|
|
1641
|
+
while(numwritten++ < ColSpaces) putchar(' ');
|
|
1642
|
+
|
|
1643
|
+
/* Skip any spaces before next word */
|
|
1644
|
+
while (iswspace(*ws)) ws++;
|
|
1645
|
+
|
|
1646
|
+
/* If done, free memory if no next entry. */
|
|
1647
|
+
if (!*ws && !e->next) {
|
|
1648
|
+
CalColumn[col] = e->next;
|
|
1649
|
+
FreeCalEntry(e);
|
|
1650
|
+
} else {
|
|
1651
|
+
e->wc_pos = ws;
|
|
1652
|
+
}
|
|
1653
|
+
if (CalColumn[col]) return 1; else return 0;
|
|
1654
|
+
} else {
|
|
1655
|
+
space = NULL;
|
|
1656
|
+
s = e->pos;
|
|
1657
|
+
|
|
1658
|
+
/* If we're at the end, and there's another entry, do a blank
|
|
1659
|
+
line and move to next entry. */
|
|
1660
|
+
if (!*s && e->next) {
|
|
1661
|
+
if (CalSepLine) {
|
|
1662
|
+
PrintLeft("", ColSpaces, ' ');
|
|
1663
|
+
}
|
|
1664
|
+
CalColumn[col] = e->next;
|
|
1665
|
+
FreeCalEntry(e);
|
|
1666
|
+
if (!CalSepLine) {
|
|
1667
|
+
e = CalColumn[col];
|
|
1668
|
+
fprintf(stderr, "BLOOP\n");
|
|
1669
|
+
goto PRINTROW;
|
|
1670
|
+
} else {
|
|
1671
|
+
return 1;
|
|
1672
|
+
}
|
|
1673
|
+
}
|
|
1674
|
+
|
|
1675
|
+
/* Find the last space char within the column. */
|
|
1676
|
+
while (s - e->pos <= ColSpaces) {
|
|
1677
|
+
if (!*s || *s == '\n') {space = s; break;}
|
|
1678
|
+
if (isspace(*s)) space = s;
|
|
1679
|
+
s++;
|
|
1680
|
+
}
|
|
1681
|
+
|
|
1682
|
+
/* Colorize reminder if necessary */
|
|
1683
|
+
if (UseVTColors && e->is_color) {
|
|
1684
|
+
ColorizeEntry(e, clamp);
|
|
1685
|
+
}
|
|
1686
|
+
|
|
1687
|
+
/* If we couldn't find a space char, print what we have. */
|
|
1688
|
+
if (!space) {
|
|
1689
|
+
for (s = e->pos; s - e->pos < ColSpaces; s++) {
|
|
1690
|
+
if (!*s) break;
|
|
1691
|
+
numwritten++;
|
|
1692
|
+
if (isspace(*s)) {
|
|
1693
|
+
putchar(' ');
|
|
1694
|
+
} else {
|
|
1695
|
+
putchar(*s);
|
|
1696
|
+
}
|
|
1697
|
+
}
|
|
1698
|
+
e->pos = s;
|
|
1699
|
+
} else {
|
|
1700
|
+
/* We found a space - print everything before it. */
|
|
1701
|
+
for (s = e->pos; s<space; s++) {
|
|
1702
|
+
if (!*s) break;
|
|
1703
|
+
numwritten++;
|
|
1704
|
+
if (isspace(*s)) {
|
|
1705
|
+
putchar(' ');
|
|
1706
|
+
} else {
|
|
1707
|
+
putchar(*s);
|
|
1708
|
+
}
|
|
1709
|
+
}
|
|
1710
|
+
}
|
|
1711
|
+
|
|
1712
|
+
/* Decolorize reminder if necessary, but keep SHADE */
|
|
1713
|
+
if (UseVTColors && e->is_color) {
|
|
1714
|
+
printf("%s", Decolorize());
|
|
1715
|
+
Backgroundize(d);
|
|
1716
|
+
}
|
|
1717
|
+
|
|
1718
|
+
/* Flesh out the rest of the column */
|
|
1719
|
+
while(numwritten++ < ColSpaces) putchar(' ');
|
|
1720
|
+
|
|
1721
|
+
/* Skip any spaces before next word */
|
|
1722
|
+
while (isspace(*s)) s++;
|
|
1723
|
+
|
|
1724
|
+
/* If done, free memory if no next entry. */
|
|
1725
|
+
if (!*s && !e->next) {
|
|
1726
|
+
CalColumn[col] = e->next;
|
|
1727
|
+
FreeCalEntry(e);
|
|
1728
|
+
} else {
|
|
1729
|
+
e->pos = s;
|
|
1730
|
+
}
|
|
1731
|
+
if (CalColumn[col]) return 1; else return 0;
|
|
1732
|
+
}
|
|
1733
|
+
}
|
|
1734
|
+
|
|
1735
|
+
/***************************************************************/
|
|
1736
|
+
/* */
|
|
1737
|
+
/* GenerateCalEntries */
|
|
1738
|
+
/* */
|
|
1739
|
+
/* Generate the calendar entries for the ith column */
|
|
1740
|
+
/* */
|
|
1741
|
+
/***************************************************************/
|
|
1742
|
+
static void GenerateCalEntries(int col)
|
|
1743
|
+
{
|
|
1744
|
+
int r;
|
|
1745
|
+
Token tok;
|
|
1746
|
+
char const *s;
|
|
1747
|
+
Parser p;
|
|
1748
|
+
|
|
1749
|
+
/* Do some initialization first... */
|
|
1750
|
+
PerIterationInit();
|
|
1751
|
+
|
|
1752
|
+
r=IncludeFile(InitialFile);
|
|
1753
|
+
if (r) {
|
|
1754
|
+
fprintf(ErrFp, "%s %s: %s\n", GetErr(E_ERR_READING), InitialFile, GetErr(r));
|
|
1755
|
+
exit(EXIT_FAILURE);
|
|
1756
|
+
}
|
|
1757
|
+
|
|
1758
|
+
while(1) {
|
|
1759
|
+
r = ReadLine();
|
|
1760
|
+
if (r == E_EOF) return;
|
|
1761
|
+
if (r) {
|
|
1762
|
+
Eprint("%s: %s", GetErr(E_ERR_READING), GetErr(r));
|
|
1763
|
+
exit(EXIT_FAILURE);
|
|
1764
|
+
}
|
|
1765
|
+
s = FindInitialToken(&tok, CurLine);
|
|
1766
|
+
|
|
1767
|
+
/* Should we ignore it? */
|
|
1768
|
+
if (tok.type != T_If &&
|
|
1769
|
+
tok.type != T_Else &&
|
|
1770
|
+
tok.type != T_EndIf &&
|
|
1771
|
+
tok.type != T_IfTrig &&
|
|
1772
|
+
tok.type != T_Set &&
|
|
1773
|
+
tok.type != T_Fset &&
|
|
1774
|
+
should_ignore_line())
|
|
1775
|
+
{
|
|
1776
|
+
/* DO NOTHING */
|
|
1777
|
+
}
|
|
1778
|
+
else {
|
|
1779
|
+
/* Create a parser to parse the line */
|
|
1780
|
+
CreateParser(s, &p);
|
|
1781
|
+
|
|
1782
|
+
switch(tok.type) {
|
|
1783
|
+
|
|
1784
|
+
case T_Empty:
|
|
1785
|
+
case T_Comment:
|
|
1786
|
+
break;
|
|
1787
|
+
|
|
1788
|
+
case T_ErrMsg: r=DoErrMsg(&p); break;
|
|
1789
|
+
case T_Rem: r=DoCalRem(&p, col); break;
|
|
1790
|
+
case T_If: r=DoIf(&p); break;
|
|
1791
|
+
case T_Return: r=DoReturn(&p); break;
|
|
1792
|
+
case T_IfTrig: r=DoIfTrig(&p); break;
|
|
1793
|
+
case T_Else: r=DoElse(&p); break;
|
|
1794
|
+
case T_EndIf: r=DoEndif(&p); break;
|
|
1795
|
+
|
|
1796
|
+
case T_Include:
|
|
1797
|
+
case T_IncludeSys:
|
|
1798
|
+
case T_IncludeR: r=DoInclude(&p, tok.type); break;
|
|
1799
|
+
|
|
1800
|
+
case T_IncludeCmd: r=DoIncludeCmd(&p); break;
|
|
1801
|
+
case T_Exit: DoExit(&p); break;
|
|
1802
|
+
case T_Set: r=DoSet(&p); break;
|
|
1803
|
+
case T_Fset: r=DoFset(&p); break;
|
|
1804
|
+
case T_Funset: r=DoFunset(&p); break;
|
|
1805
|
+
case T_Frename: r=DoFrename(&p); break;
|
|
1806
|
+
case T_UnSet: r=DoUnset(&p); break;
|
|
1807
|
+
case T_Clr: r=DoClear(&p); break;
|
|
1808
|
+
case T_Flush: r=DoFlush(&p); break;
|
|
1809
|
+
case T_Debug: break; /* IGNORE DEBUG CMD */
|
|
1810
|
+
case T_Dumpvars: break; /* IGNORE DUMPVARS CMD */
|
|
1811
|
+
case T_Banner: break; /* IGNORE BANNER CMD */
|
|
1812
|
+
case T_Omit: r=DoOmit(&p);
|
|
1813
|
+
if (r == E_PARSE_AS_REM) {
|
|
1814
|
+
DestroyParser(&p);
|
|
1815
|
+
CreateParser(s, &p);
|
|
1816
|
+
r=DoCalRem(&p, col);
|
|
1817
|
+
}
|
|
1818
|
+
break;
|
|
1819
|
+
case T_Pop: r=PopOmitContext(&p); break;
|
|
1820
|
+
case T_Push: r=PushOmitContext(&p); break;
|
|
1821
|
+
case T_PushVars:
|
|
1822
|
+
r=PushVars(&p);
|
|
1823
|
+
break;
|
|
1824
|
+
case T_PopVars:
|
|
1825
|
+
r=PopVars(&p);
|
|
1826
|
+
break;
|
|
1827
|
+
case T_PushFuncs:
|
|
1828
|
+
r=PushUserFuncs(&p);
|
|
1829
|
+
break;
|
|
1830
|
+
case T_PopFuncs:
|
|
1831
|
+
r=PopUserFuncs(&p);
|
|
1832
|
+
break;
|
|
1833
|
+
case T_Preserve: r=DoPreserve(&p); break;
|
|
1834
|
+
case T_Expr: r = DoExpr(&p); break;
|
|
1835
|
+
case T_Translate: r = DoTranslate(&p); break;
|
|
1836
|
+
case T_RemType: if (tok.val == RUN_TYPE) {
|
|
1837
|
+
r=DoRun(&p);
|
|
1838
|
+
break;
|
|
1839
|
+
} else {
|
|
1840
|
+
CreateParser(CurLine, &p);
|
|
1841
|
+
r=DoCalRem(&p, col);
|
|
1842
|
+
break;
|
|
1843
|
+
}
|
|
1844
|
+
|
|
1845
|
+
/* If we don't recognize the command, do a REM by default */
|
|
1846
|
+
/* Note: Since the parser hasn't been used yet, we don't */
|
|
1847
|
+
/* need to destroy it here. */
|
|
1848
|
+
|
|
1849
|
+
default:
|
|
1850
|
+
if (!SuppressImplicitRemWarnings) {
|
|
1851
|
+
if (warning_level("05.00.03")) {
|
|
1852
|
+
Wprint(tr("Unrecognized command; interpreting as REM"));
|
|
1853
|
+
}
|
|
1854
|
+
WarnedAboutImplicit = 1;
|
|
1855
|
+
}
|
|
1856
|
+
CreateParser(CurLine, &p);
|
|
1857
|
+
r=DoCalRem(&p, col);
|
|
1858
|
+
break;
|
|
1859
|
+
}
|
|
1860
|
+
if (r && (!Hush || r != E_RUN_DISABLED)) Eprint("%s", GetErr(r));
|
|
1861
|
+
|
|
1862
|
+
/* Destroy the parser - free up resources it may be tying up */
|
|
1863
|
+
DestroyParser(&p);
|
|
1864
|
+
}
|
|
1865
|
+
}
|
|
1866
|
+
}
|
|
1867
|
+
|
|
1868
|
+
|
|
1869
|
+
/***************************************************************/
|
|
1870
|
+
/* */
|
|
1871
|
+
/* WriteCalHeader */
|
|
1872
|
+
/* */
|
|
1873
|
+
/***************************************************************/
|
|
1874
|
+
static void WriteCalHeader(void)
|
|
1875
|
+
{
|
|
1876
|
+
char buf[80];
|
|
1877
|
+
int y, m, d;
|
|
1878
|
+
|
|
1879
|
+
FromDSE(DSEToday, &y, &m, &d);
|
|
1880
|
+
snprintf(buf, sizeof(buf), "%s %d", get_month_name(m), y);
|
|
1881
|
+
|
|
1882
|
+
WriteTopCalLine();
|
|
1883
|
+
|
|
1884
|
+
gon();
|
|
1885
|
+
DRAW(tb);
|
|
1886
|
+
goff();
|
|
1887
|
+
PrintCentered(buf, CalWidth-2, " ");
|
|
1888
|
+
gon();
|
|
1889
|
+
DRAW(tb);
|
|
1890
|
+
goff();
|
|
1891
|
+
putchar('\n');
|
|
1892
|
+
|
|
1893
|
+
WritePostHeaderLine();
|
|
1894
|
+
WriteCalDays();
|
|
1895
|
+
WriteIntermediateCalLine();
|
|
1896
|
+
}
|
|
1897
|
+
|
|
1898
|
+
/***************************************************************/
|
|
1899
|
+
/* */
|
|
1900
|
+
/* WriteCalTrailer */
|
|
1901
|
+
/* */
|
|
1902
|
+
/***************************************************************/
|
|
1903
|
+
static void WriteCalTrailer(void)
|
|
1904
|
+
{
|
|
1905
|
+
putchar('\f');
|
|
1906
|
+
}
|
|
1907
|
+
|
|
1908
|
+
/***************************************************************/
|
|
1909
|
+
/* */
|
|
1910
|
+
/* DoCalRem */
|
|
1911
|
+
/* */
|
|
1912
|
+
/* Do the REM command in the context of a calendar. */
|
|
1913
|
+
/* */
|
|
1914
|
+
/***************************************************************/
|
|
1915
|
+
static int DoCalRem(ParsePtr p, int col)
|
|
1916
|
+
{
|
|
1917
|
+
size_t oldLen;
|
|
1918
|
+
Trigger trig;
|
|
1919
|
+
TimeTrig tim;
|
|
1920
|
+
Value v;
|
|
1921
|
+
int r, err;
|
|
1922
|
+
int dse;
|
|
1923
|
+
CalEntry *CurCol;
|
|
1924
|
+
CalEntry *e;
|
|
1925
|
+
char const *s, *s2;
|
|
1926
|
+
DynamicBuffer buf, obuf, pre_buf, raw_buf;
|
|
1927
|
+
Token tok;
|
|
1928
|
+
int nonconst_expr = 0;
|
|
1929
|
+
|
|
1930
|
+
int is_color, col_r, col_g, col_b;
|
|
1931
|
+
|
|
1932
|
+
if (col >= 0) {
|
|
1933
|
+
CurCol = CalColumn[col];
|
|
1934
|
+
} else {
|
|
1935
|
+
CurCol = NULL;
|
|
1936
|
+
}
|
|
1937
|
+
is_color = 0;
|
|
1938
|
+
DBufInit(&buf);
|
|
1939
|
+
DBufInit(&pre_buf);
|
|
1940
|
+
DBufInit(&raw_buf);
|
|
1941
|
+
|
|
1942
|
+
/* Parse the trigger date and time */
|
|
1943
|
+
if ( (r=ParseRem(p, &trig, &tim)) ) {
|
|
1944
|
+
FreeTrig(&trig);
|
|
1945
|
+
return r;
|
|
1946
|
+
}
|
|
1947
|
+
|
|
1948
|
+
if (trig.tz != NULL && tim.ttime == NO_TIME) {
|
|
1949
|
+
FreeTrig(&trig);
|
|
1950
|
+
return E_TZ_NO_AT;
|
|
1951
|
+
}
|
|
1952
|
+
|
|
1953
|
+
/* An empty string for time zone is just a missing time zone */
|
|
1954
|
+
if (trig.tz != NULL && !*trig.tz) {
|
|
1955
|
+
free( (void *) trig.tz);
|
|
1956
|
+
trig.tz = NULL;
|
|
1957
|
+
}
|
|
1958
|
+
|
|
1959
|
+
if (trig.typ == MSG_TYPE ||
|
|
1960
|
+
trig.typ == CAL_TYPE ||
|
|
1961
|
+
trig.typ == MSF_TYPE) {
|
|
1962
|
+
is_color = (
|
|
1963
|
+
DefaultColorR != -1
|
|
1964
|
+
&& DefaultColorG != -1
|
|
1965
|
+
&& DefaultColorB != -1);
|
|
1966
|
+
if (is_color) {
|
|
1967
|
+
col_r = DefaultColorR;
|
|
1968
|
+
col_g = DefaultColorG;
|
|
1969
|
+
col_b = DefaultColorB;
|
|
1970
|
+
}
|
|
1971
|
+
}
|
|
1972
|
+
|
|
1973
|
+
if (trig.typ == NO_TYPE) {
|
|
1974
|
+
FreeTrig(&trig);
|
|
1975
|
+
return E_EOLN;
|
|
1976
|
+
}
|
|
1977
|
+
if (trig.typ == SAT_TYPE) {
|
|
1978
|
+
EnterTimezone(trig.tz);
|
|
1979
|
+
r=DoSatRemind(&trig, &tim, p);
|
|
1980
|
+
ExitTimezone(trig.tz);
|
|
1981
|
+
if (r) {
|
|
1982
|
+
if (r == E_CANT_TRIG && trig.maybe_uncomputable) {
|
|
1983
|
+
r = OK;
|
|
1984
|
+
}
|
|
1985
|
+
FreeTrig(&trig);
|
|
1986
|
+
if (r == E_EXPIRED) return OK;
|
|
1987
|
+
return r;
|
|
1988
|
+
}
|
|
1989
|
+
if (!LastTrigValid) {
|
|
1990
|
+
FreeTrig(&trig);
|
|
1991
|
+
return OK;
|
|
1992
|
+
}
|
|
1993
|
+
r=ParseToken(p, &buf);
|
|
1994
|
+
if (r) {
|
|
1995
|
+
FreeTrig(&trig);
|
|
1996
|
+
return r;
|
|
1997
|
+
}
|
|
1998
|
+
FindToken(DBufValue(&buf), &tok);
|
|
1999
|
+
DBufFree(&buf);
|
|
2000
|
+
if (tok.type == T_Empty || tok.type == T_Comment) {
|
|
2001
|
+
r = OK;
|
|
2002
|
+
if (trig.addomit) {
|
|
2003
|
+
r = AddGlobalOmit(LastTriggerDate);
|
|
2004
|
+
}
|
|
2005
|
+
FreeTrig(&trig);
|
|
2006
|
+
return r;
|
|
2007
|
+
}
|
|
2008
|
+
if (tok.type != T_RemType || tok.val == SAT_TYPE) {
|
|
2009
|
+
FreeTrig(&trig);
|
|
2010
|
+
return E_PARSE_ERR;
|
|
2011
|
+
}
|
|
2012
|
+
if (tok.val == PASSTHRU_TYPE) {
|
|
2013
|
+
r=ParseToken(p, &buf);
|
|
2014
|
+
if (r) return r;
|
|
2015
|
+
if (!DBufLen(&buf)) {
|
|
2016
|
+
DBufFree(&buf);
|
|
2017
|
+
FreeTrig(&trig);
|
|
2018
|
+
return E_EOLN;
|
|
2019
|
+
}
|
|
2020
|
+
StrnCpy(trig.passthru, DBufValue(&buf), PASSTHRU_LEN);
|
|
2021
|
+
DBufFree(&buf);
|
|
2022
|
+
}
|
|
2023
|
+
trig.typ = tok.val;
|
|
2024
|
+
|
|
2025
|
+
/* Convert some SPECIALs back to plain types */
|
|
2026
|
+
FixSpecialType(&trig);
|
|
2027
|
+
|
|
2028
|
+
if (trig.typ == MSG_TYPE ||
|
|
2029
|
+
trig.typ == CAL_TYPE ||
|
|
2030
|
+
trig.typ == MSF_TYPE) {
|
|
2031
|
+
is_color = (
|
|
2032
|
+
DefaultColorR != -1
|
|
2033
|
+
&& DefaultColorG != -1
|
|
2034
|
+
&& DefaultColorB != -1);
|
|
2035
|
+
if (is_color) {
|
|
2036
|
+
col_r = DefaultColorR;
|
|
2037
|
+
col_g = DefaultColorG;
|
|
2038
|
+
col_b = DefaultColorB;
|
|
2039
|
+
}
|
|
2040
|
+
}
|
|
2041
|
+
dse = LastTriggerDate;
|
|
2042
|
+
if (!LastTrigValid) {
|
|
2043
|
+
FreeTrig(&trig);
|
|
2044
|
+
return OK;
|
|
2045
|
+
}
|
|
2046
|
+
if (dse < 0 && !ParseUntriggered) {
|
|
2047
|
+
/* Expired */
|
|
2048
|
+
FreeTrig(&trig);
|
|
2049
|
+
return OK;
|
|
2050
|
+
}
|
|
2051
|
+
} else {
|
|
2052
|
+
/* Calculate the trigger date */
|
|
2053
|
+
EnterTimezone(trig.tz);
|
|
2054
|
+
dse = ComputeTrigger(get_scanfrom(&trig), &trig, &tim, &r, 1);
|
|
2055
|
+
ExitTimezone(trig.tz);
|
|
2056
|
+
if (r) {
|
|
2057
|
+
if (r == E_CANT_TRIG && trig.maybe_uncomputable) {
|
|
2058
|
+
r = OK;
|
|
2059
|
+
}
|
|
2060
|
+
FreeTrig(&trig);
|
|
2061
|
+
return r;
|
|
2062
|
+
}
|
|
2063
|
+
if (dse < 0 && !ParseUntriggered) {
|
|
2064
|
+
/* Expired */
|
|
2065
|
+
FreeTrig(&trig);
|
|
2066
|
+
return OK;
|
|
2067
|
+
}
|
|
2068
|
+
}
|
|
2069
|
+
|
|
2070
|
+
/* Adjust trigger date/time to time zone */
|
|
2071
|
+
dse = AdjustTriggerForTimeZone(&trig, dse, &tim, 1);
|
|
2072
|
+
|
|
2073
|
+
/* Add to global OMITs if so indicated */
|
|
2074
|
+
if (trig.addomit) {
|
|
2075
|
+
r = AddGlobalOmit(dse);
|
|
2076
|
+
if (r) {
|
|
2077
|
+
FreeTrig(&trig);
|
|
2078
|
+
return r;
|
|
2079
|
+
}
|
|
2080
|
+
}
|
|
2081
|
+
|
|
2082
|
+
/* If we're not actually generating any calendar entries, we're done */
|
|
2083
|
+
if (col < 0) {
|
|
2084
|
+
FreeTrig(&trig);
|
|
2085
|
+
return OK;
|
|
2086
|
+
}
|
|
2087
|
+
|
|
2088
|
+
/* Don't include timed reminders in calendar if -a option supplied. */
|
|
2089
|
+
if (DontIssueAts && tim.ttime != NO_TIME) {
|
|
2090
|
+
FreeTrig(&trig);
|
|
2091
|
+
return OK;
|
|
2092
|
+
}
|
|
2093
|
+
|
|
2094
|
+
/* Filter unwanted events/todos */
|
|
2095
|
+
if ((TodoFilter == ONLY_TODOS && !trig.is_todo) ||
|
|
2096
|
+
(TodoFilter == ONLY_EVENTS && trig.is_todo)) {
|
|
2097
|
+
FreeTrig(&trig);
|
|
2098
|
+
return OK;
|
|
2099
|
+
}
|
|
2100
|
+
|
|
2101
|
+
/* Save nonconst_expr flag */
|
|
2102
|
+
nonconst_expr = trig.nonconst_expr;
|
|
2103
|
+
/* Convert PS and PSF to PASSTHRU */
|
|
2104
|
+
if (trig.typ == PS_TYPE) {
|
|
2105
|
+
strcpy(trig.passthru, "PostScript");
|
|
2106
|
+
trig.typ = PASSTHRU_TYPE;
|
|
2107
|
+
} else if (trig.typ == PSF_TYPE) {
|
|
2108
|
+
strcpy(trig.passthru, "PSFile");
|
|
2109
|
+
trig.typ = PASSTHRU_TYPE;
|
|
2110
|
+
}
|
|
2111
|
+
|
|
2112
|
+
/* If it's a plain reminder but we have a default color, add the
|
|
2113
|
+
three colors to the prebuf and change passthru to "COLOR" */
|
|
2114
|
+
if (trig.typ == MSG_TYPE ||
|
|
2115
|
+
trig.typ == CAL_TYPE ||
|
|
2116
|
+
trig.typ == MSF_TYPE) {
|
|
2117
|
+
if ((PsCal || DoSimpleCalendar) && is_color) {
|
|
2118
|
+
char cbuf[24];
|
|
2119
|
+
snprintf(cbuf, sizeof(cbuf), "%d %d %d ", col_r, col_g, col_b);
|
|
2120
|
+
DBufPuts(&pre_buf, cbuf);
|
|
2121
|
+
strcpy(trig.passthru, "COLOR");
|
|
2122
|
+
/* Don't change trig.typ or next if() will trigger! */
|
|
2123
|
+
}
|
|
2124
|
+
}
|
|
2125
|
+
if (trig.typ == PASSTHRU_TYPE) {
|
|
2126
|
+
if (!strcasecmp(trig.passthru, "SHADE") && dse == DSEToday) {
|
|
2127
|
+
Shaded++;
|
|
2128
|
+
if (!PsCal) {
|
|
2129
|
+
DBufInit(&obuf);
|
|
2130
|
+
r = DoSubst(p, &obuf, &trig, &tim, dse, CAL_MODE);
|
|
2131
|
+
if (r) {
|
|
2132
|
+
DBufFree(&obuf);
|
|
2133
|
+
FreeTrig(&trig);
|
|
2134
|
+
return r;
|
|
2135
|
+
}
|
|
2136
|
+
SetShadeEntry(dse, DBufValue(&obuf));
|
|
2137
|
+
DBufFree(&obuf);
|
|
2138
|
+
}
|
|
2139
|
+
}
|
|
2140
|
+
if (!PsCal && !strcasecmp(trig.passthru, "WEEK")) {
|
|
2141
|
+
if (dse == DSEToday) {
|
|
2142
|
+
DBufInit(&obuf);
|
|
2143
|
+
r = DoSubst(p, &obuf, &trig, &tim, dse, CAL_MODE);
|
|
2144
|
+
if (r) {
|
|
2145
|
+
DBufFree(&obuf);
|
|
2146
|
+
FreeTrig(&trig);
|
|
2147
|
+
return r;
|
|
2148
|
+
}
|
|
2149
|
+
sscanf(DBufValue(&obuf), "%31[^\x01]", weeks[DayOf(dse)]);
|
|
2150
|
+
DBufFree(&obuf);
|
|
2151
|
+
}
|
|
2152
|
+
}
|
|
2153
|
+
if (!PsCal && strcasecmp(trig.passthru, "COLOR") && strcasecmp(trig.passthru, "COLOUR") && strcasecmp(trig.passthru, "MOON")) {
|
|
2154
|
+
FreeTrig(&trig);
|
|
2155
|
+
return OK;
|
|
2156
|
+
}
|
|
2157
|
+
if (!PsCal && !strcasecmp(trig.passthru, "MOON")) {
|
|
2158
|
+
if (dse == DSEToday) {
|
|
2159
|
+
DBufInit(&obuf);
|
|
2160
|
+
r = DoSubst(p, &obuf, &trig, &tim, dse, CAL_MODE);
|
|
2161
|
+
if (r) {
|
|
2162
|
+
DBufFree(&obuf);
|
|
2163
|
+
FreeTrig(&trig);
|
|
2164
|
+
return r;
|
|
2165
|
+
}
|
|
2166
|
+
SetMoonEntry(dse, DBufValue(&obuf));
|
|
2167
|
+
DBufFree(&obuf);
|
|
2168
|
+
}
|
|
2169
|
+
}
|
|
2170
|
+
if (!strcasecmp(trig.passthru, "COLOR") ||
|
|
2171
|
+
!strcasecmp(trig.passthru, "COLOUR")) {
|
|
2172
|
+
is_color = 1;
|
|
2173
|
+
/* Strip off the three color numbers */
|
|
2174
|
+
DBufFree(&buf);
|
|
2175
|
+
r=ParseToken(p, &buf);
|
|
2176
|
+
DBufPuts(&pre_buf, DBufValue(&buf));
|
|
2177
|
+
DBufPutc(&pre_buf, ' ');
|
|
2178
|
+
DBufFree(&buf);
|
|
2179
|
+
if (r) {
|
|
2180
|
+
FreeTrig(&trig);
|
|
2181
|
+
return r;
|
|
2182
|
+
}
|
|
2183
|
+
r=ParseToken(p, &buf);
|
|
2184
|
+
DBufPuts(&pre_buf, DBufValue(&buf));
|
|
2185
|
+
DBufPutc(&pre_buf, ' ');
|
|
2186
|
+
DBufFree(&buf);
|
|
2187
|
+
if (r) {
|
|
2188
|
+
FreeTrig(&trig);
|
|
2189
|
+
return r;
|
|
2190
|
+
}
|
|
2191
|
+
r=ParseToken(p, &buf);
|
|
2192
|
+
DBufPuts(&pre_buf, DBufValue(&buf));
|
|
2193
|
+
DBufPutc(&pre_buf, ' ');
|
|
2194
|
+
DBufFree(&buf);
|
|
2195
|
+
if (r) {
|
|
2196
|
+
FreeTrig(&trig);
|
|
2197
|
+
return r;
|
|
2198
|
+
}
|
|
2199
|
+
(void) sscanf(DBufValue(&pre_buf), "%d %d %d",
|
|
2200
|
+
&col_r, &col_g, &col_b);
|
|
2201
|
+
if (col_r < 0 || col_g < 0 || col_b < 0 ||
|
|
2202
|
+
col_r > 255 || col_g > 255 || col_b > 255) {
|
|
2203
|
+
is_color = 0;
|
|
2204
|
+
col_r = -1;
|
|
2205
|
+
col_g = -1;
|
|
2206
|
+
col_b = -1;
|
|
2207
|
+
trig.passthru[0] = 0;
|
|
2208
|
+
DBufFree(&pre_buf);
|
|
2209
|
+
} else {
|
|
2210
|
+
if (!PsCal && !DoSimpleCalendar) {
|
|
2211
|
+
DBufFree(&pre_buf);
|
|
2212
|
+
}
|
|
2213
|
+
}
|
|
2214
|
+
}
|
|
2215
|
+
}
|
|
2216
|
+
|
|
2217
|
+
/* If trigger date == today, add it to the current entry */
|
|
2218
|
+
DBufInit(&obuf);
|
|
2219
|
+
if ((dse == DSEToday) ||
|
|
2220
|
+
(DoSimpleCalDelta &&
|
|
2221
|
+
ShouldTriggerReminder(&trig, &tim, dse, &err))) {
|
|
2222
|
+
/* The parse_ptr should not be nested, but just in case... */
|
|
2223
|
+
if (!p->isnested) {
|
|
2224
|
+
if (DBufPuts(&raw_buf, p->pos) != OK) {
|
|
2225
|
+
DBufFree(&obuf);
|
|
2226
|
+
DBufFree(&pre_buf);
|
|
2227
|
+
FreeTrig(&trig);
|
|
2228
|
+
return E_NO_MEM;
|
|
2229
|
+
}
|
|
2230
|
+
}
|
|
2231
|
+
if (DoSimpleCalendar || tim.ttime != NO_TIME) {
|
|
2232
|
+
/* Suppress time if it's not today or if it's a non-COLOR special */
|
|
2233
|
+
if (dse != DSEToday ||
|
|
2234
|
+
(trig.typ == PASSTHRU_TYPE &&
|
|
2235
|
+
strcasecmp(trig.passthru, "COLOUR") &&
|
|
2236
|
+
strcasecmp(trig.passthru, "COLOR"))) {
|
|
2237
|
+
if (DBufPuts(&obuf, SimpleTime(NO_TIME)) != OK) {
|
|
2238
|
+
DBufFree(&obuf);
|
|
2239
|
+
DBufFree(&raw_buf);
|
|
2240
|
+
DBufFree(&pre_buf);
|
|
2241
|
+
FreeTrig(&trig);
|
|
2242
|
+
return E_NO_MEM;
|
|
2243
|
+
}
|
|
2244
|
+
} else {
|
|
2245
|
+
if (DBufPuts(&obuf, CalendarTime(tim.ttime, tim.duration)) != OK) {
|
|
2246
|
+
DBufFree(&raw_buf);
|
|
2247
|
+
DBufFree(&obuf);
|
|
2248
|
+
DBufFree(&pre_buf);
|
|
2249
|
+
FreeTrig(&trig);
|
|
2250
|
+
return E_NO_MEM;
|
|
2251
|
+
}
|
|
2252
|
+
}
|
|
2253
|
+
}
|
|
2254
|
+
if (trig.typ != PASSTHRU_TYPE &&
|
|
2255
|
+
UserFuncExists("calprefix")==1) {
|
|
2256
|
+
char evalBuf[64];
|
|
2257
|
+
snprintf(evalBuf, sizeof(evalBuf), "calprefix(%d)", trig.priority);
|
|
2258
|
+
s2 = evalBuf;
|
|
2259
|
+
r = EvalExpr(&s2, &v, NULL);
|
|
2260
|
+
if (!r) {
|
|
2261
|
+
if (!DoCoerce(STR_TYPE, &v)) {
|
|
2262
|
+
if (DBufPuts(&obuf, v.v.str) != OK) {
|
|
2263
|
+
DestroyValue(v);
|
|
2264
|
+
DBufFree(&raw_buf);
|
|
2265
|
+
DBufFree(&obuf);
|
|
2266
|
+
DBufFree(&pre_buf);
|
|
2267
|
+
FreeTrig(&trig);
|
|
2268
|
+
return E_NO_MEM;
|
|
2269
|
+
}
|
|
2270
|
+
}
|
|
2271
|
+
DestroyValue(v);
|
|
2272
|
+
}
|
|
2273
|
+
}
|
|
2274
|
+
oldLen = DBufLen(&obuf);
|
|
2275
|
+
|
|
2276
|
+
/* In -sa mode, run in ADVANCE mode if we're triggering
|
|
2277
|
+
* before the actual date */
|
|
2278
|
+
if (dse != DSEToday) {
|
|
2279
|
+
r = DoSubst(p, &obuf, &trig, &tim, dse, ADVANCE_MODE);
|
|
2280
|
+
} else {
|
|
2281
|
+
r = DoSubst(p, &obuf, &trig, &tim, dse, CAL_MODE);
|
|
2282
|
+
}
|
|
2283
|
+
if (r) {
|
|
2284
|
+
DBufFree(&pre_buf);
|
|
2285
|
+
DBufFree(&obuf);
|
|
2286
|
+
DBufFree(&raw_buf);
|
|
2287
|
+
FreeTrig(&trig);
|
|
2288
|
+
return r;
|
|
2289
|
+
}
|
|
2290
|
+
if (DBufLen(&obuf) <= oldLen) {
|
|
2291
|
+
DBufFree(&obuf);
|
|
2292
|
+
DBufFree(&pre_buf);
|
|
2293
|
+
DBufFree(&raw_buf);
|
|
2294
|
+
FreeTrig(&trig);
|
|
2295
|
+
return OK;
|
|
2296
|
+
}
|
|
2297
|
+
if (trig.typ != PASSTHRU_TYPE &&
|
|
2298
|
+
UserFuncExists("calsuffix")==1) {
|
|
2299
|
+
char evalBuf[64];
|
|
2300
|
+
snprintf(evalBuf, sizeof(evalBuf), "calsuffix(%d)", trig.priority);
|
|
2301
|
+
s2 = evalBuf;
|
|
2302
|
+
r = EvalExpr(&s2, &v, NULL);
|
|
2303
|
+
if (!r) {
|
|
2304
|
+
if (!DoCoerce(STR_TYPE, &v)) {
|
|
2305
|
+
if (DBufPuts(&obuf, v.v.str) != OK) {
|
|
2306
|
+
DestroyValue(v);
|
|
2307
|
+
DBufFree(&raw_buf);
|
|
2308
|
+
DBufFree(&obuf);
|
|
2309
|
+
DBufFree(&pre_buf);
|
|
2310
|
+
FreeTrig(&trig);
|
|
2311
|
+
return E_NO_MEM;
|
|
2312
|
+
}
|
|
2313
|
+
}
|
|
2314
|
+
DestroyValue(v);
|
|
2315
|
+
}
|
|
2316
|
+
}
|
|
2317
|
+
s = DBufValue(&obuf);
|
|
2318
|
+
if (DedupeReminders) {
|
|
2319
|
+
if (ShouldDedupe(dse, tim.ttime, DBufValue(&obuf))) {
|
|
2320
|
+
DBufFree(&obuf);
|
|
2321
|
+
DBufFree(&raw_buf);
|
|
2322
|
+
DBufFree(&pre_buf);
|
|
2323
|
+
FreeTrig(&trig);
|
|
2324
|
+
return OK;
|
|
2325
|
+
}
|
|
2326
|
+
}
|
|
2327
|
+
|
|
2328
|
+
if (!DoSimpleCalendar) while (isempty(*s)) s++;
|
|
2329
|
+
DBufPuts(&pre_buf, s);
|
|
2330
|
+
s = DBufValue(&pre_buf);
|
|
2331
|
+
NumTriggered++;
|
|
2332
|
+
e = NEW(CalEntry);
|
|
2333
|
+
if (!e) {
|
|
2334
|
+
DBufFree(&obuf);
|
|
2335
|
+
DBufFree(&raw_buf);
|
|
2336
|
+
DBufFree(&pre_buf);
|
|
2337
|
+
FreeTrig(&trig);
|
|
2338
|
+
return E_NO_MEM;
|
|
2339
|
+
}
|
|
2340
|
+
e->infos = NULL;
|
|
2341
|
+
e->nonconst_expr = nonconst_expr;
|
|
2342
|
+
e->if_depth = get_if_pointer() - get_base_if_pointer();
|
|
2343
|
+
e->trig = trig;
|
|
2344
|
+
if (e->trig.tz) {
|
|
2345
|
+
e->trig.tz = strdup(e->trig.tz);
|
|
2346
|
+
}
|
|
2347
|
+
e->tt = tim;
|
|
2348
|
+
e->wc_pos = NULL;
|
|
2349
|
+
e->wc_text = NULL;
|
|
2350
|
+
e->is_color = is_color;
|
|
2351
|
+
e->r = col_r;
|
|
2352
|
+
e->g = col_g;
|
|
2353
|
+
e->b = col_b;
|
|
2354
|
+
e->text = strdup(s);
|
|
2355
|
+
e->raw_text = strdup(DBufValue(&raw_buf));
|
|
2356
|
+
DBufFree(&raw_buf);
|
|
2357
|
+
DBufFree(&obuf);
|
|
2358
|
+
DBufFree(&pre_buf);
|
|
2359
|
+
if (!e->text || !e->raw_text) {
|
|
2360
|
+
if (e->text) free(e->text);
|
|
2361
|
+
if (e->raw_text) free(e->raw_text);
|
|
2362
|
+
FreeTrigInfoChain(e->infos);
|
|
2363
|
+
free(e);
|
|
2364
|
+
FreeTrig(&trig);
|
|
2365
|
+
return E_NO_MEM;
|
|
2366
|
+
}
|
|
2367
|
+
make_wchar_versions(e);
|
|
2368
|
+
DBufInit(&(e->tags));
|
|
2369
|
+
DBufPuts(&(e->tags), DBufValue(&(trig.tags)));
|
|
2370
|
+
if (SynthesizeTags) {
|
|
2371
|
+
AppendTag(&(e->tags), SynthesizeTag());
|
|
2372
|
+
}
|
|
2373
|
+
|
|
2374
|
+
/* Take over any TrigInfo! */
|
|
2375
|
+
e->infos = trig.infos;
|
|
2376
|
+
trig.infos = NULL;
|
|
2377
|
+
|
|
2378
|
+
/* Don't need tags any more */
|
|
2379
|
+
FreeTrig(&trig);
|
|
2380
|
+
e->duration = tim.duration;
|
|
2381
|
+
e->priority = trig.priority;
|
|
2382
|
+
e->filename = GetCurrentFilename();
|
|
2383
|
+
e->lineno = LineNo;
|
|
2384
|
+
e->lineno_start = LineNoStart;
|
|
2385
|
+
|
|
2386
|
+
if (trig.typ == PASSTHRU_TYPE || is_color) {
|
|
2387
|
+
StrnCpy(e->passthru, trig.passthru, PASSTHRU_LEN);
|
|
2388
|
+
} else {
|
|
2389
|
+
e->passthru[0] = 0;
|
|
2390
|
+
}
|
|
2391
|
+
e->pos = e->text;
|
|
2392
|
+
if (dse == DSEToday) {
|
|
2393
|
+
e->time = tim.ttime;
|
|
2394
|
+
} else {
|
|
2395
|
+
e->time = NO_TIME;
|
|
2396
|
+
}
|
|
2397
|
+
e->next = CurCol;
|
|
2398
|
+
CalColumn[col] = e;
|
|
2399
|
+
SortCol(&CalColumn[col]);
|
|
2400
|
+
} else {
|
|
2401
|
+
/* Parse the rest of the line to catch expression-pasting errors */
|
|
2402
|
+
while (ParseChar(p, &r, 0)) {
|
|
2403
|
+
if (r != 0) {
|
|
2404
|
+
return r;
|
|
2405
|
+
}
|
|
2406
|
+
}
|
|
2407
|
+
}
|
|
2408
|
+
return OK;
|
|
2409
|
+
}
|
|
2410
|
+
|
|
2411
|
+
static void WriteSimpleEntryProtocol1(CalEntry const *e)
|
|
2412
|
+
{
|
|
2413
|
+
if (e->passthru[0]) {
|
|
2414
|
+
printf(" %s", e->passthru);
|
|
2415
|
+
} else {
|
|
2416
|
+
printf(" *");
|
|
2417
|
+
}
|
|
2418
|
+
if (*DBufValue(&(e->tags))) {
|
|
2419
|
+
printf(" %s ", DBufValue(&(e->tags)));
|
|
2420
|
+
} else {
|
|
2421
|
+
printf(" * ");
|
|
2422
|
+
}
|
|
2423
|
+
if (e->duration != NO_TIME) {
|
|
2424
|
+
printf("%d ", e->duration);
|
|
2425
|
+
} else {
|
|
2426
|
+
printf("* ");
|
|
2427
|
+
}
|
|
2428
|
+
if (e->time != NO_TIME) {
|
|
2429
|
+
printf("%d ", e->time);
|
|
2430
|
+
} else {
|
|
2431
|
+
printf("* ");
|
|
2432
|
+
}
|
|
2433
|
+
printf("%s\n", e->text);
|
|
2434
|
+
}
|
|
2435
|
+
|
|
2436
|
+
void WriteJSONTimeTrigger(TimeTrig const *tt)
|
|
2437
|
+
{
|
|
2438
|
+
PrintJSONKeyPairTime("time", tt->ttime);
|
|
2439
|
+
if (tt->ttime != tt->ttime_orig) {
|
|
2440
|
+
PrintJSONKeyPairTime("time_in_tz", tt->ttime_orig);
|
|
2441
|
+
}
|
|
2442
|
+
if (tt->nextdtime != NO_DATETIME) {
|
|
2443
|
+
PrintJSONKeyPairTime("nexttime", tt->nextdtime % MINUTES_PER_DAY);
|
|
2444
|
+
PrintJSONKeyPairDateTime("nextdtime", tt->nextdtime);
|
|
2445
|
+
}
|
|
2446
|
+
PrintJSONKeyPairInt("tdelta", tt->delta);
|
|
2447
|
+
PrintJSONKeyPairInt("trep", tt->rep);
|
|
2448
|
+
if (tt->duration != NO_TIME) {
|
|
2449
|
+
PrintJSONKeyPairInt("duration", tt->duration);
|
|
2450
|
+
}
|
|
2451
|
+
}
|
|
2452
|
+
|
|
2453
|
+
static char const *
|
|
2454
|
+
get_url(TrigInfo *infos)
|
|
2455
|
+
{
|
|
2456
|
+
TrigInfo *ti = infos;
|
|
2457
|
+
char const *url;
|
|
2458
|
+
if (!TerminalHyperlinks) {
|
|
2459
|
+
/* Nope, not doing links in terminal */
|
|
2460
|
+
return NULL;
|
|
2461
|
+
}
|
|
2462
|
+
while (ti) {
|
|
2463
|
+
char const *colon = strchr(ti->info, ':');
|
|
2464
|
+
if (!colon) {
|
|
2465
|
+
ti = ti->next;
|
|
2466
|
+
continue;
|
|
2467
|
+
}
|
|
2468
|
+
if (!strncasecmp(ti->info, "url", colon-ti->info)) {
|
|
2469
|
+
url = colon+1;
|
|
2470
|
+
while (*url && isspace(*url)) {
|
|
2471
|
+
url++;
|
|
2472
|
+
}
|
|
2473
|
+
if (!*url) return NULL;
|
|
2474
|
+
return url;
|
|
2475
|
+
}
|
|
2476
|
+
ti = ti->next;
|
|
2477
|
+
}
|
|
2478
|
+
return NULL;
|
|
2479
|
+
}
|
|
2480
|
+
|
|
2481
|
+
void
|
|
2482
|
+
WriteJSONInfoChain(TrigInfo *ti)
|
|
2483
|
+
{
|
|
2484
|
+
printf("\"info\":{");
|
|
2485
|
+
while (ti) {
|
|
2486
|
+
/* Skanky... */
|
|
2487
|
+
char *colon = (char *) strchr(ti->info, ':');
|
|
2488
|
+
char const *value;
|
|
2489
|
+
if (!colon) {
|
|
2490
|
+
/* Should be impossible... */
|
|
2491
|
+
ti = ti->next;
|
|
2492
|
+
continue;
|
|
2493
|
+
}
|
|
2494
|
+
/* Terminate the string at the colon */
|
|
2495
|
+
*colon = 0;
|
|
2496
|
+
|
|
2497
|
+
value = colon+1;
|
|
2498
|
+
while(*value && isspace(*value)) {
|
|
2499
|
+
value++;
|
|
2500
|
+
}
|
|
2501
|
+
printf("\"");
|
|
2502
|
+
PrintJSONStringLC(ti->info);
|
|
2503
|
+
printf("\":\"");
|
|
2504
|
+
PrintJSONString(value);
|
|
2505
|
+
printf("\"");
|
|
2506
|
+
|
|
2507
|
+
/* Restore the value of the colon */
|
|
2508
|
+
*colon = ':';
|
|
2509
|
+
if (ti->next) {
|
|
2510
|
+
printf(",");
|
|
2511
|
+
}
|
|
2512
|
+
ti = ti->next;
|
|
2513
|
+
}
|
|
2514
|
+
printf("},");
|
|
2515
|
+
}
|
|
2516
|
+
void WriteJSONTrigger(Trigger const *t, int include_tags)
|
|
2517
|
+
{
|
|
2518
|
+
/* wd is an array of days from 0=monday to 6=sunday.
|
|
2519
|
+
We convert to array of strings */
|
|
2520
|
+
if (t->wd != NO_WD) {
|
|
2521
|
+
printf("\"wd\":[");
|
|
2522
|
+
int done = 0;
|
|
2523
|
+
int i;
|
|
2524
|
+
for (i=0; i<7; i++) {
|
|
2525
|
+
if (t->wd & (1 << i)) {
|
|
2526
|
+
if (done) {
|
|
2527
|
+
printf(",");
|
|
2528
|
+
}
|
|
2529
|
+
done = 1;
|
|
2530
|
+
printf("\"%s\"", DayName[i]);
|
|
2531
|
+
}
|
|
2532
|
+
}
|
|
2533
|
+
printf("],");
|
|
2534
|
+
}
|
|
2535
|
+
if (t->d != NO_DAY) {
|
|
2536
|
+
PrintJSONKeyPairInt("d", t->d);
|
|
2537
|
+
}
|
|
2538
|
+
if (t->m != NO_MON) {
|
|
2539
|
+
PrintJSONKeyPairInt("m", t->m+1);
|
|
2540
|
+
}
|
|
2541
|
+
if (t->y != NO_YR) {
|
|
2542
|
+
PrintJSONKeyPairInt("y", t->y);
|
|
2543
|
+
}
|
|
2544
|
+
PrintJSONKeyPairInt("is_todo", t->is_todo);
|
|
2545
|
+
PrintJSONKeyPairDate("complete_through", t->complete_through);
|
|
2546
|
+
if (t->back) {
|
|
2547
|
+
PrintJSONKeyPairInt("back", t->back);
|
|
2548
|
+
}
|
|
2549
|
+
if (t->delta) {
|
|
2550
|
+
PrintJSONKeyPairInt("delta", t->delta);
|
|
2551
|
+
}
|
|
2552
|
+
if (t->rep) {
|
|
2553
|
+
PrintJSONKeyPairInt("rep", t->rep);
|
|
2554
|
+
}
|
|
2555
|
+
if (t->d != NO_DAY && t->m != NO_MON && t->y != NO_YR) {
|
|
2556
|
+
printf("\"trigbase\":\"%04d-%02d-%02d\",",
|
|
2557
|
+
t->y, t->m+1, t->d);
|
|
2558
|
+
}
|
|
2559
|
+
/* Local omit is an array of days from 0=monday to 6=sunday.
|
|
2560
|
+
We convert to array of strings */
|
|
2561
|
+
if (t->localomit != NO_WD) {
|
|
2562
|
+
printf("\"localomit\":[");
|
|
2563
|
+
int done = 0;
|
|
2564
|
+
int i;
|
|
2565
|
+
for (i=0; i<7; i++) {
|
|
2566
|
+
if (t->localomit & (1 << i)) {
|
|
2567
|
+
if (done) {
|
|
2568
|
+
printf(",");
|
|
2569
|
+
}
|
|
2570
|
+
done = 1;
|
|
2571
|
+
printf("\"%s\"", DayName[i]);
|
|
2572
|
+
}
|
|
2573
|
+
}
|
|
2574
|
+
printf("],");
|
|
2575
|
+
}
|
|
2576
|
+
switch(t->skip) {
|
|
2577
|
+
case SKIP_SKIP:
|
|
2578
|
+
PrintJSONKeyPairString("skip", "SKIP");
|
|
2579
|
+
break;
|
|
2580
|
+
case BEFORE_SKIP:
|
|
2581
|
+
PrintJSONKeyPairString("skip", "BEFORE");
|
|
2582
|
+
break;
|
|
2583
|
+
case AFTER_SKIP:
|
|
2584
|
+
PrintJSONKeyPairString("skip", "AFTER");
|
|
2585
|
+
break;
|
|
2586
|
+
}
|
|
2587
|
+
PrintJSONKeyPairDate("until", t->until);
|
|
2588
|
+
if (t->once != NO_ONCE) {
|
|
2589
|
+
PrintJSONKeyPairInt("once", t->once);
|
|
2590
|
+
}
|
|
2591
|
+
if (t->scanfrom != NO_SCANFROM) {
|
|
2592
|
+
if (t->scanfrom >= 0) {
|
|
2593
|
+
PrintJSONKeyPairDate("scanfrom", t->scanfrom);
|
|
2594
|
+
} else {
|
|
2595
|
+
PrintJSONKeyPairInt("scanfrom", t->scanfrom);
|
|
2596
|
+
}
|
|
2597
|
+
}
|
|
2598
|
+
if (t->max_overdue >= 0) {
|
|
2599
|
+
PrintJSONKeyPairInt("max_overdue", t->max_overdue);
|
|
2600
|
+
}
|
|
2601
|
+
PrintJSONKeyPairDate("from", t->from);
|
|
2602
|
+
PrintJSONKeyPairInt("priority", t->priority);
|
|
2603
|
+
PrintJSONKeyPairDateTime("eventstart", t->eventstart);
|
|
2604
|
+
if (t->eventstart_orig != NO_DATETIME &&
|
|
2605
|
+
t->eventstart_orig != t->eventstart) {
|
|
2606
|
+
PrintJSONKeyPairDateTime("eventstart_in_tz", t->eventstart_orig);
|
|
2607
|
+
}
|
|
2608
|
+
if (t->eventduration != NO_TIME) {
|
|
2609
|
+
PrintJSONKeyPairInt("eventduration", t->eventduration);
|
|
2610
|
+
}
|
|
2611
|
+
if (t->maybe_uncomputable) {
|
|
2612
|
+
PrintJSONKeyPairInt("maybe_uncomputable", 1);
|
|
2613
|
+
}
|
|
2614
|
+
if (t->noqueue) {
|
|
2615
|
+
PrintJSONKeyPairInt("noqueue", 1);
|
|
2616
|
+
}
|
|
2617
|
+
PrintJSONKeyPairString("sched", t->sched);
|
|
2618
|
+
PrintJSONKeyPairString("warn", t->warn);
|
|
2619
|
+
PrintJSONKeyPairString("omitfunc", t->omitfunc);
|
|
2620
|
+
if (t->addomit) {
|
|
2621
|
+
PrintJSONKeyPairInt("addomit", 1);
|
|
2622
|
+
}
|
|
2623
|
+
if (include_tags) {
|
|
2624
|
+
if (t->infos) {
|
|
2625
|
+
WriteJSONInfoChain(t->infos);
|
|
2626
|
+
}
|
|
2627
|
+
PrintJSONKeyPairString("tags", DBufValue(&(t->tags)));
|
|
2628
|
+
}
|
|
2629
|
+
PrintJSONKeyPairString("tz", t->tz);
|
|
2630
|
+
}
|
|
2631
|
+
|
|
2632
|
+
static void WriteSimpleEntryProtocol2(CalEntry *e)
|
|
2633
|
+
{
|
|
2634
|
+
char const *s;
|
|
2635
|
+
if (DoPrefixLineNo) {
|
|
2636
|
+
PrintJSONKeyPairString("filename", e->filename);
|
|
2637
|
+
PrintJSONKeyPairInt("lineno", e->lineno);
|
|
2638
|
+
if (e->lineno != e->lineno_start) {
|
|
2639
|
+
PrintJSONKeyPairInt("lineno_start", e->lineno_start);
|
|
2640
|
+
}
|
|
2641
|
+
}
|
|
2642
|
+
PrintJSONKeyPairString("passthru", e->passthru);
|
|
2643
|
+
PrintJSONKeyPairString("tags", DBufValue(&(e->tags)));
|
|
2644
|
+
if (e->infos) {
|
|
2645
|
+
WriteJSONInfoChain(e->infos);
|
|
2646
|
+
}
|
|
2647
|
+
if (e->duration != NO_TIME) {
|
|
2648
|
+
PrintJSONKeyPairInt("duration", e->duration);
|
|
2649
|
+
}
|
|
2650
|
+
if (e->time != NO_TIME) {
|
|
2651
|
+
PrintJSONKeyPairInt("time", e->time);
|
|
2652
|
+
if (e->tt.ttime_orig != e->tt.ttime) {
|
|
2653
|
+
PrintJSONKeyPairInt("time_in_tz", e->tt.ttime_orig);
|
|
2654
|
+
}
|
|
2655
|
+
if (e->tt.delta) {
|
|
2656
|
+
PrintJSONKeyPairInt("tdelta", e->tt.delta);
|
|
2657
|
+
}
|
|
2658
|
+
if (e->tt.rep) {
|
|
2659
|
+
PrintJSONKeyPairInt("trep", e->tt.rep);
|
|
2660
|
+
}
|
|
2661
|
+
}
|
|
2662
|
+
WriteJSONTrigger(&e->trig, 0);
|
|
2663
|
+
if (e->nonconst_expr) {
|
|
2664
|
+
PrintJSONKeyPairInt("nonconst_expr", e->nonconst_expr);
|
|
2665
|
+
}
|
|
2666
|
+
if (e->if_depth) {
|
|
2667
|
+
PrintJSONKeyPairInt("if_depth", e->if_depth);
|
|
2668
|
+
}
|
|
2669
|
+
|
|
2670
|
+
if (e->is_color) {
|
|
2671
|
+
PrintJSONKeyPairInt("r", e->r);
|
|
2672
|
+
PrintJSONKeyPairInt("g", e->g);
|
|
2673
|
+
PrintJSONKeyPairInt("b", e->b);
|
|
2674
|
+
} else if (!strcasecmp(e->passthru, "SHADE")) {
|
|
2675
|
+
int r, g, b, n;
|
|
2676
|
+
n = sscanf(e->text, "%d %d %d", &r, &g, &b);
|
|
2677
|
+
if (n < 3) {
|
|
2678
|
+
g = r;
|
|
2679
|
+
b = r;
|
|
2680
|
+
}
|
|
2681
|
+
if (r < 0) r = 0;
|
|
2682
|
+
else if (r > 255) r = 255;
|
|
2683
|
+
if (g < 0) g = 0;
|
|
2684
|
+
else if (g > 255) g = 255;
|
|
2685
|
+
if (b < 0) b = 0;
|
|
2686
|
+
else if (b > 255) b = 255;
|
|
2687
|
+
PrintJSONKeyPairInt("r", r);
|
|
2688
|
+
PrintJSONKeyPairInt("g", g);
|
|
2689
|
+
PrintJSONKeyPairInt("b", b);
|
|
2690
|
+
}
|
|
2691
|
+
/* Only print rawbody if it differs from body */
|
|
2692
|
+
if (strcmp(e->raw_text, e->text)) {
|
|
2693
|
+
PrintJSONKeyPairString("rawbody", e->raw_text);
|
|
2694
|
+
}
|
|
2695
|
+
|
|
2696
|
+
/* Figure out calendar_body and plain_body */
|
|
2697
|
+
if (DontSuppressQuoteMarkers) {
|
|
2698
|
+
s = strstr(e->text, "%\"");
|
|
2699
|
+
if (s) {
|
|
2700
|
+
s += 2;
|
|
2701
|
+
printf("\"calendar_body\":\"");
|
|
2702
|
+
while (*s) {
|
|
2703
|
+
if (*s == '%' && *(s+1) == '"') {
|
|
2704
|
+
break;
|
|
2705
|
+
}
|
|
2706
|
+
PrintJSONChar(*s);
|
|
2707
|
+
s++;
|
|
2708
|
+
}
|
|
2709
|
+
printf("\",");
|
|
2710
|
+
}
|
|
2711
|
+
}
|
|
2712
|
+
s = strstr(e->text, "%\"");
|
|
2713
|
+
if (s || e->is_color) {
|
|
2714
|
+
printf("\"plain_body\":\"");
|
|
2715
|
+
s = e->text;
|
|
2716
|
+
if (e->is_color) {
|
|
2717
|
+
while(*s && !isspace(*s)) s++;
|
|
2718
|
+
while(*s && isspace(*s)) s++;
|
|
2719
|
+
while(*s && !isspace(*s)) s++;
|
|
2720
|
+
while(*s && isspace(*s)) s++;
|
|
2721
|
+
while(*s && !isspace(*s)) s++;
|
|
2722
|
+
while(*s && isspace(*s)) s++;
|
|
2723
|
+
}
|
|
2724
|
+
while(*s) {
|
|
2725
|
+
if (*s == '%' && *(s+1) == '"') {
|
|
2726
|
+
s += 2;
|
|
2727
|
+
continue;
|
|
2728
|
+
}
|
|
2729
|
+
PrintJSONChar(*s);
|
|
2730
|
+
s++;
|
|
2731
|
+
}
|
|
2732
|
+
printf("\",");
|
|
2733
|
+
}
|
|
2734
|
+
printf("\"body\":\"");
|
|
2735
|
+
PrintJSONString(e->text);
|
|
2736
|
+
printf("\"");
|
|
2737
|
+
}
|
|
2738
|
+
|
|
2739
|
+
/***************************************************************/
|
|
2740
|
+
/* */
|
|
2741
|
+
/* WriteSimpleEntries */
|
|
2742
|
+
/* */
|
|
2743
|
+
/* Write entries in 'simple calendar' format. */
|
|
2744
|
+
/* */
|
|
2745
|
+
/***************************************************************/
|
|
2746
|
+
static void WriteSimpleEntries(int col, int dse)
|
|
2747
|
+
{
|
|
2748
|
+
CalEntry *e = CalColumn[col];
|
|
2749
|
+
CalEntry *n;
|
|
2750
|
+
int y, m, d;
|
|
2751
|
+
|
|
2752
|
+
FromDSE(dse, &y, &m, &d);
|
|
2753
|
+
while(e) {
|
|
2754
|
+
if (DoPrefixLineNo) {
|
|
2755
|
+
if (PsCal != PSCAL_LEVEL2 && PsCal != PSCAL_LEVEL3) {
|
|
2756
|
+
printf("# fileinfo %d %s\n", e->lineno, e->filename);
|
|
2757
|
+
}
|
|
2758
|
+
}
|
|
2759
|
+
if (PsCal >= PSCAL_LEVEL2) {
|
|
2760
|
+
if (PsCal == PSCAL_LEVEL3) {
|
|
2761
|
+
if (DidADay) {
|
|
2762
|
+
printf(",\n");
|
|
2763
|
+
}
|
|
2764
|
+
}
|
|
2765
|
+
DidADay = 1;
|
|
2766
|
+
printf("{\"date\":\"%04d-%02d-%02d\",", y, m+1, d);
|
|
2767
|
+
WriteSimpleEntryProtocol2(e);
|
|
2768
|
+
printf("}");
|
|
2769
|
+
if (PsCal != PSCAL_LEVEL3) {
|
|
2770
|
+
printf("\n");
|
|
2771
|
+
}
|
|
2772
|
+
} else {
|
|
2773
|
+
printf("%04d/%02d/%02d", y, m+1, d);
|
|
2774
|
+
WriteSimpleEntryProtocol1(e);
|
|
2775
|
+
}
|
|
2776
|
+
|
|
2777
|
+
free(e->text);
|
|
2778
|
+
free(e->raw_text);
|
|
2779
|
+
FreeTrigInfoChain(e->infos);
|
|
2780
|
+
if (e->wc_text) free(e->wc_text);
|
|
2781
|
+
n = e->next;
|
|
2782
|
+
free(e);
|
|
2783
|
+
e = n;
|
|
2784
|
+
}
|
|
2785
|
+
CalColumn[col] = NULL;
|
|
2786
|
+
}
|
|
2787
|
+
|
|
2788
|
+
/***************************************************************/
|
|
2789
|
+
/* */
|
|
2790
|
+
/* Various functions for writing different types of lines. */
|
|
2791
|
+
/* */
|
|
2792
|
+
/***************************************************************/
|
|
2793
|
+
static void WriteTopCalLine(void)
|
|
2794
|
+
{
|
|
2795
|
+
gon();
|
|
2796
|
+
DRAW(br);
|
|
2797
|
+
PrintCentered("", CalWidth-2, linestruct->lr);
|
|
2798
|
+
DRAW(bl);
|
|
2799
|
+
goff();
|
|
2800
|
+
putchar('\n');
|
|
2801
|
+
}
|
|
2802
|
+
|
|
2803
|
+
static void WriteBottomCalLine(void)
|
|
2804
|
+
{
|
|
2805
|
+
int i;
|
|
2806
|
+
gon();
|
|
2807
|
+
DRAW(tr);
|
|
2808
|
+
for (i=0; i<7; i++) {
|
|
2809
|
+
PrintCentered("", ColSpaces, linestruct->lr);
|
|
2810
|
+
if (i != 6) {
|
|
2811
|
+
DRAW(tlr);
|
|
2812
|
+
} else {
|
|
2813
|
+
DRAW(tl);
|
|
2814
|
+
}
|
|
2815
|
+
}
|
|
2816
|
+
goff();
|
|
2817
|
+
putchar('\n');
|
|
2818
|
+
}
|
|
2819
|
+
|
|
2820
|
+
static void WritePostHeaderLine(void)
|
|
2821
|
+
{
|
|
2822
|
+
int i;
|
|
2823
|
+
gon();
|
|
2824
|
+
DRAW(tbr);
|
|
2825
|
+
for (i=0; i<7; i++) {
|
|
2826
|
+
PrintCentered("", ColSpaces, linestruct->lr);
|
|
2827
|
+
if (i != 6) {
|
|
2828
|
+
DRAW(blr);
|
|
2829
|
+
} else {
|
|
2830
|
+
DRAW(tbl);
|
|
2831
|
+
}
|
|
2832
|
+
}
|
|
2833
|
+
goff();
|
|
2834
|
+
putchar('\n');
|
|
2835
|
+
}
|
|
2836
|
+
|
|
2837
|
+
static void WriteWeekHeaderLine(void)
|
|
2838
|
+
{
|
|
2839
|
+
int i;
|
|
2840
|
+
gon();
|
|
2841
|
+
DRAW(br);
|
|
2842
|
+
for (i=0; i<7; i++) {
|
|
2843
|
+
PrintCentered("", ColSpaces, linestruct->lr);
|
|
2844
|
+
if (i != 6) {
|
|
2845
|
+
DRAW(blr);
|
|
2846
|
+
} else {
|
|
2847
|
+
DRAW(bl);
|
|
2848
|
+
}
|
|
2849
|
+
}
|
|
2850
|
+
goff();
|
|
2851
|
+
putchar('\n');
|
|
2852
|
+
}
|
|
2853
|
+
|
|
2854
|
+
static void WriteIntermediateCalLine(void)
|
|
2855
|
+
{
|
|
2856
|
+
int i;
|
|
2857
|
+
|
|
2858
|
+
gon();
|
|
2859
|
+
DRAW(tbr);
|
|
2860
|
+
for (i=0; i<7; i++) {
|
|
2861
|
+
PrintCentered("", ColSpaces, linestruct->lr);
|
|
2862
|
+
if (i != 6) {
|
|
2863
|
+
DRAW(tblr);
|
|
2864
|
+
} else {
|
|
2865
|
+
DRAW(tbl);
|
|
2866
|
+
}
|
|
2867
|
+
}
|
|
2868
|
+
goff();
|
|
2869
|
+
putchar('\n');
|
|
2870
|
+
}
|
|
2871
|
+
|
|
2872
|
+
static void WriteCalDays(void)
|
|
2873
|
+
{
|
|
2874
|
+
int i;
|
|
2875
|
+
gon();
|
|
2876
|
+
DRAW(tb);
|
|
2877
|
+
goff();
|
|
2878
|
+
for (i=0; i<7; i++) {
|
|
2879
|
+
if (!MondayFirst)
|
|
2880
|
+
PrintCentered(get_day_name((i+6)%7), ColSpaces, " ");
|
|
2881
|
+
else
|
|
2882
|
+
PrintCentered(get_day_name(i%7), ColSpaces, " ");
|
|
2883
|
+
gon();
|
|
2884
|
+
DRAW(tb);
|
|
2885
|
+
goff();
|
|
2886
|
+
}
|
|
2887
|
+
putchar('\n');
|
|
2888
|
+
}
|
|
2889
|
+
|
|
2890
|
+
/***************************************************************/
|
|
2891
|
+
/* */
|
|
2892
|
+
/* CalendarTime */
|
|
2893
|
+
/* */
|
|
2894
|
+
/* Format the time according to simple time format. */
|
|
2895
|
+
/* Answer is returned in a static buffer. */
|
|
2896
|
+
/* A trailing space is always added. */
|
|
2897
|
+
/* This takes into account duration */
|
|
2898
|
+
/* */
|
|
2899
|
+
/***************************************************************/
|
|
2900
|
+
static char const *
|
|
2901
|
+
CalendarTime(int tim, int duration)
|
|
2902
|
+
{
|
|
2903
|
+
static char buf[128];
|
|
2904
|
+
int h, min, hh;
|
|
2905
|
+
int h2, min2, hh2, newtim, days;
|
|
2906
|
+
char const *ampm1;
|
|
2907
|
+
char const *ampm2;
|
|
2908
|
+
char daybuf[64];
|
|
2909
|
+
|
|
2910
|
+
buf[0] = 0;
|
|
2911
|
+
|
|
2912
|
+
if (duration == NO_TIME) {
|
|
2913
|
+
/* No duration... just call into SimpleTime */
|
|
2914
|
+
return SimpleTime(tim);
|
|
2915
|
+
}
|
|
2916
|
+
if (tim == NO_TIME) {
|
|
2917
|
+
/* No time... nothing to return */
|
|
2918
|
+
return buf;
|
|
2919
|
+
}
|
|
2920
|
+
h = tim/60;
|
|
2921
|
+
min = tim % 60;
|
|
2922
|
+
if (h == 0) hh=12;
|
|
2923
|
+
else if (h > 12) hh=h-12;
|
|
2924
|
+
else hh = h;
|
|
2925
|
+
|
|
2926
|
+
newtim = tim + duration;
|
|
2927
|
+
|
|
2928
|
+
/* How many days in duration? */
|
|
2929
|
+
days = newtim / MINUTES_PER_DAY;
|
|
2930
|
+
newtim = newtim % MINUTES_PER_DAY;
|
|
2931
|
+
h2 = newtim/60;
|
|
2932
|
+
min2 = newtim % 60;
|
|
2933
|
+
if (h2 == 0) hh2=12;
|
|
2934
|
+
else if (h2 > 12) hh2=h2-12;
|
|
2935
|
+
else hh2 = h2;
|
|
2936
|
+
|
|
2937
|
+
if (days) {
|
|
2938
|
+
snprintf(daybuf, sizeof(daybuf), "+%d", days);
|
|
2939
|
+
} else {
|
|
2940
|
+
daybuf[0] = 0;
|
|
2941
|
+
}
|
|
2942
|
+
|
|
2943
|
+
if (h >= 12) {
|
|
2944
|
+
ampm1 = tr("pm");
|
|
2945
|
+
} else {
|
|
2946
|
+
ampm1 = tr("am");
|
|
2947
|
+
}
|
|
2948
|
+
if (h2 >= 12) {
|
|
2949
|
+
ampm2 = tr("pm");
|
|
2950
|
+
} else {
|
|
2951
|
+
ampm2 = tr("am");
|
|
2952
|
+
}
|
|
2953
|
+
if (!days) {
|
|
2954
|
+
if (!strcmp(ampm1, ampm2)) {
|
|
2955
|
+
ampm1 = "";
|
|
2956
|
+
}
|
|
2957
|
+
}
|
|
2958
|
+
|
|
2959
|
+
switch(ScFormat) {
|
|
2960
|
+
case SC_AMPM:
|
|
2961
|
+
snprintf(buf, sizeof(buf), "%d%c%02d%s-%d%c%02d%s%s ",
|
|
2962
|
+
hh, TimeSep, min, ampm1, hh2, TimeSep, min2, ampm2, daybuf);
|
|
2963
|
+
break;
|
|
2964
|
+
|
|
2965
|
+
case SC_MIL:
|
|
2966
|
+
snprintf(buf, sizeof(buf), "%02d%c%02d-%02d%c%02d%s ",
|
|
2967
|
+
h, TimeSep, min, h2, TimeSep, min2, daybuf);
|
|
2968
|
+
break;
|
|
2969
|
+
}
|
|
2970
|
+
return buf;
|
|
2971
|
+
}
|
|
2972
|
+
|
|
2973
|
+
/***************************************************************/
|
|
2974
|
+
/* */
|
|
2975
|
+
/* SimpleTime */
|
|
2976
|
+
/* */
|
|
2977
|
+
/* Format the time according to simple time format. */
|
|
2978
|
+
/* Answer is returned in a static buffer. */
|
|
2979
|
+
/* A trailing space is always added. */
|
|
2980
|
+
/* */
|
|
2981
|
+
/***************************************************************/
|
|
2982
|
+
char const *SimpleTime(int tim)
|
|
2983
|
+
{
|
|
2984
|
+
static char buf[128];
|
|
2985
|
+
int h, min, hh;
|
|
2986
|
+
|
|
2987
|
+
buf[0] = 0;
|
|
2988
|
+
|
|
2989
|
+
switch(ScFormat) {
|
|
2990
|
+
|
|
2991
|
+
case SC_AMPM:
|
|
2992
|
+
if (tim != NO_TIME) {
|
|
2993
|
+
h = tim / 60;
|
|
2994
|
+
min = tim % 60;
|
|
2995
|
+
if (h == 0) hh=12;
|
|
2996
|
+
else if (h > 12) hh=h-12;
|
|
2997
|
+
else hh=h;
|
|
2998
|
+
snprintf(buf, sizeof(buf), "%d%c%02d%.64s ", hh, TimeSep, min, (h>=12) ? tr("pm") :
|
|
2999
|
+
tr("am"));
|
|
3000
|
+
}
|
|
3001
|
+
break;
|
|
3002
|
+
|
|
3003
|
+
case SC_MIL:
|
|
3004
|
+
if (tim != NO_TIME) {
|
|
3005
|
+
h = tim / 60;
|
|
3006
|
+
min = tim % 60;
|
|
3007
|
+
snprintf(buf, sizeof(buf), "%02d%c%02d ", h, TimeSep, min);
|
|
3008
|
+
}
|
|
3009
|
+
break;
|
|
3010
|
+
}
|
|
3011
|
+
return buf;
|
|
3012
|
+
}
|
|
3013
|
+
|
|
3014
|
+
/***************************************************************/
|
|
3015
|
+
/* */
|
|
3016
|
+
/* SortCol */
|
|
3017
|
+
/* */
|
|
3018
|
+
/* Sort the calendar entries in a column by time and priority */
|
|
3019
|
+
/* */
|
|
3020
|
+
/***************************************************************/
|
|
3021
|
+
static void SortCol(CalEntry **col)
|
|
3022
|
+
{
|
|
3023
|
+
CalEntry *cur, *prev, *next;
|
|
3024
|
+
|
|
3025
|
+
cur = *col;
|
|
3026
|
+
prev = NULL;
|
|
3027
|
+
|
|
3028
|
+
/* Note that we use <= comparison rather than > comparison to preserve the
|
|
3029
|
+
file order of reminders which have the same time and priority */
|
|
3030
|
+
|
|
3031
|
+
while (cur->next &&
|
|
3032
|
+
CompareRems(0, cur->time, cur->priority,
|
|
3033
|
+
0, cur->next->time, cur->next->priority,
|
|
3034
|
+
SortByDate, SortByTime, SortByPrio, UntimedBeforeTimed) <= 0) {
|
|
3035
|
+
next = cur->next;
|
|
3036
|
+
/* Swap cur and next */
|
|
3037
|
+
if (!prev) {
|
|
3038
|
+
*col = next;
|
|
3039
|
+
cur->next = next->next;
|
|
3040
|
+
next->next = cur;
|
|
3041
|
+
prev = next;
|
|
3042
|
+
} else {
|
|
3043
|
+
prev->next = next;
|
|
3044
|
+
cur->next = next->next;
|
|
3045
|
+
next->next = cur;
|
|
3046
|
+
prev = next;
|
|
3047
|
+
}
|
|
3048
|
+
}
|
|
3049
|
+
}
|
|
3050
|
+
|
|
3051
|
+
char const *SynthesizeTag(void)
|
|
3052
|
+
{
|
|
3053
|
+
struct MD5Context ctx;
|
|
3054
|
+
unsigned char buf[16];
|
|
3055
|
+
static char out[128];
|
|
3056
|
+
MD5Init(&ctx);
|
|
3057
|
+
MD5Update(&ctx, (unsigned char *) CurLine, strlen(CurLine));
|
|
3058
|
+
MD5Final(buf, &ctx);
|
|
3059
|
+
snprintf(out, sizeof(out), "__syn__%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x",
|
|
3060
|
+
(unsigned int) buf[0], (unsigned int) buf[1],
|
|
3061
|
+
(unsigned int) buf[2], (unsigned int) buf[3],
|
|
3062
|
+
(unsigned int) buf[4], (unsigned int) buf[5],
|
|
3063
|
+
(unsigned int) buf[6], (unsigned int) buf[7],
|
|
3064
|
+
(unsigned int) buf[8], (unsigned int) buf[9],
|
|
3065
|
+
(unsigned int) buf[10], (unsigned int) buf[11],
|
|
3066
|
+
(unsigned int) buf[12], (unsigned int) buf[13],
|
|
3067
|
+
(unsigned int) buf[14], (unsigned int) buf[15]);
|
|
3068
|
+
return out;
|
|
3069
|
+
}
|