CVS::log_err CVS::write(bool print, const string fmt, ...) { va_list args; va_start(args, fmt); if (makeLog(print, fmt.c_str(), args) == LOG_ERR) { va_end(args); return LOG_ERR; } va_end(args); return LOG_OK; }
Logger::log_err Logger::warn(bool print, const string TAG, const string fmt, ...) { if (loggingSwitch) { va_list args; va_start(args, fmt); if (makeLog(print, TAG, WARN, fmt.c_str(), args) == LOG_ERR) { va_end(args); return LOG_ERR; } va_end(args); } return LOG_OK; }
void drawShapes (TGraph ** tg_sample_par, int Npar) { TGraph * log_tg_sample_par0 = makeLog (tg_sample_par[0]) ; //PG loop on candidate masses for (double mass = 300 ; mass < 1100 ; mass += 25) { TF1 * func = new TF1 ("func",crystalBallLowHigh, 200, 2000, 7) ; func->SetParameter (0, TMath::Exp (log_tg_sample_par0->Eval (mass))) ; for (int iPar = 1 ; iPar < Npar ; ++iPar) func->SetParameter (iPar, tg_sample_par[iPar]->Eval (mass)) ; func->SetLineWidth (1) ; func->SetLineColor (kBlue + 1) ; func->SetNpx (10000) ; func->Draw ("same") ; } //PG loop on candidate masses return ; }
int main() { FILE *fp; FILE *fp2; char* file_name = "students.txt"; char* file_name2 = "log.txt"; int studentId; char name[30]; char class[10]; char department[10]; int r; StudentNode temp; StudentNode* result; int i; int loop; int userChoice; //Initialize index array for (i = 0; i<20; i++) { indexArray[i].r = i; indexArray[i].node = NULL; cur[i] = NULL; } printf("Begin of program\n\n"); //Try to open file to read if ((fp = fopen(file_name, "r")) == NULL) { printf("No such file\n"); exit(1); } //Add students to their corespoding indexes while (fscanf(fp, "%d:%[^:]:%[^:]:%[^:\n]", &studentId, name, class, department) == 4) { addStudent(studentId, name, class, department); } //Link indexes together linkIndexes(); //Menu loop = 1; while (loop) { printf ("******************************\n* What do you wanna do? *\n* 1- Add student *\n* 2- Delete student *\n* 3- Find student *\n* 4- Edit student *\n* 5- Student list *\n* 6- Exit *\n******************************"); printf("\nYour choice: "); scanf("%d%*c", &userChoice); switch (userChoice) { case 1: studentId = askForId(); temp = findStudentById(studentId); if (temp == NULL) { strcpy(name, askForName()); strcpy(class, askForClass()); strcpy(department, askForDepartment()); addStudent (studentId, name, class, department); linkIndexes(); addStudentToFile(studentId, name, class, department, file_name); makeLog(studentId, "APPEND", file_name2); printf("Add success!\n"); } else printf("ID already existed!\n"); break; case 2: studentId = askForId(); if (deleteStudent(studentId) == 1) { deleteStudentFromFile(studentId, file_name); makeLog(studentId, "DELETE", file_name2); printf("Delete success!\n"); } else printf("Can't find any student with given ID!\n"); break; case 3: printf("\nFind by which criteria?\n1- Student ID\n2- Name\n3- Class\n4- Department\n5- Back to menu\nYour choice: "); scanf("%d%*c", &userChoice); switch (userChoice) { case 1: studentId = askForId(); temp = findStudentById(studentId); printf("\nResult:\n"); if (temp != NULL) { printf("%-10d | %-30s | %-10s | %-10s\n", temp->studentId, temp->name, temp->class, temp->department); } else
/* Fonction qui interprete une requette passee en parametre dans input, fournit le chemin du fichier demandé dans path, fournit le header dans output, index précise s'il faut conserver la connection dans keep_alive (0/1) */ static int interpreter(client_t *client, int *index, int *keep_alive, char *encoding, int *endRequete) { request_t requete = {0, {0}, {0}, client->ip, {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, 0, 0, 0, 0, 0}; reponse_t reponse = {200, {0}, {NULL, 0, 0}, 0, 10}; reponse.header = bufinit(&reponse.header, BUFFER_SIZE, " 200 OK", 9); reponse.header.use = 9; reponse.time = time(NULL); #ifndef NDEBUG printf("<interpreter> requete entrante :\n'%s'\n", client->requete.ptr); #endif int ret = decode(&client->requete, &requete); if(ret != 0){ erreur(ret, &reponse); } if(requete.method == 1){ // GET getVarGET(&requete, &client->vars); }else if(requete.method == 3){ // POST int size = min(requete.content_length, client->requete.use - *endRequete); bufstrcpy(&client->vars, client->requete.ptr+(*endRequete), size); } printf("variables : %s\n", client->vars.ptr); /* Validation du path */ if(valider_path(&requete, &reponse)){ erreur(404, &reponse); } struct stat file_stat; if(reponse.code == 200){ if(stat(requete.path, &file_stat) == -1){ perror("stats"); erreur(500, &reponse); } } /*droit de lecture */ if(reponse.code == 200){ if(!valider_access(file_stat.st_mode)){ erreur(403, &reponse); } } /* Authentification */ if(reponse.code == 200){ if(passFileExistInDir(requete.path)){ char login[30] = {0}; char password[15] = {0}; if(!getAuthorization(requete.authorization, login, password) && !getLoginAndPassword(requete.query, login, password)){ erreur(401,&reponse); requete.keep_alive = 0; }else{ char pass_path[SMALL_BUFF]; getPassFilePath(requete.path,pass_path,isDir(&file_stat)); if(!authentifier(login,password,pass_path)){ erreur(401,&reponse); requete.keep_alive = 0; } } } /* Get content type*/ getContentType(&requete, &reponse, &file_stat); if(requete.method == 2){ *index = 4; // methode HEAD }else{ *index = requete.index; } } bufstrcpy(&client->path, requete.path, strlen(requete.path)); /* On creer le header dans output */ encoder(&client->reponse, &reponse, &requete); if(strlen(requete.encoding) > 0){ get_encoding(requete.encoding,encoding); } makeLog(&requete,&reponse); *keep_alive = requete.keep_alive; *endRequete += requete.content_length; bufkill(&reponse.header); return reponse.code; }
void testInterpolation (TGraph ** tg_sample_par, TString sample, int Npar) { //PG testing sets for the test TGraph ** tg_test_par = new TGraph * [7] ; // [parameter][mass] for (int k = 0 ; k < Npar ; ++k) tg_test_par[k] = new TGraph (4) ; TCanvas * c_merge = new TCanvas () ; bkg = (TH1F *) c_merge->DrawFrame (200, 0.0000001, 1500, 0.002) ; // c_merge->SetLogy () ; bkg->GetXaxis ()->SetTitle ("m_{WW}") ; bkg->GetYaxis ()->SetTitle ("signal") ; //PG loop on the point to be removed for (int iTest = 0 ; iTest < 5 ; ++iTest) { cout << " ==== iTest " << iTest << endl ; int iActualMass = 0 ; //PG fill the temporary graphs for (int iMass = 0 ; iMass < 5 ; ++iMass) { if (iMass == iTest) continue ; double x = 0 ; double y = 0 ; for (int k = 0 ; k < 7 ; ++k) { tg_sample_par[k]->GetPoint (iMass, x, y) ; tg_test_par[k]->SetPoint (iActualMass, x, y) ; } ++iActualMass ; } //PG fill the temporary graphs // plot the interpolation bkg->Draw () ; drawShapes (tg_test_par, Npar) ; // overlap the missing point double dummy = 0 ; double mass = 0 ; tg_sample_par[0]->GetPoint (iTest, mass, dummy) ; TF1 * func = new TF1 ("func",crystalBallLowHigh, 200, 2000, 7) ; TGraph * log_tg_this_sample_par0 = makeLog (tg_sample_par[0]) ; func->SetParameter (0, TMath::Exp (log_tg_this_sample_par0->Eval (mass))) ; for (int iPar = 1 ; iPar < Npar ; ++iPar) func->SetParameter (iPar, tg_sample_par[iPar]->Eval (mass)) ; func->SetLineColor (kRed) ; func->Draw ("same") ; // output // c_merge->SetLogy (1) ; // TString name = "test_interpol_log_" ; // name += sample ; name += "_" ; name += iTest ; name += ".pdf" ; // c_merge->Print (name, "pdf") ; TString name = "test_interpol_lin_" ; name += sample ; name += "_" ; name += iTest ; name += ".pdf" ; c_merge->SetLogy (0) ; c_merge->Print (name, "pdf") ; } //PG loop on the point to be removed return ; }