int main(int argc, char **argv)
{
    MSG msg;
    char buf[1024];
    char *filename;

    fz_cpudetect();
    fz_accelerate();

    pdfapp_init(&gapp);

    associate(argv[0]);
    winopen();

    if (argc == 2)
	filename = fz_strdup(argv[1]);
    else
    {
	if (!winfilename(buf, sizeof buf))
	    exit(0);
	filename = buf;
    }

    pdfapp_open(&gapp, filename);

    while (GetMessage(&msg, NULL, 0, 0))
    {
	TranslateMessage(&msg);
	DispatchMessage(&msg);
    }

    pdfapp_close(&gapp);

    return 0;
}
Esempio n. 2
0
void WriteHeadofSubroutineLoop()
{
   char ligne[LONG_40M];
   FILE * subloop;

   if ( todebug == 1 ) printf("Enter in WriteHeadofSubroutineLoop\n");
   tofich(fortranout,"\n",1);
   /* Open this newfile                                                       */
   sprintf(ligne,"Sub_Loop_%s.h",subroutinename);
   subloop = associate(ligne);
   /*                                                                         */
   if (isrecursive) 
   {
   sprintf(ligne,"      recursive subroutine Sub_Loop_%s(",subroutinename);
   }
   else
   {
   sprintf(ligne,"      subroutine Sub_Loop_%s(",subroutinename);
   }
   /*                                                                         */
   WriteVariablelist_subloop(subloop,ligne);
   WriteVariablelist_subloop_Def(subloop,ligne);
   /*                                                                         */
     strcat(ligne,")");
   tofich(subloop,ligne,1);
   /* if USE agrif_Uti l should be add                                        */
   AddUseAgrifUtil_0(subloop);
   /*                                                                         */
   oldfortranout = fortranout;
   fortranout = subloop;
   if ( todebug == 1 ) printf("Out of WriteHeadofSubroutineLoop\n");
}
Esempio n. 3
0
    std::string AssociatedRelayConsumer::checkid_setup(const std::string &return_to,
                                                       const std::string &trust_root) {
        // Try to find our assoc handle.
        const std::string *assoc_handle_ptr = lookup_assoc_handle(openid_provider());
        if(!assoc_handle_ptr)
            assoc_handle_ptr = associate();
        
        // If the handle is "DUMB", we have to fall back to the dumb consumer.
        if(assoc_handle_ptr->compare("DUMB") == 0) {
            delete assoc_handle_ptr;
            return DumbRelayConsumer::checkid_setup(return_to, trust_root);
        }
        
        // Move the string to the stack, so that return can free it.
        std::string assoc_handle(*assoc_handle_ptr);
        delete assoc_handle_ptr;
        
        // construct check_id url.
        std::string redirect_url(DumbRelayConsumer::checkid_setup(return_to, trust_root));

        // cURL handle used for escaping.
        CURL *curl = new_curl_handle();
        redirect_url.append("&openid.assoc_handle=");
        char *tmp = curl_easy_escape(curl, assoc_handle.c_str(), assoc_handle.size());
        redirect_url.append(tmp);
        curl_free(tmp);
        
        // Clean up after curl.
        curl_easy_cleanup(curl);
        
        return redirect_url;
    }
Esempio n. 4
0
void write_Getnumberofcells_file(char *name)
{
  char ligne[LONG_C];
  FILE *getnumberofcells;

  if ( IndicenbmaillesX != 0 )
  {
  getnumberofcells=associate(name);
  sprintf (ligne,
           "Agrif_Curgrid %% tabvars(%d) %% var %% iarray0 = Agrif_Gr %% nb(1)",
           IndicenbmaillesX);
  tofich (getnumberofcells, ligne,1);
  if (dimprob > 1)
    {
      sprintf (ligne,
           "Agrif_Curgrid %% tabvars(%d) %% var %% iarray0 = Agrif_Gr %% nb(2)",
           IndicenbmaillesY);
      tofich (getnumberofcells, ligne,1);
    }
  if (dimprob > 2)
    {
      sprintf (ligne,
           "Agrif_Curgrid %% tabvars(%d) %% var %% iarray0 = Agrif_Gr %% nb(3)",
           IndicenbmaillesZ);
      tofich (getnumberofcells, ligne,1);
    }
  fclose (getnumberofcells);
  }
}
Esempio n. 5
0
void
ControlSystem::NewPackage (const std::string& str)
{
  Package *pkg = new Package (str);

  associate (pkg);
}
Esempio n. 6
0
void write_Setnumberofcells_file(char *name)
{
  char ligne[LONG_C];
  FILE *setnumberofcells;

  if ( IndicenbmaillesX != 0 )
  {
  setnumberofcells=associate(name);

  if (onlyfixedgrids != 1 )
  {
  sprintf (ligne,
           "Agrif_Gr %% nb(1) = Agrif_Gr %% tabvars(%d) %% var %% iarray0",
           IndicenbmaillesX);
  }
  else
  {
  sprintf (ligne,
           "Agrif_Gr %% nb(1) = Agrif_Curgrid %% tabvars(%d) %% var %% iarray0",
           IndicenbmaillesX);
  }
  tofich (setnumberofcells, ligne,1);
  if (dimprob > 1)
  {
     if (onlyfixedgrids != 1 )
     {
     sprintf (ligne,
           "Agrif_Gr %% nb(2) = Agrif_Gr %% tabvars(%d) %% var %% iarray0",
           IndicenbmaillesY);
     }
     else
     {
     sprintf (ligne,
           "Agrif_Gr %% nb(2) = Agrif_Curgrid %% tabvars(%d) %% var %% iarray0",
           IndicenbmaillesY);
     }

     tofich (setnumberofcells, ligne,1);
  }
  if (dimprob > 2)
  {
     if (onlyfixedgrids != 1 )
     {
     sprintf (ligne,
           "Agrif_Gr %% nb(3) = Agrif_Gr %% tabvars(%d) %% var %% iarray0",
           IndicenbmaillesZ);
     }
     else
     {
     sprintf (ligne,
           "Agrif_Gr %% nb(3) = Agrif_Curgrid %% tabvars(%d) %% var %% iarray0",
           IndicenbmaillesZ);
     }
     tofich (setnumberofcells, ligne,1);
  }

  fclose (setnumberofcells);
  }
}
Esempio n. 7
0
void write_probdimagrif_file()
{
  FILE *probdim;
  char ligne[LONG_C];

  probdim = associate("probdim_agrif.h");
  sprintf (ligne, "Agrif_Probdim = %d", dimprob);
  tofich (probdim, ligne,1);
  fclose (probdim);
}
Esempio n. 8
0
EclOutDlg::EclOutDlg( QWidget* parent, const char* name ) :
	EclOutDlgBase(parent, name)
{
	QObject::connect( done, SIGNAL(clicked()), 
		this, SLOT( accept() ) );

	QObject::connect( cancel, SIGNAL(clicked()), 
		this, SLOT( reject() ) );
	
	QObject::connect(assoc, SIGNAL(clicked()), this, SLOT(associate()));
}
Esempio n. 9
0
void write_modtypeagrif_file()
{
  char ligne[LONG_C];
  FILE *typedata;

  typedata = associate ("modtype_agrif.h");
  /* AGRIF_NbVariables : number of variables                                  */
  sprintf (ligne, "AGRIF_NbVariables = %d",indicemaxtabvars);
  tofich(typedata,ligne,1);
  fclose (typedata);
}
Esempio n. 10
0
int _tmain(int argc, TCHAR* argv[]) {
	if (argc < 2) return -1;
	
	int flags = _ttoi(argv[1]);
	const cubeice::detail::ext_map& exts = cubeice::detail::extensions();
	for (cubeice::detail::ext_map::const_iterator pos = exts.begin(); pos != exts.end(); pos++) {
		associate(pos->first, pos->second.first, ((flags & pos->second.second) != 0));
	}
	SHChangeNotify(SHCNE_ASSOCCHANGED,SHCNF_FLUSH,0,0);

	return 0;
}
Esempio n. 11
0
/* bind/construct representative of an internal cluster of a model graph */
static rep_t model_clust(Agraph_t *model, Agraph_t *origclust)
{
	rep_t		rep;

	rep = association(model,origclust);
	if (rep.type) return rep;

	rep.p = newpath(model,NILnode,GD_minrank(origclust),NILnode,GD_maxrank(origclust));
	rep.type = SKELETON;
	associate(model,origclust,rep);
	return rep;
}
Esempio n. 12
0
/**
 * Create a new rust channel and associate it with the specified port.
 */
rust_chan::rust_chan(rust_task *task, maybe_proxy<rust_port> *port) :
    task(task), port(port), buffer(task->dom, port->delegate()->unit_sz) {

    if (port) {
        associate(port);
    }

    task->log(rust_log::MEM | rust_log::COMM,
              "new rust_chan(task=0x%" PRIxPTR
              ", port=0x%" PRIxPTR ") -> chan=0x%" PRIxPTR,
              (uintptr_t) task, (uintptr_t) port, (uintptr_t) this);
}
Esempio n. 13
0
void Write_Alloc_Agrif_Files()
{
   listnom *parcours;
   FILE *alloccalls;
   FILE *AllocUSE;

   AllocUSE= associate("include_use_Alloc_agrif.h");
   alloccalls = associate("allocations_calls_agrif.h");

   parcours = List_Subroutine_For_Alloc;
   while ( parcours )
   {
      fprintf(AllocUSE,"      USE %s\n", parcours -> o_nom );
      fprintf (alloccalls,"      Call Alloc_agrif_%s(Agrif_Gr)\n",
                                                            parcours -> o_nom );
      parcours = parcours -> suiv;
   }

   fclose (AllocUSE);
   fclose (alloccalls);
}
Esempio n. 14
0
void write_keysagrif_file()
{
  FILE *keys;

  keys = associate ("keys_agrif.h");
  fprintf(keys,"      AGRIF_USE_FIXED_GRIDS = 0\n");
  fprintf(keys,"      AGRIF_USE_ONLY_FIXED_GRIDS = 0\n");
  if (fixedgrids     == 1) fprintf(keys,"      AGRIF_USE_FIXED_GRIDS = 1\n");
  if (onlyfixedgrids == 1)
                         fprintf(keys,"      AGRIF_USE_ONLY_FIXED_GRIDS = 1\n");

  fclose(keys);
}
Esempio n. 15
0
Package*
ControlSystem::LoadPackage (const std::string& str, unsigned int
index_cards)
  throw (Package::BadPackageFileException)
/*throw (Package::NotFoundPackageException, Package::BadPackageFileException,
  RepeatPackageException)*/
{
  Package *pkg = new Package(str, index_cards, true);
  associate (pkg);
  DialogPackage *pdpkg = new DialogPackage (pkg);
  DialogPackage::insertDialogPackage (pdpkg);

  return pkg;
}
Esempio n. 16
0
/* Deauths and re-associates a MAC address with the AP. Returns 0 on failure, 1 for success. */
int reassociate()
{
    int tries = 0, retval = 0;

    /* Make sure we can still see beacons (also, read_ap_beaon will ensure we're on the right channel) */
    read_ap_beacon();

    if(!get_external_association())
    {
        /* Deauth to void any previous association with the AP */
        deauthenticate();

        /* Try MAX_AUTH_TRIES times to authenticate to the AP */
        do
        {
            authenticate();
            tries++;
        }
        while((associate_recv_loop() != AUTH_OK) && (tries < MAX_AUTH_TRIES));

        /* If authentication was successful, try MAX_AUTH_TRIES to associate with the AP */
        if(tries < MAX_AUTH_TRIES)
        {
            tries = 0;

            do
            {
                associate();
                tries++;
            }
            while((associate_recv_loop() != ASSOCIATE_OK) && (tries < MAX_AUTH_TRIES));
        }

        if(tries < MAX_AUTH_TRIES)
        {
            retval = 1;
        }
        else
        {
            retval = 0;
        }
    }
    else
    {
        retval = 1;
    }

    return retval;
}
Esempio n. 17
0
/* bind/construct representative of an external endpoint to a model graph */
static rep_t model_extnode(Agraph_t *model, Agnode_t *orig)
{
	Agnode_t	*v;
	rep_t		rep;

	rep = association(model,orig);
	if (rep.type) return rep;

	/* assume endpoint is represented by one node, even if orig is multi-rank */
	rep.p = v = agnode(model,orig->name);
	rep.type = EXTNODE;
	ND_rank(v) = ND_rank(orig);	/* should be ND_rank(orig)+ranksize(orig)? */
	associate(model,orig,rep);
	return rep;
}
Esempio n. 18
0
FdEventQueue::FdEventQueue(bool) throw(Exception) {
  if (pipe(wake_pipe) != -1) {
    try {
      if (!associate(wake_pipe[0], FdEvent::TYPE_READ_READY)) {
        throw Exception();
      }
    } catch (Exception&) {
      close(wake_pipe[0]);
      close(wake_pipe[1]);
      throw;
    }
  } else {
    throw Exception();
  }
}
Esempio n. 19
0
static void model_edge(Agraph_t *model, Agedge_t *orig)
{
	Agedge_t	*e;
	Agnode_t	*low, *high, *u, *v;
	port_t		lowport, highport;
	vpath_t		*path;
	rep_t			rep;
	int				i;

	rep = association(model,orig);
	if (rep.type == 0) {
		low = orig->tail; high = orig->head;
		getlowhigh(&low,&high);
		u = association(model,low).p; assert(u);
		v = association(model,high).p; assert(v);
		path = newpath(model,u,ND_rank(low),v,ND_rank(high));
		rep.type = PATH;
		rep.p = path;
		associate(model,orig,rep);
	}
	else path = rep.p;

	/* merge the attributes of orig */
	for (i = path->low; i < path->high; i++) {
		e = path->e[i];
		ED_xpenalty(e) += ED_xpenalty(orig);
		ED_weight(e) += ED_weight(orig);
	}

	/* deal with ports.  note that ends could be swapped! */
	if (ND_rank(orig->tail) <= ND_rank(orig->head)) {
		lowport = ED_tailport(orig);
		highport = ED_headport(orig);
	}
	else {
		highport = ED_tailport(orig);
		lowport = ED_headport(orig);
	}
	if (lowport.defined)
		path->avgtailport = ((path->weight * path->avgtailport) + ED_weight(orig) * lowport.p.x) / (path->weight + ED_weight(orig));
	if (highport.defined)
		path->avgheadport = ((path->weight * path->avgheadport) + ED_weight(orig) * highport.p.x) / (path->weight + ED_weight(orig));
	path->weight += ED_weight(orig);
}
Esempio n. 20
0
/* bind/construct representative of an internal node in a model graph */
static rep_t model_intnode(Agraph_t *model, Agnode_t *orig)
{
	int				nr;
	rep_t			rep;
	Agnode_t	*v;
	
	rep = association(model,orig);
	if (rep.type) return rep;
	
	nr = ND_ranksize(orig);
	if (nr <= 1) {			/* simple case */
		v = rep.p = agnode(model,orig->name);
		rep.type = NODE;
		ND_rank(v) = ND_rank(orig);
	}
	else {							/* multi-rank node case */
		rep.p = newpath(model,NILnode,ND_rank(orig),NILnode,ND_rank(orig)+nr-1);
		rep.type = TALLNODE;
	}
	associate(model,orig,rep);
	return rep;
}
Esempio n. 21
0
std::vector<Component> work(cv::Mat &left_c, cv::Mat &right_c)
{
    std::vector<Component> components;
    cv::Mat left, right;
    cv::cvtColor(left_c, left, CV_RGB2GRAY);
    cv::cvtColor(right_c, right, CV_RGB2GRAY);
    cv::Mat map = (getDepthMapBM(left, right));
    //cv::Mat map = (getDepthMapVar(left, right));
    //char buf[512];
    //static int j = 0;
    //j++;
    //sprintf(buf, "dumps/%i.pcd", j);
    /*cv::Mat xyz;
    cv::Mat Q = cv::Mat::eye(4, 4, CV_32S);
    reprojectImageTo3D(map, xyz, Q, true);
    saveXYZ(buf, xyz);*/
    //saveToPCD(map, buf);
    
    components = associate((map), 20);//10 2
    components = componentsFilter(components);
    cv::Mat res;
    left_c.copyTo(res);
    int i = 0;
    for(auto it : components)
    {
        cv::rectangle(res, cv::Point(it.Y1, it.X1), cv::Point(it.Y2, it.X2), cv::Scalar(40 * (i), 40*((i+1)%5), 0));
        i++;
    }
    cv::imshow("res", res);
    std::cout<<components.size()<<std::endl;
    cv::imshow("left", left_c);
    cv::imshow("right", right_c);
    //cv::waitKey();
    map = normalize(map);
    cv::imshow("Out", map);
    return components;
    //showComponents(components, map);
}
Esempio n. 22
0
bool Associator::getAssociations( const Measurement& measurement, AssociatedMeasurement& associations, const int goal_node_i )
{
    unassociated_points_ = measurement;

    // Find a path through the graph starting from the associated nodes
    PathFinder pathFinder( *graph_ptr_, associations.nodes );
    pathFinder.findPath( goal_node_i, path_ );

    // Calculate the positions of graph nodes on the path
    AssociatedMeasurement path_positions = associations;
    calculatePositions( *graph_ptr_, path_, path_positions );

    associations.clear();

    if ( !costCalculators_.size() )
    {
        std::cout << "\033[31m" << "[ASSOCIATOR] GetAssociations: No cost calculator modules available!" << "\033[0m" << std::endl;
    }

    for ( int i = 0; i < costCalculators_.size(); ++i )
    {
        // Reduce unassociated_points with any associated points and path_positions with the associated nodes before calling associate
        for ( int j = 0; j < associations.nodes.size(); ++j )
        {
            path_positions.erase( path_positions.node_indices[ associations.nodes[j] ] );
            unassociated_points_.points.erase( std::find(unassociated_points_.points.begin(), unassociated_points_.points.end(), associations.measurement.points[i] ) );
        }

        // Call the recursive association algorithms
        associate( path_positions, unassociated_points_, associations, *costCalculators_[i], max_assoc_dists_[i]);

        std::cout << associations.nodes.size() << " associations found after using costcalculator " << i << std::endl;
    }

    associated_ = true;

    return true;
}
Esempio n. 23
0
/* Deauths and re-associates a MAC address with the AP. Returns 0 on failure, 1 for success. */
int reassociate(void)
{
	if (get_external_association()) return 1;

	int state = 0, ret;

	while(1) {
		switch(state) {
			case 0:
				deauthenticate();
				state++;
				break;
			case 1:
				authenticate();
				state++;
				break;
			case 2:
				ret = process_authenticate_associate_resp(0);
				if(ret) state++;
				else return 0;
				break;
			case 3:
				associate();
				state++;
				break;
			case 4:
				ret = process_authenticate_associate_resp(0);
				if(ret) state++;
				else return 0;
				break;
			case 5:
				return 1;

		}
	}
}
Esempio n. 24
0
 bool	Socket::bind(int port)
 {
   return associate(NULL, port, ::bind);
 }
Esempio n. 25
0
    bool AssociatedRelayConsumer::check_authentication(const std::multimap<std::string, std::string> &params) {
        // Try to find our assoc handle.
        const std::string *assoc_handle_ptr = lookup_assoc_handle(openid_provider());
        if(!assoc_handle_ptr)
            assoc_handle_ptr = associate();
        
        // If the handle is "DUMB", we have to fall back to the dumb consumer.
        if(assoc_handle_ptr->compare("DUMB") == 0) {
            delete assoc_handle_ptr;
            return DumbRelayConsumer::check_authentication(params);
        }
        
        // Move the string to the stack, so that return can free it.
        std::string assoc_handle(*assoc_handle_ptr);
        delete assoc_handle_ptr;
        
        // Not possible to be missing the assoc_handle
        std::multimap<std::string, std::string>::const_iterator assoc_iter = params.find(std::string("openid.assoc_handle"));
        if(assoc_iter == params.end())
            return false;

        if(assoc_handle.compare(assoc_iter->second) == 0) {
            // make sure this request was signed.
            std::multimap<std::string, std::string>::const_iterator sig_iter = params.find(std::string("openid.sig"));
            if(sig_iter == params.end())
                return false;
            std::string their_signature(sig_iter->second);
            
            // Look for the signed fields.
            sig_iter = params.find(std::string("openid.signed"));
            if(sig_iter == params.end())
                return false;
            std::string signed_params(sig_iter->second), key;
            
            // construct the message that was signed.
            std::ostringstream message;
            std::string::const_iterator iter = signed_params.begin();
            while(iter != signed_params.end()) {
                char c = *iter;
                ++iter;
                
                // We hit a non-key character, 
                if(c == '\n' || c == ',' || iter == signed_params.end()) {
                    // store the last char in the string.
                    if(iter == signed_params.end()) key.push_back(c);
                    // look for the param
                    std::string key_to_find("openid.");
                    key_to_find.append(key);
                    sig_iter = params.find(key_to_find);
                    if(sig_iter == params.end())
                        return false;
                    
                    // add to the message data.
                    message << key << ":" << sig_iter->second << "\n";
                    
                    // clear the key to start over.
                    key.clear();
                } else {
                    key.push_back(c);
                }
            }
            
            // attempt to recreate the signature.
            Association *assoc = lookup_association(assoc_handle);
            if(!assoc)
                return false;
            std::string our_signature(create_signature(message.str(), assoc->secret));
            delete assoc;

            // Test that the signature created matches the one given.
            return (their_signature.compare(our_signature) == 0);
            
        } else if(assoc_handle.compare(assoc_iter->second) != 0 &&
           (assoc_iter = params.find("openid.invalidate_handle")) != params.end()) {
            
            // Prepare the verification post data.
            std::ostringstream data;
            CURL *curl = new_curl_handle();
            data << "openid.mode=check_authentication";
            for(std::multimap<std::string, std::string>::const_iterator iter = params.begin();
                iter != params.end();
                ++iter) {
                if(iter->first.compare("openid.mode") == 0) continue;
                
                char *tmp;
                tmp = curl_easy_escape(curl, iter->first.c_str(), iter->first.size());
                data << "&" << tmp << "=";
                curl_free(tmp);
                
                tmp = curl_easy_escape(curl, iter->second.c_str(), iter->second.size());
                data << tmp;
                curl_free(tmp);
            }
            // Clean up after curl.
            curl_easy_cleanup(curl);
            
            // execute.
            std::string content = contact_openid_provider(data.str());
            
            // Check for invalidating the handle.
            std::string invalidate_substring("\ninvalidate_handle:");
            invalidate_substring.append(assoc_iter->second).append("\n");
            if(content.find(invalidate_substring) != content.npos)
                invalidate_assoc_handle(assoc_iter->second);
            
            // Test for is_valid.
            return content.find("\nis_valid:true\n") != content.npos;
        }
        
        // If we didn't match any other cases, return false.
        return false;
    }
Esempio n. 26
0
void host_configure(void)
{
  char **pext;
  HKEY  key;
  DWORD disposition;
  char *u3_host_exec_path;
  char *u3_device_exec_path;
  char *u3_device_serial;
  char *u3_device_document_path;
  char wireshark_path[MAX_PATH+1];
  char winpcap_path[MAX_PATH+1];
  char vcredist_path[MAX_PATH+1];
  char my_captures_path[MAX_PATH+1];
  char reg_key[BUFSIZ];
  char buffer[BUFSIZ];
  int  buflen = BUFSIZ;
  boolean hasWinPcap = FALSE;
  boolean hasRedist = FALSE;

  /* CREATE THE U3 Wireshark TYPE */
  if(RegCreateKeyEx(HKEY_CLASSES_ROOT, WIRESHARK_ASSOC, 0, NULL, 0,
		    (KEY_READ | KEY_WRITE), NULL, &key, &disposition) == ERROR_SUCCESS) {

    (void)RegSetValueEx(key, "", 0, REG_SZ, WIRESHARK_DESC, strlen(WIRESHARK_DESC) + 1);

    RegCloseKey(key);
  }

  /* compute the U3 path to wireshark */
  u3_host_exec_path = getenv("U3_HOST_EXEC_PATH");
  strncpy(wireshark_path, u3_host_exec_path, strlen(u3_host_exec_path) + 1);
  strncat(wireshark_path, U3UTIL_APPSTART, strlen(U3UTIL_APPSTART) + 1);

  strncpy(reg_key, WIRESHARK_ASSOC, strlen(WIRESHARK_ASSOC) + 1);
  strncat(reg_key, SHELL_OPEN_COMMAND, strlen(SHELL_OPEN_COMMAND) + 1);

  /* associate the application */
  if(RegCreateKeyEx(HKEY_CLASSES_ROOT, reg_key, 0, NULL, 0,
		    (KEY_READ | KEY_WRITE), NULL, &key, &disposition) == ERROR_SUCCESS) {
    (void)RegSetValueEx(key, "", 0, REG_SZ, wireshark_path, strlen(wireshark_path) + 1);

    RegCloseKey(key);

  }

  /* associate the icon */
  strncpy(reg_key, WIRESHARK_ASSOC, strlen(WIRESHARK_ASSOC) + 1);
  strncat(reg_key, DEFAULT_ICON, strlen(DEFAULT_ICON) + 1);

  /* the icon is in the exe */
  strncpy(wireshark_path, u3_host_exec_path, strlen(u3_host_exec_path) + 1);
  strncat(wireshark_path, WIRESHARK_EXE, strlen(WIRESHARK_EXE) + 1);
  strncat(wireshark_path, ",1", 3);

  /* associate the application */
  if(RegCreateKeyEx(HKEY_CLASSES_ROOT, reg_key, 0, NULL, 0,
		    (KEY_READ | KEY_WRITE), NULL, &key, &disposition) == ERROR_SUCCESS) {

    (void)RegSetValueEx(key, "", 0, REG_SZ, wireshark_path, strlen(wireshark_path) + 1);

    RegCloseKey(key);
  }

  /* CREATE THE FILE ASSOCIATIONS */

  for(pext = extensions; *pext; pext++)
    associate(*pext);

  /* update icons */
  SHChangeNotify(SHCNE_ASSOCCHANGED, SHCNF_IDLIST, 0, 0);

  /* START WINPCAP INSTALLATION IF NOT ALREADY INSTALLED */

  if(RegOpenKeyEx(HKEY_LOCAL_MACHINE, WINPCAP_KEY, 0, (KEY_READ), &key) == ERROR_SUCCESS) {

    if(RegQueryValueEx(key, WINPCAP_UNINSTALL, NULL, NULL, buffer, &buflen) == ERROR_SUCCESS) {

      if(buffer[0] != '\0')
	hasWinPcap = TRUE;
    }

    RegCloseKey(key);
  }

  if(!hasWinPcap &&
     (MessageBox(NULL,
		 TEXT("If you want to capture packets from the network you will need to install WinPcap.\nIt will be uninstalled when you remove your U3 device.\n\nDo you want to install WinPcap?"),
		 TEXT("U3 Wireshark: Install WinPcap?"),
		 MB_YESNO|MB_TOPMOST|MB_ICONQUESTION) == IDYES)) {

    /* compute the U3 path to the WinPcap installation package - it stays on the device */
    u3_device_exec_path = getenv("U3_DEVICE_EXEC_PATH");
    strncpy(winpcap_path, "\"", 2);
    strncat(winpcap_path, u3_device_exec_path, strlen(u3_device_exec_path) + 1);
    strncat(winpcap_path, WINPCAP_PACKAGE, strlen(WINPCAP_PACKAGE) + 1);
    strncat(winpcap_path, "\"", 2);

    ExecuteAndWait(winpcap_path);

    /* if installation was successful this key will now exist */
    if(RegOpenKeyEx(HKEY_LOCAL_MACHINE, WINPCAP_KEY, 0, (KEY_READ | KEY_WRITE), &key) == ERROR_SUCCESS) {

      u3_device_serial = getenv("U3_DEVICE_SERIAL");

      (void)RegSetValueEx(key, WINPCAP_U3INSTALLED, 0, REG_SZ, u3_device_serial, strlen(u3_device_serial) + 1);

      winpcap_auto_start();

    }
  }

  /* START VCREDIST INSTALLATION IF NOT ALREADY INSTALLED */

  if(RegOpenKeyEx(HKEY_LOCAL_MACHINE, VCREDIST_KEY, 0, (KEY_READ), &key) == ERROR_SUCCESS) {

    buflen = BUFSIZ;

    if(RegQueryValueEx(key, VCREDIST_UNINSTALL, NULL, NULL, buffer, &buflen) == ERROR_SUCCESS) {

      if(buffer[0] != '\0')
	hasRedist = TRUE;
    }

    RegCloseKey(key);

  } 

  if(!hasRedist) {

    /* compute the U3 path to the Visual C++  redistributables package - it stays on the device */
    u3_device_exec_path = getenv("U3_DEVICE_EXEC_PATH");
    strncpy(vcredist_path, "\"", 2);
    strncat(vcredist_path, u3_device_exec_path, strlen(u3_device_exec_path) + 1);
    strncat(vcredist_path, VCREDIST_PACKAGE, strlen(VCREDIST_PACKAGE) + 1);
    strncat(vcredist_path, "\" /q", 5); /* do things quietly */

    ExecuteAndWait(vcredist_path);

    if(RegOpenKeyEx(HKEY_LOCAL_MACHINE, VCREDIST_KEY, 0, (KEY_READ | KEY_WRITE), &key) == ERROR_SUCCESS) {

      u3_device_serial = getenv("U3_DEVICE_SERIAL");

      (void)RegSetValueEx(key, VCREDIST_U3INSTALLED, 0, REG_SZ, u3_device_serial, strlen(u3_device_serial) + 1);

    }
  }


  /* CREATE THE "My Captures" FOLDER IF IT DOESN'T ALREADY EXIST */

  u3_device_document_path = getenv("U3_DEVICE_DOCUMENT_PATH");
  strncpy(my_captures_path, u3_device_document_path, strlen(u3_device_document_path) + 1);
  strncat(my_captures_path, MY_CAPTURES, strlen(MY_CAPTURES) + 1);

  /* don't care if it succeeds or fails */
  (void) CreateDirectory(my_captures_path, NULL);

  /* Save the environment so we can use it in the file assocation */
  save_environment();
}
Esempio n. 27
0
void write_allocation_Global_0()
{
   listnom *parcours_nom;
   listvar *parcours;
   listvar *parcoursprec;
   listvar *parcours1;
   FILE *allocationagrif;
   char ligne[LONGNOM];
   variable *v;
   int IndiceMax;
   int IndiceMin;
   int compteur;
   int out;
   int indiceprec;
   int ValeurMax;
   char initialvalue[LONG_4C];
   int typeiswritten ;

   parcoursprec = (listvar *)NULL;
   parcours_nom = List_NameOfModule;
   ValeurMax = 2;
   while ( parcours_nom  )
   {
      /*                                                                      */
      if ( parcours_nom->o_val == 1 )
      {
         IndiceMax = 0;
         IndiceMin = indicemaxtabvars;
         /* Open the file to create the Alloc_agrif subroutine                */
         sprintf(ligne,"alloc_agrif_%s.h",parcours_nom->o_nom);
         allocationagrif = associate (ligne);
         /*                                                                   */
         if ( ModuleIsDefineInInputFile(parcours_nom->o_nom) == 1 )
         {
             /* add the call to initworkspace                                 */
            tofich(allocationagrif,"if ( .NOT. Agrif_Root() ) then ",1);
            fprintf(allocationagrif,"#include \"GetNumberofcells.h\" \n");
            tofich(allocationagrif,"else ",1);
            fprintf(allocationagrif,"#include \"SetNumberofcells.h\" \n");
            tofich(allocationagrif,"endif ",1);
            tofich(allocationagrif,"Call Agrif_InitWorkspace ",1);
         }

         typeiswritten = 0;

         parcours = List_Global_Var;
         while ( parcours )
         {
            if ( !strcasecmp(parcours->var->v_modulename,parcours_nom->o_nom) &&
                 parcours->var->v_VariableIsParameter == 0                  &&
                 parcours->var->v_notgrid == 0                              &&
                 !strcasecmp(parcours->var->v_modulename,parcours_nom->o_nom)  )
            {
               /***************************************************************/
               /***************************************************************/
               /***************************************************************/
               v = parcours->var;
               IndiceMax = 0;
               IndiceMin = indicemaxtabvars;
  /* body of the file                                                         */
  if ( !strcasecmp(v->v_commoninfile,mainfile) )
  {
     if (onlyfixedgrids != 1 && v->v_nbdim!=0)
     {
        strcpy (ligne, "If (.not. associated(");
        strcat (ligne, vargridnametabvars(v,0));
        strcat (ligne, "))                       then");
        Save_Length(ligne,48);
        tofich (allocationagrif, ligne,1);
     }
     if ( v->v_allocatable != 1 && ( v->v_dimsempty != 1) )
     {
        /*                ALLOCATION                                          */
        if ( v->v_dimension != 0  )
        {
           if ( v->v_indicetabvars < IndiceMin ||
                v->v_indicetabvars > IndiceMax )
           {
              parcours1 = parcours;
              compteur = -1;
              out = 0;
              indiceprec = parcours->var->v_indicetabvars -1 ;
              while ( parcours1 && out == 0 &&
                      !strcasecmp(  parcours->var->v_readedlistdimension,
                                  parcours1->var->v_readedlistdimension) &&
                      !strcasecmp(  parcours->var->v_typevar,
                                  parcours1->var->v_typevar) &&
                             ( parcours1->var->v_indicetabvars == indiceprec+1 )
                     )
              {

               if ( !strcasecmp(parcours1->var->v_modulename,
                                parcours_nom->o_nom) ||
                    !strcasecmp(parcours1->var->v_commonname,
                                parcours_nom->o_nom) )
                 {
                      compteur = compteur +1 ;
                      indiceprec = parcours1->var->v_indicetabvars;
                      parcoursprec = parcours1;
                      parcours1 = parcours1->suiv;
                 }
                 else out = 1;
              }
              if ( compteur > ValeurMax )
              {
                 fprintf(allocationagrif,"      DO i = %d , %d\n",
                                          parcours->var->v_indicetabvars,
                                       parcours->var->v_indicetabvars+compteur);
                 IndiceMin = parcours->var->v_indicetabvars;
                 IndiceMax = parcours->var->v_indicetabvars+compteur;
                 strcpy (ligne, "allocate ");
                 strcat (ligne, "(");
                 strcat (ligne, vargridnametabvars(v,1));
                 strcat (ligne, vargridparam(v,0));
                 strcat (ligne, ")");
                 Save_Length(ligne,48);
                 tofich (allocationagrif, ligne,1);
                 fprintf(allocationagrif,"      end do\n");
                 parcours = parcoursprec;
              }
              else
              {
                 strcpy (ligne, "allocate ");
                 strcat (ligne, "(");
                 strcat (ligne, vargridnametabvars(v,0));
                 strcat (ligne, vargridparam(v,0));
                 strcat (ligne, ")");
                 Save_Length(ligne,48);
                 tofich (allocationagrif, ligne,1);
              }
           }
        } /* end of the allocation part                                       */

        /*                INITIALISATION                                      */
        if ( strcasecmp(v->v_initialvalue,"") )
        {
           strcpy (ligne, "");
           strcat (ligne, vargridnametabvars(v,0));
           /* We should modify the initialvalue in the case of variable has   */
           /*    been defined with others variables                           */

           strcpy(initialvalue,
                  ChangeTheInitalvaluebyTabvarsName
                                      (v->v_initialvalue,List_Global_Var,0));
           if ( !strcasecmp(initialvalue,v->v_initialvalue) )
           {
              strcpy(initialvalue,"");
              strcpy(initialvalue,ChangeTheInitalvaluebyTabvarsName
                                      (v->v_initialvalue,List_Common_Var,0));
           }
           if ( !strcasecmp(initialvalue,v->v_initialvalue) )
           {
              strcpy(initialvalue,"");
              strcpy(initialvalue,ChangeTheInitalvaluebyTabvarsName
                                     (v->v_initialvalue,List_ModuleUsed_Var,0));
           }
           strcat (ligne," = ");
           strcat (ligne,initialvalue);
           /*                                                                 */
           Save_Length(ligne,48);
           tofich (allocationagrif, ligne,1);
        }
     }
/* Case of structure types */
        if ((typeiswritten == 0) && !strcasecmp(v->v_typevar,"type"))
        {
        sprintf(ligne,"If (.Not.Allocated(Agrif_%s_var)) Then",v->v_modulename);
        tofich(allocationagrif, ligne, 1);
        sprintf(ligne,"Allocate(Agrif_%s_var(0:Agrif_NbMaxGrids))",v->v_modulename);
        tofich(allocationagrif, ligne, 1);
        strcpy(ligne,"End If");
        tofich(allocationagrif, ligne, 1);
        typeiswritten = 1;
        }
     if (onlyfixedgrids != 1 && v->v_nbdim!=0)
     {
        strcpy (ligne, "   End if");
        tofich (allocationagrif, ligne,1);
     }
  }
               /***************************************************************/
               /***************************************************************/
               /***************************************************************/
            }
            parcours = parcours -> suiv;
         }
         /*                                                                   */
         if ( ModuleIsDefineInInputFile(parcours_nom->o_nom) == 1 )
         {
            /* add the call to initworkspace                                  */
            tofich(allocationagrif,"if ( .NOT. Agrif_Root() ) then ",1);
            fprintf(allocationagrif,"#include \"GetNumberofcells.h\" \n");
            tofich(allocationagrif,"else ",1);
            fprintf(allocationagrif,"#include \"SetNumberofcells.h\" \n");
            tofich(allocationagrif,"endif ",1);
            tofich(allocationagrif,"Call Agrif_InitWorkspace ",1);
         }
         /* Close the file Alloc_agrif                                        */
         fclose(allocationagrif);
      } /* end parcours_nom == 1                                              */
      /*                                                                      */
      parcours_nom = parcours_nom -> suiv;
   }
}
Esempio n. 28
0
void write_allocation_Common_0()
{
   listnom *parcours_nom;
   listnom *neededparameter;
   listvar *parcours;
   listvar *parcoursprec;
   listvar *parcours1;
   FILE *allocationagrif;
   FILE *paramtoamr;
   char ligne[LONGNOM];
   char ligne2[LONGNOM];   
   variable *v;
   int IndiceMax;
   int IndiceMin;
   int compteur;
   int out;
   int indiceprec;
   int ValeurMax;
   char initialvalue[LONG_4C];
   listindice *list_indic;
   listindice *parcoursindic;
   int i;

   parcoursprec = (listvar *)NULL;
   parcours_nom = List_NameOfCommon;
   ValeurMax = 2;
   while ( parcours_nom  )
   {
      /*                                                                      */
      if ( parcours_nom->o_val == 1 )
      {
         /* Open the file to create the Alloc_agrif subroutine                */
         sprintf(ligne,"alloc_agrif_%s.h",parcours_nom->o_nom);
         allocationagrif = associate (ligne);
         /*                                                                   */
         fprintf(allocationagrif,"#include \"Param_toamr_%s.h\" \n",
                                                           parcours_nom->o_nom);
         /*                                                                   */
         sprintf(ligne,"Param_toamr_%s.h",parcours_nom->o_nom);
         paramtoamr = associate (ligne);
         neededparameter = (listnom * )NULL;
         /*                                                                   */
         list_indic = (listindice *)NULL;
         /*                                                                   */
         shouldincludempif = 1 ;
         parcours = List_Common_Var;
         while ( parcours )
         {
            if ( !strcasecmp(parcours->var->v_commonname,parcours_nom->o_nom) &&
                  IndiceInlist(parcours->var->v_indicetabvars,list_indic) == 0
               )
            {
               /***************************************************************/
               /***************************************************************/
               /***************************************************************/
               v = parcours->var;
               IndiceMax = 0;
               IndiceMin = indicemaxtabvars;
  /* body of the file                                                         */
  if ( !strcasecmp(v->v_commoninfile,mainfile) )
  {
     if (onlyfixedgrids != 1 && v->v_nbdim!=0)
     {
        strcpy (ligne, "If (.not. associated(");
        strcat (ligne, vargridnametabvars(v,0));
        strcat (ligne, "))                       then");
        Save_Length(ligne,48);
        tofich (allocationagrif, ligne,1);
     }
     if ( v->v_allocatable != 1 && ( v->v_dimsempty != 1) )
     {
        /*                ALLOCATION                                          */
        if ( v->v_dimension != 0  )
        {
           if ( v->v_indicetabvars < IndiceMin ||
                v->v_indicetabvars > IndiceMax )
           {
              parcours1 = parcours;
              compteur = -1;
              out = 0;
              indiceprec = parcours->var->v_indicetabvars -1 ;
              while ( parcours1 && out == 0 &&
                      !strcasecmp(  parcours->var->v_readedlistdimension,
                                  parcours1->var->v_readedlistdimension) &&
                      !strcasecmp(  parcours->var->v_typevar,
                                  parcours1->var->v_typevar) &&
                            ( parcours1->var->v_indicetabvars == indiceprec+1 )
                     )
              {

               if ( !strcasecmp(parcours1->var->v_modulename,
                                parcours_nom->o_nom) ||
                    !strcasecmp(parcours1->var->v_commonname,
                                parcours_nom->o_nom) )
                 {
                      compteur = compteur +1 ;
                      indiceprec = parcours1->var->v_indicetabvars;
                      parcoursprec = parcours1;
                      parcours1 = parcours1->suiv;
                 }
                 else out = 1;
              }

              if ( compteur > ValeurMax )
              {
                 fprintf(allocationagrif,"      DO i = %d , %d\n",
                                         parcours->var->v_indicetabvars,
                                       parcours->var->v_indicetabvars+compteur);
                 IndiceMin = parcours->var->v_indicetabvars;
                 IndiceMax = parcours->var->v_indicetabvars+compteur;
                 strcpy (ligne, "allocate ");
                 strcat (ligne, "(");
                 strcat (ligne, vargridnametabvars(v,1));
                 strcat (ligne, vargridparam(v,0));
                 strcat (ligne, ")");
                 Save_Length(ligne,48);
                 tofich (allocationagrif, ligne,1);
                 fprintf(allocationagrif,"      end do\n");
                 i=parcours->var->v_indicetabvars;
                 do
                 {
                    parcoursindic =  (listindice *)malloc(sizeof(listindice));
                    parcoursindic -> i_indice = i;
                    parcoursindic -> suiv = list_indic;
                    list_indic = parcoursindic;
                    i = i + 1;
                 } while ( i <= parcours->var->v_indicetabvars+compteur );
                 parcours = parcoursprec;
                 /*                                                           */
              }
              else
              {
                 strcpy (ligne, "allocate ");
                 strcat (ligne, "(");
                 strcat (ligne, vargridnametabvars(v,0));
                 strcat (ligne, vargridparam(v,0));
                 strcat (ligne, ")");
                 Save_Length(ligne,48);
                 tofich (allocationagrif, ligne,1);
                 /*                                                           */
                 parcoursindic =  (listindice *)malloc(sizeof(listindice));
                 parcoursindic -> i_indice = parcours->var->v_indicetabvars;
                 parcoursindic -> suiv = list_indic;
                 list_indic = parcoursindic;
              }
                neededparameter = writedeclarationintoamr(List_Parameter_Var,
                              paramtoamr,v,parcours_nom->o_nom,neededparameter,
                                                               v->v_commonname);
              /*                                                              */
           }
        } /* end of the allocation part                                       */
        /*                INITIALISATION                                      */
        if ( strcasecmp(v->v_initialvalue,"") )
        {
           strcpy (ligne, "");
           strcat (ligne, vargridnametabvars(v,0));
           /* We should modify the initialvalue in the case of variable has   */
           /*    been defined with others variables                           */
                      
           strcpy(initialvalue,
                  ChangeTheInitalvaluebyTabvarsName
                                      (v->v_initialvalue,List_Global_Var,0));
           if ( !strcasecmp(initialvalue,v->v_initialvalue) )
           {
              strcpy(initialvalue,"");
              strcpy(initialvalue,ChangeTheInitalvaluebyTabvarsName
                                      (v->v_initialvalue,List_Common_Var,0));
           }
           if ( !strcasecmp(initialvalue,v->v_initialvalue) )
           {
              strcpy(initialvalue,"");
              strcpy(initialvalue,ChangeTheInitalvaluebyTabvarsName
                                     (v->v_initialvalue,List_ModuleUsed_Var,0));
           }
           strcat (ligne," = ");

           if (v->v_nbdim == 0)
           {
           strcpy(ligne2,initialvalue);
           }
           else
           {
           sprintf(ligne2,"RESHAPE(%s,SHAPE(%s))",initialvalue,vargridnametabvars(v,0));
           }
           strcat (ligne,ligne2);
           /*                                                                 */
           Save_Length(ligne,48);
           tofich (allocationagrif, ligne,1);
        }
     }
     if (onlyfixedgrids != 1 && v->v_nbdim!=0)
     {
        strcpy (ligne, "   End if");
        tofich (allocationagrif, ligne,1);
     }
  }
               /***************************************************************/
               /***************************************************************/
               /***************************************************************/
            }
            parcours = parcours -> suiv;
         }
         /* Close the file Alloc_agrif                                        */
         fclose(allocationagrif);
         fclose(paramtoamr);
      }
      /*                                                                      */
      parcours_nom = parcours_nom -> suiv;
   }

}
Esempio n. 29
0
int _main_(int _argc, char** _argv)
{
	bx::CommandLine cmdLine(_argc, _argv);

	if (cmdLine.hasArg('h', "help") )
	{
		help();
		return EXIT_FAILURE;
	}
	else if (cmdLine.hasArg("associate") )
	{
		associate();
		return EXIT_FAILURE;
	}

	uint32_t width  = 1280;
	uint32_t height = 720;
	uint32_t debug  = BGFX_DEBUG_TEXT;
	uint32_t reset  = BGFX_RESET_VSYNC;

	inputAddBindings(s_bindingName[Binding::App],  s_binding[Binding::App]);
	inputAddBindings(s_bindingName[Binding::View], s_binding[Binding::View]);

	View view;
	cmdAdd("view", cmdView, &view);

	bgfx::init();
	bgfx::reset(width, height, reset);

	// Set view 0 clear state.
	bgfx::setViewClear(0
		, BGFX_CLEAR_COLOR|BGFX_CLEAR_DEPTH
		, 0x101010ff
		, 1.0f
		, 0
		);

	imguiCreate();

	PosUvColorVertex::init();

	bgfx::RendererType::Enum type = bgfx::getRendererType();

	bgfx::ShaderHandle vsTexture      = bgfx::createEmbeddedShader(s_embeddedShaders, type, "vs_texture");
	bgfx::ShaderHandle fsTexture      = bgfx::createEmbeddedShader(s_embeddedShaders, type, "fs_texture");
	bgfx::ShaderHandle fsTextureArray = bgfx::createEmbeddedShader(s_embeddedShaders, type, "fs_texture_array");

	bgfx::ProgramHandle textureProgram = bgfx::createProgram(
			  vsTexture
			, fsTexture
			, true
			);

	bgfx::ProgramHandle textureArrayProgram = bgfx::createProgram(
			  vsTexture
			, bgfx::isValid(fsTextureArray)
			? fsTextureArray
			: fsTexture
			, true
			);

	bgfx::ProgramHandle textureCubeProgram = bgfx::createProgram(
			  bgfx::createEmbeddedShader(s_embeddedShaders, type, "vs_texture_cube")
			, bgfx::createEmbeddedShader(s_embeddedShaders, type, "fs_texture_cube")
			, true
			);

	bgfx::ProgramHandle textureSDFProgram = bgfx::createProgram(
			  vsTexture
			, bgfx::createEmbeddedShader(s_embeddedShaders, type, "fs_texture_sdf")
			, true);

	bgfx::UniformHandle s_texColor = bgfx::createUniform("s_texColor", bgfx::UniformType::Int1);
	bgfx::UniformHandle u_mtx      = bgfx::createUniform("u_mtx",      bgfx::UniformType::Mat4);
	bgfx::UniformHandle u_params   = bgfx::createUniform("u_params",   bgfx::UniformType::Vec4);

	float speed = 0.37f;
	float time  = 0.0f;

	Interpolator mip(0.0f);
	Interpolator layer(0.0f);
	Interpolator zoom(1.0f);
	Interpolator scale(1.0f);

	const char* filePath = _argc < 2 ? "" : _argv[1];
	bool directory = false;

	bx::FileInfo fi;
	bx::stat(filePath, fi);
	directory = bx::FileInfo::Directory == fi.m_type;

	std::string path = filePath;
	if (!directory)
	{
		const char* fileName = directory ? filePath : bx::baseName(filePath);
		path.assign(filePath, fileName);
		view.updateFileList(path.c_str(), fileName);
	}
	else
	{
		view.updateFileList(path.c_str() );
	}

	int exitcode = EXIT_SUCCESS;
	bgfx::TextureHandle texture = BGFX_INVALID_HANDLE;

	if (view.m_fileList.empty() )
	{
		exitcode = EXIT_FAILURE;
		if (2 > _argc)
		{
			help("File path is not specified.");
		}
		else
		{
			fprintf(stderr, "Unable to load '%s' texture.\n", filePath);
		}
	}
	else
	{
		uint32_t fileIndex = 0;

		entry::MouseState mouseState;
		while (!entry::processEvents(width, height, debug, reset, &mouseState) )
		{
			imguiBeginFrame(mouseState.m_mx
				, mouseState.m_my
				, (mouseState.m_buttons[entry::MouseButton::Left  ] ? IMGUI_MBUT_LEFT   : 0)
				| (mouseState.m_buttons[entry::MouseButton::Right ] ? IMGUI_MBUT_RIGHT  : 0)
				| (mouseState.m_buttons[entry::MouseButton::Middle] ? IMGUI_MBUT_MIDDLE : 0)
				, mouseState.m_mz
				, width
				, height
				);

			static bool help = false;

			if (help == false
			&&  help != view.m_help)
			{
				ImGui::OpenPopup("Help");
			}

			if (ImGui::BeginPopupModal("Help", NULL, ImGuiWindowFlags_AlwaysAutoResize) )
			{
				ImGui::SetWindowFontScale(1.0f);

				ImGui::Text(
					"texturev, bgfx texture viewer tool " ICON_KI_WRENCH "\n"
					"Copyright 2011-2017 Branimir Karadzic. All rights reserved.\n"
					"License: https://github.com/bkaradzic/bgfx#license-bsd-2-clause\n"
					);
				ImGui::Separator();
				ImGui::NextLine();

				ImGui::Text("Key bindings:\n\n");

				ImGui::PushFont(ImGui::Font::Mono);
				ImGui::TextColored(ImVec4(1.0f, 1.0f, 0.0f, 1.0f), "ESC");   ImGui::SameLine(64); ImGui::Text("Exit.");
				ImGui::TextColored(ImVec4(1.0f, 1.0f, 0.0f, 1.0f), "h");     ImGui::SameLine(64); ImGui::Text("Toggle help screen.");
				ImGui::TextColored(ImVec4(1.0f, 1.0f, 0.0f, 1.0f), "f");     ImGui::SameLine(64); ImGui::Text("Toggle full-screen.");
				ImGui::NextLine();

				ImGui::TextColored(ImVec4(1.0f, 1.0f, 0.0f, 1.0f), "-");     ImGui::SameLine(64); ImGui::Text("Zoom out.");
				ImGui::TextColored(ImVec4(1.0f, 1.0f, 0.0f, 1.0f), "=");     ImGui::SameLine(64); ImGui::Text("Zoom in.");
				ImGui::NextLine();

				ImGui::TextColored(ImVec4(1.0f, 1.0f, 0.0f, 1.0f), ",");     ImGui::SameLine(64); ImGui::Text("MIP level up.");
				ImGui::TextColored(ImVec4(1.0f, 1.0f, 0.0f, 1.0f), ".");     ImGui::SameLine(64); ImGui::Text("MIP level down.");
				ImGui::TextColored(ImVec4(1.0f, 1.0f, 0.0f, 1.0f), "/");     ImGui::SameLine(64); ImGui::Text("Toggle linear/point texture sampling.");
				ImGui::NextLine();

				ImGui::TextColored(ImVec4(1.0f, 1.0f, 0.0f, 1.0f), "left");  ImGui::SameLine(64); ImGui::Text("Previous layer in texture array.");
				ImGui::TextColored(ImVec4(1.0f, 1.0f, 0.0f, 1.0f), "right"); ImGui::SameLine(64); ImGui::Text("Next layer in texture array.");
				ImGui::NextLine();

				ImGui::TextColored(ImVec4(1.0f, 1.0f, 0.0f, 1.0f), "up");    ImGui::SameLine(64); ImGui::Text("Previous texture.");
				ImGui::TextColored(ImVec4(1.0f, 1.0f, 0.0f, 1.0f), "down");  ImGui::SameLine(64); ImGui::Text("Next texture.");
				ImGui::NextLine();

				ImGui::TextColored(ImVec4(1.0f, 1.0f, 0.0f, 1.0f), "r/g/b"); ImGui::SameLine(64); ImGui::Text("Toggle R, G, or B color channel.");
				ImGui::TextColored(ImVec4(1.0f, 1.0f, 0.0f, 1.0f), "a");     ImGui::SameLine(64); ImGui::Text("Toggle alpha blending.");
				ImGui::NextLine();

				ImGui::TextColored(ImVec4(1.0f, 1.0f, 0.0f, 1.0f), "s");     ImGui::SameLine(64); ImGui::Text("Toggle Multi-channel SDF rendering");

				ImGui::PopFont();

				ImGui::NextLine();

				ImGui::Dummy(ImVec2(0.0f, 0.0f) );
				ImGui::SameLine(ImGui::GetWindowWidth() - 136.0f);
				if (ImGui::Button("Close", ImVec2(128.0f, 0.0f) )
				|| !view.m_help)
				{
					view.m_help = false;
					ImGui::CloseCurrentPopup();
				}

				ImGui::EndPopup();
			}

			help = view.m_help;

			imguiEndFrame();

			if (!bgfx::isValid(texture)
			||  view.m_fileIndex != fileIndex)
			{
				if (bgfx::isValid(texture) )
				{
					bgfx::destroyTexture(texture);
				}

				fileIndex = view.m_fileIndex;

				filePath = view.m_fileList[view.m_fileIndex].c_str();

				texture = loadTexture(filePath
						, 0
						| BGFX_TEXTURE_U_CLAMP
						| BGFX_TEXTURE_V_CLAMP
						| BGFX_TEXTURE_W_CLAMP
						, 0
						, &view.m_info
						);

				std::string title;
				bx::stringPrintf(title, "%s (%d x %d%s, %s)"
					, filePath
					, view.m_info.width
					, view.m_info.height
					, view.m_info.cubeMap ? " CubeMap" : ""
					, bgfx::getName(view.m_info.format)
					);
				entry::WindowHandle handle = { 0 };
				entry::setWindowTitle(handle, title.c_str() );
			}

			int64_t now = bx::getHPCounter();
			static int64_t last = now;
			const int64_t frameTime = now - last;
			last = now;
			const double freq = double(bx::getHPFrequency() );

			time += (float)(frameTime*speed/freq);

			float ortho[16];
			bx::mtxOrtho(ortho, 0.0f, (float)width, (float)height, 0.0f, 0.0f, 1000.0f);
			bgfx::setViewTransform(0, NULL, ortho);
			bgfx::setViewRect(0, 0, 0, width, height);
			bgfx::touch(0);

			bgfx::dbgTextClear();

			scale.set(
				  bx::fmin( float(width) / float(view.m_info.width)
				, float(height) / float(view.m_info.height)
				)
				, 0.1f
				);
			zoom.set(view.m_zoom, 0.25);

			float ss = scale.getValue() * zoom.getValue();

			screenQuad( int(width  - view.m_info.width  * ss)/2
				, int(height - view.m_info.height * ss)/2
				, int(view.m_info.width  * ss)
				, int(view.m_info.height * ss)
				, view.m_abgr
				);

			float mtx[16];
			bx::mtxRotateXY(mtx, 0.0f, time);
			bgfx::setUniform(u_mtx, mtx);

			mip.set(float(view.m_mip), 0.5f);
			layer.set(float(view.m_layer), 0.25f);

			float params[4] = { mip.getValue(), layer.getValue(), 0.0f, 0.0f };
			bgfx::setUniform(u_params, params);

			bgfx::setTexture(0
				, s_texColor
				, texture
				, view.m_filter
				? BGFX_TEXTURE_NONE
				: 0
				| BGFX_TEXTURE_MIN_POINT
				| BGFX_TEXTURE_MIP_POINT
				| BGFX_TEXTURE_MAG_POINT
				);
			bgfx::setState(0
				| BGFX_STATE_RGB_WRITE
				| BGFX_STATE_ALPHA_WRITE
				| (view.m_alpha ? BGFX_STATE_BLEND_ALPHA : BGFX_STATE_NONE)
				);
			bgfx::submit(0
					,     view.m_info.cubeMap   ? textureCubeProgram
					: 1 < view.m_info.numLayers ? textureArrayProgram
					:     view.m_sdf            ? textureSDFProgram
					:                             textureProgram
					);

			bgfx::frame();
		}
	}

	if (bgfx::isValid(texture) )
	{
		bgfx::destroyTexture(texture);
	}
	bgfx::destroyUniform(s_texColor);
	bgfx::destroyUniform(u_mtx);
	bgfx::destroyUniform(u_params);
	bgfx::destroyProgram(textureProgram);
	bgfx::destroyProgram(textureArrayProgram);
	bgfx::destroyProgram(textureCubeProgram);

	imguiDestroy();

	bgfx::shutdown();

	return exitcode;
}
Esempio n. 30
0
void creefichieramr (char *NameTampon)
{
  listvar *newvar;
  variable *v;
  int erreur;
  char filefich[LONG_C];
  char ligne[LONG_C];
  int IndiceMax;
  int IndiceMin;
  int InitEmpty;
  int VarnameEmpty;
  int donotwrite;

  FILE *initproc;
  FILE *initglobal;
  FILE *createvarname;
  FILE *createvarnameglobal;

  if ( todebug == 1 ) printf("Enter in creefichieramr\n");
  strcpy (filefich, "cd ");
  strcat (filefich, nomdir);
  erreur = system (filefich);
  if (erreur)
  {
     strcpy (filefich, "mkdir ");
     strcat (filefich, nomdir);
     system (filefich);
     printf ("%s: Directory created\n", nomdir);
  }

/******************************************************************************/
/******************** Creation of AGRIF_INC files *****************************/
/******************************************************************************/

/*----------------------------------------------------------------------------*/
  if ( todebug == 1 )
  {
     strcpy(ligne,"initialisations_agrif_");
     strcat(ligne,NameTampon);
     strcat(ligne,".h");
     initproc = associate (ligne);
/*----------------------------------------------------------------------------*/
     strcpy(ligne,"createvarname_agrif_");
     strcat(ligne,NameTampon);
     strcat(ligne,".h");
     createvarname = associate (ligne);
/*----------------------------------------------------------------------------*/
     InitEmpty = 1 ;
     VarnameEmpty = 1 ;

     newvar = List_Global_Var;
     while ( newvar && todebug == 1 )
     {
        donotwrite = 0;
        v = newvar->var;

        if ( ( v->v_common == 1 || v->v_module == 1 ) && donotwrite == 0 )
        {
          write_createvarnameagrif_file(v,createvarname,&VarnameEmpty);
          write_initialisationsagrif_file(v,initproc,&InitEmpty);
        }
        newvar = newvar->suiv;
     }
  /*                                                                          */
     fclose (createvarname);
     fclose (initproc);
  /*--------------------------------------------------------------------------*/
     if ( Did_filetoparse_readed(curmodulename) == 0 )
     {
        if ( InitEmpty != 1  )
        {
           initglobal = associateaplus("initialisations_agrif.h");
           strcpy(ligne,"#include \"initialisations_agrif_");
           strcat(ligne,NameTampon);
           strcat(ligne,".h\"\n");
           fprintf(initglobal,ligne);
           fclose(initglobal);
        }
  /*--------------------------------------------------------------------------*/
        if ( VarnameEmpty != 1 )
        {
           createvarnameglobal= associateaplus("createvarname_agrif.h");
           strcpy(ligne,"#include \"createvarname_agrif_");
           strcat(ligne,NameTampon);
           strcat(ligne,".h\"\n");
           fprintf(createvarnameglobal,ligne);
           fclose(createvarnameglobal);
        }
     }
  }
/*----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------*/
  IndiceMax = 0;
  IndiceMin = 0;

  write_allocation_Common_0();
  write_allocation_Global_0();

  Write_Alloc_Agrif_Files();
  write_probdimagrif_file();
  write_keysagrif_file();
  write_modtypeagrif_file();
  if ( NbMailleXDefined == 1 )
                             write_Setnumberofcells_file("SetNumberofcells.h");
  if ( NbMailleXDefined == 1 )
                             write_Getnumberofcells_file("GetNumberofcells.h");
  retour77 = 0;
  if ( NbMailleXDefined == 1 )
                          write_Setnumberofcells_file("SetNumberofcellsFree.h");
  if ( NbMailleXDefined == 1 )
                          write_Getnumberofcells_file("GetNumberofcellsFree.h");
  retour77 = 1;
  if ( NbMailleXDefined == 1 )
                         write_Setnumberofcells_file("SetNumberofcellsFixed.h");
  if ( NbMailleXDefined == 1 )
                         write_Getnumberofcells_file("GetNumberofcellsFixed.h");
  if ( todebug == 1 ) printf("Out of creefichieramr\n");
}