Пример #1
0
char			*usr_cmd(int fd, t_history *histo, t_options options)
{
  struct termios	set;
  struct termios	unset;
  char			*str;
  char			*cmd;
  int			rev_c;
  int			histo_pl;

  (void)options;
  if (init_termios(&set, &unset) == -1 ||
      init_values(&histo_pl, &rev_c, &str, &cmd) == -1)
    return (unset_termios(&unset));
  show_cmd(str[0], fd, cmd, rev_c);
  while (str[0] != 10 || str[1] != 0 || str[2] != 0)
    {
      if (read_cmd(fd, &str, &cmd, &rev_c) == -1)
	return (unset_termios(&unset));
      if (histo_pl < length_of_history(histo) && chk_str(str, 27, 91, 65) == 0)
	if (take_cmd_from_history(++histo_pl, &rev_c, &cmd, histo) == -1)
	  return (unset_termios(&unset));
      if (histo_pl > 0 && chk_str(str, 27, 91, 66) == 0)
	if (take_cmd_from_history(--histo_pl, &rev_c, &cmd, histo) == -1)
	  return (unset_termios(&unset));
      show_cmd(str[0], fd, cmd, rev_c);
    }
  return (finish_usr_cmd(cmd, str, unset));
}
Пример #2
0
/****************
 * MAINFUNCTION *
 ****************/
int
main(void) {

	struct state state;

	/* Einlesen der uebergebenen Argumente */
	read_env(param);
	
        /* 
	 * Initialisieren der Datenstruktur zum Abbilden des programminternen 
	 * Berechnungsstatus
	 */
	init_values(&state);

	/* Schreiben des KML-Headers */
	print_header(&state);

	/* Schreiben der zu verwendenden Farbkonfigurationen */
	print_colorstyles(&state);

	/* Plotten der einzelnen Netzelemente (Dichtedarstellung) und 
	 * verwendeten Trajketorien (unsichtbar) 
	 */ 
	plot(&state); 

	/* Schliessen der KML-Strukturen */
	print_end(&state);

	/* Reservierte Speicherbereiche wieder freigeben */
	reset_state(&state);

	return 0;
}
Пример #3
0
// creates a new MandelPod window
void new_mandel_window(void)
{
	// get the graphics context
	mandel_gc = pz_get_gc(1);
		
	// create the main window
	mandel_wid = pz_new_window (0, 21,
				screen_info.cols, screen_info.rows - (HEADER_TOPLINE+1),
				draw_header, handle_event);
#ifdef MANDELPOD_STATUS
	// create the status window
	status_wid = pz_new_window (22, 4, 12, 12, draw_idle_status, handle_event);
#endif
	 // get screen info
	GrGetWindowInfo(mandel_wid, &wi);
	
	// select the event types
	GrSelectEvents (mandel_wid, GR_EVENT_MASK_EXPOSURE | GR_EVENT_MASK_KEY_DOWN | GR_EVENT_MASK_KEY_UP | GR_EVENT_MASK_TIMER);
		
	// display the window
	GrMapWindow (mandel_wid);
#ifdef MANDELPOD_STATUS
	GrMapWindow (status_wid);
#endif

    // create the timer for the busy status animation
    mandel_timer_id = GrCreateTimer (mandel_wid, 250);

	// start main app
	init_values();
	create_status();
	draw_header();
	calculate_mandel();
}
Пример #4
0
static plc_t configure_counters(const config_t conf, plc_t plc){

    sequence_t seq = get_sequence_entry(CONFIG_MREG, conf);
    
    if(seq) {
        plc_t p = plc;
        int i = 0;
        char * val = NULL;
        for(; i < seq->size; i++){
            //names
            p = declare_names(OP_MEMORY, &(seq->vars[i]), p);
            //defaults
            p = init_values(OP_MEMORY, &(seq->vars[i]), p);
            //readonlies
            p = configure_readonly(OP_MEMORY, &(seq->vars[i]), p);
            //directions    
            if((val = get_param_val("COUNT", seq->vars[i].params))){
                p = configure_counter_direction(p, i, val);
                val = NULL;
            }
        }
        return p;   
    } 
    return plc;
}
Пример #5
0
int main(int argc, const char *argv[])
{
	init_tools();
	init_values();
	init_evaluator();
	init_interpreter();
	init_tests();
	init_sexp_to_c();
	
	// TO TRY: Add an -O3 flag to Xcode's compile. Then compile and profile, and see if it runs faster.
	
//	run_tests();
//	run_benchmarks();
		
	if (argc > 1) {
		if (streq(argv[1], "test")) {
			run_tests();
		} else if (streq(argv[1], "benchmark")) {
			run_benchmarks();
		} else {
			value str = value_set_str(argv[1]);
			value_import(str);
			value_clear(&str);
		}
	} else {
		run_interpreter();
	}
	
	return 0;
}
Пример #6
0
int main(int argc, char* args[])
{

    //AllocConsole();
    //freopen("CONOUT$", "a", stdout);

    //Initialize our vertices based off of the XML file
    init_values("resources/defaults.xml");

    //Start our networking thread
    pthread_t thread;
    int rc;
    rc = pthread_create(&thread, NULL, networking_listen_entry, (void*)NULL); //Create the thread

    sendValues.init("2410", true, "192.168.0.1");

    //Initialize our Libraries
    glutInit(&argc, args);
    init();

    //Start the Program
    main_loop();

    pthread_cancel(thread);

    //Wait until the networking thread exits
    pthread_exit(NULL);

    return 0;
}
Пример #7
0
static plc_t configure_reals(const config_t conf, plc_t plc){

    sequence_t seq = get_sequence_entry(CONFIG_MVAR, conf);
    
    if(seq) {
        plc_t p = plc;
        int i = 0;
        for(; i < seq->size; i++){
            //names
            p = declare_names(OP_REAL_MEMORY, &(seq->vars[i]), plc);
            //defaults
            p = init_values(OP_REAL_MEMORY, &(seq->vars[i]), p);
            //readonlies
            p = configure_readonly(OP_REAL_MEMORY, &(seq->vars[i]), p); 
        }
        return p; 
    } 
    return plc;
}
Пример #8
0
ADVANCED_COMPRESSOR::ADVANCED_COMPRESSOR (double peak_limit, double release_time, double cfrate,
					  double crate) 
  : rlevelsqn(ADVANCED_COMPRESSOR::NFILT),
    rlevelsqe(ADVANCED_COMPRESSOR::NEFILT)
{
  init_values();

  set_parameter(1, peak_limit);
  set_parameter(2, release_time);
  set_parameter(3, cfrate);
  set_parameter(4, crate);

  MESSAGE_ITEM otemp;
  otemp.setprecision(2);
  otemp << "(audiofx_compressor) Advanced compressor enabled;";
  otemp << " peak limit " << peakpercent;
  otemp << " release time " << release_time;
  otemp << " cfrate " << fastgaincompressionratio;
  otemp << " crate " << compressionratio << ".";
  ECA_LOG_MSG(ECA_LOGGER::info, otemp.to_string());
}
Пример #9
0
int main(int argc, char* argv[])
{
    Registers registers;
    Decoder decoder;
    Reader reader;
    int memory[1001];
    
    init_values(&registers, memory);
    read_lines(&reader, argv[1]);
    
    while(registers.regs[eip] != 0)
    {
        char* line;
        line = fetch_instruction(&registers, &reader);
        parse(&registers, &decoder, line, memory);
        parse_operand(&registers, &decoder, memory);
        printf(" eip: %*i", 3,  registers.regs[eip]); 
        printf(" eax: %*i", 3, registers.regs[eax]);
        printf(" ebp: %*i", 3, registers.regs[ebp]); 
        printf(" esp: %i\n", registers.regs[esp]);
    } // while ()
    
    return 0;
}  // main()
Пример #10
0
int main(int argc, char *argv[])
{
    struct pollfd p[3];
    struct timespec timeout;
    struct device_settings settings;
    struct sigaction sa;
    sigset_t sigs;
    short events;

    if (argc < 3) {
        std::cout << "Running " << argv[0] << " requires 'sixad'. Please run sixad instead" << std::endl;
        return 1;
    }

    const char *mac = argv[1];
    debug = atoi(argv[2]);

    open_log("sixad-remote");
    settings = init_values(mac);
    settings.joystick.axis = false;
    settings.joystick.sbuttons = false;
    settings.joystick.accel = false;
    settings.joystick.speed = false;
    settings.joystick.pos = false;;
    settings.led.enabled = false;
    settings.rumble.enabled = false;

    ufd = uinput_open(DEV_TYPE_REMOTE, mac, settings);

    if (ufd->js < 0 || ufd->mk < 0) {
        return 1;
    } else if (ufd->js == 0 && ufd->mk == 0) {
        syslog(LOG_ERR, "remote config has no joystick or input mode selected - please choose one!");
        return 1;
    }

    int modes = 0;
    if (settings.remote.numeric) modes |= REMOTE_KEYMODE_NUMBERIC;
    if (settings.remote.dvd) modes |= REMOTE_KEYMODE_DVD;
    if (settings.remote.directional) modes |= REMOTE_KEYMODE_DIRECTIONAL;
    if (settings.remote.multimedia) modes |= REMOTE_KEYMODE_MULTIMEDIA;

    sigfillset(&sigs);
//    sigdelset(&sigs, SIGCHLD);
//    sigdelset(&sigs, SIGPIPE);
//    sigdelset(&sigs, SIGTERM);
//    sigdelset(&sigs, SIGINT);
//    sigdelset(&sigs, SIGHUP);

    memset(&sa, 0, sizeof(sa));
    sa.sa_flags = SA_NOCLDSTOP;

    sa.sa_handler = sig_term;
    sigaction(SIGTERM, &sa, NULL);
    sigaction(SIGINT, &sa, NULL);

    sa.sa_handler = SIG_IGN;
    sigaction(SIGCHLD, &sa, NULL);
    sigaction(SIGPIPE, &sa, NULL);

    if (debug) syslog(LOG_INFO, "Press any to activate");

    p[0].fd = 0;
    p[0].events = POLLIN | POLLERR | POLLHUP;

    p[1].fd = 1;
    p[1].events = POLLIN | POLLERR | POLLHUP;

    p[2].fd = ufd->mk ? ufd->mk : ufd->js;
    p[2].events = POLLIN | POLLERR | POLLHUP;

    while (!io_canceled()) {
        int i, idx = 3;
        for (i = 0; i < idx; i++)
            p[i].revents = 0;

        timeout.tv_sec = 1;
        timeout.tv_nsec = 0;

        if (ppoll(p, idx, &timeout, &sigs) < 1)
            continue;

        if (p[1].revents & POLLIN) {
            process_remote(settings, mac, modes);
        }

        events = p[0].revents | p[1].revents | p[2].revents;

        if (events & (POLLERR | POLLHUP)) {
            break;
        }
    }

    if (debug) syslog(LOG_INFO, "Closing uinput...");

    if (settings.joystick.enabled) {
        uinput_close(ufd->js, debug);
    }
    if (settings.remote.enabled || settings.input.enabled) {
        uinput_close(ufd->mk, debug);
    }
    
    delete ufd;

    shutdown(isk, SHUT_RDWR);
    shutdown(csk, SHUT_RDWR);

    if (debug) syslog(LOG_INFO, "Done");

    return 0;
}
Пример #11
0
int ACE_TMAIN(int argc, ACE_TCHAR* argv[])
{
  timer = RTIHighResolutionClock_new();
  DDS_ReturnCode_t retcode;
  ::DDS::DataReader * data_reader = 0;
  ::DDS::DataReader * dum_data_reader = 0;

  HelloListener listener;
  DummyListener dum_listener;
  const char * type_name = 0;
  int main_result = 1; /* error by default */

  ::DDS::Topic * receive_topic = 0;
  ::DDS::Topic * send_topic = 0;
  ::DDS::DataWriter * data_writer = 0;
  ::DDS::DataWriter * dum_data_writer = 0;
  DummyPublisherListener * pub_listener = 0;
  ::DDS::Publisher * pub = 0;

  try
    {
      ACE_Env_Value<int> id (ACE_TEXT("DDS4CCM_DEFAULT_DOMAIN_ID"), domain_id_);
      domain_id_ = id;

      if (parse_args (argc, argv) != 0)
        {
          ACE_ERROR ((LM_ERROR,
                      ACE_TEXT ("Error arguments.\n")));
          return 1;
        }

      /* Create the domain participant */
      DDSDomainParticipant * participant =
                              DDSDomainParticipantFactory::get_instance()->
                              create_participant_with_profile(
                                  domain_id_,
                                  lib_name_,
                                  prof_name_,
                                  0,
                                  DDS_STATUS_MASK_NONE);
      if (!participant)
        {
          ACE_ERROR ((LM_ERROR,
                        ACE_TEXT ("Sender : Unable to create domain participant.\n")));
          goto clean_exit;
        }

      /* Register type before creating topic */
      type_name = LatencyTestTypeSupport::get_type_name();
      retcode = LatencyTestTypeSupport::register_type (participant,
                                                      type_name);
      if (retcode != DDS_RETCODE_OK)
        {
          goto clean_exit;
        }

      send_topic = participant->create_topic_with_profile (
                                                            "send",
                                                            type_name,
                                                            lib_name_,
                                                            prof_name_,
                                                            0,
                                                            DDS_STATUS_MASK_NONE);
      if (!send_topic)
        {
          ACE_ERROR ((LM_ERROR, ACE_TEXT ("Unable to create topic.\n")));
          goto clean_exit;
        }

      receive_topic = participant->create_topic_with_profile (
                                                            "receive",
                                                            type_name,
                                                            lib_name_,
                                                            prof_name_,
                                                            0,
                                                            DDS_STATUS_MASK_NONE);
      if (!receive_topic)
        {
          ACE_ERROR ((LM_ERROR, ACE_TEXT ("Unable to create topic.\n")));
          goto clean_exit;
        }

      pub_listener = new DummyPublisherListener ();
      pub = participant->create_publisher_with_profile (
                                                lib_name_,
                                                prof_name_,
                                                0,
                                                DDS_STATUS_MASK_NONE);

      if (!pub)
        {
          ACE_ERROR ((LM_ERROR, ACE_TEXT ("Unable to create publisher.\n")));
          goto clean_exit;
        }

      /* Create the data writer using the publisher */
      data_writer = pub->create_datawriter_with_profile(
                                                send_topic,
                                                lib_name_,
                                                prof_name_,
                                                pub_listener,
                                                DDS_OFFERED_DEADLINE_MISSED_STATUS |
                                                DDS_OFFERED_INCOMPATIBLE_QOS_STATUS |
                                                DDS_RELIABLE_WRITER_CACHE_CHANGED_STATUS |
                                                DDS_RELIABLE_READER_ACTIVITY_CHANGED_STATUS |
                                                DDS_LIVELINESS_LOST_STATUS |
                                                DDS_PUBLICATION_MATCHED_STATUS);
      if (!data_writer)
        {
          ACE_ERROR ((LM_ERROR, ACE_TEXT ("Unable to create data writer.\n")));
          goto clean_exit;
        }

      /* Create a data reader, which will not be used, but is there for
      *  compatibility with DDS4CCM latency test, where there is always a
      *  reader and a writer per connector.
      */
      if (both_read_write_)
        {
          dum_data_reader = participant->create_datareader_with_profile(
                                                  send_topic,
                                                  lib_name_,
                                                  prof_name_,
                                                  &dum_listener,
                                                  DDS_DATA_AVAILABLE_STATUS);

          if (!dum_data_reader )
            {
              ACE_ERROR ((LM_ERROR, ACE_TEXT ("Unable to create dummy data reader.\n")));
              goto clean_exit;
            }
        }

      data_reader = participant->create_datareader_with_profile(
                                                  receive_topic,
                                                  lib_name_,
                                                  prof_name_,
                                                  &listener,
                                                  DDS_DATA_AVAILABLE_STATUS);
      if (!data_reader)
        {
          ACE_ERROR ((LM_ERROR, ACE_TEXT ("Unable to create data reader.\n")));
          goto clean_exit;
        }

      /* Create a data writer, which will not be used, but is there for
      *   compatibility with DDS4CCM latency test, where there is always a
      *  reader and a writer per connector
      */
      if (both_read_write_)
        {
          dum_data_writer = participant->create_datawriter_with_profile(
                                    receive_topic,
                                      lib_name_,
                                      prof_name_,
                                      0,
                                      DDS_STATUS_MASK_NONE);
          if (!dum_data_writer)
            {
              ACE_ERROR ((LM_ERROR, ACE_TEXT ("Unable to create dummy data writer.\n")));
              goto clean_exit;
            }
        }

      /* Create data sample for writing */
      instance_ = LatencyTestTypeSupport::create_data ();
      if (instance_ == 0)
        {
          ACE_ERROR ((LM_ERROR, ACE_TEXT ("Unable to create data sample.\n")));
          goto clean_exit;
        }

      init_values();

      test_data_writer_ = LatencyTestDataWriter::narrow (data_writer);
      if (!test_data_writer_)
        {
          ACE_ERROR ((LM_ERROR,
                      ACE_TEXT ("LatencyTestDataWriter_narrow failed.\n")));
          goto clean_exit;
        }

      // Sleep a couple seconds to allow discovery to happen
      ACE_OS::sleep (5);

      // handle writing of messages
      start();

      /* --- Clean Up --- */
      ACE_OS::sleep (5);
      main_result = 0;

  clean_exit:
      const char * read_write_str = 0;
      if (both_read_write_)
        {
          read_write_str = "Used a extra dummy reader and writer per topic.";
        }
      else
        {
          read_write_str = "Used a reader for one topic and a writer for other topic.";
        }

      if((nr_of_runs_ -1) != datalen_idx_)
        {
          ACE_DEBUG ((LM_DEBUG, "SUMMARY SENDER : %u of %u runs completed.\n"
                              " Number of messages sent of last run (%u): %u\n"
                              "%C\n\n",
                              datalen_idx_,
                              nr_of_runs_,
                              datalen_idx_ + 1,
                              number_of_msg_,
                              read_write_str));
        }
      else
        {
          ACE_DEBUG ((LM_DEBUG, "TEST successful, number of runs (%u) of "
                                "%u messages.\n"
                                "%C\n\n",
                                nr_of_runs_,
                                number_of_msg_,
                                read_write_str));
        }
      ACE_DEBUG ((LM_DEBUG, "\tNumber of unexpected events : %u\n",
                    unexpected_count_));
      if (participant)
        {
          retcode = participant->delete_contained_entities ();
          if (retcode != DDS_RETCODE_OK)
            {
              ACE_ERROR ((LM_ERROR, ACE_TEXT ("Deletion failed.\n")));
              main_result = 1;
            }
          retcode = DDSDomainParticipantFactory::get_instance()->
                          delete_participant (participant);
          if (retcode != DDS_RETCODE_OK)
            {
              ACE_ERROR ((LM_ERROR, ACE_TEXT ("Deletion failed.\n")));
              main_result = 1;
            }
        }
    }
  catch (const ::CORBA::Exception &ex)
    {
      ex._tao_print_exception("ERROR : Unexpected CORBA exception caught :");
      main_result = 1;
    }

  delete [] datalen_range_;
  delete [] duration_times_;
  delete pub_listener;

  return main_result;
}
Пример #12
0
Asset::Asset(const int plugin_type, const char *plugin_title)
 : Indexable(1), ListItem<Asset>()
{
	init_values();
}
Пример #13
0
ossimString ossimDms::toString(const ossimString& formatString)const
{
   ossimString result="";
   std::string::const_iterator stringIter;
   ossimString tempFormatString = formatString;
   if(formatString == ossimString(""))
   {
      tempFormatString = ossimDms::DEFAULT_FORMAT;
   }

   stringIter = tempFormatString.begin();
   int i, d_s;
   
/* assign a default format if none is given */
      
   init_values(theDegrees);
   
   while(stringIter != tempFormatString.end())
   {
      switch(*stringIter)
      {
         case '-':
         {
            result +=(theWorking < 0.0) ? ('-') : (' ');
            stringIter++;
            break;
         }
         
         case 'c':
         case 'C':
         {
            char temp;
            if (theWorking < 0.0)
            {
               temp = (theLatFlag == true) ? ('S') : ('W');
            }
            else
            {
               temp= (theLatFlag == true) ? ('N') : ('E');
            }
            
            if(*stringIter == 'c')
            {
               temp = tolower(temp);
            }
            result += temp;
            stringIter++;
            break;
         }
         
         case 'd':
         case 'D':
         {			/* how many 'd's until not 'd' */
            d_s = 1;
            ++stringIter;
            while (*stringIter == 'd' || *stringIter == 'D')
            {
               ++d_s;
               ++stringIter;
            }
            if (theAfterDot == true)
            {		/* beyond the decimal point */
               double fractionalDegrees = std::abs(theDegrees-(int)theDegrees);
               i = d_s;
               while (i > 0)
               {
                  fractionalDegrees = fractionalDegrees * 10.0;
                  result += ossimString::toString((int)fractionalDegrees);
                  fractionalDegrees = fractionalDegrees - (int)fractionalDegrees;
                  --i;
               }
               theIntDegs = (int)(theDecDegs);
            }
            else
            {
               theIntDegs = static_cast<int>( std::abs(theDegrees) );
               ossimString temp = ossimString::toString(theIntDegs);
               ossimString prefix;
               d_s -= (int)temp.length();
               while(d_s > 0)
               {
                  prefix += '0';
                  --d_s;
               }
               temp = prefix + temp;
               result += temp;
            }
//             // fill the rest with blanks
//             ossimString temp = ossimString::toString(theIntDegs);
//             d_s -= temp.length();
//             if(d_s>0)
//             {
//                if(theAfterDot)
//                {
                  
//                   while(d_s > 0)
//                   {
//                      temp+='0';
//                      --d_s;
//                   }
//                }
//                else
//                {
//                   ossimString prefix;
//                   while(d_s > 0)
//                   {
//                      prefix += '0';
//                      --d_s;
//                   }
//                   temp = prefix + temp;
//                }
//             }
            
            break;
         }
 
         case ' ':
         {			
            result += *stringIter;
            
            while (*stringIter == ' ')
            {
               result += *stringIter;
               stringIter++;
            }
            break;
         }
         
         case '.': 
         {
            theAfterDot = true;              
            result +=  *stringIter++;
            break;
         }
         
         case 'm':
         case 'M':
         case 's':
         case 'S':
         {
            if((*stringIter == 's') ||
               (*stringIter == 'S'))
            {
               theDoingSeconds = true;
            }
            
            calc_mins_or_secs(&theDecDegs, stringIter, result);
            break;
         }
         
         // This is code that I added so you can do additional
         // formatting.
         //
         case '\'':
         case '"':
         {
            result += *stringIter++;
            break;
         }
         case '@':
         {
            result += (char)theDegreeSign;
            stringIter++;
            break;
         }
         default:
         {
            if(theDoingSeconds)
            {
               theAfterDot = true;
            }
            result += *stringIter++;
         }
      }	/* end switch statement */
   }	/* end while loop */
   
   return result;   
}
Пример #14
0
Asset::Asset(const int plugin_type, const char *plugin_title)
 : ListItem<Asset>(), GarbageObject("Asset")
{
	init_values();
}
Пример #15
0
Asset::Asset(Asset &asset)
 : ListItem<Asset>(), GarbageObject("Asset")
{
	init_values();
	*this = asset;
}
Пример #16
0
void
PrefAgent::create_ui()
{
  // Create main preferences window.

  XmStringLocalized mtfstring;
  String	    string;
  int		    decorations=MWM_DECOR_BORDER  |
                                MWM_DECOR_RESIZEH |
                                MWM_DECOR_TITLE   |
                                MWM_DECOR_MENU;

  f_shell = WTopLevelShell (window_system().toplevel(), WPopup, "preferences");
  window_system().register_shell(&f_shell);

  string = CATGETS(Set_PrefAgent, 1, "Dtinfo: Preferences");
  XtVaSetValues((Widget)f_shell,
                XmNtitle, string,
                XmNmwmDecorations, decorations,
                NULL);

  DECL  (WXmForm,         form,         f_shell,      "form");
  DECLMC(WXmOptionMenu,   options,      form,         "options");
  DECLC (WXmPulldownMenu, options_menu, form,         "options_menu");

  mtfstring = CATGETS(Set_AgentLabel, 186, "Preferences for");
  XtVaSetValues(options, XmNlabelString, (XmString)mtfstring, NULL);

  ASSNM (WXmPushButton,   f_ok,         form,         "ok");
  ASSNM (WXmPushButton,   f_apply,      form,         "apply");
  ASSNM (WXmPushButton,   f_reset,      form,         "reset");
  DECLM (WXmPushButton,   cancel,       form,         "cancel");
  DECLM (WXmPushButton,   help,         form,         "help");

  mtfstring = CATGETS(Set_AgentLabel, 161, "OK");
  XtVaSetValues(f_ok, XmNlabelString, (XmString)mtfstring, NULL);
  mtfstring = CATGETS(Set_AgentLabel, 201, "Apply");
  XtVaSetValues(f_apply, XmNlabelString, (XmString)mtfstring, NULL);
  mtfstring = CATGETS(Set_AgentLabel, 202, "Reset");
  XtVaSetValues(f_reset, XmNlabelString, (XmString)mtfstring, NULL);
  mtfstring = CATGETS(Set_AgentLabel, 162, "Cancel");
  XtVaSetValues(cancel, XmNlabelString, (XmString)mtfstring, NULL);
  mtfstring = CATGETS(Set_AgentLabel, 48, "Help");
  XtVaSetValues(help, XmNlabelString, (XmString)mtfstring, NULL);

  SET_CALLBACK (f_ok,Activate,ok);
  SET_CALLBACK (f_apply,Activate,apply);
  SET_CALLBACK (f_reset,Activate,reset);
  SET_CALLBACK (cancel,Activate,cancel);
  help_agent().add_activate_help (help, (char*)"preferences_help");

  DECLM (WXmFrame,        frame,        form,         "frame");
  DECL  (WXmForm,         container,    frame,        "container");

  // Create browsing preferences.
  DECLM (WXmPushButton,   browse,          options_menu,  "browse");

  DECL  (WXmForm,         browse_form,     container,     "browse_prefs");
  DECLM (WXmLabel,        browse_label,    browse_form,   "browse_label");
  DECLM (WXmPushButton,   get_browse_geo,  browse_form,   "get_browse_geo");
  ASSNM (WXmTextField,    f_browse_geo,    browse_form,   "browse_geo");
  DECLM (WXmLabel,        fs_label,        browse_form,   "fs_label");
  DECL  (WXmForm,         fs_form,         browse_form,   "fs_form");
  ASSNM (WXmTextField,    f_fs_field,      fs_form,       "scale_field");
  DECLM (WXmArrowButton,  scale_up,        fs_form,       "scale_up");
  DECLM (WXmArrowButton,  scale_down,      fs_form,       "scale_down");
  DECLM (WXmLabel,        lock_label,      browse_form,   "lock_label");
  ASSNM (WXmToggleButton, f_lock_toggle,   browse_form,   "lock_toggle");

  mtfstring = CATGETS(Set_AgentLabel, 187, "Browsing");
  XtVaSetValues(browse, XmNlabelString, (XmString)mtfstring, NULL);
  mtfstring = CATGETS(Set_AgentLabel, 190, "Browser Geometry");
  XtVaSetValues(browse_label, XmNlabelString, (XmString)mtfstring, NULL);
  mtfstring = CATGETS(Set_AgentLabel, 270, "...");
  XtVaSetValues(get_browse_geo, XmNlabelString, (XmString)mtfstring, NULL);
  mtfstring = CATGETS(Set_AgentLabel, 192, "Font Scale");
  XtVaSetValues(fs_label, XmNlabelString, (XmString)mtfstring, NULL);
  mtfstring = CATGETS(Set_AgentLabel, 193, "Pin Window");
  XtVaSetValues(lock_label, XmNlabelString, (XmString)mtfstring, NULL);
  mtfstring = CATGETS(Set_AgentLabel, 194, "File a Bug");
  XtVaSetValues(f_lock_toggle, XmNlabelString, (XmString)mtfstring, NULL);

  Dimension height;
  ChangeData *inc, *dec;

  // Assume that the fields are taller than the labels.  If the user
  // changes the font resources and violates this assumtion he's screwed
  // and that's the way we like it.

  height = f_fs_field.Height();

  browse_label.Height (height);
  fs_label.Height (height);
  scale_up.Height (height/2);
  scale_down.Height (height/2);

  f_lock_toggle.LabelType (XmPIXMAP);
  lock_label.Height (height);

  fs_form.Manage();
  browse_form.Manage();
  f_top_panel = browse_form;

  SET_CALLBACK_D (browse,Activate,switch_to_window,(Widget)browse_form);
  SET_CALLBACK_D (get_browse_geo,Activate,get_geometry,(Widget)f_browse_geo);
  SET_CALLBACK (f_browse_geo,ValueChanged,something_changed);
  SET_CALLBACK (f_fs_field,ValueChanged,something_changed);
  SET_CALLBACK (f_lock_toggle,ValueChanged,something_changed);
  SET_CALLBACK (f_lock_toggle,ValueChanged,lock_toggle);

  inc = new ChangeData(f_fs_field, scale_up, scale_down, 1, 5);
  dec = new ChangeData(f_fs_field, scale_up, scale_down, -1, -2);
  SET_CALLBACK_D (scale_up,Activate,change_cb,inc);
  SET_CALLBACK_D (scale_up,Arm,arm_arrow,inc);
  SET_CALLBACK  (scale_up,Disarm,disarm_arrow);
  SET_CALLBACK_D (scale_down,Activate,change_cb,dec);
  SET_CALLBACK_D (scale_down,Arm,arm_arrow,dec);
  SET_CALLBACK  (scale_down,Disarm,disarm_arrow);

  // Create map window preferences
  DECLM (WXmPushButton,   map,             options_menu,  "map");
  DECLM (WXmForm,         map_form,        container,     "map_prefs");
  DECLM (WXmLabel,        map_label,       map_form,      "map_label");
  DECLM (WXmPushButton,   get_map_geo,     map_form,      "get_map_geo");
  ASSNM (WXmTextField,    f_map_geo,       map_form,      "map_geo");
  DECLM (WXmLabel,        update_label,    map_form,      "update_label");
  ASSNM (WXmToggleButton, f_update_toggle, map_form,      "update_toggle");

  mtfstring = CATGETS(Set_AgentLabel, 188, "Map");
  XtVaSetValues(map, XmNlabelString, (XmString)mtfstring, NULL);
  mtfstring = CATGETS(Set_AgentLabel, 195, "Map Geometry");
  XtVaSetValues(map_label, XmNlabelString, (XmString)mtfstring, NULL);
  mtfstring = CATGETS(Set_AgentLabel, 270, "...");
  XtVaSetValues(get_map_geo, XmNlabelString, (XmString)mtfstring, NULL);
  mtfstring = CATGETS(Set_AgentLabel, 196, "Auto Update");
  XtVaSetValues(update_label, XmNlabelString, (XmString)mtfstring, NULL);
  mtfstring = CATGETS(Set_AgentLabel, 194, "File a Bug");
  XtVaSetValues(f_update_toggle, XmNlabelString, (XmString)mtfstring, NULL);

  height = f_map_geo.Height();
  map_label.Height (height);
  update_label.Height (height);
  
  SET_CALLBACK_D (get_map_geo,Activate,get_geometry,(Widget)f_map_geo);
  SET_CALLBACK_D (map,Activate,switch_to_window,(Widget)map_form);
  SET_CALLBACK (f_map_geo,ValueChanged,something_changed);
  SET_CALLBACK (f_update_toggle,ValueChanged,something_changed);
  SET_CALLBACK (f_update_toggle,ValueChanged,update_toggle);

  map_form.Manage();

  // Create history preferences 
  DECLM (WXmPushButton,   history,      options_menu, "history");

  mtfstring = CATGETS(Set_AgentLabel, 260, "History");
  XtVaSetValues(history, XmNlabelString, (XmString)mtfstring, NULL);

  DECL  (WXmForm,         hist_form,     container,     "history_prefs");
  DECLM (WXmLabel,        nh_label,      hist_form,     "nh_label");
  DECL  (WXmForm,         nh_form,       hist_form,     "nh_form");
  ASSNM (WXmTextField,    f_nh_field,    nh_form,       "nh_field");
  DECLM (WXmArrowButton,  nh_up,         nh_form,       "nh_up");
  DECLM (WXmArrowButton,  nh_down,       nh_form,       "nh_down");
  DECLM (WXmLabel,        sh_label,      hist_form,     "sh_label");
  DECL  (WXmForm,         sh_form,       hist_form,     "sh_form");
  ASSNM (WXmTextField,    f_sh_field,    sh_form,       "sh_field");
  DECLM (WXmArrowButton,  sh_up,         sh_form,       "sh_up");
  DECLM (WXmArrowButton,  sh_down,       sh_form,       "sh_down");

  mtfstring = CATGETS(Set_AgentLabel, 197, "Section History Size");
  XtVaSetValues(nh_label, XmNlabelString, (XmString)mtfstring, NULL);
  mtfstring = CATGETS(Set_AgentLabel, 198, "Search History Size");
  XtVaSetValues(sh_label, XmNlabelString, (XmString)mtfstring, NULL);

  height = f_nh_field.Height();
  nh_label.Height (height);
  nh_up.Height (height/2);
  nh_down.Height (height/2);

  height = f_sh_field.Height();
  sh_label.Height (height);
  sh_up.Height (height/2);
  sh_down.Height (height/2);

  nh_form.Manage();
  sh_form.Manage();
  hist_form.Manage();
  
  SET_CALLBACK_D (history,Activate,switch_to_window,(Widget)hist_form);
  SET_CALLBACK (f_nh_field,ValueChanged,something_changed);
  SET_CALLBACK (f_sh_field,ValueChanged,something_changed);

  inc = new ChangeData (f_nh_field, nh_up, nh_down, 10, 1000);
  dec = new ChangeData (f_nh_field, nh_up, nh_down, -10, 10);
  SET_CALLBACK_D (nh_up,Activate,change_cb,inc);
  SET_CALLBACK_D (nh_up,Arm,arm_arrow,inc);
  SET_CALLBACK (nh_up,Disarm,disarm_arrow);
  SET_CALLBACK_D (nh_down,Activate,change_cb,dec);
  SET_CALLBACK_D (nh_down,Arm,arm_arrow,dec);
  SET_CALLBACK (nh_down,Disarm,disarm_arrow);

  inc = new ChangeData (f_sh_field, sh_up, sh_down, 10, 1000);
  dec = new ChangeData (f_sh_field, sh_up, sh_down, -10, 10);
  SET_CALLBACK_D (sh_up,Activate,change_cb,inc);
  SET_CALLBACK_D (sh_up,Arm,arm_arrow,inc);
  SET_CALLBACK (sh_up,Disarm,disarm_arrow);
  SET_CALLBACK_D (sh_down,Activate,change_cb,dec);
  SET_CALLBACK_D (sh_down,Arm,arm_arrow,dec);
  SET_CALLBACK (sh_down,Disarm,disarm_arrow);

  // Create Search preferences.

  DECLM (WXmPushButton,   search,            options_menu,  "search");

  mtfstring = CATGETS(Set_AgentLabel, 189, "Searching");
  XtVaSetValues(search, XmNlabelString, (XmString)mtfstring, NULL);

  DECL  (WXmForm,         search_form,       container,     "search_prefs");
  DECLM (WXmLabel,        max_hits_label,    search_form,   "max_hits");
  DECL  (WXmForm,         hits_form,         search_form,   "hits_form");
  ASSNM (WXmTextField,    f_max_hits_field,  hits_form,     "hits_field");
  DECLM (WXmArrowButton,  hits_up,           hits_form,     "hits_up");
  DECLM (WXmArrowButton,  hits_down,         hits_form,     "hits_down");
  DECLM (WXmLabel,        adisplay_label,    search_form,   "adisplay_label");
  ASSNM (WXmToggleButton, f_adisplay_toggle, search_form,   "adisplay_toggle");

  mtfstring = CATGETS(Set_AgentLabel, 199, "Maximum Search Hits");
  XtVaSetValues(max_hits_label, XmNlabelString, (XmString)mtfstring, NULL);
  mtfstring = CATGETS(Set_AgentLabel, 200, "Auto Display First Hit");
  XtVaSetValues(adisplay_label, XmNlabelString, (XmString)mtfstring, NULL);
  mtfstring = CATGETS(Set_AgentLabel, 194, "File a Bug");
  XtVaSetValues(f_adisplay_toggle, XmNlabelString, (XmString)mtfstring, NULL);

  height = f_max_hits_field.Height();
  max_hits_label.Height (height);
  hits_up.Height (height/2);
  hits_down.Height (height/2);
  adisplay_label.Height (height);

  hits_form.Manage();
  search_form.Manage();

  SET_CALLBACK_D (search,Activate,switch_to_window,(Widget)search_form);
  SET_CALLBACK (f_max_hits_field,ValueChanged,something_changed);

  inc = new ChangeData (f_max_hits_field, hits_up, hits_down, 10, 500);
  dec = new ChangeData (f_max_hits_field, hits_up, hits_down, -10, 10);
  SET_CALLBACK_D (hits_up,Activate,change_cb,inc);
  SET_CALLBACK_D (hits_up,Arm,arm_arrow,inc);
  SET_CALLBACK (hits_up,Disarm,disarm_arrow);
  SET_CALLBACK_D (hits_down,Activate,change_cb,dec);
  SET_CALLBACK_D (hits_down,Arm,arm_arrow,dec);
  SET_CALLBACK (hits_down,Disarm,disarm_arrow);
  SET_CALLBACK (f_adisplay_toggle,ValueChanged,something_changed);
  SET_CALLBACK (f_adisplay_toggle,ValueChanged,adisplay_toggle);

  /* -------- node history size, search history size -------- */

  options.SubMenuId (options_menu);

  container.Manage();
  form.DefaultButton (f_ok);
  form.ShadowThickness (0);
  form.Manage();

  f_shell.Realize();
  Dimension width;
  f_shell.Get (WArgList (XmNheight, (XtArgVal) &height,
			 XmNwidth, &width,
			 NULL));
  f_shell.Set (WArgList (XmNminHeight, height,
			 XmNmaxHeight, height,
			 XmNminWidth,  width,
			 XmNmaxWidth,  width,
			 NULL));

  map_form.Unmanage();
  hist_form.Unmanage();
  search_form.Unmanage();

  // Values get displayed when reset() is called on dialog display. 
  init_values();
}
Пример #17
0
asmlinkage long xcrypt(void *arg)
{
	struct file_struct file_info;
	struct user_args_t *user_args;
	int err = 0;

	init_values(&file_info);

	if (arg == NULL) {
		printk(KERN_ALERT"NULL arg received in syscall\n");
		err = -EINVAL;
		goto ERR;
	}

	user_args = kmalloc(sizeof(struct user_args_t), GFP_KERNEL);
	if (!user_args) {
		printk(KERN_ALERT"Couldn't allocate memory for user struct\n");
		err = -ENOMEM;
		goto ERR;
	}

	printk(KERN_ALERT"flag = %d and keylen = %d\n", user_args->flags, user_args->keylen);
	printk(KERN_ALERT"all validations passed\n");
	if (copy_from_user(user_args, arg, sizeof(struct user_args_t))) {
		printk(KERN_ALERT"error in copy from user\n");
		err = -EFAULT;
		goto ERR_FREE;
	}

	err = validate_user_args(user_args);
	if (err)
		goto ERR_FREE;
	file_info.in_file = getname(user_args->user_input_file);
	if (IS_ERR(file_info.in_file)) {
		printk(KERN_ALERT"error in file input getname\n");
		err = PTR_ERR(file_info.in_file);
		goto ERR_FREE;
	}
	printk(KERN_ALERT"getnamed inp file is %s\n",  file_info.in_file->name);

	file_info.out_file = getname(user_args->user_output_file);
	if (IS_ERR(file_info.out_file)) {
		printk(KERN_ALERT"error in file output getname\n");
		err = PTR_ERR(file_info.out_file);
		goto ERR_FREE;
	}


	printk(KERN_ALERT"getnamed out file is %s\n", file_info.out_file->name);
	printk(KERN_ALERT"flag = %d and keylen = %d\n", user_args->flags, user_args->keylen);

	err = main_enc_dec(&file_info, user_args);
	if (err) {
		printk(KERN_ALERT"got error from main_enc_dec\n");
		goto ERR_FREE;
	}
	err = 0;
ERR_FREE:
	kfree(user_args);
ERR:
	printk(KERN_ALERT"Returning %d\n", err);
	return err;
}
int main(int argc, char **argv){
	assert (argc == 2);

	init_values();
	
	src_org = cvLoadImage(argv[1]);
	
	//aloca memoria para origem "dinamica" para acontecer esta ser uma origem acumulativa!
	src = cvCreateImage(cvGetSize(src_org),src_org->depth,src_org->nChannels);
	
	cvCopy(src_org,src);

	//cvNamedWindow("src-org");
	//cvShowImage("src-org",src_org);

	cvNamedWindow("src");
	updateSrc();
	
	cvNamedWindow("dst");

	cvNamedWindow("config");

	cvNamedWindow("config2");
	
	int x = 30;
	int y = 50;
	int offset = 10;
	cvMoveWindow("src",x,y);
	cvMoveWindow("dst",x+offset+cvGetSize(src).width,y);
	cvMoveWindow("config",670,y);
	cvMoveWindow("config2",1000,y);

	cvCreateTrackbar("gaussian","config",&gaussian_value,gaussian_max,gaussianCallBack);
	cvCreateTrackbar("canny-low","config",&canny_low_value,canny_low_max,NULL);
	cvCreateTrackbar("canny-high","config",&canny_high_value,canny_high_max,NULL);
	cvCreateTrackbar("canny-en","config",&canny_enable,1,cannyCallBack);
	cvCreateTrackbar("hough-minDist","config",&hough_minDist_value,hough_minDist_max,NULL);
	cvCreateTrackbar("hough-param1","config",&hough_param1_value,hough_param1_max,NULL);
	cvCreateTrackbar("hough-param2","config",&hough_param2_value,hough_param2_max,NULL);
	cvCreateTrackbar("hough-minRadius","config",&hough_minRadius_value,hough_minRadius_max,NULL);
	cvCreateTrackbar("hough-maxRadius","config",&hough_maxRadius_value,hough_maxRadius_max,NULL);
	cvCreateTrackbar("hough-en","config",&hough_enable,1,houghCallBack);
	cvCreateTrackbar("apply","config",&apply_value,1,applySrcCallBack);	

	cvCreateTrackbar("hue-min","config2",&hue_min_value,hue_max,NULL);
	cvCreateTrackbar("hue-max","config2",&hue_max_value,hue_max,NULL);
	cvCreateTrackbar("sat-min","config2",&sat_min_value,sat_max,NULL);
	cvCreateTrackbar("sat-max","config2",&sat_max_value,sat_max,NULL);
	cvCreateTrackbar("val-min","config2",&val_min_value,val_max,NULL);
        cvCreateTrackbar("val-max","config2",&val_max_value,val_max,NULL);

	// HSV color picker na janela SRC
	cvSetMouseCallback("src",mouseCallBack,(void*)src);

	// loop central... ESQ finaliza!
	while(true){
		if(cvWaitKey(10) == 27) break;
	}
	
	cvDestroyWindow("src");
	//cvDestroyWindow("src-org");
	cvDestroyWindow("dst");
	cvDestroyWindow("config");
	cvDestroyWindow("config2");	
	
	cvReleaseImage(&src_org);
	cvReleaseImage(&src);
	cvReleaseImage(&dst);
}
Пример #19
0
/*----------------------------------------------------------*/
int main(int argc, char *argv[])
{
  xc_values_type xc;
  xc_lda_type lda_func;
  xc_gga_type gga_func;
  xc_hyb_gga_type hyb_gga_func;
  const xc_func_info_type *info;
  FLOAT *pv2rho = NULL;

  if(argc != 8){
    printf("Usage:\n%s funct pol rhoa rhob sigmaaa sigmaab sigmabb\n", argv[0]);
    return 1;
  }

  init_values(&xc, argv);

  if(xc.nspin == 1){
    xc.rho[0]   += xc.rho[1];
    xc.sigma[0] += 2.0*xc.sigma[1] + xc.sigma[2];
  }

  info = NULL;
  switch(xc_family_from_id(xc.functional))
    {
    case XC_FAMILY_LDA:
      if(xc.functional == XC_LDA_X)
	xc_lda_x_init(&lda_func, xc.nspin, 3, 0);
      else
	xc_lda_init(&lda_func, xc.functional, xc.nspin);
      info = lda_func.info;
      break;
    case XC_FAMILY_GGA:
      xc_gga_init(&gga_func, xc.functional, xc.nspin);
      info = gga_func.info;
      break;
    case XC_FAMILY_HYB_GGA:
      xc_hyb_gga_init(&hyb_gga_func, xc.functional, xc.nspin);
      info = hyb_gga_func.info;
      break;
    default:
      fprintf(stderr, "Functional '%d' not found\n", xc.functional);
      exit(1);  
    }
  if(info->provides & XC_PROVIDES_FXC){
    pv2rho = xc.v2rho;
  }

  switch(xc_family_from_id(xc.functional))
    {
    case XC_FAMILY_LDA:
      xc_lda(&lda_func, xc.rho, &xc.zk, xc.vrho, pv2rho, NULL);
      break;
    case XC_FAMILY_GGA:
      xc_gga(&gga_func, xc.rho, xc.sigma, &xc.zk, 
	     xc.vrho, xc.vsigma, pv2rho, xc.v2rhosigma, xc.v2sigma);
      xc_gga_end(&gga_func);
      break;
    case XC_FAMILY_HYB_GGA:
      xc_hyb_gga(&hyb_gga_func, xc.rho, xc.sigma, &xc.zk, xc.vrho, xc.vsigma);
      xc_hyb_gga_end(&hyb_gga_func);
      break;
    }

  if(xc.nspin == 1){
    xc.vrho[1] = xc.vrho[0];
    xc.zk *= xc.rho[0] ;
  }else{
    xc.zk *= (xc.rho[0] + xc.rho[1]);
  }

  print_values(&xc);

  return 0;
}
Пример #20
0
Circuit_Handler::Circuit_Handler(){
	init_values();

}
Пример #21
0
Asset::Asset()
 : ListItem<Asset>(), GarbageObject("Asset")
{
	init_values();
}
Пример #22
0
Impedance::Impedance(){
	init_values();
}
Пример #23
0
Asset::Asset(const char *path)
 : ListItem<Asset>(), GarbageObject("Asset")
{
	init_values();
	strcpy(this->path, path);
}
Пример #24
0
Asset::Asset()
 : Indexable(1), ListItem<Asset>()
{
	init_values();
}
Пример #25
0
int main(int argc, char **argv)
{
    int i, fd, nr;
    unsigned char buf[128];
    struct uinput_fd *ufd;
    struct device_settings settings;

    if (argc < 2) {
        std::cout << "Usage: " << argv[0] << " /dev/hidrawX" << std::endl;
        return 1;
    }

    if ((fd = open(argv[1], O_RDONLY)) < 0) {
        std::cerr << "sixad-raw::open(hidrawX) - failed to open hidraw device" << std::endl;
        return 1;
    }

    if ((nr=read(fd, buf, sizeof(buf))) < 0) {
        std::cerr << "sixad-raw::read(fd) - failed to read from device" << std::endl;
        return 1;
    }

    if (nr < 49 || nr > 50) {
        std::cerr <<  "sixad-raw::read(fd) - not a sixaxis (nr = " << nr << ")" << std::endl;
        return 1;
    }

    open_log("sixad-raw");
    settings = init_values("hidraw");

    // hidraw has no rumble/led support
    settings.remote.enabled = false;
    settings.led.enabled = false;
    settings.rumble.enabled = false;

    ufd = uinput_open(DEV_TYPE_SIXAXIS, "hidraw", settings);

    if (ufd->js < 0 || ufd->mk < 0) {
        return 1;
    } else if (ufd->js == 0 && ufd->mk == 0) {
        syslog(LOG_ERR, "sixaxis config has no joystick or input mode selected - please choose one!");
        return 1;
    }

    bool msg = true;
    while (true) {

        nr=read(fd, buf, sizeof(buf));

        if (nr < 49 || nr > 50) {
          std::cerr <<  "sixad-raw::read(fd, buf) - failed to read from device" << std::endl;
          break;
        } else if (nr == 49) {
          for (i=50; i>0; i--) {
            buf[i] = buf[i-1];
          }
        }

        if (msg) {
            syslog(LOG_INFO, "Connected 'PLAYSTATION(R)3 Controller (hidraw)' [Battery %02X]", buf[31]);
            if (nr == 49) syslog(LOG_INFO, "Notice: non-standard Sixaxis buffer size (49)");
            msg = false;
        }

        if (settings.joystick.enabled) do_joystick(ufd->js, buf, settings.joystick);
        if (settings.input.enabled) do_input(ufd->mk, buf, settings.input);
    }

    if (settings.joystick.enabled) {
        uinput_close(ufd->js, 0);
    }
    if (settings.input.enabled) {
        uinput_close(ufd->mk, 0);
    }

    std::cerr <<  "sixad-raw::read(buf) - connection has been broken" << std::endl;
    
    delete ufd;

    return 0;
}
Пример #26
0
Asset::Asset(Asset &asset)
 : Indexable(1), ListItem<Asset>()
{
	init_values();
	this->copy_from(&asset, 1);
}
Пример #27
0
ossimString ossimDms::degree_to_string(double degrees,
                                       char format[],
                                       bool lat_flag)const
{
   char cdegrees[64];
   char str_fmt[10];
   char *rptr, *fptr, *sptr;
   int i, d_s;
   
/* assign a default format if none is given */
   
   if (format[0] == '\0')
   {
      set_default(format, cdegrees);
   }
   else
   {
      memset(cdegrees, ' ', 64);
//       strcpy(cdegrees, SPACES);
   }
   
   init_values(degrees);
   
   rptr = cdegrees;
   fptr = format;
   sptr = str_fmt;
   
/* cycle through characters of the format and plug in values */
   
   while (*fptr != '\0') {
      
	 switch (*fptr) {

	   case '-': {
		(theWorking < 0.0) ? (*rptr = '-') : (*rptr = ' ');
		rptr++, fptr++;
		break;
	   }

	   case 'c':
	   case 'C': {
		if (theWorking < 0.0)
		   (lat_flag == true) ? (*rptr = 'S') : (*rptr = 'W');
		else
		   (lat_flag == true) ? (*rptr = 'N') : (*rptr = 'E');
		
		rptr++, fptr++;
		break;
	   }

	   case 'd':
	   case 'D': {			/* how many 'd's until not 'd' */
	   	d_s = 1, fptr++;
	   	while (*fptr == 'd') {
		   d_s++, fptr++;
	   	}
		setup_printf(d_s, sptr);	/* printf's fmt will be %x.xd */

		if (theAfterDot == true) {		/* beyond the decimal point */
		   i = d_s;
		   while (i-- > 0)
			theDecDegs = theDecDegs * 10.0;
//		   theIntDegs = (int)(theDecDegs + 0.5);
		   theIntDegs = (int)(theDecDegs);
		 }

		sprintf(rptr, str_fmt, theIntDegs);

		if (*rptr == '0' && !theAfterDot)	/* remove leading zero */
		   *rptr = ' ';
	   	rptr += d_s;
		break;
	   }

	   case ' ': {			/* compress multiple spaces in format */
		*rptr = *fptr;
		while (*fptr == ' ')
			fptr++;
		rptr++;
		break;
	   }

	   case '.': {
		if (theAfterDot == true) {		/* a second decimal point? */
		   set_default(format, cdegrees);
		   fptr = format;
		   rptr = cdegrees;
		   init_values(degrees);
		}
		else {
		   *rptr = *fptr;
		   rptr++, fptr++;
		   theAfterDot = true;
		}
		break;
	   }

         case 'm':
         case 'M':
         case 's':
         case 'S':
         {
		i = calc_mins_or_secs(&theDecDegs, fptr, rptr);
		fptr += i, rptr += i;		/* i == num to advance format */
		break;
	   }

           // This is code that I added so you can do additional
           // formatting.
           //
         case '\'':
         case '"':
         {
            *rptr = *fptr;
            rptr++;
            fptr++;
            break;
         }
         case '@':
         {
            *rptr = (char)theDegreeSign;
            rptr++;
            fptr++;
            break;
         }
	   default: {
		set_default(format, cdegrees);
		fptr = format;
		rptr = cdegrees;
		init_values(degrees);
	   }
	 }	/* end switch statement */

	}	/* end while loop */

	*rptr = '\0';
	return(cdegrees);
}
Пример #28
0
Asset::Asset(const char *path)
 : Indexable(1), ListItem<Asset>()
{
	init_values();
	strcpy(this->path, path);
}