home *** CD-ROM | disk | FTP | other *** search
/ ST-Computer Leser 2002 January / STC_CD_01_2002.iso / GAMES / BOINKO21 / SRC / SRC / AVFUNCS.C next >
C/C++ Source or Header  |  2000-11-27  |  4KB  |  163 lines

  1. /*
  2.  * AVFUNCS.c
  3.  *
  4.  *   This program is free software; you can redistribute it and/or modify
  5.  *   it under the terms of the GNU General Public License as published by
  6.  *   the Free Software Foundation; either version 2 of the License, or
  7.  *   (at your option) any later version.
  8.  *
  9.  *   This program is distributed in the hope that it will be useful,
  10.  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
  11.  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  12.  *   GNU General Public License for more details.
  13.  *
  14.  *   You should have received a copy of the GNU General Public License
  15.  *   along with this program; if not, write to the Free Software
  16.  *   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  17.  *
  18.  *   Electronic contact can be made via the following web address
  19.  *      http://www.netset.com/~baldrick/stik2.html
  20.  *
  21.  * Routines for AV PROTOCOL programs
  22.  * mostly scavenged elsewhere, but some small modifications
  23.  * 
  24.  */
  25.  
  26. #include <aes.h>
  27. #include <vdi.h>
  28. #include <string.h>
  29. #include <time.h>
  30. #include <tos.h>
  31. #include <process.h>
  32. #include <stdlib.h>
  33. #include <stdio.h>     /* for the string functions */
  34. #include <ext.h>
  35. #include <ctype.h>        /* for toupper() */
  36.  
  37. #include "boink.h"
  38.  
  39.  
  40. char        *va_helpbuf = NULL;            /* ST-Guide */
  41. short av_id = -100;
  42.  
  43. void do_help(char *pattern)
  44. {
  45.   int i;
  46.  
  47.   if ((i=appl_find("ST-GUIDE"))>=0)
  48.   {
  49.     strcpy(va_helpbuf, "*:\\boinkout.hyp ");
  50.     strcat(va_helpbuf, pattern);
  51.  
  52.     send_extmessage(i, VA_START, 0, (int)(((long)va_helpbuf >> 16) & 0x0000ffffL), (int)((long)va_helpbuf & 0x0000ffffL), 0, 0, 0);
  53.   }
  54.   else
  55.     form_alert(1, "[1][Can't Find ST Guide.][ OK ]" );
  56. }
  57.  
  58. int send_vastart(char *path, char *cmdline)
  59. {
  60.     int i;
  61.     char progname[32];
  62.     char *dummy;
  63.  
  64.     strncpy(progname,path,min((strlen(path)),32));
  65.  
  66.     dummy = strrchr(progname,'.');
  67.     
  68.     dummy[0] = '\0';
  69.  
  70.     if (strlen(progname)>8)
  71.         progname[8]=0;
  72.     else
  73.         while (strlen(progname)<8) 
  74.             strcat(progname," ");
  75.  
  76.     /* make certain the name is uppercase */
  77.  
  78.     for (i=0;i<8;i++)
  79.         progname[i]=toupper(progname[i]);
  80.  
  81.     if ((i=appl_find(progname))>=0)
  82.     {    
  83.         strcpy(va_helpbuf, (char *)&cmdline[1]);
  84.  
  85.         send_extmessage(i, VA_START, 0, (int)(((long)va_helpbuf >> 16) & 0x0000ffffL), (int)((long)va_helpbuf & 0x0000ffffL), 0, 0, 0);
  86.  
  87.         return(1);
  88.     }
  89.     
  90.     return(0);
  91.         
  92. }
  93.  
  94. short get_avserver(void)
  95. {
  96.     short ret;
  97.     char *av_env;
  98.  
  99.     if((av_env = getenv("AVSERVER")))
  100.     {
  101.         ret = appl_find(av_env);
  102.  
  103.         if (ret >= 0)
  104.             return ret;
  105.     }
  106.  
  107.     ret = appl_find("AVSERVER");
  108.  
  109.     if (ret >= 0)
  110.         return ret;
  111.  
  112.     ret = appl_find("JINNEE  ");
  113.  
  114.     if (ret >= 0)
  115.         return ret;
  116.  
  117.     ret = appl_find("THING   ");
  118.  
  119.     if (ret >= 0)
  120.         return ret;
  121.  
  122.     ret = appl_find("MAGXDESK");
  123.  
  124.     if (ret >= 0)
  125.         return ret;
  126.  
  127.     ret = appl_find("GEMINI  ");
  128.  
  129.     if (ret >= 0)
  130.         return ret;
  131.  
  132.     ret = appl_find("STRNGSRV");
  133.  
  134.     if (ret >= 0)
  135.         return ret;
  136.  
  137.     return -100;
  138. }
  139.  
  140. void send_avprot(void)
  141. {
  142.     av_id = get_avserver();
  143.     
  144.     if (av_id != -100)
  145.     {
  146.         strcpy(va_helpbuf, "BOINKOUT");
  147.         send_extmessage(get_avserver(), AV_PROTOKOLL, 0,(2|16), 0, 0,(int)(((long)va_helpbuf >> 16) & 0x0000ffffL), (int)((long)va_helpbuf & 0x0000ffffL));
  148.     }
  149. }
  150.  
  151.  
  152. void send_avexit(void)
  153. {
  154.     if (av_id != -100)
  155.     {
  156.  #ifdef __GNUC__
  157.          send_extmessage(get_avserver(), AV_EXIT, 0, _global[2] , 0, 0,0,0);
  158.  #else
  159.           send_extmessage(get_avserver(), AV_EXIT, 0, _GemParBlk.global[2] , 0, 0,0,0);
  160.  #endif
  161.     }
  162. }
  163.