Annotation of sbbs/uifc/uifctest.c, revision 1.1.1.1

1.1       root        1: /* uedit.c */
                      2: 
                      3: /* Synchronet for *nix user editor */
                      4: 
                      5: /* $Id: uifctest.c,v 1.4 2004/07/26 22:06:35 rswindell Exp $ */
                      6: 
                      7: /****************************************************************************
                      8:  * @format.tab-size 4          (Plain Text/Source Code File Header)                    *
                      9:  * @format.use-tabs true       (see http://www.synchro.net/ptsc_hdr.html)              *
                     10:  *                                                                                                                                                     *
                     11:  * Copyright 2003 Rob Swindell - http://www.synchro.net/copyright.html         *
                     12:  *                                                                                                                                                     *
                     13:  * This program is free software; you can redistribute it and/or                       *
                     14:  * modify it under the terms of the GNU General Public License                         *
                     15:  * as published by the Free Software Foundation; either version 2                      *
                     16:  * of the License, or (at your option) any later version.                                      *
                     17:  * See the GNU General Public License for more details: gpl.txt or                     *
                     18:  * http://www.fsf.org/copyleft/gpl.html                                                                                *
                     19:  *                                                                                                                                                     *
                     20:  * Anonymous FTP access to the most recent released source is available at     *
                     21:  * ftp://vert.synchro.net, ftp://cvs.synchro.net and ftp://ftp.synchro.net     *
                     22:  *                                                                                                                                                     *
                     23:  * Anonymous CVS access to the development source and modification history     *
                     24:  * is available at cvs.synchro.net:/cvsroot/sbbs, example:                                     *
                     25:  * cvs -d :pserver:[email protected]:/cvsroot/sbbs login                       *
                     26:  *     (just hit return, no password is necessary)                                                     *
                     27:  * cvs -d :pserver:[email protected]:/cvsroot/sbbs checkout src                *
                     28:  *                                                                                                                                                     *
                     29:  * For Synchronet coding style and modification guidelines, see                                *
                     30:  * http://www.synchro.net/source.html                                                                          *
                     31:  *                                                                                                                                                     *
                     32:  * You are encouraged to submit any modifications (preferably in Unix diff     *
                     33:  * format) via e-mail to [email protected]                                                                      *
                     34:  *                                                                                                                                                     *
                     35:  * Note: If this box doesn't appear square, then you need to fix your tabs.    *
                     36:  ****************************************************************************/
                     37: 
                     38: #include <signal.h>
                     39: #include <stdio.h>
                     40: /* #include "curs_fix.h" */
                     41: #include "uifc.h"
                     42: 
                     43: /********************/
                     44: /* Global Variables */
                     45: /********************/
                     46: uifcapi_t uifc; /* User Interface (UIFC) Library API */
                     47: char YesStr[]="Yes";
                     48: char NoStr[]="No";
                     49: char *ok[2]={"OK",""};
                     50: 
                     51: int main(int argc, char** argv)  {
                     52:        char**  opt;
                     53:        char**  mopt;
                     54:        int             main_dflt=0;
                     55:        int             main_bar=0;
                     56:        char    revision[16];
                     57:        char    str[256],ctrl_dir[41],*p;
                     58:        char    title[256];
                     59:        int             i,j;
                     60:        int             done;
                     61:        int             last;
                     62:        int             edtuser=0;
                     63:        char    longtitle[1024];
                     64:        /******************/
                     65:        /* Ini file stuff */
                     66:        /******************/
                     67:        char    ini_file[MAX_PATH+1];
                     68:        FILE*                           fp;
                     69: 
                     70:        sscanf("$Revision: 1.4 $", "%*s %s", revision);
                     71: 
                     72:     printf("\nSynchronet UIFC Test Suite Copyright 2004 "
                     73:         "Rob Swindell\n");
                     74: 
                     75:     memset(&uifc,0,sizeof(uifc));
                     76: 
                     77:        uifc.esc_delay=500;
                     78: 
                     79:        for(i=1;i<argc;i++) {
                     80:         if(argv[i][0]=='-')
                     81:             switch(toupper(argv[i][1])) {
                     82:                 case 'C':
                     83:                                uifc.mode|=UIFC_COLOR;
                     84:                     break;
                     85:                 case 'L':
                     86:                     uifc.scrn_len=atoi(argv[i]+2);
                     87:                     break;
                     88:                 case 'E':
                     89:                     uifc.esc_delay=atoi(argv[i]+2);
                     90:                     break;
                     91:                                case 'I':
                     92:                                        /* Set up ex-ascii codes */
                     93:                                        uifc.mode|=UIFC_IBM;
                     94:                                        break;
                     95:                 default:
                     96:                     printf("\nusage: %s [ctrl_dir] [options]"
                     97:                         "\n\noptions:\n\n"
                     98:                         "-c  =  force color mode\n"
                     99:                         "-e# =  set escape delay to #msec\n"
                    100:                                                "-i  =  force IBM charset\n"
                    101:                         "-l# =  set screen lines to #\n"
                    102:                                                ,argv[0]
                    103:                         );
                    104:                                exit(0);
                    105:                }
                    106:                if(atoi(argv[i]))
                    107:                        edtuser=atoi(argv[i]);
                    108:     }
                    109: 
                    110: #ifdef __unix__
                    111:        signal(SIGPIPE, SIG_IGN);
                    112: #endif
                    113: 
                    114:        uifc.size=sizeof(uifc);
                    115: #ifdef USE_CURSES
                    116:        i=uifcinic(&uifc);  /* curses */
                    117: #else
                    118:        i=uifcini32(&uifc);  /* curses */
                    119: #endif
                    120:        if(i!=0) {
                    121:                printf("uifc library init returned error %d\n",i);
                    122:                exit(1);
                    123:        }
                    124: 
                    125:        opt=(char **)malloc(sizeof(char *)*(MAX_OPTS+1));
                    126:        for(i=0;i<(MAX_OPTS+1);i++)
                    127:                opt[i]=(char *)malloc(MAX_OPLN);
                    128: 
                    129:        mopt=(char **)malloc(sizeof(char *)*MAX_OPTS);
                    130:        for(i=0;i<MAX_OPTS;i++)
                    131:                mopt[i]=(char *)malloc(MAX_OPLN);
                    132: 
                    133:        sprintf(title,"Synchronet Test Suite");
                    134:        if(uifc.scrn(title)) {
                    135:                printf(" USCRN (len=%d) failed!\n",uifc.scrn_len+1);
                    136:                return(1);
                    137:        }
                    138: 
                    139:        strcpy(mopt[0],"Long Title");
                    140:        strcpy(mopt[1],"String Input");
                    141:        mopt[2][0]=0;
                    142: 
                    143:        uifc.helpbuf=   "`Test Suite:`\n"
                    144:                                        "\nToDo: Add Help";
                    145: 
                    146:        while(1) {
                    147:                j=uifc.list(WIN_L2R|WIN_ESC|WIN_ACT|WIN_DYN|WIN_ORG,0,5,70,&main_dflt,&main_bar
                    148:                        ,title,mopt);
                    149: 
                    150:                if(j <= -2)
                    151:                        continue;
                    152: 
                    153:                if(j==-1) {
                    154:                        uifc.bail();
                    155:                        return(0);
                    156:                }
                    157: 
                    158:                if(j==0) {
                    159:                        /* Long Title */
                    160:                        strcpy(longtitle,"This is a long title...");
                    161:                        for(p=strchr(longtitle,0);p<longtitle+sizeof(longtitle)-1;p++)
                    162:                                *p='.';
                    163:                        *p=0;
                    164:                        done=0;
                    165:                        uifc.list(WIN_ORG|WIN_MID|WIN_ACT,0,0,0,&i,0,longtitle,ok);
                    166:                }
                    167:                if(j==1) {
                    168:                        /* String input */
                    169:                        strcpy(longtitle,"This is a test if string input... enter/edit this field");
                    170:                        uifc.input(WIN_MID,0,0,"Input",longtitle,sizeof(longtitle),K_EDIT);
                    171:                        uifc.showbuf(WIN_MID, 0, 0, uifc.scrn_width-4, uifc.scrn_len-4, "Result:", longtitle, NULL, NULL);
                    172:                }
                    173:        }
                    174: }

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.