Beispiel #1
0
int tconnect(int argc, descriptor *argv)	/*: connect to TCP socket */
   {
   char *hostname, filename[1000];
   unsigned char *p;
   int port, fd, i, d[4];
   FILE *fp;
   struct hostent *h;
   struct sockaddr_in sin;

   memset(&sin, 0, sizeof(sin));

   /* check arguments */
   ArgString(1);
   hostname = StringVal(argv[1]);

   ArgInteger(2);
   port = IntegerVal(argv[2]);

   /* get host address */
   if (sscanf(hostname, "%d.%d.%d.%d", &d[0], &d[1], &d[2], &d[3]) == 4) {
      p = (unsigned char *) &sin.sin_addr;
      for (i = 0; i < 4; i++)
         p[i] = d[i];
      }
   else {
      h = gethostbyname(hostname);
      if (!h)
         Fail;
      memcpy(&sin.sin_addr, h->h_addr, sizeof(struct in_addr));
      endhostent();
      }

   /* create socket and connect */
   sin.sin_family = AF_INET;
   sin.sin_port = htons(port);
   if ((fd = socket(AF_INET, SOCK_STREAM, 0)) < 0)
      Fail;
   if (connect(fd, (struct sockaddr *) &sin, sizeof(sin)) < 0)
      Fail;

   /* create stdio file pointer */
   fp = fdopen(fd, "r+");
   if (!fp)
      Fail;

   /* return Icon file */
   sprintf(filename, "%s:%d", hostname, port);
   RetFile(fp, Fs_Read | Fs_Write, filename);
   }
Beispiel #2
0
/*
 * Set initial variables at INIT stage
 */
void set_preset_variables(int argc)
{
char *ttemp;

    if (argc)
    { /* Started from Shell */
	if (args[ARG_APPNAME])
	{
	    set_variable("@app-name", (STRPTR)args[ARG_APPNAME], 0);
	}
	else
	{
	    set_variable("@app-name", "DemoApp", 0);
	}

	if (args[ARG_LANGUAGE])
	{
	    set_variable("@language", (char *)args[ARG_LANGUAGE], 0);
	}
	else
	{
	    set_variable("@language", "english", 0);
	}
    }
    else
    { /* Started from Workbench */
	ttemp = ArgString(tooltypes, "APPNAME", NULL);
	if (ttemp)
	{
	    set_variable("@app-name", ttemp, 0);
	}
	else
	{
	    set_variable("@app-name", "DemoApp", 0);
	}
	set_variable("@language", ArgString(tooltypes, "LANGUAGE", "english"), 0);
    }

    set_variable("@abort-button", ABORT_BUTTON, 0);
    set_variable("@default-dest", DEFAULT_DEST, 0);
    set_variable("@installer-version", NULL, (INSTALLER_VERSION << 16) + INSTALLER_REVISION);
    set_variable("@user-level", NULL, preferences.defusrlevel);
    set_variable("@pretend",    NULL, preferences.pretend);

    /* Set help texts */
    set_variable("@askchoice-help",  ASKCHOICE_HELP,  0);
    set_variable("@asknumber-help",  ASKNUMBER_HELP,  0);
    set_variable("@askoptions-help", ASKOPTIONS_HELP, 0);
    set_variable("@askstring-help",  ASKSTRING_HELP,  0);

    /* Set other variables to (NULL|0) */
    set_variable("@askdir-help",    NULL, 0);
    set_variable("@askdisk-help",   NULL, 0);
    set_variable("@askfile-help",   NULL, 0);
    set_variable("@copyfiles-help", NULL, 0);
    set_variable("@copylib-help",   NULL, 0);
    set_variable("@each-name",      NULL, 0);
    set_variable("@each-type",      NULL, 0);
    set_variable("@error-msg",      NULL, 0);
    set_variable("@execute-dir",    NULL, 0);
    set_variable("@icon",           NULL, 0);
    set_variable("@ioerr",          NULL, 0);
    set_variable("@makedir-help",   NULL, 0);
    set_variable("@special-msg",    NULL, 0);
    set_variable("@startup-help",   NULL, 0);
}