Initialize the GSSContext to provide SPNEGO feature.

@param inputBuf
@param offset
@param len
@return response token
177523
@Override
    public byte[] initSecContext ( byte[] inputBuf, int offset, int len ) throws CIFSException {
        SpnegoToken resp;
        if ( this.completed ) {
            throw new CIFSException("Already complete");
        }
        else if ( len == 0 ) {
            resp = initialToken();
        }
        else {
            resp = negotitate(inputBuf, offset, len);
        }

        if ( resp == null ) {
            return null;
        }
        return resp.toByteArray();
    }
200139
public void setBytes(long memoryOffset, byte[] buffer, int bufferOffset, int count)
    {
        if (buffer == null)
            throw new NullPointerException();
        else if (bufferOffset < 0
                 || count < 0
                 || bufferOffset + count > buffer.length)
            throw new IndexOutOfBoundsException();
        else if (count == 0)
            return;

        long end = memoryOffset + count;
        checkBounds(memoryOffset, end);

        unsafe.copyMemory(buffer, BYTE_ARRAY_BASE_OFFSET + bufferOffset, null, peer + memoryOffset, count);
    }
592553
public static char[] cencode(byte[] input, int inOffset, int inLen)
    {
        final char[] output = new char[((inLen + 2) / 3) * 4];
        cencode(input, inOffset, inLen, output, 0);
        return output;
    }
698550
private Input processGA4GHInput(String input) throws IOException, GeneralSecurityException, URISyntaxException {
    GA4GHUrl url = new GA4GHUrl(input);
    SAMFilePump pump;
    if (usingGrpc) {
      factoryGrpc.configure(url.getRootUrl(), 
        new Settings(clientSecretsFilename, apiKey, noLocalServer));
      pump = new ReadIteratorToSAMFilePump<
          com.google.genomics.v1.Read,
          com.google.genomics.v1.ReadGroupSet, 
          com.google.genomics.v1.Reference>(
              factoryGrpc
                .get(url.getRootUrl())
                .getReads(url));
    } else {
      factoryRest.configure(url.getRootUrl(), 
          new Settings(clientSecretsFilename, apiKey, noLocalServer));
        pump = new ReadIteratorToSAMFilePump<
            com.google.api.services.genomics.model.Read,
            com.google.api.services.genomics.model.ReadGroupSet, 
            com.google.api.services.genomics.model.Reference>(
                factoryRest
                  .get(url.getRootUrl())
                  .getReads(url)); 
    }
    return new Input(input, STDIN_FILE_NAME, pump);
  }
443798
function (sspiClient) {
      if (!initializeExecutionCompleted) {
        // You cannot user process.nextTick() here as it will block all
        // I/O which means initialization in native code will never get
        // a chance to run and the process will just hang.
        setImmediate(invokeGetNextBlob, sspiClient);
      } else if (!initializeSucceeded) {
        cb(null, null, initializeErrorCode, initializeErrorString);
      } else {
        sspiClient.sspiClientImpl.getNextBlob(serverResponse, serverResponseBeginOffset, serverResponseLength,
          // Cannot use => function syntax here as that does not have the 'arguments'.
          function() {
            sspiClient.getNextBlobInProgress = false;
            cb.apply(null, arguments);
          });
      }
    }
67322
function(firstByte, secondByte, callback) {
    if (!this._spi) {
      throw "SPI device not initialized";
    }

    for (var i = 0; i < this._buffer.length; i += 2) {
      this._buffer[i] = MAX7219._Registers.NoOp;
      this._buffer[i + 1] = 0x00;
    }

    var offset = this._activeController * 2;
    this._buffer[offset] = firstByte;
    this._buffer[offset + 1] = secondByte;

    this._spi.write(this._buffer, callback);
  }
208053
@Override
  public int acceptInitialRead(byte []buffer, int offset, int length)
  {
    synchronized (_readLock) {
      // initialize fields from the _fd
      int result = nativeAcceptInit(_socketFd, _localAddrBuffer, _remoteAddrBuffer,
                                    buffer, offset, length);

      return result;
    }
  }
1276936
public void messageReceived(NextFilter nextFilter, ByteBuffer buf) throws SSLException {
        // append buf to inNetBuffer
        if (inNetBuffer == null) {
            inNetBuffer = IoBuffer.allocate(buf.remaining()).setAutoExpand(true);
        }

        inNetBuffer.put(buf);
        if (!handshakeComplete) {
            handshake(nextFilter);
        } else {
            decrypt(nextFilter);
        }

        if (isInboundDone()) {
            // Rewind the MINA buffer if not all data is processed and inbound is finished.
            int inNetBufferPosition = inNetBuffer == null? 0 : inNetBuffer.position();
            buf.position(buf.position() - inNetBufferPosition);
            inNetBuffer = null;
        }
    }
773172
def create_string_buffer(init, size=None):
    
    if isinstance(init, (str, unicode)):
        if size is None:
            size = len(init) + 1
        buftype = c_char * size
        buf = buftype()
        buf.value = init
        return buf
    elif isinstance(init, (int, long)):
        buftype = c_char * init
        buf = buftype()
        return buf
    raise TypeError, init
1052544
@Override
    protected void initInputSource(WstxInputSource newInput, boolean isExt, String entityId)
        throws XMLStreamException
    {
        if (mFlattenWriter != null) {
            // Anything to flush from previous buffer contents?
            mFlattenWriter.flush(mInputBuffer, mInputPtr);
            mFlattenWriter.disableOutput();
            try {
                /* Then let's let base class do the 'real' input source setup;
                 * this includes skipping of optional XML declaration that we
                 * do NOT want to output
                 */
                super.initInputSource(newInput, isExt, entityId);
            } finally {
                // This will effectively skip declaration
                mFlattenWriter.enableOutput(mInputPtr);
            }
        } else {
            super.initInputSource(newInput, isExt, entityId);
        }
    }
789911
@Override
    public SmbComBlankResponse initResponse ( CIFSContext tc ) {
        SmbComBlankResponse resp = new SmbComBlankResponse(tc.getConfig());
        setResponse(resp);
        return resp;
    }
315077
static final byte[] inflate(final byte[] in, final int offset, final int length)
			throws DataFormatException {
		byte[] infBuf = new byte[length << 1];
		int payloadLength;
		synchronized (inflater) {
			inflater.reset();
			inflater.setInput(in, offset, length);
			payloadLength = inflater.inflate(infBuf);
		}
		return resizeBuffer(infBuf, payloadLength);
	}
1340138
@Handler
    public void onInput(Input<ByteBuffer> event, IOSubchannel channel)
            throws InterruptedException, UnsupportedEncodingException {
        Optional<FormContext> ctx = channel.associated(this, FormContext.class);
        if (!ctx.isPresent()) {
            return;
        }
        ctx.get().fieldDecoder.addData(event.data());
        if (!event.isEndOfRecord()) {
            return;
        }

        long invocations = (Long) ctx.get().session.computeIfAbsent(
            "invocations", key -> {
                return 0L;
            });
        ctx.get().session.put("invocations", invocations + 1);

        HttpResponse response = ctx.get().request.response().get();
        response.setStatus(HttpStatus.OK);
        response.setHasPayload(true);
        response.setField(HttpField.CONTENT_TYPE,
            MediaType.builder().setType("text", "plain")
                .setParameter("charset", "utf-8").build());
        String data = "First name: "
            + ctx.get().fieldDecoder.fields().get("firstname")
            + "\r\n" + "Last name: "
            + ctx.get().fieldDecoder.fields().get("lastname")
            + "\r\n" + "Previous invocations: " + invocations;
        channel.respond(new Response(response));
        ManagedBuffer<ByteBuffer> out = channel.byteBufferPool().acquire();
        out.backingBuffer().put(data.getBytes("utf-8"));
        channel.respond(Output.fromSink(out, true));
    }
179342
@Override
  public final void initialize(FlowletContext ctx) throws Exception {
    super.initialize(ctx);
    portsAnnouncementList = Lists.newArrayList();
    DefaultInputFlowletConfigurer configurer = new DefaultInputFlowletConfigurer(this);
    create(configurer);
    InputFlowletSpecification spec = configurer.createInputFlowletSpec();

    dataIngestionPortsMap = Maps.newHashMap();
    int httpPort = 0;
    if (ctx.getRuntimeArguments().get(Constants.HTTP_PORT) != null) {
      httpPort = Integer.parseInt(ctx.getRuntimeArguments().get(Constants.HTTP_PORT));
    }
    dataIngestionPortsMap.put(Constants.HTTP_PORT, httpPort);
    for (String inputName : spec.getInputSchemas().keySet()) {
      int tcpPort = 0;
      if (ctx.getRuntimeArguments().get(Constants.TCP_INGESTION_PORT_PREFIX + inputName) != null) {
        tcpPort = Integer.parseInt(ctx.getRuntimeArguments().get(Constants.TCP_INGESTION_PORT_PREFIX + inputName));
      }
      dataIngestionPortsMap.put(Constants.TCP_INGESTION_PORT_PREFIX + inputName, tcpPort);
    }

    // Setup temporary directory structure
    tmpFolder = Files.createTempDir();
    File baseDir = new File(tmpFolder, "baseDir");
    baseDir.mkdirs();

    InputFlowletConfiguration inputFlowletConfiguration = new LocalInputFlowletConfiguration(baseDir, spec);
    File binDir = inputFlowletConfiguration.createStreamEngineProcesses();

    healthInspector = new HealthInspector(this);
    metricsRecorder = new MetricsRecorder(metrics);

    //Initiating AbstractInputFlowlet Components
    recordQueue = new GDATRecordQueue();

    //Initiating Netty TCP I/O ports
    inputFlowletService = new InputFlowletService(binDir, spec, healthInspector, metricsRecorder, recordQueue,
                                                  dataIngestionPortsMap, this);
    inputFlowletService.startAndWait();

    //Starting health monitor service
    healthInspector.startAndWait();

    //Initializing methodsDriver
    Map<String, StreamSchema> schemaMap = MetaInformationParser.getSchemaMap(new File(binDir.toURI()));
    methodsDriver = new MethodsDriver(this, schemaMap);

    //Initialize stopwatch and retry counter
    stopwatch = new Stopwatch();
    retryCounter = 0;
  }
903462
public static LinkedBuffer sencode(final byte[] input, int inOffset, int inLen,
            final WriteSession session,
            final LinkedBuffer lb) throws IOException
    {
        int outputSize = ((inLen + 2) / 3) * 4;
        session.size += outputSize;

        int available = lb.buffer.length - lb.offset;
        if (outputSize > available)
        {
            final byte[] buffer = lb.buffer;
            int offset = lb.offset, remaining = inLen % 3, chunks = available / 4;
            byte b0, b1, b2;

            for (int stop = inOffset + (inLen - remaining); inOffset < stop; chunks--)
            {
                if (chunks == 0)
                {
                    // available size is less than 4
                    // flush and reset
                    offset = session.flush(buffer, lb.start, offset - lb.start);
                    // available = buffer.length - offset;
                    chunks = (buffer.length - offset) / 4;
                }

                b0 = input[inOffset++];
                b1 = input[inOffset++];
                b2 = input[inOffset++];
                buffer[offset++] = nibble2code[(b0 >>> 2) & 0x3f];
                buffer[offset++] = nibble2code[(b0 << 4) & 0x3f | (b1 >>> 4) & 0x0f];
                buffer[offset++] = nibble2code[(b1 << 2) & 0x3f | (b2 >>> 6) & 0x03];
                buffer[offset++] = nibble2code[b2 & 077];
            }

            switch (remaining)
            {
                case 0:
                    break;
                case 1:
                    if (chunks == 0)
                        offset = session.flush(buffer, lb.start, offset - lb.start);

                    b0 = input[inOffset++];
                    buffer[offset++] = nibble2code[(b0 >>> 2) & 0x3f];
                    buffer[offset++] = nibble2code[(b0 << 4) & 0x3f];
                    buffer[offset++] = pad;
                    buffer[offset++] = pad;
                    break;
                case 2:
                    if (chunks == 0)
                        offset = session.flush(buffer, lb.start, offset - lb.start);

                    b0 = input[inOffset++];
                    b1 = input[inOffset++];
                    buffer[offset++] = nibble2code[(b0 >>> 2) & 0x3f];
                    buffer[offset++] = nibble2code[(b0 << 4) & 0x3f | (b1 >>> 4) & 0x0f];
                    buffer[offset++] = nibble2code[(b1 << 2) & 0x3f];
                    buffer[offset++] = pad;
                    break;

                default:
                    throw new IllegalStateException("should not happen");
            }

            lb.offset = offset;
            return lb;
        }

        encode(input, inOffset, inLen, lb.buffer, lb.offset);
        lb.offset += outputSize;

        return lb;
    }
468713
public static void append(StringBuilder buf, String s, int offset, int length) {
        synchronized (buf) {
            int end = offset + length;
            for (int i = offset; i < end; i++) {
                if (i >= s.length())
                    break;
                buf.append(s.charAt(i));
            }
        }
    }
1072314
@Override
    public V get(String s, int offset, int len) {
        int t = 0;
        for (int i = 0; i < len; i++) {
            char c = s.charAt(offset + i);
            int index = __lookup[c & 0x7f];
            if (index >= 0) {
                int idx = t * ROW_SIZE + index;
                t = _rowIndex[idx];
                if (t == 0)
                    return null;
            } else {
                char[] big = _bigIndex == null ? null : _bigIndex[t];
                if (big == null)
                    return null;
                t = big[c];
                if (t == 0)
                    return null;
            }
        }
        return _value[t];
    }