int _cdk_filter_text( void * opaque, int ctl, FILE * in, FILE * out ) { if( ctl == STREAMCTL_READ ) return text_encode( opaque, in, out ); else if( ctl == STREAMCTL_WRITE ) return text_decode( opaque, in, out ); else if( ctl == STREAMCTL_FREE ) { text_filter_t * tfx = opaque; if( tfx ) { _cdk_log_debug( "free text filter\n" ); tfx->lf = NULL; } } return CDK_Inv_Mode; }
void YumScriptJob::process(){try{ rwfile rw(QString("scripts/%1.src").arg(number)); TASSUME(rw.issue.isEmpty(),rw.issue); ImasScript script(&rw); TASSUME(script.issue.isEmpty(),QString("scripts/%1.src: %2").arg(number).arg(script.issue)); ImasScriptText text(file); TASSUME(text.issue.isEmpty(),text.issue); int lineno=0; for(int i=0;i<script.nodes.count();i++){ QString errstr; ImasScriptNode *node=script.nodes.value(i); if(node->group==SCIPT_GROUP_TEXT){ if(text.lines.count()<=lineno){ issue="Not enough lines in script file you supplied"; state=JOB_STATE_FAILED; return; } node->text=text_encode(text.line(lineno),&errstr); if(!errstr.isEmpty()){ output.append(QString("line %1: couldn't encode text: %2") .arg(text.lineno(lineno)) .arg(errstr)); } lineno++; } else if(node->group>=SCIPT_GROUP_NAME){ int nameno=node->group-SCIPT_GROUP_NAME; if(text.names.count()<nameno){ issue="Not enough names in script file you supplied"; state=JOB_STATE_FAILED; return; } node->text=text_encode(text.name(nameno),&errstr); if(!errstr.isEmpty()){ output.append(QString("Couldn't encode name ``%1'': %2") .arg(text.name(nameno)) .arg(errstr)); } } } if(text.lines.count()!=lineno) output.append("Too many lines in script file you supplied"); QByteArray bytes=script.spit(); TASSUME(script.issue.isEmpty(),script.issue); Yum y(isofile,number); TASSUME(y.issue.isEmpty(),y.issue); y.spit(bytes.data(),bytes.size()); TASSUME(y.issue.isEmpty(),y.issue); if(output.isEmpty()){ state=JOB_STATE_OK; } else{ state=JOB_STATE_WARNINGS; } } catch(QString ss){ state=JOB_STATE_FAILED; }}