static bool isCommand(const QString &str, const CommandIdType cmd)
{
    switch (cmd) {
    case CommandIdType::NORTH:
    case CommandIdType::SOUTH:
    case CommandIdType::EAST:
    case CommandIdType::WEST:
    case CommandIdType::UP:
    case CommandIdType::DOWN:
    case CommandIdType::FLEE:
        return isCommand(str, Abbrev{getLowercase(cmd), 1});

    case CommandIdType::SCOUT:
        return isCommand(str, Abbrev{getLowercase(cmd), 2});

    case CommandIdType::LOOK:
        return isCommand(str, Abbrev{getLowercase(cmd), 1}) || isCommand(str, Abbrev{"examine", 3});

    case CommandIdType::UNKNOWN:
    case CommandIdType::NONE:
        return false;
    }

    return false;
}
Example #2
0
unsigned int parseInput(struct directory* cluster, unsigned char* buffer, 
		unsigned int FDS, unsigned int SPC, unsigned int RSC,
		unsigned int BPS, char* PWD, char* command)
{
	char* args = (char*)calloc(sizeof(char),64);
	int return_val;	

	getc(stdin); //ignore space
	fgets(args,64,stdin);
	removeTrailingNewline(args);
	return_val = isCommand(cluster,buffer,FDS,SPC,RSC,BPS,command,args);
	if(return_val){
		switch(return_val){
			case 2:{
				presentWorkingDirectory(ADD,args);
				break;}
			case 3:{
				presentWorkingDirectory(SUB,"");
				break;}
		}
	}else{
		printf("%s is not a valid command\n",command);
	}
	return currentClusterNumber(GET,0);

}
Example #3
0
int getop(char s [])
{
	int c, res;
	while ((s[0] = c = getch()) == ' ' || c == '\t');

	s[1] = '\0';

	if (isCommand(s))
		return COMMAND;
	res = isNumber(s);
	if (res)
		return res;
	if (isAssigner(s))
		return ASSIGNER;
	if (isVariable(s))
		return VARIABLE;
	if (isOperator(s))
		return OPERATOR;
	res = isFunction(s);
	if (res)
		return res;
	if (s[0] == '\n')
		return '\n';
	if (c == EOF)
		return EOF;
	return ERROR;
}
Example #4
0
QString CronSegment::toString() const {
    QString str;

    if (isCommand())
        return command;

    for(int i=0; i<singles.size(); i++) {
        str.append(QVariant(singles[i]).toString());
        if (i < singles.size()-1)
            str.append(',');
    }

    if (not time_spans.isEmpty())
        str.append(',');

    for(int i=0; i<time_spans.size(); i++) {
        str.append(time_spans[i].toString());
        if (i < time_spans.size()-1)
            str.append(',');
    }

    if (glob) {
        if (not str.isEmpty()) str.append(',');
        str.append('*');
    }

    if (repeater != 0)
        str.append(QString("/%1").arg(repeater));

    return str;
}
Example #5
0
uint8_t respondToIbusRequest(uint8_t const * const ibusPacket)
{
    ibusAddress_t returnAddress = getAddress(ibusPacket);
    autodetectFirstReceivedAddressAsBaseAddress(returnAddress);

    if (theAddressIsWithinOurRange(returnAddress)) {
        if (isCommand(IBUS_COMMAND_DISCOVER_SENSOR, ibusPacket)) {
            return sendIbusDiscoverSensorReply(returnAddress);
        } else if (isCommand(IBUS_COMMAND_SENSOR_TYPE, ibusPacket)) {
            return sendIbusSensorType(returnAddress);
        } else if (isCommand(IBUS_COMMAND_MEASUREMENT, ibusPacket)) {
            return dispatchMeasurementReply(returnAddress);
        }
    }

    return 0;
}
bool ConsoleCommandParser::performParsing(const NetworkId & /* track */, const StringVector_t & argv, const String_t &, String_t & result, const CommandParser *)
{
	bool successResult = false;

	if(isCommand(argv[0], "planet"))
	{
		if(argv.size() > 2)
		{
			if(isCommand(argv[2], "runState"))
			{
				successResult = true;
				result += Unicode::narrowToWide("running");
			}
		}
	}
		
	return successResult;
}
StatusWith<OplogApplier::Operations> OplogApplier::getNextApplierBatch(
    OperationContext* opCtx, const BatchLimits& batchLimits) {
    if (batchLimits.ops == 0) {
        return Status(ErrorCodes::InvalidOptions, "Batch size must be greater than 0.");
    }

    std::uint32_t totalBytes = 0;
    Operations ops;
    BSONObj op;
    while (_oplogBuffer->peek(opCtx, &op)) {
        auto entry = OplogEntry(op);

        // Check for oplog version change. If it is absent, its value is one.
        if (entry.getVersion() != OplogEntry::kOplogVersion) {
            std::string message = str::stream()
                << "expected oplog version " << OplogEntry::kOplogVersion << " but found version "
                << entry.getVersion() << " in oplog entry: " << redact(entry.toBSON());
            severe() << message;
            return {ErrorCodes::BadValue, message};
        }

        // Commands must be processed one at a time. The only exception to this is applyOps because
        // applyOps oplog entries are effectively containers for CRUD operations. Therefore, it is
        // safe to batch applyOps commands with CRUD operations when reading from the oplog buffer.
        if (entry.isCommand() && (entry.getCommandType() != OplogEntry::CommandType::kApplyOps ||
                                  entry.shouldPrepare())) {
            if (ops.empty()) {
                // Apply commands one-at-a-time.
                ops.push_back(std::move(entry));
                BSONObj opToPopAndDiscard;
                invariant(_oplogBuffer->tryPop(opCtx, &opToPopAndDiscard));
                dassert(ops.back() == OplogEntry(opToPopAndDiscard));
            }

            // Otherwise, apply what we have so far and come back for the command.
            return std::move(ops);
        }

        // Apply replication batch limits.
        if (ops.size() >= batchLimits.ops) {
            return std::move(ops);
        }

        // Never return an empty batch if there are operations left.
        if ((totalBytes + entry.getRawObjSizeBytes() >= batchLimits.bytes) && (ops.size() > 0)) {
            return std::move(ops);
        }

        // Add op to buffer.
        totalBytes += entry.getRawObjSizeBytes();
        ops.push_back(std::move(entry));
        BSONObj opToPopAndDiscard;
        invariant(_oplogBuffer->tryPop(opCtx, &opToPopAndDiscard));
        dassert(ops.back() == OplogEntry(opToPopAndDiscard));
    }
    return std::move(ops);
}
Example #8
0
AutoGetCollectionForRead::~AutoGetCollectionForRead() {
    // Report time spent in read lock
    auto currentOp = CurOp::get(_txn);
    Top::get(_txn->getClient()->getServiceContext())
        .record(currentOp->getNS(),
                currentOp->getOp(),
                -1,  // "read locked"
                _timer.micros(),
                currentOp->isCommand());
}
Example #9
0
OplogEntry::OplogEntry(BSONObj rawInput) : raw(std::move(rawInput)) {
    raw = raw.getOwned();

    parseProtected(IDLParserErrorContext("OplogEntryBase"), raw);

    // Parse command type from 'o' and 'o2' fields.
    if (isCommand()) {
        _commandType = parseCommandType(getObject());
    }
}
Example #10
0
    void Request::process( int attempt ) {
        init();
        int op = _m.operation();
        assert( op > dbMsg );

        if ( op == dbKillCursors ) {
            cursorCache.gotKillCursors( _m );
            return;
        }


        log(3) << "Request::process ns: " << getns() << " msg id:" << (int)(_m.header()->id) << " attempt: " << attempt << endl;

        Strategy * s = SINGLE;
        _counter = &opsNonSharded;

        _d.markSet();

        if ( _chunkManager ) {
            s = SHARDED;
            _counter = &opsSharded;
        }

        bool iscmd = false;
        if ( op == dbQuery ) {
            iscmd = isCommand();
            try {
                s->queryOp( *this );
            }
            catch ( StaleConfigException& staleConfig ) {
                log() << staleConfig.what() << " attempt: " << attempt << endl;
                uassert( 10195 ,  "too many attempts to update config, failing" , attempt < 5 );
                ShardConnection::checkMyConnectionVersions( getns() );
                if (!staleConfig.justConnection() )
                    sleepsecs( attempt );
                reset( ! staleConfig.justConnection() );
                _d.markReset();
                process( attempt + 1 );
                return;
            }
        }
        else if ( op == dbGetMore ) {
            s->getMore( *this );
        }
        else {
            char cl[256];
            nsToDatabase(getns(), cl);
            uassert(15845, "unauthorized", _clientInfo->getAuthenticationInfo()->isAuthorized(cl));

            s->writeOp( op, *this );
        }

        globalOpCounters.gotOp( op , iscmd );
        _counter->gotOp( op , iscmd );
    }
Example #11
0
AutoStatsTracker::~AutoStatsTracker() {
    auto curOp = CurOp::get(_opCtx);
    Top::get(_opCtx->getServiceContext())
        .record(_opCtx,
                curOp->getNS(),
                curOp->getLogicalOp(),
                _lockType,
                durationCount<Microseconds>(curOp->elapsedTimeExcludingPauses()),
                curOp->isCommand(),
                curOp->getReadWriteType());
}
Example #12
0
void adjustSizes(char** argv, int argc,
				 size_t& commandsSize, size_t& filesSizes)
{
	for (int word = 1; word < argc; ++word)
	{
		if (isPath(argv[word]))
			filesSizes++;
		else if (isCommand(argv[word]))
			commandsSize++;
	}
}
Example #13
0
ChatCommandContext::ChatCommandContext(const tstring& s) {
  dcassert(isCommand(s));
  const string::size_type i = s.find(' ');
  if (i != string::npos) {
    param = s.substr(i + 1);
    command = s.substr(1, i - 1);
  } 
  else {
    command = s.substr(1);
  }
}
Example #14
0
SCgObject* SCgMainWindow::resolveUri(const ScUri &uri)
{
    // trying to find scg-object with uri
    const SCgObject::SCgObjectList& list = SCgObject::objectsByScUri(uri);

    //! TODO: resolve situation with multiply
    if (!list.empty()) return list.front();

    UiRootInterface *root = SCgPlugin::rootInterface();

    ScMemoryInterface *memory = root->scMemory();
    SCgObject *res = 0;

    // get element type and create scg-object
    ScElementType type = memory->get_el_type(uri);

    // create new scg-object
    if (type.check(ScNode))
    {
        // check if it a command
        if (isCommand(uri))
        {
            SCgControl *control = mScene->construction()->createControl();
            res = control;
        }else
        {
            SCgNode *node = mScene->construction()->createNode();
            res = node;
        }
    }else
        if (type.check(ScArcMask))
        {

        }else
            if (type.check(ScLink))
            {

            }

    // setup identifier
    QString idtf_value = root->scHelper()->stringIdtf(uri, root->currentLanguage());
    if (!idtf_value.isEmpty())
        res->setIdentifier(idtf_value);

    if (res != 0)
    {
        res->setUri(uri);
        res->setObjectType(type);
    }



    return res;
}
Example #15
0
int processMgmt(Array command){
  pid_t process = fork();
  if (process<0){
    return (int)process;
  }
  else if (process==0){
    if (command.c[0].str[0]!='/'){
      //Relative path
      char *pathList = getenv("PATH");
      char *path = strtok(pathList,":");
      char *temp;
      do{
        temp = malloc(sizeof(char)*(command.c[0].length+strlen(path)));
        temp = strcpy(temp,path);
        strcat(temp,"/");
        strcat(temp,command.c[0].str);
      } while (!isCommand(temp) && (path=strtok(NULL,":"))!=NULL );
      
      if (path!=NULL){
        command.c[0].str = temp;
      }
    }
    
    int argc=command.length+1;
    if (isBooleanOperator(command.c[command.length-1].str)){
      argc--;
    }
    
    {
      char *args[argc];
      int i;
      
      for (i=0;i<argc-1;i++){
        args[i]=command.c[i].str;
      }
      args[i]=0;
      
      int status = execve(command.c[0].str,args,environ);
    }
    
    write(0,command.c[0].str,command.c[0].length);
    write(0,": command not found\n",20);
    
    exit(-1);
  }
  else if (process>0){
    int status;
    waitpid(process,&status,0);
    
    return status;
  }
  
  return -1;
}
bool ConsoleCommandParser::performParsing(const NetworkId &, const StringVector_t & argv, const String_t &, String_t & result, const CommandParser *)
{
    bool successResult = false;

    if(isCommand(argv[0], "runState"))
    {
        result += Unicode::narrowToWide("running");
        successResult = true;
    }

    return successResult;
}
Example #17
0
OldClientContext::~OldClientContext() {
    // Lock must still be held
    invariant(_txn->lockState()->isLocked());

    auto currentOp = CurOp::get(_txn);
    Top::get(_txn->getClient()->getServiceContext())
        .record(currentOp->getNS(),
                currentOp->getOp(),
                _txn->lockState()->isWriteLocked() ? 1 : -1,
                _timer.micros(),
                currentOp->isCommand());
}
Example #18
0
int noArgCommand(token **ptr, const char *com) {
	token *now = *ptr;
	if (!now || !isCommand(now, com)) {
		return 0;
	}
	now = now->next;
	if (!now || now->type != CRLF) {
		return 0;
	}
	*ptr = now;
	return 1;
}
//
// function that disgtinguish commands from files
// save the commands in char** commands array
// save the file and their paths in char** pathsToFiles array
//
void ConsoleInput::distinguishConsoleInput(int argc, char* argv[]) {
	int counterCommands = 0;
	int counterFiles = 0;

	for (int i = 1; i < argc; i++) {
		if (isCommand(argv[i])) {
			counterCommands++;
		}
		else {
			counterFiles++;
		}
	}

	this->numberFiles = counterFiles;
	this->numberCommands = counterCommands;

	this->commands = new char*[this->numberCommands];
	this->pathsToFiles = new char*[this->numberFiles];

	int indexCommands = 0;
	int indexFiles = 0;

	for (int i = 1; i < argc; i++) {
		size_t buffSize = strlen(argv[i]) + 1;

		if (isCommand(argv[i])) {
			buffSize -= 2;
			this->commands[indexCommands] = new char[buffSize];
			strcpy_s(this->commands[indexCommands], buffSize, argv[i] + 2);
			indexCommands++;
		}
		else {
			this->pathsToFiles[indexFiles] = new char[buffSize];
			strcpy_s(this->pathsToFiles[indexFiles], buffSize, argv[i]);
			indexFiles++;
		}
	}

	reOrderHtmlCommand();
}
Example #20
0
/*
  returns number of bytes consumed
*/
int QtTelnetPrivate::parseIAC(const QByteArray &data)
{
    if (data.isEmpty())
        return 0;

    Q_ASSERT(uchar(data.at(0)) == Common::IAC);

    if (data.size() >= 3 && isOperation(data[1])) { // IAC, Operation, Option
        const uchar operation = data[1];
        const uchar option = data[2];
        if (operation == Common::WONT && option == Common::Logout) {
            q->close();
            return 3;
        }
        if (operation == Common::DONT && option == Common::Authentication) {
            if (loginp.isEmpty() && passp.isEmpty())
                emit q->loggedIn();
            nullauth = true;
        }
        if (replyNeeded(operation, option)) {
            bool allowed = allowOption(operation, option);
            sendCommand(opposite(operation, allowed), option);
            setMode(operation, option);
        }
        return 3;
    }
    if (data.size() >= 2 && isCommand(data[1])) { // IAC Command
        return 2;
    }

    QByteArray suboption = getSubOption(data);
    if (suboption.isEmpty())
        return 0;

    // IAC SB Operation SubOption [...] IAC SE
    switch (suboption[0]) {
    case Common::Authentication:
        parseSubAuth(suboption);
        break;
    case Common::TerminalType:
        parseSubTT(suboption);
        break;
    case Common::NAWS:
        parseSubNAWS(data);
        break;
    default:
        qWarning("QtTelnetPrivate::parseIAC: unknown suboption %d",
                 quint8(suboption.at(0)));
        break;
    }
    return suboption.size() + 4;
}
Example #21
0
int getop(char s [])
{
	int i, c;
	int nextChar;
	while ((s[0] = c = getch()) == ' ' || c == '\t');
	s[1] = '\0';

	if (isNumber(s))
		return NUMBER;
	if (isCommand(s))
		return COMMAND;
	return c;
}
Example #22
0
void recordStatsForTopCommand(OperationContext* txn) {
    auto curOp = CurOp::get(txn);
    const int writeLocked = 1;

    Top::get(txn->getClient()->getServiceContext())
        .record(txn,
                curOp->getNS(),
                curOp->getLogicalOp(),
                writeLocked,
                curOp->elapsedMicros(),
                curOp->isCommand(),
                curOp->getReadWriteType());
}
Example #23
0
/**
 * Attempts to interpret a 'command'.  These appear in the file as
 * $$[command-name] [options]
 *
 * Returns true on success, false on error, and puts resulting elements
 * into the 'target' buffer.
 *
 * If the commands are instructions to the interpreter, these are processed
 * frmo this function as well.
 */
bool MathInterpreter::interpretCommand (MDEVector &target,
					const std::string &src,
					size_t &i)
{
  // We should only be attempting this if this is the very start of a line of
  // text.
  assert (m_isStartOfLine == true);

  if (src.substr(i, 2) != "$$")
    return false;

  i += 2;
  std::string commandName, commandParameters;

  // Handle $$+EnableMoreFeatures and $$-EnableMoreFeatures.  Include a
  // trailing space in case more parameters show up below
  if (src [i] == '+') {
    commandParameters = "true ";
    i++;
  } else if (src [i] == '-') {
    commandParameters = "false ";
    i++;
  }

  // Grab the command name
  while (i < src.length() && isalpha(src [i])) {
    commandName += src[i];
    i++;
  }

  // Grab the parameters, if there are any, to EOL.  If there is already
  // a parameter there, add a space after it.
  while (i < src.length()) {
    commandParameters += src[i];
    i++;
  }
  boost::trim(commandParameters);

  if (!isCommand(commandName)) {
    LOG_TRACE << "* found unrecognized command: " << commandName << " // " << commandParameters;
    MSG_ERROR(UNKNOWN_COMMAND, boost::str(boost::format("'%s'") % commandName));
    BOOST_THROW_EXCEPTION (MathInterpreterException());

  }
  LOG_TRACE << "* found command: " << commandName << " // " << commandParameters;

  MathDocumentElementPtr e = boost::make_shared<MDE_Command>(commandName, commandParameters);

  target.push_back (e);
  return true;
}
Example #24
0
    void Request::process( int attempt ) {
        init();
        int op = _m.operation();
        verify( op > dbMsg );

        if ( op == dbKillCursors ) {
            cursorCache.gotKillCursors( _m );
            return;
        }

        int msgId = (int)(_m.header()->id);

        Timer t;
        LOG(3) << "Request::process begin ns: " << getns()
               << " msg id: " << msgId
               << " op: " << op
               << " attempt: " << attempt
               << endl;

        Strategy * s = SHARDED;
        _counter = &opsNonSharded;

        _d.markSet();

        bool iscmd = false;
        if ( op == dbQuery ) {
            iscmd = isCommand();
            if (iscmd) {
                SINGLE->queryOp(*this);
            }
            else {
                s->queryOp( *this );
            }
        }
        else if ( op == dbGetMore ) {
            s->getMore( *this );
        }
        else {
            s->writeOp( op, *this );
        }

        LOG(3) << "Request::process end ns: " << getns()
               << " msg id: " << msgId
               << " op: " << op
               << " attempt: " << attempt
               << " " << t.millis() << "ms"
               << endl;

        globalOpCounters.gotOp( op , iscmd );
        _counter->gotOp( op , iscmd );
    }
Example #25
0
OldClientContext::~OldClientContext() {
    // Lock must still be held
    invariant(_opCtx->lockState()->isLocked());

    auto currentOp = CurOp::get(_opCtx);
    Top::get(_opCtx->getClient()->getServiceContext())
        .record(_opCtx,
                currentOp->getNS(),
                currentOp->getLogicalOp(),
                _opCtx->lockState()->isWriteLocked() ? Top::LockType::WriteLocked
                                                     : Top::LockType::ReadLocked,
                _timer.micros(),
                currentOp->isCommand(),
                currentOp->getReadWriteType());
}
Example #26
0
void execCommand(char* command) {
    // Interpret the user command
    if(isCommand("boot\0", command)) {
        interrupt(33, 11, 0, 0, 0);
    }
    else if(isCommand("cls\0", command)) {
        interrupt(33, 12, 4, 11, 0);
    }
    else if(isCommand("dir\0", command)) {
        printDir();
    }
    else if(isCommand("copy\0", command)) {
        copy(command + 5);
    }
    else if(isCommand("del\0", command)) {
        delete(command + 4);
    }
    else if(isCommand("echo\0", command)) {
        echo(command + 5);
    }
    else if(isCommand("type\0", command)) {
        type(command + 5);
    }
    else if(isCommand("run\0", command)) {
        run(command + 4);
    }
    else if(isCommand("tweet\0", command)) {
        tweet(command + 6);
    }
    else if(isCommand("help\0", command)) {
        help();
    }
    else {
        commandNotRecognized();
    }
}
Example #27
0
void Preprocessor::parse(const char* name, const char* text)
{
  if (std::find(names.begin(), names.end(), name) != names.end())
    return;

  files.push_back(File(name, text));
  names.push_back(name);

  list += format("( file %u: %s )\n", (uint) names.size(), name);

  output.reserve(output.size() + std::strlen(text));
  appendToOutput(format("#line 0 %u /* entering %s */\n",
                        (uint) files.size(),
                        files.back().name).c_str());

  while (hasMore())
  {
    if (isMultiLineComment())
      parseMultiLineComment();
    else if (isSingleLineComment())
      parseSingleLineComment();
    else if (isNewLine())
      parseNewLine();
    else if (isWhitespace())
      parseWhitespace();
    else if (isCommand())
      parseCommand();
    else
    {
      advance(1);
      appendToOutput();
      setFirstOnLine(false);
    }
  }

  files.pop_back();

  if (!files.empty())
  {
    appendToOutput(format("\n#line %u %u /* returning to %s */",
                          files.back().line,
                          (uint) files.size(),
                          files.back().name).c_str());
  }
}
Example #28
0
    void Request::process( int attempt ) {
        init();
        int op = _m.operation();
        assert( op > dbMsg );

        if ( op == dbKillCursors ) {
            cursorCache.gotKillCursors( _m );
            return;
        }


        MONGO_LOG(3) << "Request::process ns: " << getns() << " msg id:" << (int)(_m.header()->id) << " attempt: " << attempt << endl;

        Strategy * s = SHARDED;
        _counter = &opsNonSharded;

        _d.markSet();

        bool iscmd = false;
        if ( op == dbQuery ) {
            try {
                iscmd = isCommand();
                s->queryOp( *this );
            }
            catch ( RecvStaleConfigException& stale ) {
                _d.markReset();
                log( attempt == 0 ) << "got RecvStaleConfigException at top level: " << stale.toString() << " attempt: " << attempt << endl;
                massert( 16062 , "too many attemps to handle RecvStaleConfigException at top level" , attempt <= 5 );
                process( attempt + 1 );
                return;
            }
        }
        else if ( op == dbGetMore ) {
            checkAuth( Auth::READ ); // this is important so someone can't steal a cursor
            s->getMore( *this );
        }
        else {
            checkAuth( Auth::WRITE );
            s->writeOp( op, *this );
        }

        globalOpCounters.gotOp( op , iscmd );
        _counter->gotOp( op , iscmd );
    }
Example #29
0
File: main.c Project: orls/Tigger
int main (int argc, char * argv[]) {
	loadCommands();

        /* option parsing */
        int c = 0;
        int option_index = 0;

        while ((c = getopt_long(argc, argv, "cf", long_options, &option_index)) != -1)
        {
                switch (c)
                {
                        case 0: /* longopt detected */
                                break;
                        case 'c': /* short option, color enabled */
                                COLOR_FLAG = 1;
                                break;
                        case 'f':
                                FORCE_FLAG = 1;
                                break;
                        default:
                                fprintf(stdout, "Unknown option code %d\n", c);
                                printUsage();
                                return EXIT_FAILURE;
                }
        }

        /* argument loop */
	if(optind < argc && argv[optind] && isCommand(argv[optind])){
		//then we want to process the command
		if (!processCommand(argv, optind)){
			if (COLOR_FLAG)
                                fprintf_red(stdout, "Your command was not processed.\n");
                        else
                                printf("Your command was not processed.\n");
		}
	}else{
		printUsage();
	}
    return 0;
}
Example #30
0
int oneStrArgCommand(token **ptr, const char *com) {
	token *now = *ptr;
	
	if (!now || !isCommand(now, com)) {
		return 0;
	}
	now = now->next;
	if (!now || now->type != SPACE) {
		return 0;
	}
	now = now->next;
	if (!now || !strings(now)) {
		return 0;
	}
	if (!now || now->type != CRLF) {
		return 0;
	}
	now = now->next;

	*ptr = now;
	return 1;
}