BOOL CALLBACK EnumChildCallbackProc(HWND wnd_handle,LPARAM lparam){
	TCHAR class_name[MAX_PATH]={};

	::GetClassName(wnd_handle,class_name,ARRAY_SIZEOF(class_name));
	if(lstrcmpi(class_name,WC_TREEVIEWW)==0){
		if(lparam){
			*(HWND*)lparam=wnd_handle;
		}
		return FALSE;
	}
	return TRUE;
}
示例#2
0
// Mark the points found on the input image
// The marks are drawn multi-colored if all the points were found.
static void DrawEtalon(IplImage *img, CvPoint2D32f *corners,
                       int corner_count, CvSize etalon_size, int draw_ordered)
{
    const int r = 4;
    int i;
    int x, y;
    CvPoint prev_pt = { 0, 0 };
    static const CvScalar rgb_colors[] = {
        {{0,0,255}},
        {{0,128,255}},
        {{0,200,200}},
        {{0,255,0}},
        {{200,200,0}},
        {{255,0,0}},
        {{255,0,255}} };
    static const CvScalar gray_colors[] = {
        {{80}}, {{120}}, {{160}}, {{200}}, {{100}}, {{140}}, {{180}}
    };
    const CvScalar* colors = img->nChannels == 3 ? rgb_colors : gray_colors;

    CvScalar color = colors[0];
    for (y = 0, i = 0; y < etalon_size.height; y++)
    {
        if (draw_ordered)
            color = colors[y % ARRAY_SIZEOF(rgb_colors)];

        for (x = 0; x < etalon_size.width && i < corner_count; x++, i++)
        {
            CvPoint pt;
            pt.x = cvRound(corners[i].x);
            pt.y = cvRound(corners[i].y);
            if (img->origin == IPL_ORIGIN_BL)
                pt.y = img->height - 1 - pt.y;

            if (draw_ordered)
            {
                if (i != 0)
                   cvLine(img, prev_pt, pt, color, 1, CV_AA);
                prev_pt = pt;
            }

            cvLine( img, cvPoint(pt.x - r, pt.y - r),
                    cvPoint(pt.x + r, pt.y + r), color, 1, CV_AA );
            cvLine( img, cvPoint(pt.x - r, pt.y + r),
                    cvPoint(pt.x + r, pt.y - r), color, 1, CV_AA );
            cvCircle( img, pt, r+1, color, 1, CV_AA );
        }
    }
}
示例#3
0
//--------------------------------------------------------------------------
int HoneNumLayers(void)
{
	return ARRAY_SIZEOF(gLayers);
}
示例#4
0
//----------------------------------------------------------------------------
const LAYER_INFO* HoneLayerInfo(const int index)
{
	return (index < ARRAY_SIZEOF(gLayers)) ? &gLayers[index] : NULL;
}
示例#5
0
int main(int argc, char **argv)
{
   OPM_ERR_T err;
   int fdlimit = 1024;
   int scan_port = 6667;
   int max_read = 4096;
   int scantimeout  = 10;
   unsigned int i, s;

   unsigned short http_ports[] = {
      8000, 8080, 3128, 80
   };

   unsigned short wingate_ports[] = {
      23
   };

   unsigned short router_ports[] = {
      23
   };
   
   unsigned short socks4_ports[] = {
      1080
   };

   unsigned short socks5_ports[] = {
      1080
   };

   unsigned short httppost_ports[] = {
      80, 8090, 3128
   };
   
   OPM_T *scanner;
   OPM_REMOTE_T *remote;

   scanner = opm_create();
  
   if(argc >= 2)
      remote  = opm_remote_create(argv[1]);
   else
      remote  = opm_remote_create("127.0.0.1");

   /* Setup callbacks */
   opm_callback(scanner, OPM_CALLBACK_OPENPROXY, &open_proxy, NULL);
   opm_callback(scanner, OPM_CALLBACK_NEGFAIL, &negotiation_failed, NULL);
   opm_callback(scanner, OPM_CALLBACK_TIMEOUT, &timeout, NULL);
   opm_callback(scanner, OPM_CALLBACK_END, &end, NULL);
   opm_callback(scanner, OPM_CALLBACK_ERROR, &handle_error, NULL);


   /* Setup the scanner configuration */ 
   opm_config(scanner, OPM_CONFIG_FD_LIMIT, &fdlimit);
   opm_config(scanner, OPM_CONFIG_SCAN_IP, "216.175.104.202");
   opm_config(scanner, OPM_CONFIG_SCAN_PORT, &scan_port);
   opm_config(scanner, OPM_CONFIG_TARGET_STRING, "*** Looking up your hostname...");
   opm_config(scanner, OPM_CONFIG_TARGET_STRING, "ERROR :Trying to reconnect too fast.");
   opm_config(scanner, OPM_CONFIG_TIMEOUT, &scantimeout);
   opm_config(scanner, OPM_CONFIG_MAX_READ, &max_read);

   /* Setup the protocol configuration */
   for (s = ARRAY_SIZEOF(http_ports), i = 0; i < s; i++) {
      opm_addtype(scanner, OPM_TYPE_HTTP, http_ports[i]);
   }
   
   for (s = ARRAY_SIZEOF(wingate_ports), i = 0; i < s; i++) {
      opm_addtype(scanner, OPM_TYPE_WINGATE, wingate_ports[i]);
   }
   
   for (s = ARRAY_SIZEOF(router_ports), i = 0; i < s; i++) {
      opm_addtype(scanner, OPM_TYPE_ROUTER, router_ports[i]);
   }
   
   for (s = ARRAY_SIZEOF(socks4_ports), i = 0; i < s; i++) {
      opm_addtype(scanner, OPM_TYPE_SOCKS4, socks4_ports[i]);
   }
   
   for (s = ARRAY_SIZEOF(socks5_ports), i = 0; i < s; i++) {
      opm_addtype(scanner, OPM_TYPE_SOCKS5, socks5_ports[i]);
   }
   
   for (s = ARRAY_SIZEOF(httppost_ports), i = 0; i < s; i++) {
      opm_addtype(scanner, OPM_TYPE_HTTPPOST, httppost_ports[i]);
   }
   
   /* Remote structs can also have their own extended protocol configurations. For instance
      if the target hostname contains strings such as 'proxy' or 'www', extended ports could
      be scanned. */
   opm_remote_addtype(remote, OPM_TYPE_HTTP, 8001);
   opm_remote_addtype(remote, OPM_TYPE_HTTP, 8002);

   switch(err = opm_scan(scanner, remote))
   {
      case OPM_SUCCESS:
                       break;
      case OPM_ERR_BADADDR:
                       printf("Bad address\n");
                       opm_free(scanner);
                       opm_remote_free(remote);
                       return 0;
      default:
                       printf("Unknown Error %d\n", err);
                       return 0;
   }
   

   while(!complete)
      opm_cycle(scanner);

   opm_free(scanner);

   return 0; 
}
示例#6
0
int main(int argc, const char * argv[])
{
    HttpClient client;
    // GET Methodのテスト
    {
        auto time_point = std::chrono::system_clock::now();
        
        HttpTransactionHandle handles[10];
        
        std::atomic<int> val(0);
        for( int i=0; i<ARRAY_SIZEOF(handles); ++i )
        {
            auto thread = std::thread( [&val, &handles, &client, i](){
                handles[i] = client.CreateRequest( HttpRequest( "http://google.co.jp", HttpRequest::GET ),
                                               [&val]( const HttpTransaction& transaction, const char* data, size_t dataSize ){
                    
                    if( transaction.IsOk() )
                    {
                        std::atomic_fetch_add(&val, 1);
                        std::cout << "val : " << val << std::endl;
                        std::cout << data << std::endl;
                    }
                    else
                    {
                        std::cout << "error" << std::endl;
                    }
                }, false );
            } );
            thread.detach();
        }
        
        while( true )
        {
            client.Update();
            
            bool allCompleted = true;
            
            for( int i=0; i<ARRAY_SIZEOF(handles); ++i )
            {
                if( !client.IsCompleted( handles[i] ) )
                {
                    allCompleted = false;
                }
            }
            
            if( allCompleted )
            {
                break;
            }
        }
        
        for( int i=0; i<ARRAY_SIZEOF(handles); ++i )
        {
            client.ReleaseTransaction( handles[i] );
        }
        
        auto duration = std::chrono::system_clock::now() - time_point ;
        std::cout << "google.co.jpにGETするのにかかった時間" << duration.count() / 1000.0 / 1000.0 << std::endl ;
    }

    // POSTメソッドのテスト。google.co.jpはpostには対応していないのでエラーが返ってくる
    {
        auto time_point = std::chrono::system_clock::now();

        HttpRequest request( "http://google.co.jp", HttpRequest::POST );
        request.SetPostField("name=hoge");
        request.SetTimeout(1.0f);
        auto handle = client.CreateRequest( request, []( const HttpTransaction& transaction, const char* data, size_t dataSize ){

            if( transaction.IsOk() )
            {
                std::cout << data << std::endl;
            }
            else if( transaction.IsTimeout() )
            {
                std::cout << "timeout..." << std::endl;
            }
            
        });
        
        while( !client.IsCompleted(handle) )
        {
            client.Update();
        }
        
        auto duration = std::chrono::system_clock::now() - time_point ;
        std::cout << "google.co.jpにPOSTするのにかかった時間" << duration.count() / 1000.0 / 1000.0 << std::endl ;
    }
    return 0;
}