/usr/share/doc/libcdk5-doc/examples/template_ex.c is in libcdk5-doc 5.0.20161210-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 | /* $Id: template_ex.c,v 1.13 2016/12/04 15:22:16 tom Exp $ */
#include <cdk_test.h>
#ifdef HAVE_XCURSES
char *XCursesProgramName = "template_ex";
#endif
/*
* This program demonstrates the Cdk template widget.
*/
int main (int argc, char **argv)
{
/* *INDENT-EQLS* */
CDKSCREEN *cdkscreen = 0;
CDKTEMPLATE *phoneNumber = 0;
const char *title = "<C>Title";
const char *label = "</5>Phone Number:<!5>";
const char *Overlay = "</B/6>(___)<!6> </5>___-____";
const char *plate = "(###) ###-####";
char *info;
char *mixed;
char temp[256];
const char *mesg[5];
CDK_PARAMS params;
CDKparseParams (argc, argv, ¶ms, CDK_MIN_PARAMS);
cdkscreen = initCDKScreen (NULL);
/* Start CDK Colors. */
initCDKColor ();
/* Declare the template. */
phoneNumber = newCDKTemplate (cdkscreen,
CDKparamValue (¶ms, 'X', CENTER),
CDKparamValue (¶ms, 'Y', CENTER),
title, label,
plate, Overlay,
CDKparamValue (¶ms, 'N', TRUE),
CDKparamValue (¶ms, 'S', FALSE));
/* Is the template pointer null? */
if (phoneNumber == 0)
{
/* Exit CDK. */
destroyCDKScreen (cdkscreen);
endCDK ();
printf ("Cannot create template. Is the window too small?");
ExitProgram (EXIT_FAILURE);
}
/* Activate the template. */
info = activateCDKTemplate (phoneNumber, 0);
/* Tell them what they typed. */
if (phoneNumber->exitType == vESCAPE_HIT)
{
mesg[0] = "<C>You hit escape. No information typed in.";
mesg[1] = "",
mesg[2] = "<C>Press any key to continue.";
popupLabel (cdkscreen, (CDK_CSTRING2) mesg, 3);
}
else if (phoneNumber->exitType == vNORMAL)
{
char *with_mix;
char *with_out;
/* Mix the plate and the number. */
mixed = mixCDKTemplate (phoneNumber);
/* Create the message to display. */
sprintf (temp, "Phone Number with out plate mixing : %.*s",
(int)(sizeof (temp) - 50),
info);
mesg[0] = with_out = copyChar (temp);
sprintf (temp, "Phone Number with the plate mixed in: %.*s",
(int)(sizeof (temp) - 50),
mixed);
mesg[1] = with_mix = copyChar (temp);
mesg[2] = "";
mesg[3] = "<C>Press any key to continue.";
popupLabel (cdkscreen, (CDK_CSTRING2) mesg, 4);
freeChar (with_out);
freeChar (with_mix);
freeChar (mixed);
}
/* Clean up. */
destroyCDKTemplate (phoneNumber);
destroyCDKScreen (cdkscreen);
endCDK ();
ExitProgram (EXIT_SUCCESS);
}
|