home *** CD-ROM | disk | FTP | other *** search
/ In'side Shareware 1995 April / ish0495.iso / win95 / wswatch / beeper.c next >
C/C++ Source or Header  |  1995-08-06  |  2KB  |  83 lines

  1. #include <windows.h>
  2. #include <stdio.h>
  3. #include <io.h>   // for access()
  4. #include <direct.h> // for getcwd()
  5. #include <string.h>
  6.  
  7. /*
  8.  Skeleton for beeper program.
  9.  
  10.  arg1 =  UP  or   DN
  11.  arg2 =  beeper_phone_number
  12.  arg3 =  host_code
  13.  arg4 =  ip_address
  14. */
  15.  
  16. char szIni[256];
  17. char szBuf[256];
  18.  
  19. int CallBeeper(int nComPort,int nBaudRate,PSTR pszMessage)
  20. {
  21.   // nComPort = 1 or 2
  22.   // nBaudRate = 0=2400, 1=9600, 2=19200, 3=38400
  23.   // pszMessage = "ATDTnumber,,,,code#"
  24.  
  25.  
  26.   return TRUE;
  27. }
  28.  
  29. int SetupBeeper(PSTR pszPhoneNumber,PSTR pszCode,int bDown,PSTR pszAddress)
  30. {
  31.   // if you have an ALPHA pager it is possible to create a full
  32.   // alpha text message and send to the pager.  you have to add in
  33.   // all the DDE or OLE stuff.
  34.   char szBeepString[150];
  35.   char szBeeperNumber[40];
  36.   char szBeeperMessage[80];
  37.   int nComPort;
  38.   int nBaudRate;
  39.  
  40.   /*
  41.   if(GetPrivateProfileInt("OPTS","BEEP_ENABLE",0,szIni)==0)
  42.     return FALSE;
  43.   */
  44.  
  45.   GetPrivateProfileString("OPTS","BEEP_STRING","ATDT%s,,,,,%s#",
  46.      szBeepString,70,szIni);
  47.   nComPort=GetPrivateProfileInt("OPTS","BEEP_PORT",1,szIni);
  48.   nBaudRate=GetPrivateProfileInt("OPTS","BEEP_BAUD",1,szIni);
  49.   if(!pszPhoneNumber || strlen(pszPhoneNumber)<4)
  50.     GetPrivateProfileString("OPTS","BEEP_NUMBER","",
  51.          szBeeperNumber,20,szIni);
  52.   else
  53.     strcpy(szBeeperNumber,pszPhoneNumber);
  54.   wsprintf(szBuf,"%s%s",
  55.             (LPSTR)((bDown==0) ? "000" : "999"),(LPSTR)pszCode);
  56.   wsprintf(szBeeperMessage,szBeepString,
  57.             (LPSTR)szBeeperNumber,(LPSTR)szBuf);
  58.   return (CallBeeper(nComPort,nBaudRate,szBeeperMessage));
  59. }
  60.  
  61. int main(int argc,char *argv[])
  62. {
  63.   FILE *fp;
  64.   int i;
  65.  
  66.   if((fp=fopen("logfile.out","a"))!=NULL)
  67.   {
  68.     for(i=0;i<argc;i++)
  69.       fprintf(fp,"%u: %s ",i,argv[i]);
  70.     fputs("\n",fp);
  71.     fclose(fp);
  72.   }
  73.  
  74.   if(access("ws_watch.ini",0)==0)
  75.     wsprintf(szIni,"%s\\ws_watch.ini",(LPSTR)getcwd(szBuf,200));
  76.   else
  77.     strcpy(szIni,"ws_watch.ini");
  78.  
  79.   SetupBeeper(argv[2],argv[3],strcmp(argv[1],"DN"),argv[4]);
  80.   return 0;
  81. }
  82.  
  83.