Ejemplo n.º 1
0
EnumSnippet::EnumSnippet(const CtagsEntry& ce) {
  m_type = 'g';
  m_filename = ce.GetSimpleFileName();
  m_line_number = ce.GetLineNumber();
  m_code = FileUtil::GetBlock(ce.GetFileName(), ce.GetLineNumber(), ce.GetType());
  get_keywords(m_code, m_name, m_alias, m_keywords);
}
Ejemplo n.º 2
0
int get_decision(struct connection_info *c_info, struct location_tuple * lt)
//TODO int get_decision(struct data_head * dh,struct connection_info *c_info)
{
    struct decision_result*dr=(struct decision_result*)malloc(4*sizeof(int));
    init_result(dr);
    if(c_info==NULL)
    {
        if (NULL != dr)
            free(dr);
        return -1;
    }
    if(c_info->p_type==13)
    dr->trie=url_match(c_info->url);
    else
    dr->url= url_match(c_info->url);
    struct logic_query_result*lr=logic_query_match(c_info->comment);
    struct logic_query_result*lr_N=logic_query_match_N(c_info->comment);
    dr->gk=lr->hit_count;
    dr->monitor=lr_N->hit_count;
    int pattern1=-1,pattern2=-1, rt=0;
    dr->trie+=trie_chk_rule(c_info->user_id, c_info->s_id, c_info->p_type, c_info->r_id, &pattern1,&pattern2);
    if (dr->url==0&&dr->gk==0&&dr->monitor==0&&dr->trie==0)
    {
        free(dr);
	free(lr);
	free(lr_N);
        return 0;
    }
    printf("===========================\n");
    printf("url:%d\ngk:%d\nmonitor%d\ntrie:%d\n",dr->url,dr->gk,dr->monitor,dr->trie) ;
    printf("===========================\n");
    if(dr->monitor>0)
    {
 	//sunpy
 	if(dr->url == 0 && dr->gk == 0 && dr->trie == 0) {
         printf("hit count: %d\n", dr->monitor);

         int i;
         for (i = 0; i < dr->monitor; i++) {
             struct loginfo log;
             initlog(&log, lt);
             log_addsocialinfo(&log, c_info);

             // sunpy: after discussing with Shao
             log_set_gk_type(&log, 4);
            
             int index = lr_N->hit_rule_list[i];
             struct query_expression* qe = query_rule_table_N->table[index];
	     log_addkeyword(&log, qe->full_text);
             log_set_full_text(&log, c_info->comment);
            
             printlog(&log);
             sendlog(&log, dr->monitor);
         }
         
         free(lr);
         free(lr_N);
         free(dr);

         return 0;
        }
    }
        if(dr->url>0)
        {
            printf("============================\n");
            printf("HIT URL\n");
            printf("============================\n");
            struct loginfo log;
            initlog(&log, lt);
            log_addsocialinfo(&log, c_info);
            log_set_gk_type(&log, 3);
            
            char * kw[dr->url];
            int z;
            for(z=0;z<dr->url;z++){
                kw[z]=(char*)malloc(256*sizeof(char));
                bzero(kw[z],256*sizeof(char));
            }
            get_keywords(c_info->url,kw);
            log_addkeywords(&log,kw,dr->url);
            log.keywords[strlen(log.keywords)-1]='\0';
            log_addkeyword(&log, c_info->url);
            log_set_full_text(&log, c_info->comment);
            printlog(&log);
            sendlog(&log,0);
            for (z=0; z < dr->url; z++)
            	FREE(kw[z]);
            //FREE(kw);
        }
        if(dr->gk>0)
        {
            printf("============================\n");
            printf("HIT GK KEYWORD\n");
            printf("============================\n");
            int i;
            for (i = 0; i < dr->gk; i++) {
                struct loginfo log;
                initlog(&log, lt);
                log_addsocialinfo(&log, c_info);
                log_set_gk_type(&log, 0);
                
                int index = lr->hit_rule_list[i];
                struct query_expression* qe = query_rule_table->table[index];
		log_addkeyword(&log, qe->full_text);
		log_set_full_text(&log, c_info->comment);
                
                //printlog(&log);
                sendlog(&log,0);
            }
        }
        if(dr->trie>0)
        {
            printf("============================\n");
            printf("HIT TRIE \n");
            printf("============================\n");
            struct loginfo log;
            initlog(&log, lt);
            log_addsocialinfo(&log, c_info);
            if (pattern1 != -1) {
                if (pattern1 % 2 == 0)
                    log_set_gk_type(&log, 1);
                else
                    log_set_gk_type(&log, 2);
            } else {
                log_set_gk_type(&log,2);
            }
            log_set_full_text(&log, c_info->comment);
//            printlog(&log);
            sendlog(&log,0);
        }
		
    free(lr);
    free(lr_N);
    free(dr);
	return 1;
}
Ejemplo n.º 3
0
EnumSnippet::EnumSnippet(const std::string& code, const std::string& filename, int line_number)
: m_code(code), m_type('g'), m_filename(filename), m_line_number(line_number) {
  get_keywords(code, m_name, m_alias, m_keywords);
}
Ejemplo n.º 4
0
int main(int argc, char **argv)
{
  char **infiles;
  char *outfile;
  int nfiles;
  int nogo;
  int errs;
  int reportcols;
  int debug;

  /*
   * Set up initial (default) parameters.
   */
  infiles = mknewa(char *, argc);
  outfile = NULL;
  nfiles = 0;
  nogo = errs = FALSE;
  reportcols = 0;
  debug = 0;

  if (argc == 1)
  {
    usage();
    exit(EXIT_SUCCESS);
  }

  /*
   * Parse command line arguments.
   */
  while (--argc)
  {
    char *p = *++argv;
    if (*p == '-')
    {
      /*
       * An option.
       */
      while (p && *++p)
      {
        char c = *p;
        switch (c)
        {
        case '-':
          /*
           * Long option.
           */
          {
            char *opt, *val;
            opt = p++;          /* opt will have _one_ leading - */
            while (*p && *p != '=')
              p++;              /* find end of option */
            if (*p == '=')
            {
              *p++ = '\0';
              val = p;
            } else
              val = NULL;
            if (!strcmp(opt, "-version"))
            {
              showversion();
              nogo = TRUE;
            } else if (!strcmp(opt, "-licence") ||
                       !strcmp(opt, "-license"))
            {
              licence();
              nogo = TRUE;
            } else if (!strcmp(opt, "-output"))
            {
              if (!val)
                errs = TRUE, error(err_optnoarg, opt);
              else
                outfile = val;
            } else if (!strcmp(opt, "-precise"))
            {
              reportcols = 1;
            } else
            {
              errs = TRUE, error(err_nosuchopt, opt);
            }
          }
          p = NULL;
          break;
        case 'V':
        case 'L':
        case 'P':
        case 'd':
          /*
           * Option requiring no parameter.
           */
          switch (c)
          {
          case 'V':
            showversion();
            nogo = TRUE;
            break;
          case 'L':
            licence();
            nogo = TRUE;
            break;
          case 'P':
            reportcols = 1;
            break;
          case 'd':
            debug = TRUE;
            break;
          }
          break;
        case 'o':
          /*
           * Option requiring parameter.
           */
          p++;
          if (!*p && argc > 1)
            --argc, p = *++argv;
          else if (!*p)
          {
            char opt[2];
            opt[0] = c;
            opt[1] = '\0';
            errs = TRUE, error(err_optnoarg, opt);
          }
          /*
           * Now c is the option and p is the parameter.
           */
          switch (c)
          {
          case 'o':
            outfile = p;
            break;
          }
          p = NULL;             /* prevent continued processing */
          break;
        default:
          /*
           * Unrecognised option.
           */
          {
            char opt[2];
            opt[0] = c;
            opt[1] = '\0';
            errs = TRUE, error(err_nosuchopt, opt);
          }
        }
      }
    } else
    {
      /*
       * A non-option argument.
       */
      infiles[nfiles++] = p;
    }
  }

  if (errs)
    exit(EXIT_FAILURE);
  if (nogo)
    exit(EXIT_SUCCESS);

  /*
   * Do the work.
   */
  if (nfiles == 0)
  {
    error(err_noinput);
    usage();
    exit(EXIT_FAILURE);
  }

  {
    input in;
    paragraph *sourceform, *p;
    indexdata *idx;
    keywordlist *keywords;

    in.filenames = infiles;
    in.nfiles = nfiles;
    in.currfp = NULL;
    in.currindex = 0;
    in.npushback = in.pushbacksize = 0;
    in.pushback = NULL;
    in.reportcols = reportcols;
    in.stack = NULL;

    idx = make_index();

    sourceform = read_input(&in, idx);
    if (!sourceform)
      exit(EXIT_FAILURE);

    sfree(in.pushback);

    mark_attr_ends(sourceform);

    sfree(infiles);

    keywords = get_keywords(sourceform);
    if (!keywords)
      exit(EXIT_FAILURE);
    gen_citations(sourceform, keywords);
    subst_keywords(sourceform, keywords);

    for (p = sourceform; p; p = p->next)
      if (p->type == para_IM)
        index_merge(idx, TRUE, p->keyword, p->words);

    build_index(idx);


    if (debug)
    {
      index_debug(idx);
      dbg_prtkws(keywords);
      dbg_prtsource(sourceform);
    }

    xhtml_backend(sourceform, keywords, idx);

    free_para_list(sourceform);
    free_keywords(keywords);
    cleanup_index(idx);
  }

  return 0;
}