home *** CD-ROM | disk | FTP | other *** search
/ Amiga Times / AmigaTimes.iso / programme / trionbbs110 / Trion / docs / RIPdoors / ripdoor.c < prev    next >
Encoding:
C/C++ Source or Header  |  1998-10-06  |  11.0 KB  |  407 lines

  1.  
  2.  
  3. /*  Trion BBS 'RIPscrip Clidoor Support' MakeRipScreen door             */
  4. /*                                                                      */
  5. /*  V 1.00   08 - Jan - 1998                                            */
  6. /*                                                                      */
  7. /*  (c) Copyright 1995-98 by Paul Spijkerman                            */
  8.  
  9.  
  10.  
  11.  
  12.  
  13. #include "ripdoor.h"
  14. #include "adoor.h"
  15.  
  16. void MakeRIPScreen(struct DoorIO *pd, struct ADS_Data *pp, int screen);
  17. char hoofdletter(char c);
  18.  
  19.  
  20.  
  21. int main(int argc, char **argv)    /* was void */
  22. {
  23.    struct ADS_Data      port , *pport;
  24.    struct DoorIO        io   , *pio;
  25.    int    node = 0, ret = 0, screen;
  26.  
  27.    pport = &port;
  28.    pio   = &io;
  29.  
  30.    onbreak(brk);
  31.  
  32.    SetOpIO(pio);
  33.  
  34.  
  35.    if (argc != 3){
  36.  
  37.       nprintf(pio, "Trion RipDoor V 1.00 Copyright 1996-98 By Paul Spijkerman\r\n\r\n");
  38.       nprintf(pio, "Use:    RipDoor  \"doors:demodoor/demodoor ~50 screen\"\r\n");
  39.       Delay(120L);
  40.  
  41.    }else{
  42.  
  43.       node   = atoi( argv[1] );
  44.       screen = atoi( argv[2] );
  45.  
  46.       if (screen >= 0 && screen <= 15){
  47.  
  48.          if (SetopPort( pport , node, 0 )){
  49.  
  50.            MakeRIPScreen(pio , pport, screen);
  51.  
  52.          }
  53.          RemovePort( pport );
  54.       }
  55.    }
  56.  
  57.    RemoveIO( pio );
  58.  
  59.    return ret;
  60. }
  61.  
  62.  
  63. UBYTE *name[16] = {
  64.    "Main menu",     "Files menu",     "Mail menu",      "Bulletin menu",
  65.    "Door menu",     "Logout menu",    "Sysop menu",     "User edit menu", 
  66.    "Test menu",     "Protocol menu",  "Browse menu",    "List menu",
  67.    "Download menu", "Read msgs menu", "Scan msgs menu", "Editor menu"  };
  68.  
  69.  
  70.  
  71. /* For instance :  "<>File<>F^M"    */
  72. /*   "File" = button text ,  "F^M" = command when presses (F + return) */
  73.  
  74. /* For instance :  " "      <- skip this button position */
  75. /* For instance :  "*"      <- goto next line of buttons */
  76.  
  77.  
  78.  
  79. UBYTE *data[16][40] = {
  80.  
  81.      /* main menu      0  */
  82.  
  83.      { "<>Mail<>M",   "<>Files<>F",    "<>Bulletins<>B","<>Door<>D",
  84.        "<>UserEd<>E", "<>Log off<>G",
  85.        "<>Page<>P",   "<>Comment<>C",  "<>Conf<>I",     "<>Listnodes<>L",
  86.        "<>SendMsg<>S","<>Sysop<>$",    "" },
  87.  
  88.      /* file menu      1  */
  89.  
  90.      { "<>Group<>G",       "<>Area<>O",      "<>File list<>C", "<>New files<>N",
  91.        "<>Scan Date<>S",   "<>Scan days<>Y",    /* "*", */
  92.        "<>Find files<>F",  "<>Download<>D", "<>Upload<>U",
  93.        "<>List menu<>L",   "<>Browse Menu<>B",  /* "*", */
  94.        "<>View archive<>T",
  95.        "<>Ratio report<>R", "<>Protocol<>P", "<>Mark file<>M", "<>Allfiles<>I",
  96.        "<>List mark.<>J",  "<>Remove marked<>V", "<>Clear marked<>*", "<>Add file<>+",
  97.        "<>Del. file<>K",  "<>Edit file<>E", "<>Make free<>H", "<>Dos files<>#",
  98.        "<>Main menu<>Q", "  <>Logoff<>G",  ""  },
  99.  
  100.      /* Mail menu      2  */
  101.  
  102.      { "<>Group<>G",      "<>Area<>O",   "<>Read menu<>R", "<>Scan menu<>S", "*",
  103.        "<>Wait mail<>W",  "<>Read new<>N","<>Read forward<>F", "<>Global new<>Z", "*",
  104.        "<>Read marked<>M","<>Unmark msgs<>U", "<>Editor<>E", "<>Edit sig<>I",
  105.        "<>Write msg<>L",  "<>Rescan wait<>?", "*",
  106.        "<>Main menu<>Q",  "<>Log off<>G", "" },
  107.  
  108.      /* Bulletin menu  3  */
  109.  
  110.      { "<>About system<>I",  "<>Teletext<>A",       "*",
  111.        "<>Lastcallers<>L",   "<>Usage<>U",          "*",
  112.        "<>Top Up/Down<>0",   "<>Top down files<>1", "<>Top down bytes<>2",
  113.        "<>Top up files<>3",  "<>Top up bytes<>4",   "<>Top callers<>5",
  114.        "<>Top time on<>6",   "<>Top msgs written<>7",  "*",
  115.        "<>Main menu<>Q",     "<>Comment sysop<>C",  "<>Logout<>G", "" },
  116.  
  117.      /* Door menu      4  */
  118.  
  119.      { "<>Tetris<>T", "<>Shell<>S", "*"
  120.        "<>PageDoor<>P", "<>SplitChat<>=", "<>LineChat<>-", "*",      
  121.        "<>Dutch robo<>R", "<>English Robo<>R", "*",
  122.        "<>CDrom door<>C", "<>Demodoor<>D", "*",
  123.        "<>Main menu<>Q", "<>Files<>F", "<>Mail<>M", "<>Bulletin<>B", "<>Log off<>G", "" },
  124.  
  125.      /* Logout menu    5  */
  126.  
  127.      { "<>Main menu<>M",    "<>Msg to sysop<>C", "<>Log off<>G", "*",
  128.        "<>Previous menu<>P","<>Msg to All<>A"  , "" },
  129.  
  130.      /* Sysop menu     6  */
  131.  
  132.      { "" },
  133.  
  134.      /* User edit menu 7  */
  135.  
  136.      { "" },
  137.  
  138.      /* test menu      8  */
  139.  
  140.      { "" },
  141.  
  142.      /* Protocol menu  9  */
  143.  
  144.      { "<>Zmodem<>Z", "*",
  145.        "<>Ymodem<>Y", "<>Ymodem-G<>G", "*",
  146.        "<>Xmodem<>X", "*",
  147.        "<>Kermit<>K", "*",
  148.        "<>Back<>Q" ,  "" },
  149.  
  150.      /* Browse menu    10 */
  151.  
  152.      { "<>Chrono<>C",   "<>Alpha<>L", "<>ChronoNew<>N", "<>AlphaNew<>M", "*",
  153.        "<>FindFile<>Z", "<>ChronoUnval<>V", "*",
  154.        "<>Chrono<>A",   "<>Alpha<>H", "<>ChronoNew<>G", "<>AlphaNew<>B", "*",
  155.        "<>FindFile<>F", "<>ChronoUnval<>U", "*",
  156.        "<>ReverseChrono<>T", "<>ReverseAlpha<>R", "" },
  157.  
  158.      /* List menu      11 */
  159.  
  160.      { "<>Chrono<>C",   "<>Alpha<>L", "<>ChronoNew<>N", "<>AlphaNew<>M", "*",
  161.        "<>FindFile<>Z", "<>ChronoUnval<>V", "*",
  162.        "<>Chrono<>A",   "<>Alpha<>H", "<>ChronoNew<>G", "<>AlphaNew<>B", "*",
  163.        "<>FindFile<>F", "<>ChronoUnval<>U", "*",
  164.        "<>ReverseChrono<>T", "<>ReverseAlpha<>R", "" },
  165.  
  166.      /* Download menu  12 */
  167.  
  168.      { "<>Download & Logoff<>G", "<>Mark a file<>M", "*",
  169.        "<>Start Download<>D",    "<>Mark allfiles<>A", "*",
  170.        " ", " ",                 "<>Remove marked<>V", "*",
  171.        "<>To file menu<>Q",      "<>Clear marked files<>*",   "" },
  172.  
  173.      /* Read msgs menu 13 */
  174.  
  175.      { "<>New<>N", "<>Forward<>F", "<>Reverse<>R", "<>Global new<>Z", "*",
  176.        "<>Wait mailing<>W", "<>Marked msgs<>M",                       "*",
  177.        "<>To User<>1", "<>From User<>2", "<>To and From<>3", "<>Subject<>4", "*",
  178.        "<>To,From,Subject<>5",
  179.        "<>To you<>6", "<>From you<>7", "<>To & From you<>8", "<>Rev. to you<>9",
  180.        "<>Rev. From you<>A", "<>Rev. To & From you<>B", ""  },
  181.  
  182.      /* Scan msgs menu 14 */
  183.  
  184.      { "<>New<>N", "<>Forward<>F", "<>Reverse<>R", "<>Global new<>Z", "*",
  185.        "<>Wait mailing<>W", "<>Marked msgs<>M",                       "*",
  186.        "<>To User<>1", "<>From User<>2", "<>To and From<>3", "<>Subject<>4", "*"
  187.        "<>To,From,Subject<>5",
  188.        "<>To you<>6", "<>From you<>7", "<>To & From you<>8", "<>Rev. to you<>9",
  189.        "<>Rev. From you<>A", "<>Rev. To & From you<>B", ""  },
  190.  
  191.      /* Editor menu    15 */
  192.  
  193.      { "<>Line Editor<>0",         "*",
  194.        "<>Line ED (CED local)<>1", "*",
  195.        "<>Full screen<>2",         "*",
  196.        "<>Back<>Q",                ""   },
  197.  
  198.  
  199. };
  200.  
  201.  
  202. void MakeRIPScreen(struct DoorIO *pd, struct ADS_Data *pp, int screen)
  203. {
  204.    int    x, y, xs, ys, xt, t, number, a[8], ready, len;
  205.    UBYTE  key , retkey , ID , str[5], *p;
  206.  
  207.  
  208.    onbreak(brk);
  209.  
  210.    printf("");          /* ClrScr(); */
  211.    printf("!\r\n");      /* RipScrip on, return !! .. rip starts on begin of line */
  212.  
  213.  
  214.    Color(15);     /* white */
  215.  
  216.    p = name[screen];
  217.  
  218.    ripprint( 250 , 15 , p );
  219.    /* ripprint( 250 , 15 , "Main menu" ); */
  220.  
  221.  
  222. /* ButtonStyle( 60, 20, 02, 32+256+512+1024, 3, 15, 8, 15, 8, 7, 0, 1, 14, 7 ); */
  223. /* RipButton  ( 400, 150, 500, 180, '=', 0, "<>Button<>b^M" ); */
  224.  
  225.    ButtonStyle( 0, 0, 02, 32+256+512+1024, 3, 15, 8, 15, 8, 7, 0, 1, 14, 7 );
  226.  
  227. /* RipButton  ( 300, 80, 400, 95, '=', 0, "<>Files<>F^M" ); */
  228. /* RipButton  ( 410, 80, 510, 95, '=', 0, "<>Mail<>M^M" );  */
  229. /* RipButton  ( 520, 80, 620, 95, '=', 0, "<>Doors<>D^M" ); */
  230.  
  231.  
  232.    number = 12;
  233.    ready  =  0;
  234.  
  235.    x  = 20;         /* starting point */
  236.    y  = 100;
  237.  
  238.    xs = 80;         /* button size */
  239.    ys = 12;
  240.  
  241.    /* for (t = 0; t < number; t++){ */
  242.    t = 0;
  243.  
  244.    while (!ready){
  245.       /* RipButton  ( x, y, x+xs, y+ys, '=', 0, "<>Doors<>D" ); */
  246.  
  247.       p = data[screen][t];
  248.  
  249.       if (*p == '\0'){
  250.          ready = 1;             /* end of buttons */
  251.       }else{
  252.          if (*p == '*'){
  253.             x  = 20;            /* start new line of buttons */
  254.             y += 24;
  255.          }else{
  256.             if (*p != ' '){
  257.                len = strlen(p) - 5;       /* length of button text */
  258.                len = len * 8;             /* in pixels ! */
  259.  
  260.                if (len < xs + 8){
  261.                   xt = xs;
  262.                }else{
  263.                   xt = 2 * xs + 15;
  264.                }
  265.  
  266.                RipButton  ( x, y, x+xt, y+ys, '=', 0, p );
  267.  
  268.                x += 15;
  269.                x += xt;
  270.                if (x > 550){
  271.                   x  = 20;
  272.                   y += 24;
  273.                }
  274.  
  275.             }else{
  276.  
  277.                x += 15;
  278.                x += xs;
  279.                if (x > 550){
  280.                   x  = 20;
  281.                   y += 24;
  282.                }
  283.  
  284.             }
  285.          }
  286.       }
  287.  
  288.  
  289.       t++;
  290.    }
  291.  
  292.    endrip();     /* RIP screen build ? */
  293.  
  294.  
  295.  
  296.  
  297.  
  298.    SplitChatMode( pp , 1);
  299.    /* nprintf(pd, "s"); */
  300.  
  301.    retkey = ' ';
  302.    ID     = 0;
  303.  
  304.    x  = 0;         /* starting point */
  305.    FillStyle(13, x);               /* pattern , color */
  306.  
  307.    ready = 0;
  308.    while ( Carrier(pd) && !ready){
  309.  
  310.       /*=== Normal ===*/
  311. /*
  312.       key = hoofdletter ( GetCharacter(pd) );
  313. */
  314.       /*=== Animated (polled I/O) ===*/
  315.  
  316.       Delay(10L);   /* wait 1/5th of a seconde, don't hog the CPU/blitter */
  317.       key = hoofdletter ( MayGetCharacter(pd) );
  318.  
  319.  
  320.       ID  = (((key & 128) >> 7) & 1);       /* Extract ID bit    (0-1)   */
  321.       key = (key & 127);                    /* Make 7 bit ASCII          */
  322.  
  323.       if (key > 0){
  324.          ready  = 1;
  325.          retkey = key;
  326.       }else{
  327.          /* animation */
  328.  
  329.          y = 1 << x;
  330.          for (t = 0; t < 8; t++){
  331.             a[t] = y;
  332.             y = y << 1;
  333.             if (y == 256) y = 1;
  334.          }
  335.          /* FillStyle(13, x+7); */              /* pattern , color */
  336.          CustomFillPattern(a[0],a[1],a[2],a[3],a[4],a[5],a[6],a[7], 13);
  337.          FilledRectangle( 20, 30, 580, 90 );
  338.          x++;
  339.          if (x > 7) x = 0;      /* x = 0 - 7 */
  340.  
  341.  
  342.          /* Color(x & 15);  */
  343.          /* LineAt( x, y, x, y+60); */
  344.          /* x++; */
  345.          /* if (x == 540) x = 0; */
  346.       }
  347.    }/* end while */
  348.  
  349.  
  350.    /* nprintf(pd, "u"); */
  351.    SplitChatMode( pp , 0);
  352.  
  353.    if (key != 0){
  354.       FlushBuffer( pp );
  355.       str[0] =  retkey;
  356.       str[1] = '\0';
  357.       PushIntoBuffer( pp, str , ID);
  358.    }
  359.  
  360.  
  361.  
  362.    printf("!");      /* RipScrip off, remove buttons, restore ANSI color */
  363.    printf("");          /* ClrScr(); */
  364.  
  365. }
  366.  
  367.  
  368.  
  369.  
  370. /*  RIP Palette is 64 EGA kleuren     */
  371. /*  default 16 color RIP palette :    */
  372. /*  Value Color          EGAnr  RGB   */
  373.  
  374. /*  00    Black          0   0x0000  (00 is always background color) */
  375. /*  01    Blue           1   0x000A  */
  376. /*  02    Green          2   0x00A0  */
  377. /*  03    Cyan           3   0x00AA  */
  378. /*  04    Red            4   0x0A00  */
  379. /*  05    Magenta        5   0x0A0A  */
  380. /*  06    Brown          20  0x0A50  ( 7 ?)  */
  381. /*  07    Light Gray     7   0x0AAA  (20 ?)  */
  382. /*  08    Dark  Gray     56  0x0555  */
  383. /*  09    Light Blue     57  0x055F  */
  384. /*  0A    Light Green    58  0x05F5  */
  385. /*  0B    Light Cyan     59  0x05FF  */
  386. /*  0C    Light Red      60  0x0F55  */
  387. /*  0D    Light Magenta  61  0x0F5F  */
  388. /*  0E    Yellow         62  0x0FF5  */
  389. /*  0F    White          63  0x0FFF  */
  390.  
  391.  
  392.  
  393.  
  394. /* Maak een hoofdletter van de aangeboden letter */
  395. /* verschil met de C-lib routine is dat niet     */
  396. /* met integers gewerkt wordt                    */
  397.  
  398. char hoofdletter(char c)
  399. {
  400.    if (c >= 'a' && c <= 'z')
  401.       return (char) (c+('A'-'a'));
  402.    else
  403.       return (char) (c);
  404. }
  405.  
  406.  
  407.