Exemplo n.º 1
0
static malValuePtr readForm(Tokeniser& tokeniser)
{
    MAL_CHECK(!tokeniser.eof(), "expected form, got EOF");
    String token = tokeniser.peek();

    MAL_CHECK(!std::regex_match(token, closeRegex),
            "unexpected '%s'", token.c_str());

    if (token == "(") {
        tokeniser.next();
        std::unique_ptr<malValueVec> items(new malValueVec);
        readList(tokeniser, items.get(), ")");
        return mal::list(items.release());
    }
    if (token == "[") {
        tokeniser.next();
        std::unique_ptr<malValueVec> items(new malValueVec);
        readList(tokeniser, items.get(), "]");
        return mal::vector(items.release());
    }
    if (token == "{") {
        tokeniser.next();
        malValueVec items;
        readList(tokeniser, &items, "}");
        return mal::hash(items.begin(), items.end(), false);
    }
    return readAtom(tokeniser);
}
Exemplo n.º 2
0
bool BinTreeNodeReader::nextTreeInternal(ProtocolTreeNode& node, QDataStream &in)
{
    quint8 b;

    in >> b;
    int size = readListSize(b,in);
    in >> b;
    if (b == 2)
        return false;

    QByteArray tag;
    readString(b, tag, in);

    int attribCount = (size - 2 + size % 2) / 2;
    AttributeList attribs;
    readAttributes(attribs,attribCount,in);

    node.setTag(tag);
    node.setAttributes(attribs);

    if ((size % 2) == 1)
        return true;

    in >> b;
    if (isListTag(b))
    {
        readList(b,node,in);
        return true;
    }

    QByteArray data;
    readString(b,data,in);
    node.setData(data);
    return true;
}
Exemplo n.º 3
0
static void readList (char *line) {
  // recursively expand; loops are detected
  if (*line == '@') {
    // line+1 is a list file name
    FILE *f = hlr_fopenRead (line+1);
    int linebuflen;
    char *fline = NULL;
    if (strstr (string (fileNames),line+1))
      die ("loop in @file including at file %s",line+1);
    stringCat (fileNames,line+1);
    stringCat (fileNames,"\001"); // a char not contained in any file name
    while (getLine (f,&fline,&linebuflen)) {
      stripNlGetLength (fline);
      readList (fline);
    }
    hlr_free (fline);
    fclose (f);
  }
  else {
    Seqspec seqspec;

    if (!seqspec_isCommentLine (line) &&
        (seqspec = seqspec_parseLine (line)) != NULL) {
      array (seqspecs,arrayMax (seqspecs),Seqspec) = seqspec_clone (seqspec);
      seqCnt++;
    }
  }
}
Exemplo n.º 4
0
Expression* APLreader::readExpression()
{
    // see if it is a scalar value
    if ((*p_ == '-') && isdigit(*(p_ + 1)))
    {
        p_++;
        return readAPLscalar(-readInteger());
    }

    if (isdigit(*p_))
    {
        return readAPLscalar(readInteger());
    }

    // see if it is a vector constant
    if (*p_ == '(')
    {
        p_++;
        skipNewlines();
        if (isdigit(*p_))
        {
            return readAPLvector(0);
        }
        return readList();
    }

    // else default
    return LispReader::readExpression();
}
Exemplo n.º 5
0
int CSysInfoWidget::ps()
{
	/* Get Processlist from ps*/
	system("ps -A > /tmp/sysinfo");
	/* Get Processlist from ps end*/

	return(readList(sinbuffer));
}
Exemplo n.º 6
0
int CSysInfoWidget::dmesg()
{
	/* Get System-Messages from dmesg*/
	system("dmesg > /tmp/sysinfo");
	/* Get System-Messages from dmesg end*/

	return(readList(sinbuffer));
}
Exemplo n.º 7
0
void SF2Reader::readPdtaList() {
    chunkHeader pdtaList;
    read(pdtaList);
    char pdtaHeader[4];
    readArray(pdtaHeader,4);
    size_t n = pdtaList.chunkSize-4;
    Assert(sizeof(SF2Bank::Rec_bag)==4);
    Assert(sizeof(SF2Bank::Rec_gen)==4);
    Assert(sizeof(SF2Bank::Rec_mod)==10);
    while(n>0) {
        if( n<sizeof(chunkHeader) )
            throw ReadError("pdta-list corrupted");
        chunkHeader item;
        read(item);
        switch(item.id()) {
            case ChunkId::phdr:
                readList(myBank->phdr,item);
                break;
            case ChunkId::pbag:
                readList(myBank->p.bag,item);
                break;
            case ChunkId::pmod:
                readList(myBank->p.mod,item);
                break;
            case ChunkId::pgen:
                readList(myBank->p.gen,item);
                break;     
            case ChunkId::inst:
                readList(myBank->inst,item);
                break;
            case ChunkId::ibag:
                readList(myBank->i.bag,item);
                break;
            case ChunkId::imod:
                readList(myBank->i.mod,item);
                break;
            case ChunkId::igen:
                readList(myBank->i.gen,item);
                break;            
            case ChunkId::shdr: 
                readList(myBank->shdr,item);
                break;
            default:
                Assert(0);
                skip(item.chunkSize);
                break;
        }
        n -= 8 + item.chunkSize;
    }
}
Exemplo n.º 8
0
PulseFileReader::PulseFileReader(string listname) :
  _listFileName(listname),
  _startPulse(PSA_PARSER_PULSE_START),
  _endPulse(PSA_PARSER_PULSE_START+PSA_ARRAY_LEN-1)
{
  readList();
  batchSelectiveReadPulseFiles(0,_pulseFiles.size());

}
Exemplo n.º 9
0
int main()
{
    ListNode *head = readList();
    Solution s;
    head = s.deleteDuplicates(head);
    printList(head);

    return 0;
}
Exemplo n.º 10
0
bool Fingerprint::isTrusted(const QString& fingerprintText)
{
	QStringList list = readList();
	foreach (QString trusted, list)
	{
		if (trusted == fingerprintText) {
			return true;
		}
	}
	return false;
}
Exemplo n.º 11
0
static Object* ReaderReadInternal(Context* ctx, Reader* r) {
  const char* token = r->tokenizer->token;
  Object* result = readNumber(ctx, token);
  if(!result) {
    result = readList(ctx, token, r);
  }
  if(!result) {
    result = readSymbol(ctx, token);
  }

  return result;
}
Exemplo n.º 12
0
int ListSeqsCommand::execute(){
	try {
		
		if (abort) { if (calledHelp) { return 0; }  return 2;	}
		
		//read functions fill names vector
		if (fastafile != "")		{	inputFileName = fastafile;	readFasta();	}
        else if (fastqfile != "")	{	inputFileName = fastqfile;	readFastq();	}
		else if (namefile != "")	{	inputFileName = namefile;	readName();		}
		else if (groupfile != "")	{	inputFileName = groupfile;	readGroup();	}
		else if (alignfile != "")	{	inputFileName = alignfile;	readAlign();	}
		else if (listfile != "")	{	inputFileName = listfile;	readList();		}
		else if (taxfile != "")		{	inputFileName = taxfile;	readTax();		}
        else if (countfile != "")	{	inputFileName = countfile;	readCount();	}
		
		if (m->getControl_pressed()) { outputTypes.clear();  return 0; }
		
		//sort in alphabetical order
		sort(names.begin(), names.end());
		
		if (outputDir == "") {  outputDir += util.hasPath(inputFileName);  }
		
        map<string, string> variables; 
        variables["[filename]"] = outputDir + util.getRootName(util.getSimpleName(inputFileName));
		string outputFileName = getOutputFileName("accnos", variables);

        util.printAccnos(outputFileName, names);
        
		outputNames.push_back(outputFileName); outputTypes["accnos"].push_back(outputFileName);
		
		if (m->getControl_pressed()) { outputTypes.clear();  util.mothurRemove(outputFileName); return 0; }
		
		current->setAccnosFile(outputFileName);
		
		m->mothurOut("\nOutput File Names: \n"); 
		m->mothurOut(outputFileName); m->mothurOutEndLine();	
		m->mothurOutEndLine();
		
		//set accnos file as new current accnosfile
		string currentName = "";
		itTypes = outputTypes.find("accnos");
		if (itTypes != outputTypes.end()) {
			if ((itTypes->second).size() != 0) { currentName = (itTypes->second)[0]; current->setAccnosFile(currentName); }
		}
		
		return 0;		
	}

	catch(exception& e) {
		m->errorOut(e, "ListSeqsCommand", "execute");
		exit(1);
	}
}
Exemplo n.º 13
0
/*
test add node and delete node
*/
void main()
{
  linklist *str =malloc(sizeof(linklist)*10) ;

   int i =0;
   while(i<10)
   {
    str[i].num=i;
    if(i<9)
    str[i].next=&str[i+1];
    i++;
   } 
   
   str[i-1].next=NULL;
   readList(str);
   addNode(str,2,9999);
   readList(str);
   delNode(str,2); 
   readList(str);
   free(str);
}//end main 
Exemplo n.º 14
0
Object * Read::read() {
    int rawChar = this->stream.peek();
    char peekChar = static_cast<char>(rawChar);
    if (peekChar == ')') {
        throw TooManyParents();
    }
    if (peekChar == '(') {
        this->stream.get();
        return readList(this->stream) ;
    }
    return readAtom(this->stream);
}
Exemplo n.º 15
0
QList<Document> TelegramCache::readRecentStickers() const
{
    QList<Document> result;
    const QString filePath = p->path + "/recent-stickers";
    const QList<QVariant> &list = readList(filePath);
    Q_FOREACH(const QVariant &var, list)
    {
        const Document &doc = Document::fromMap( var.toMap() );
        result << doc;
    }
    return result;
}
Exemplo n.º 16
0
void mafGene(char *dbName, char *mafTable, char *geneTable, 
   char *speciesList, char *outName)
/* mafGene - output protein alignments using maf and genePred. */
{
struct slName *speciesNames = readList(speciesList);
FILE *f = mustOpen(outName, "w");
struct genePred *list = NULL;

if (geneList != NULL)
    {
    struct slName *geneNames = readList(geneList);
    for(; geneNames; geneNames = geneNames->next)
	{
	struct genePred *pred = 
	    getPredsForName(geneNames->name, geneTable, dbName);
	if (pred != NULL)
	    slCat(&list, pred);
	}
    }
else if (useFile)
    /* Read genePreds from a file passed instead of a table */
    list = genePredReaderLoadFile(geneTable, NULL);
else if (geneName != NULL)
    list = getPredsForName(geneName, geneTable, dbName);
else if (geneBeds != NULL)
    list = getPredsFromBeds(geneBeds, geneTable, dbName);
else
    list = queryPreds(dbName, geneTable);

for(; list; list = list->next)
    {
    verbose(2, "outting  gene %s \n",list->name);
    outGenePred(f, list, dbName, mafTable, geneTable,  speciesNames);
    if (delay)
	{
	verbose(2, "delaying %d seconds\n",delay);
	sleep(delay);
	}
    }
}
Exemplo n.º 17
0
// -----------------------------------------------------------------
// Name : readAny
// -----------------------------------------------------------------
JoS_Element * JoSon::readAny(std::stringstream * stream)
{
	char nextc = getNextChar(stream);
	switch (nextc) {
	case '{':
		return readMap(stream);
	case '[':
		return readList(stream);
	default:
		streamUnget(stream);
		return readLeaf(stream);
	}
}
Exemplo n.º 18
0
void mafToProtein(char *dbName, char *mafTable, char *frameTable, 
    char *org,  char *speciesList, char *outName)
/* mafToProtein - output protein alignments using maf and frames. */
{
struct slName *geneNames = NULL;
struct slName *speciesNames = readList(speciesList);
FILE *f = mustOpen(outName, "w");

hSetDb(dbName);

newTableType = hHasField(frameTable, "isExonStart");

if (inExons && !newTableType)
    errAbort("must have new mafFrames type to output in exons");

if (geneList != NULL)
    geneNames = readList(geneList);
else if (geneName != NULL)
    {
    int len = strlen(geneName);
    geneNames = needMem(sizeof(*geneNames)+len);
    strcpy(geneNames->name, geneName);
    }
else
    geneNames = queryNames(dbName, frameTable, org);

for(; geneNames; geneNames = geneNames->next)
    {
    verbose(2, "outting  gene %s \n",geneNames->name);
    outGene(f, geneNames->name, dbName, mafTable, 
	frameTable, org, speciesNames);
    if (delay)
	{
	verbose(2, "delaying %d seconds\n",delay);
	sleep(delay);
	}
    }
}
Exemplo n.º 19
0
bool BinTreeNodeReader::nextTreeInternal(ProtocolTreeNode& node)
{
    quint8 b;

    if (!readInt8(b))
        return false;

    int size = -1;
    if (!readListSize(b, size))
        return false;
    if (size < 0)
        return false;

    if (!readInt8(b))
        return false;

    if (b == 2)
        return false;

    QByteArray tag;
    if (!readString(b, tag))
        return false;

    int attribCount = (size - 2 + size % 2) / 2;

    AttributeList attribs;
    if (!readAttributes(attribs,attribCount))
        return false;

    node.setTag(tag);
    node.setAttributes(attribs);

    if ((size % 2) == 1)
        return true;

    if (!readInt8(b))
        return false;

    if (isListTag(b))
    {
        return readList(b,node);
    }

    QByteArray data;
    if (!readString(b,data))
        return false;

    node.setData(data);
    return true;
}
Exemplo n.º 20
0
MessagesDialogs TelegramCache::readDialogs() const
{
    MessagesDialogs result(MessagesDialogs::typeMessagesDialogs);

    const QString filePath = p->path + "/dialogs";
    const QList<QVariant> &list = readList(filePath);
    QList<Dialog> dialogs;

    QHash<QByteArray, Chat> chats;
    QHash<QByteArray, User> users;
    QHash<QByteArray, Message> messages;

    Q_FOREACH(const QVariant &var, list)
    {
        const Dialog &dialog = Dialog::fromMap( var.toMap() );

        const Peer &peer = dialog.peer();
        const QByteArray &key = TelegramTools::identifier(peer);
        switch(static_cast<int>(peer.classType()))
        {
        case Peer::typePeerChannel:
        case Peer::typePeerChat:
            if(!chats.contains(key))
                chats[key] = readChat(peer);
            break;
        case Peer::typePeerUser:
            if(!users.contains(key))
                users[key] = readUser(peer);
            break;
        }

        if(dialog.topMessage())
        {
            QByteArray topMsgKey = TelegramTools::identifier(dialog.peer(), dialog.topMessage());
            const QString &messageFolder = getMessageFolder(peer);
            const QString messageFile = messageFolder + "/" + QString::number(dialog.topMessage());
            messages[topMsgKey] = Message::fromMap( readMap(messageFile) );
        }

        dialogs << dialog;
    }

    result.setDialogs(dialogs);
    result.setChats(chats.values());
    result.setUsers(users.values());
    result.setMessages(messages.values());
    result.setCount(dialogs.count());

    return result;
}
Exemplo n.º 21
0
void WebEventServiceImpl::runMain()
{
    while (!_stopped)
    {
        try
        {
            Poco::Net::Socket::SocketList readList(_socketList);
            Poco::Net::Socket::SocketList writeList;
            Poco::Net::Socket::SocketList exceptList(_socketList);

            Poco::Timespan timeout(5000);
            int n = Poco::Net::Socket::select(readList, writeList, exceptList, timeout);
            if (n > 0)
            {
                for (Poco::Net::Socket::SocketList::iterator it = readList.begin(); it != readList.end(); ++it)
                {
                    SocketMap::iterator its = _socketMap.find(*it);
                    if (its != _socketMap.end())
                    {
                        receive(its->second->pWebSocket);
                        unwatchSocketImpl(*it);
                    }
                }
                for (Poco::Net::Socket::SocketList::iterator it = exceptList.begin(); it != exceptList.end(); ++it)
                {
                    SocketMap::iterator its = _socketMap.find(*it);
                    if (its != _socketMap.end())
                    {
                        removeSubscriberImpl(its->second->pWebSocket, false);
                    }
                }
            }

            Poco::Notification::Ptr pNf = _socketList.empty() ? _mainQueue.waitDequeueNotification() : _mainQueue.dequeueNotification();
            while (pNf)
            {
                TaskNotification::Ptr pTaskNf = pNf.cast<TaskNotification>();
                if (pTaskNf)
                {
                    pTaskNf->execute();
                }
                pNf = _socketList.empty() ? _mainQueue.waitDequeueNotification() : _mainQueue.dequeueNotification();
            }
        }
        catch (Poco::Exception& exc)
        {
            _pContext->logger().error("Exception in main thread: " + exc.displayText());
        }
    }
}
Exemplo n.º 22
0
int main(int argc, char *argv[])
{
  int x,m;
  char *qs;
  entry *entries;
    
  int n;
  char **list,**urls;
  
  /* récupération de la chaîne de paramètres */
  qs = get_query_string(argc,argv);

  /* récupération des couples (nom,valeur) */
  entries = get_entries(qs,&m);

  /* émission de l'entête */
  print_html_head("R&eacute;sultat");

  /* affichage éventuel des informations de debug */
  if (DEBUG) print_debug_query(entries,m,qs,argc,argv);

  /* lecture de la liste des images */
  list = readList("/u/q/quenotg/HMUL8R6A/PROJET/test/list.txt",&n);
  if (list == NULL) {printf("Failed to read %s file.\n","list.txt"); exitfail();}
  if (DEBUG) printf("Read list, %d images.<BR>\n",n);
  
  /* lecture des urls des images */
  urls = readList("/u/q/quenotg/HMUL8R6A/PROJET/test/urls.txt",&n);
  if (list == NULL) {printf("Failed to read %s file.\n","list.txt"); exitfail();}
  if (DEBUG) printf("Read list, %d images.<BR>\n",n);
  
  /* émission de la fin de corps et de document */
  print_html_tail();
    
  exit(0);
}
Exemplo n.º 23
0
static OBJ
readList(OBJ inStream){
	
	int ch;
	OBJ car, cdr;
	
	ch = skipWhiteSpace(inStream);
	if( ch == ')'){
		return js_nil;
	}
	unreadChar(inStream, ch);

	car = js_read(inStream);
	cdr = readList(inStream);
	return newCons(car, cdr);
}
Exemplo n.º 24
0
/// reads the next plist type
/// @param level the level we're currently parsing
QVariant BasePListParser::readNextPlistType( int level )
{
    if( readNextElement("",level) ) {
        // reads a dictionary
        if( xml_->name().compare( "dict", Qt::CaseInsensitive ) == 0 ) {
            return readDict();

        // reads an array
        } else if( xml_->name().compare( "array", Qt::CaseInsensitive ) == 0 ) {
            return readList( );

        // reads a string
        } else if( xml_->name().compare( "string", Qt::CaseInsensitive ) == 0 ) {
            return readElementText();
        }
    }
    return QVariant();
}
void MemorizeStorageSpace::onInit(){
	robotName = "sobit";
	listName = "StorageSpaceList.txt";

	receiveObject = false;
	receiveStorageSpace = false;

	maxObjectNameLength = 0;
	maxStorageSpaceNameLength = 0;

	maxCleanUpCount = 0;

	autoMode = "auto_mode";
	selectMode = "select_mode";

	readList();
	
}
Exemplo n.º 26
0
int seqspec_readList (char *wildseq) {
  /**
     Do EMBOSS-sytle listfile expansion on 'wildseq'.<br>
     Postcondition: seqspec_iterInit() can be called
     @param[in] wildseq - a wildcrd sequence specification
     @return number of sequence-specifing lines recognized
  */
  /*
    in EMBOSS there are two sorts of 'wildcarding':
    (1) thru joker characters (*, ?)
    (2) thru file inclusion (@file)
    this function re-implements the @file resolution
  */
  seqCnt = 0;
  seqspecsInitClear ();
  stringCreateClear (fileNames,100);
  readList (wildseq);
  return seqCnt;
}
Exemplo n.º 27
0
int CSysInfoWidget::cpuinfo()
{
	char Wert1[30];
	char Wert2[10];
	char Wert3[10];
	char Wert4[10];
	char Wert5[6];
	char Wert6[30];

	FILE *f,*w;
	char line[256];
	int i = 0;
	
	/* Get file-info from /proc/cpuinfo*/
	system("df > /tmp/systmp");
	f=fopen("/tmp/systmp","r");
	if(f)
	{
		w=fopen("/tmp/sysinfo","w");
		if(w)
		{
			while((fgets(line,256, f)!=NULL))
			{
				sscanf(line,"%s %s %s %s %s %s ", &Wert1, &Wert2, &Wert3, &Wert4, &Wert5, &Wert6);
				if(i++)
					fprintf(w,"\nFilesystem: %s\n  1-KBlocks: %s\n  Used: %s\n  Free: %s\n  Use%%: %s\nMounted on: %s\n",Wert1,Wert2,Wert3,Wert4,Wert5,Wert6);
			}
			fprintf(w,"\nCPU:\n\n");
			fclose(w);
		}
	}
	fclose(f);
	/* Get file-info from /proc/cpuinfo end*/

	/* Get cpuinfo from /proc/cpuinfo*/
	system("cat /proc/cpuinfo >> /tmp/sysinfo");
	unlink("/tmp/systmp");
	/* Get cpuinfo from /proc/cpuinfo end*/
	
	return(readList(sinbuffer));

}
Exemplo n.º 28
0
static Pointer readForm(Tokeniser* t)
{
    if (tokeniser_eof(t)) {
        return nil_make();
    }

    Pointer ret = tokeniser_token(t);

    // If ret is a string, it's ready to return
    if (ret.type == Type_symbol) {
        const char* token = symbol_get(ret);

        int intValue;
        if (util_streq(token, "(")) {
            tokeniser_next(t);  // consume the '(', read the list and
            return readList(t); // return immediately to avoid hitting the
                                // tokeniser_next() below
        }
        else if (util_streq(token, "nil")) {
            ret = nil_make();
        }
        else if (util_streq(token, "true")) {
            ret = boolean_make(1);
        }
        else if (util_streq(token, "false")) {
            ret = boolean_make(0);
        }
        else if (readInteger(token, &intValue)) {
            ret = integer_make(intValue);
        }
        else {
            // Insert the symbol into the symbol table. We may or may not get
            // the same symbol back.
            ret = symtab_insert(ret);
        }
    }

    PUSH(ret);
    tokeniser_next(t);
    return POP();
}
Exemplo n.º 29
0
Object * Read::readList(std::istream& stream, bool firstTime) {
     Object * first;

    int rawChar = stream.peek();
    char peekChar = static_cast<char>(rawChar);

    cout << peekChar;

    if (peekChar == EOF) throw UnterminatedList();

    if (peekChar == ')') {
        stream.get(peekChar);
        return new Nil();
    }

    if ((not firstTime) and (peekChar == '.')) {
        stream.get(peekChar);

        peekChar = stream.peek();

        if (peekChar == EOF)
            throw LackingCdr();

        Read * toRead = new Read(stream);
        first =  toRead->read();

        peekChar = stream.peek();

        if (peekChar == EOF)
            throw UnterminatedCons();
        if (not (peekChar == ')'))
            throw TooMuchInCdr() ;

        stream.get(peekChar);
        return first;
    }
    Read * toRead = new Read(stream);
    first =  toRead->read();
    Doublet * doublet = new Doublet(first, readList(stream, false));
    return doublet;
}
Exemplo n.º 30
0
static Pointer readList(Tokeniser* t)
{
    if (tokeniser_eof(t)) {
        THROW("Expected ), got EOF");
    }

    Pointer token = tokeniser_token(t);
    if ((token.type == Type_symbol) && util_streq(symbol_get(token), ")")) {
        tokeniser_next(t);
        return nil_make();
    }

    StackIndex carIndex = PUSH(readForm(t));
    StackIndex cdrIndex = PUSH(readList(t));

    Pointer ret = pair_make(carIndex, cdrIndex);

    DROP(2);

    return ret;
}