int next_token( struct char_buffer* cbuff, char* output ) { int i = 0; //clear the leading space while( cbuff->state != CBUFF_EMPTY && cbuffer_peek( cbuff ) == CHAR_SPACE ) { //pop the space cbuffer_pop( cbuff ); } //we have reached the token while( cbuff->state != CBUFF_EMPTY && cbuffer_peek( cbuff ) != CHAR_SPACE ) { output[i++] = cbuffer_pop( cbuff ); } //add the null terminator output[i] = '\0'; return i; }
/* * Files are queued in a list * Get one file from the list */ static FileInfo* file_agent_get_file(void) { ElemType file; if(cbuffer_peek(file_list, &file)) { return NULL; } return (FileInfo*) file; }