home *** CD-ROM | disk | FTP | other *** search
/ Amiga ISO Collection / AmigaUtilCD2.iso / Misc / JOE_SOUR.LHA / Sources.lha / Amiexpress / Joinconf / joinconf.c next >
Encoding:
C/C++ Source or Header  |  1995-08-03  |  4.1 KB  |  189 lines

  1.  
  2. #include <AE.Includes/doorheader.h>
  3. #include <AE.Includes/glue.h>
  4.  
  5. #include <string.h>
  6. #include <proto/exec.h>
  7. #include <dos/dos.h>
  8. #include <ctype.h>
  9. #include <time.h>
  10. #include <clib/dos_protos.h>
  11. #include <stdio.h>
  12. #include <proto/icon.h>
  13. #include <dos.h>
  14. #include <stdlib.h>
  15.  
  16.  
  17.  
  18. #define Ver "$VER: sTATUS 1.0 (21-07-94) - ©1994 jOE cOOl/mOTION"
  19.  
  20. #define sm sendmessage
  21. #define pm prompt
  22. #define gu getuserstring
  23. #define pu putuserstring
  24.  
  25. #define Beep 0x07
  26.  
  27. /***[ SubRoutines ]**********************************************************/
  28.  
  29. void start(int);
  30. void GetAEinfo(void);
  31. void GetDate(char);
  32. void end(void);
  33. void DExit(void);
  34. void LastCommand(void);
  35. BOOL GetIconTooltype(char *text, char *buffer);
  36.  
  37. /***[ Global Variables ]*****************************************************/
  38.  
  39. int  Node,num;
  40. struct Library *IconBase;
  41. struct DiskObject *dobj;
  42. BYTE *tooltype;
  43.  
  44.  
  45.  
  46.  
  47. /***[ Main ]*****************************************************************/
  48.  
  49. void main (int argc,char *argv[]) 
  50. {
  51.   if(argc!=2)
  52.   { printf("\n %s \n",Ver);
  53.     exit(0);
  54.   }
  55.   Node=atoi(argv[1]);
  56.   Register(argv[1][0]-'0');
  57.   IconBase=(struct Library *) OpenLibrary("icon.library", 33);
  58.   if (IconBase == NULL)
  59.     {
  60.      sm("",1);
  61.      sm("System Error - Unable to open Icon.library",1);
  62.      sm("",1);
  63.      DExit();
  64.     }
  65.   start(Node);
  66.   CloseLibrary((struct Library *)IconBase);
  67.   DExit();
  68. }
  69. /****************************************************************************/
  70.  
  71. void start(int node)
  72.  
  73.  
  74. { char buffer[400],buffer2[400];
  75.   int confs=0,i=0,j,k=0,bytes=0,relative=NULL,*axx=NULL;
  76.   char confname[15][40];
  77.   char *p=NULL,*s=NULL,**ap=NULL,*t=NULL;
  78.   ULONG size=0,nr=0;
  79. sm ("CAJoin by H!-Tex",1);
  80.                  
  81.   dobj = GetDiskObject("bbs:confconfig");
  82. if (dobj==NULL) DExit();
  83.  
  84.    GetIconTooltype("NCONFS",buffer);
  85.    confs=atoi(buffer);
  86.    strcpy(buffer,"RELATIVE_CONFERENCES");
  87.    relative=GetIconTooltype(buffer, buffer2);
  88.     while (k<confs)
  89.     {       p=s;
  90.  
  91.         sprintf(buffer,"NAME.%d",k+1);
  92.         GetIconTooltype(buffer, buffer2);
  93.                 if ((s=realloc(s,(bytes+strlen(buffer2)+1)))!=NULL)
  94.                    {if (s!=p)
  95.                     for (j=0;j<i;j++)
  96.                     ap[j]+=s-p;
  97.                     strcpy(s+bytes,buffer2);
  98.                     if ((ap=realloc(ap, ((i+1)*sizeof(char *))))==NULL)
  99.                     DExit();
  100.                     ap[i]=s+bytes;
  101.                     bytes += strlen(buffer2)+1;
  102.                     i++;
  103.                     } else DExit();
  104.                 k++;
  105.        }
  106.     
  107.    FreeDiskObject(dobj);
  108. gu (buffer,DT_CONFACCESS);
  109. sprintf (buffer2,"bbs:access/area.%s",buffer);
  110.  
  111. dobj = GetDiskObject(buffer2);
  112. if (dobj==NULL) {sm(buffer2,0);sm(" not found!",1);DExit();}
  113. if ((axx=realloc(axx,((confs)*sizeof(int))))==NULL)
  114. DExit();
  115.                     
  116. k=0;
  117.     while (k<confs)
  118.                {
  119.         sprintf(buffer,"conf.%d",k+1);
  120.                 axx[k]=GetIconTooltype(buffer, buffer2);
  121.                 k++;
  122.        }
  123.   FreeDiskObject(dobj);
  124. j=0;
  125.  
  126. gu (buffer,BB_MAINLINE);
  127. p=strchr(buffer,32);
  128. if (p!=NULL) {strcpy(buffer2,p);
  129.               nr=atoi(buffer2);
  130.               if ((nr!=0) && (nr<=confs) && (axx[nr-1])) 
  131.                 {sprintf(buffer,"j %d",nr); 
  132.                  pu (buffer,PRV_COMMAND);
  133.                  DExit();
  134.                 }
  135.              }
  136.  
  137. //sm("c",0);
  138. for (i=0;i<confs;i++)
  139. if (axx[i]) {if (!(relative)) {sprintf (buffer,"%2d  ",(i+1));
  140.                                sm (buffer,0);sm (ap[i],1);}
  141.                        else   {sprintf (buffer,"%2d  ",(j+1));
  142.                                j++;sm (buffer,0);sm (ap[i],1);}
  143.             }
  144. //gu (buffer,BB_MAINLINE);
  145. //p=strchr(buffer,32);
  146. //if (p!=NULL) ce",1);
  147. //sm (buffer,1);
  148. //pu ("j 8",PRV_COMMAND);
  149.  
  150.  
  151. //RETURNCOMMAND
  152. //PRV_COMMAND
  153. }  
  154.  
  155.  
  156. /****************************************************************************/
  157.  
  158.  
  159. void DExit(void)
  160. {
  161.   ShutDown();
  162.   end();
  163. }
  164.  
  165. void end (void)
  166. {
  167.   exit(0);
  168. }
  169.  
  170. void LastCommand (void)
  171. {
  172. }
  173. BOOL GetIconTooltype(char *text, char *buffer)
  174. {
  175.     UBYTE **toolarray;
  176.  
  177.    toolarray = (char **)dobj->do_ToolTypes;
  178.    if (tooltype=FindToolType(toolarray, text))
  179.    {
  180.      strcpy(buffer,tooltype);
  181.      return(1);
  182.    }
  183.    else
  184.    {
  185.      buffer=NULL;
  186.      return(0);
  187.    }
  188. }
  189.