Exemple #1
0
int
msg_run_assign(struct msg *msg, int off,
    const struct run* value)
{
  if (!msg->run_set || off < 0 || off >= msg->run_length)
    return (-1);

  {
    int had_error = 0;
    struct evbuffer *tmp = NULL;
    run_clear(msg->run_data[off]);
    if ((tmp = evbuffer_new()) == NULL) {
      event_warn("%s: evbuffer_new()", __func__);
      had_error = 1;
      goto done;
    }
    run_marshal(tmp, value);
    if (run_unmarshal(msg->run_data[off], tmp) == -1) {
      event_warnx("%s: run_unmarshal", __func__);
      had_error = 1;
      goto done;
    }
    done:if (tmp != NULL)
      evbuffer_free(tmp);
    if (had_error) {
      run_clear(msg->run_data[off]);
      return (-1);
    }
  }
  return (0);
}
Exemple #2
0
int main(int argc, char *argv[])
{
int callrun;

#ifdef MTRACE_DEBUG
mtrace();
#endif
   /* Start initialisation:*/
   /* Pick out the number from the string "$Revision: 2.37 $":*/
   {/*Block begin*/
        char *tmp=currentrevision;
        for( tmp=currentrevision;(*tmp!=' ')&&(*tmp!='\0');tmp++);
        if(*tmp == ' ') tmp++;
        for( currentRevisionNumber=tmp;(*tmp!=' ')&&(*tmp!='\0');tmp++);
        *tmp='\0';
   }/*Block end*/

   /* Check here is there the request for the version information.
    * If so, output the revision number and quit, if there are no any
    * other option:
    */
   for(i=1; i<argc; i++)
      if( (s_cmp(argv[i],"-V")==0)||(s_cmp(argv[i],"-version")==0)){
        printf("%s\n",currentRevisionNumber);
        if(argc == 2) exit(0);
      }

   first_init();/*module init.c*/
   read_command_line(argc, argv);/*module cmd_line.c*/
   message(INITIALIZATION,NULL);
   /*End initialisation*/
   message(READINGCONFIG,config_name);
   scaner_init(config_name,cnf_comment);/*module init.c*/
   read_config_file_before_truns();/*module cnf_read.c*/
   if( is_bit_set(&mode,bitCHECKMOMENTABALANCE)&&
       (!is_bit_set(&mode,bitONLYINTERPRET))
    ){

       check_momenta_balance_on_each_topology();
   }
   message(DONE,NULL);

   /*Translation of the TM program:*/
   {char tmp[MAX_STR_LEN];

       if (
             (is_bit_set(&mode,bitONLYINTERPRET))||
             (!is_bit_set(&mode,bitBROWS))||
             (is_bit_set(&mode,bitVERIFY))||
             (is_bit_set(&mode,bitFORCEDTRUNSLATION))
          ){
             command_init();/*module truns.c*/
             if(!is_bit_set(&mode,bitONLYINTERPRET)){
                if (set_table==NULL)set_table=create_hash_table(
                      set_hash_size,str_hash,str_cmp,c_destructor);
                if(is_bit_set(&mode,bitBROWS))
                  install(new_str("_specmode"),new_str("browser"),set_table);
                else
                  install(new_str("_specmode"),new_str("common"),set_table);
             }
             message(BEGINTRUNS,NULL);
             do{
               if(truns(&current_number_of_trunslated_lines,
                           &current_array_of_trunslated_lines)){
                  number_of_trunslated_lines=
                                        current_number_of_trunslated_lines;
                  current_number_of_trunslated_lines=0;
                  array_of_trunslated_lines=
                                         current_array_of_trunslated_lines;
                  current_array_of_trunslated_lines=NULL;
               }
             }while(number_of_trunslated_lines==0);
             message(ENDTRUNS,NULL);
             mem_esc_char=esc_char;
             macro_done();/*module macro.c*/
             reject_proc();/*module truns.c*/
             command_done();/*module truns.c*/
             clear_defs();/*module truns.c*/
             clear_label_stack();/*module truns.c*/
             for_done();/*module truns.c*/
             IF_done();/*module truns.c*/
             if(s_scmp(sc_get_token(tmp),"translate"))
                halt(UNEXPECTED ,tmp);
       }
   }
   sc_done();/*module tools.c*/
   /*TM program is translated. The resulting code is in array_of_trunslated_lines*/

/*Keep the table up to the end of the program!:*/
#ifdef SKIP
   if (vectors_table!=NULL){
      hash_table_done(vectors_table);/*module hash.c*/
      vectors_table=NULL;
   }
#endif

   message(DONEINIT,NULL);

   if (is_bit_set(&mode,bitVERIFY)){
     message(ONLYVERIFY,NULL);
     errorlevel=0;halt(NOERROR,NULL);
   }

   if (g_ttnames != NULL){/*Topology tables were defined in the config file*/
      HASH_TABLE wrktrans;
      message(LOADINGTABLES,NULL);
      read_topology_tables();/*module utils.c*/
      free_mem(&g_ttnames);
      /*Create the working table:*/
      g_tt_wrk=tt_createNewTable(g_defaultTokenDictSize,g_defaultHashTableSize);

      /*Check success, if not, halt the system:*/
      checkTT(g_tt_wrk,FAILCREATINGWRKTABLE);

      /*Collect translations from all tables:*/
      wrktrans=tt_table[g_tt_wrk-1]->htrans;
      /*Full toplogies:*/
      for(i=0;i<g_tt_top_full;i++){
         HASH_TABLE  ttrans=tt_table[g_tt_full[i]-1]->htrans;
         if( ttrans!=NULL )
              binary_operations_under_hash_table(
                 ttrans,/*"from"*/
                 wrktrans,/*"to"*/
                 -1);/*see "hash.c"; op>0 -> add enties to "to" from "from", only if they
                 are absent in "to", op<0 -> rewrite entries in "to" by the corresponding
                 "from", op==0 -> remove all entries in "to" matching "from"*/
      }/*for(i=0;i<g_tt_top_full;i++)*/
      /*Internal topologies:*/
      for(i=0;i<g_tt_top_int;i++){
         HASH_TABLE  ttrans=tt_table[g_tt_int[i]-1]->htrans;
         if( ttrans!=NULL )
              binary_operations_under_hash_table(
                 ttrans,/*"from"*/
                 wrktrans,/*"to"*/
                 -1);/*see "hash.c"; op>0 -> add enties to "to" from "from", only if they
                 are absent in "to", op<0 -> rewrite entries in "to" by the corresponding
                 "from", op==0 -> remove all entries in "to" matching "from"*/
      }/*for(i=0;i<g_tt_top_int;i++)*/

      /*Override translations, if present, in wrk table; in loaded tables
        translations remain to be untranslated!:*/
      if( g_ttTokens_table!=NULL )
              binary_operations_under_hash_table(
                 g_ttTokens_table,/*"from"*/
                 wrktrans,/*"to"*/
                 -1);/*see "hash.c"; op>0 -> add enties to "to" from "from", only if they
                 are absent in "to", op<0 -> rewrite entries in "to" by the corresponding
                 "from", op==0 -> remove all entries in "to" matching "from"*/

      /*Now wrk table is ready*/
      /*Override translations, if present, in full toplogies:*/
      if( g_ttTokens_table!=NULL )for(i=0;i<g_tt_top_full;i++){
         HASH_TABLE  ttrans=tt_table[g_tt_full[i]-1]->htrans;
         if( ttrans!=NULL )/*BTW, it CANNOT be a NULL! See, how tt_createNewTableis invoked
                             in the beginning of tt_loadTable, file tt_load.c*/
              binary_operations_under_hash_table(
                 g_ttTokens_table,/*"from"*/
                 ttrans,/*"to"*/
                 -1);/*see "hash.c"; op>0 -> add enties to "to" from "from", only if they
                 are absent in "to", op<0 -> rewrite entries in "to" by the corresponding
                 "from", op==0 -> remove all entries in "to" matching "from"*/
      }/*for(i=0;i<g_tt_top_full;i++)*/
      message(DONE,NULL);
   }/*if (g_ttnames != NULL)*/

   /*If only interpret, we need not analyse diagrams:*/
   if(is_bit_set(&mode,bitONLYINTERPRET)){
    int exitcode;
      run_init(1);/*module init.c*/
      esc_char=mem_esc_char;
      islast=1;
      g_nocurrenttopology=1;/*Similar to islast, but specially for topologies.*/
      message(CALLTOINTERPRETER,NULL);
      exitcode=run(number_of_trunslated_lines,array_of_trunslated_lines);
      message(DONE,NULL);
      {char endmessage[MAX_STR_LEN];
         sprintf(endmessage,EXITCODEFROMINTERPRETER,exitcode);
         errorlevel=exitcode;
         halt(endmessage,NULL);
      }
      /*Stop running...*/
   }/*if(is_bit_set(&mode,bitONLYINTERPRET)*/

   /*ok, if we are here then we have to read diagrams...*/
   detect_last_diagram_number();/*module last_num.c*/
   message(LOOKINGFORFIRRSTDIAGRAM,NULL);
   scaner_init(input_name,0);/*module init.c*/
   skip_until_first_actual_diagram();/*module read_inp.c*/
   create_table(&dbuf,&dtable,MAX_VERTEX,MAX_I_LINE,ext_lines);/*module utils.c*/
   create_table(&wrkbuf,&wrktable,MAX_VERTEX,MAX_I_LINE,ext_lines);
   message(DONE,NULL);
   message(READDIAGRAMS,NULL);

   for(i=start_diagram;!(i>finish_diagram);i++){/*begin main loop*/
      skip_to_new_diagram();/* module read_inp.c Reads until '['*/

      if(i % STEP_INDICATOR == 0){
        char mes[MAX_STR_LEN];
          sprintf(mes,INDICATE_MESSAGE,i,finish_diagram);
          message(mes,NULL);
      }/*if(i % STEP_INDICATOR == 0)*/

      /* Check should we process this diagram:*/
      if (set_in(i % 250,dmask[i / 250])) continue;

      new_diagram();/*module read_inp.c. Some initializations
                                                       before each diagram.*/

      detect_number_and_coefficient();/*module read_inp.c
                                        This function must receive from
                                        scaner exactly 'd###'*/
      if(i!=diagram_count)
         halt(CURRUPTEDINPUT,input_name);
      create_primary_diagram_table();/*module read_inp.c*/

      if ( skiptadpoles && thisistadpole )
         continue;
      define_topology();/*module read_inp.c*/
      /*compare_topology() returns 1 if topology is not actual.
      If topology is undefined, this procedure will call
      'out_undefined_topology();' (if bitBROWS is not set) and set bitTERROR.
      */
      if(compare_topology())/*module read_inp.c*/
         continue;

      create_diagram_table();/*module read_inp.c*/

      define_prototype();/*module read_inp.c*/
      if(!is_bit_set(&mode,bitFORCEDTRUNSLATION))
          if(skip_prototype())/*module utils.c*/
            continue;
      create_indices_table();/*module read_inp.c*/
      if(must_diagram_be_skipped())/*module utils.c*/
         continue;
      if (is_bit_set(&mode,bitBROWS))
         fill_up_diagram_array(count);/*module read_inp.c*/
      count++;
      if(is_bit_set(&mode,bitFORCEDTRUNSLATION)){
         if(g_tt_try_loaded>0)/*Automatic momenta distribution mechanism*/
            callrun=1;
         else if(   ( is_bit_set(&mode,bitTERROR) )&&(!is_bit_set(&mode,bitBROWS)))
           callrun=0;
         else
           callrun=1;
      }else{
         callrun=(
              (!is_bit_set(&mode,bitTERROR) )&&
              (!is_bit_set(&mode,bitBROWS) )
         );
      }
      /*Run the interpreter:*/
      if(callrun){
         build_form_input();/*module read_inp.c*/
         run_init(0);/*module init.c*/
         esc_char=mem_esc_char;
         if(run(number_of_trunslated_lines,array_of_trunslated_lines)==HALT)
             set_bit(&mode,bitRUNSIGNAL);
         run_clear();/*module init.c*/
         if(is_bit_set(&mode, bitSKIP)){
            unset_bit(&mode,bitSKIP);
            count--;
         }else if((is_bit_set(&mode,bitFORCEDTRUNSLATION))&&
                            (skip_prototype()/*module utils.c*/)){
            count--;
         }else{
            if(g_topologyLabel!=NULL){/*First occurence, otherwise will be NULL*/
               /*Mark topology as occurred*/
               set_bit(g_topologyLabel,0);
               if(g_tt_try_loaded>0){/*Table were loaded*/

                  if( topologies[cn_topol].orig==NULL )/*Undefined topology*/
                     process_topol_tables(0);/*try to find momenta, read_inp.c*/

                  if(topologies[cn_topol].coordinates_ok==0)/*No coords*/
                     process_topol_tables(1);/*try to find coordinates, read_inp.c*/
                  /*Now current topology is marked, and wrk toable is built.*/
               }else{
                  if( topologies[cn_topol].orig==NULL ){/*Undefined topology*/
                     if( automatic_momenta_group(NULL,cn_topol)==1)
                        /*Now momenta are distributed automatically:*/
                        set_bit(g_topologyLabel,2);
                        /*Bit 0: 0, if topology not occures, or 1;
                          bit 1: 1, if topology was produced form generic, or 0.
                          bit 2: 1, automatic momenta is implemented, or 0
                        */
                  }/*if( topologies[cn_topol].orig==NULL )*/
               }/*if(g_tt_try_loaded>0)...else...*/
            }/*if(g_topologyLabel!=NULL)*/
            output_common_protocol(count);/*module read_inp.c*/
         }/*if(is_bit_set(&mode, bitSKIP)) ... else ... else*/
         if(is_bit_set(&mode,bitRUNSIGNAL)){
            sc_done();
            errorlevel=0;
            halt(RUNSIGNAL,NULL);
         }/*if(is_bit_set(&mode,bitRUNSIGNAL))*/
      }/*if(callrun)*/
   }/*end main loop*/

   sc_done();
   message(DONEDIAGRAMS,NULL);

   /*Check should we run the interpreter once more:*/
   if(is_bit_set(&mode,bitEND)){
      /*To use some of specmode operators during "extra call":*/
      new_diagram();

      run_init(1);
      esc_char=mem_esc_char;
      islast=1;

      g_nocurrenttopology=1;/*Similar to islast, but specially for topologies.*/
      cn_topol=top_topol;/*Indicate that there is no special topology */
      message(EXTRACALL,NULL);
      if(run(number_of_trunslated_lines,array_of_trunslated_lines)==HALT){
         errorlevel=0;
         halt(RUNSIGNAL,NULL);
      }
      message(DONE,NULL);
   }/*if(is_bit_set(&mode,bitEND))*/

   if (is_bit_set(&mode,bitBROWS)){
      message(BROWSERMODEDETECT,NULL);
      out_browse_head(count);/*module browser.c*/
      message(SORTINGDIAGRAMS,NULL);
      sort_diargams(count);/*module browser.c*/
      message(DONE,NULL);
      message(PRINTINGDIAGRAMS,NULL);
      print_diagrams(count);/*module browser.c*/
      message(DONE,NULL);
      sort_prototypes();/*module browser.c*/
      print_prototypes();/*module browser.c*/
      print_all_found_topologies();/*module browser.c*/
      print_not_found_topologies();/*module browser.c*/
      print_undefined_topologies();/*module browser.c*/
   }/*if (is_bit_set(&mode,bitBROWS))*/
   errorlevel=0;
   halt(NOERROR,NULL);
   return(0);/*Actually, the control can't reach this point*/
}/*main*/