home *** CD-ROM | disk | FTP | other *** search
/ Amiga ISO Collection / AmigaUtilCD2.iso / Misc / JOE_SOUR.LHA / Sources.lha / Amiexpress / Joinconf / joinconf2.c < prev    next >
Encoding:
C/C++ Source or Header  |  1995-08-03  |  4.3 KB  |  211 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.     char buffer[400],buffer2[400];
  73.     int confs=0,i=0,j,k=0,bytes=0,relative=NULL,*axx=NULL;
  74.     char *p=NULL,*s=NULL,**ap=NULL;
  75.     ULONG nr=0;
  76.  
  77.     dobj = GetDiskObject("bbs:confconfig");
  78.     if (dobj==NULL) DExit();
  79.  
  80.    GetIconTooltype("NCONFS",buffer);
  81.    confs=atoi(buffer);
  82.    strcpy(buffer,"RELATIVE_CONFERENCES");
  83.    relative=GetIconTooltype(buffer, buffer2);
  84.     while (k<confs)
  85.     {       p=s;
  86.  
  87.         sprintf(buffer,"NAME.%d",k+1);
  88.         GetIconTooltype(buffer, buffer2);
  89.                 if ((s=realloc(s,(bytes+strlen(buffer2)+1)))!=NULL)
  90.                    {if (s!=p)
  91.                     for (j=0;j<i;j++)
  92.                     ap[j]+=s-p;
  93.                     strcpy(s+bytes,buffer2);
  94.                     if ((ap=realloc(ap, ((i+1)*sizeof(char *))))==NULL)
  95.                     DExit();
  96.                     ap[i]=s+bytes;
  97.                     bytes += strlen(buffer2)+1;
  98.                     i++;
  99.                     } else DExit();
  100.                 k++;
  101.        }
  102.     
  103.    FreeDiskObject(dobj);
  104. gu (buffer,DT_CONFACCESS);
  105. sprintf (buffer2,"bbs:access/area.%s",buffer);
  106.  
  107. dobj = GetDiskObject(buffer2);
  108. if (dobj==NULL) {sm(buffer2,0);sm(" not found!",1);DExit();}
  109. if ((axx=realloc(axx,((confs)*sizeof(int))))==NULL)
  110. DExit();
  111.                     
  112. k=0;
  113.     while (k<confs)
  114.                {
  115.         sprintf(buffer,"conf.%d",k+1);
  116.                 axx[k]=GetIconTooltype(buffer, buffer2);
  117.                 k++;
  118.        }
  119.   FreeDiskObject(dobj);
  120. j=0;
  121.  
  122. gu (buffer,BB_MAINLINE);
  123. p=strchr(buffer,32);
  124. if (p!=NULL) {strcpy(buffer2,p);
  125.               nr=atoi(buffer2);
  126.               if ((nr!=0) && (nr<=confs) && (axx[nr-1])) 
  127.                 {sprintf(buffer,"j %d",nr); 
  128.                  pu (buffer,PRV_COMMAND);
  129.                  DExit();
  130.                 }
  131.              }
  132.  
  133. //sm("c",0);
  134. for (i=0;i<confs;i++)
  135. if (axx[i]) {if (!(relative)) {sprintf (buffer,"%2d  ",(i+1));
  136.                                sm (buffer,0);sm (ap[i],1);}
  137.                        else   {sprintf (buffer,"%2d  ",(j+1));
  138.                                j++;sm (buffer,0);sm (ap[i],1);}
  139.             }
  140.  
  141.  
  142. sm ("",1);
  143.  
  144. gu(buffer,JH_HK);
  145. i=0;
  146. while (buffer[0]!=13)
  147. {
  148. buffer2[i]=buffer[0];
  149. buffer2[i+1]='\0';
  150. sm ("A",0);
  151. sm (buffer2,1);
  152. gu(buffer,JH_HK);
  153. i++;
  154. }
  155.   
  156.  
  157. nr=atoi(buffer2);
  158. if ((nr!=0) && (nr<=confs) && (axx[nr-1])) 
  159. {sprintf(buffer,"j %d",nr); 
  160. pu (buffer,PRV_COMMAND);
  161. DExit();
  162. }              
  163.  
  164.  
  165. //gu (buffer,BB_MAINLINE);
  166. //p=strchr(buffer,32);
  167. //if (p!=NULL) ce",1);
  168. //sm (buffer,1);
  169. //pu ("j 8",PRV_COMMAND);
  170.  
  171.  
  172. //RETURNCOMMAND
  173. //PRV_COMMAND
  174. }  
  175.  
  176.  
  177. /****************************************************************************/
  178.  
  179.  
  180. void DExit(void)
  181. {
  182.   ShutDown();
  183.   end();
  184. }
  185.  
  186. void end (void)
  187. {
  188.   exit(0);
  189. }
  190.  
  191. void LastCommand (void)
  192. {
  193. }
  194. BOOL GetIconTooltype(char *text, char *buffer)
  195. {
  196.     UBYTE **toolarray;
  197.  
  198.    toolarray = (char **)dobj->do_ToolTypes;
  199.    if (tooltype=FindToolType(toolarray, text))
  200.    {
  201.      strcpy(buffer,tooltype);
  202.      return(1);
  203.    }
  204.    else
  205.    {
  206.      buffer=NULL;
  207.      return(0);
  208.    }
  209. }
  210.