示例#1
0
文件: ssl_io.c 项目: alexgirao/ipsvd
void finish(void) {
  if (fdstdou != -1)
    for (;;) {
      decou.start =decou.end =decou.buf;
      rc =matrixSslEncodeClosureAlert(ssl, &decou);
      if (rc == SSL_FULL) {
        if (! blowup(&decou, &decoubuf, bufsizeou)) die_nomem();
        if (verbose > 1) infou("decode output buffer size: ", decou.size);
        continue;
      }
      if (rc == SSL_ERROR)
        if (verbose) warnx("unable to encode ssl close notify");
      if (rc == 0) {
        if (write(fdstdou, decou.start, decou.end -decou.start)
            != (decou.end -decou.start)) {
          if (verbose) warn("unable to send ssl close notify");
          break;
        }
        if (verbose > 2) info("sending ssl close notify");
        if (verbose > 2) infou("write bytes: ", decou.end -decou.start);
        bytesou +=decou.end -decou.start;
      }
      break;
    }
  /* bummer */
  matrixSslFreeKeys(keys);
  matrixSslDeleteSession(ssl);
  matrixSslClose();
  if (fdstdou != -1) close(fdstdou);
  if (encpipe[0] != -1) close(encpipe[0]);
  if (fdstdin != -1) close(fdstdin);
  if (decpipe[1] != -1) close(decpipe[1]);
  if (verbose) { infou("bytes in: ", bytesin); infou("bytes ou: ", bytesou); }
}
示例#2
0
void LayerEnemy::enemyBlowupAll()
{
	int i = _vecEmemy.size() - 1;
	for (; i >= 0 ; i--)
	{
		auto enemy = _vecEmemy.at(i);
		if (enemy->hpGet() > 0)
		{
			enemy->blowup();
		}
	}
}
示例#3
0
文件: ssl_io.c 项目: alexgirao/ipsvd
void encode(void) {
  if ((len =read(encpipe[0], encinbuf.s, encin.size)) < 0)
    fatal("unable to read from prog");
  if (len == 0) {
    if (verbose > 2) info("eof reading from proc");
    if (quit == 0) {
      finish();
      _exit(0);
    } else {
      close(encpipe[0]); encpipe[0] = -1;
      if (shutdown(fdstdou, SHUT_WR) == 0) {
	fdstdou =-1;
	if (verbose > 2) info("shutdown network");
      } else {
	if (verbose > 2) info("close network");
	close(fdstdou); fdstdou =-1;
      }
      sig_catch(sig_alarm, quit_handler);
      alarm(quit);
      return;
    }
  }
  for (;;) {
    rc =matrixSslEncode(ssl, encin.buf, len, &encou);
    if (rc == SSL_ERROR) {
      close(fdstdou); fdstdou =-1;
      fatalx("unable to encode data");
    }
    if (rc == SSL_FULL) {
      if (! blowup(&encou, &encoubuf, bufsizeou)) die_nomem();
      if (verbose > 1) infou("encode output buffer size: ", encou.size);
      continue;
    }
    if (write(fdstdou, encou.start, encou.end -encou.start)
        != encou.end -encou.start) fatal("unable to write to network");
    if (verbose > 2) infou("write bytes: ", encou.end -encou.start);
    bytesou +=encou.end -encou.start;
    encou.start =encou.end =encou.buf =encoubuf.s;
    return;
  }
}
示例#4
0
VSCREEN* global uivopen( register VSCREEN *vptr )
/***********************************************/
{
    register    char*                   box;
    register    ATTR                    attr;
    register    int                     priority;
    register    void                    (_FAR *updatertn)( struct sarea, void * );
    register    bool                    okbuffer;
    register    int                     len;
    register    ORD                     col;
    register    unsigned int            flags;
    register    bool                    covered;
    auto        SAREA                   area;

    okarea( vptr->area );
    flags = vptr->flags;
    area = vptr->area;
    if( ( flags & V_DIALOGUE ) != 0 ) {
        if( flags & V_LISTBOX ) {
            box = (char *)&UiGChar[ UI_SBOX_TOP_LEFT ];
            attr = UIData->attrs[ ATTR_NORMAL ];
        } else {
            box = (char *)&UiGChar[ UI_BOX_TOP_LEFT ];
            attr = UIData->attrs[ ATTR_DIAL_FRAME ];
        }
        priority = P_DIALOGUE;
    } else {
        flags &= ~V_UNBUFFERED;
        box = (char *)&UiGChar[ UI_SBOX_TOP_LEFT ];
        attr = UIData->attrs[ ATTR_FRAME ];
        priority = P_VSCREEN;
    }
    if( ( flags & V_UNFRAMED ) == 0 ) {
        (area.row)--;
        (area.col)--;
        (area.height) += 2;
        (area.width) += 2;
        okarea( area );
    }
    if( ( flags & V_UNBUFFERED ) != 0 ) {
        priority = P_UNBUFFERED;
        bfake( &(vptr->window.type.buffer), area.row, area.col );
        okbuffer = TRUE;
        updatertn = NULL;
    } else {
        okbuffer = balloc( &(vptr->window.type.buffer), area.height, area.width );
        updatertn = (void(*)(struct sarea,void *))update;
    }
    if( okbuffer ) {
        vptr->window.area = area;
        vptr->window.priority = priority;
        vptr->window.update = updatertn;
        vptr->window.parm = vptr;
        covered = openwindow( &(vptr->window) );
        vptr->flags = flags;
        if( ( flags & V_UNFRAMED ) == 0 ) {
            if( ( !UIData->no_blowup ) &&
                ( covered == FALSE ) &&
                ( ( flags & V_NO_ZOOM ) == 0 ) ) {
                blowup( &UIData->screen, area, box, attr );
            }
            area.row = 0;
            area.col = 0;
            drawbox( &(vptr->window.type.buffer), area, box, attr, FALSE );
            if( vptr->name != NULL ) {
#if 0
do not delete this stuff
                col = 0;
                len = area.width;
                bstring( &(vptr->window.type.buffer), 0, col,
                         UIData->attrs[ATTR_CURR_SELECT_DIAL], " ", len );
                len = __min( strlen( vptr->name ), area.width );
                col = ( area.width - len ) / 2;
                bstring( &(vptr->window.type.buffer), 0, col,
                         UIData->attrs[ATTR_CURR_SELECT_DIAL], vptr->name, len );
#else
                len = __min( strlen( vptr->name ), area.width );
                col = ( area.width - len ) / 2;
                bstring( &(vptr->window.type.buffer), 0, col,
                         attr, vptr->name, len );
#endif
            }
            bframe( &(vptr->window.type.buffer ) );
        }
        area = vptr->area;
        area.row = 0;
        area.col = 0;
        vptr->open = TRUE;
        uivfill( vptr, area, UIData->attrs[ ATTR_NORMAL ], ' ' );
        uivsetcursor( vptr );

        return( vptr );
    }
    return( NULL );
}
示例#5
0
文件: ssl_io.c 项目: alexgirao/ipsvd
void decode(void) {
  do {
    if (getdec) {
      len =decin.size -(decin.end -decin.buf);
      if ((len =read(fdstdin, decin.end, len)) < 0)
        fatal("unable to read from network");
      if (len == 0) {
        if (verbose > 2) info("eof reading from network");
        close(fdstdin); close(decpipe[1]);
        fdstdin =decpipe[1] =-1;
        return;
      }
      if (verbose > 2) infou("read bytes: ", len);
      bytesin +=len;
      decin.end +=len;
      getdec =0;
    }
    for (;;) {
      rc =matrixSslDecode(ssl, &decin, &decou, &error, &alvl, &adesc);
      if (rc == SSL_SUCCESS) break;
      if (rc == SSL_ERROR) {
        if (decou.end > decou.start)
          if (write(fdstdou, decou.start, decou.end -decou.start)
              != decou.end -decou.start) warn("unable to write to network");
        close(fdstdou); fdstdou =-1;
        fatals("ssl decode error", error);
      }
      if (rc == SSL_PROCESS_DATA) {
        if (write(decpipe[1], decou.start, decou.end -decou.start)
            != decou.end -decou.start) fatal("unable to write to prog");
        decou.start =decou.end =decou.buf;
        if (decin.start > decin.buf) { /* align */
          byte_copy(decin.buf, decin.end -decin.start, decin.start);
          decin.end -=decin.start -decin.buf;
          decin.start =decin.buf;
        }
        break;
      }
      if (rc == SSL_SEND_RESPONSE) {
        if (write(fdstdou, decou.start, decou.end -decou.start)
            != (decou.end -decou.start))
          fatal("unable to send ssl response");
        bytesou +=decou.end -decou.start;
        if (verbose > 2) info("sending ssl handshake response");
        if (verbose > 2) infou("write bytes: ", decou.end -decou.start);
        decou.start =decou.end =decou.buf;
        break;
      }
      if (rc == SSL_ALERT) {
        close(fdstdou); fdstdou =-1;
        if (adesc != SSL_ALERT_CLOSE_NOTIFY)
          fatals("ssl alert from peer", adesc);
        if (verbose > 2) info("ssl close notify from peer");
        finish();
        _exit(0);
      }
      if (rc == SSL_PARTIAL) {
        getdec =1;
        if (decin.size -(decin.end -decin.buf) < bufsizein) {
          if (! blowup(&decin, &decinbuf, bufsizein)) die_nomem();
          if (verbose > 1) infou("decode input buffer size: ", decin.size);
        }
        break;
      }
      if (rc == SSL_FULL) {
        if (! blowup(&decou, &decoubuf, bufsizeou)) die_nomem();
        if (verbose > 1) infou("decode output buffer size: ", decou.size);
        continue;
      }
    }
    if (decin.start == decin.end) {
      decin.start =decin.end =decin.buf;
      getdec =1;
    }
  } while (getdec == 0);
  if (handshake)
    if (matrixSslHandshakeIsComplete(ssl)) {
      handshake =0;
      if (verbose > 2) info("ssl handshake complete");
    }
}