// ################
// ## 6. LE MAIN ##
// ################
int main () {
    int n;
    BOOL b;

    init_graphics(600,600);

    write_text("Bonjour");
    write_text("Au revoir");
    write_text("ЮИХНТОГ юихнтог");

    n = 23;
    write_int(n);
    write_int(42);

    b = (2<3);
    write_bool(b);
    write_bool(2 == 3);

    POINT centre;
    centre = wait_clic();
    draw_fill_circle(centre, 20, rouge);

    wait_escape();
    exit (0);
}
Example #2
0
/* Join a group.  The group context is returned in *contextp.  
 */
hot_err_t hot_ens_Join(
    hot_ens_JoinOps_t *jops,
    hot_context_t *contextp	/*OUT*/ 
) {
    hot_err_t err = HOT_OK ;
    hot_context_t s ;

    /* Initialize global state if not done so already.
     */
    if (!g.initialized) {
	err = hot_ens_Init(jops->outboard, jops->argv); 
	if (err != HOT_OK)
	    return err;
    }

    begin_write(); {    
	begin_critical(); {    
	    /* Allocate a new group context 
	     * Initialize the group record.
	     */
	    s = alloc_context();
	    s->joining = 1 ;
	    s->leaving = 0 ;
	    s->conf = jops->conf;
	    s->env = jops->env;
	    s->view = NULL ;
	    *contextp = s ;
	} end_critical();
	
	/* Write the downcall.
	 */
  	write_hdr(s,DN_JOIN);
	write_int(jops->heartbeat_rate);
	write_string(jops->transports);
	write_string(jops->protocol);
	write_string(jops->group_name);
	write_string(jops->properties);
	write_bool(jops->use_properties);
	write_bool(jops->groupd);
	write_string(jops->params);
	write_bool(jops->client);
	write_bool(jops->debug);

	if (jops->endpt.name[0] != 0x0) {
	    hot_sys_Warning("HOT_OUTBOARD does not support 'endpt' in join ops") ;
	    jops->endpt.name[0] = 0x0;
	}
	write_string(jops->princ);
	write_string(jops->key);
	write_bool(jops->secure);

    } end_write();

    return HOT_OK;
}
Example #3
0
File: inifile.c Project: LinLL/ipc
int main (void)
{
	printf ("Hello World\n");
	OpenIniFile ("Test.Ini");
#ifdef INIFILE_TEST_READ_AND_WRITE
	write_string  ("Test", "Name", "Value");
	write_string  ("Test", "Name", "OverWrittenValue");
	write_string  ("Test", "Port", "COM1");
	write_string  ("Test", "User", "James Brown jr.");
	write_string  ("Configuration", "eDriver", "MBM2.VXD");
	write_string  ("Configuration", "Wrap", "LPT.VXD");
	write_int 	 ("IO-Port", "Com", 2);
	write_bool 	 ("IO-Port", "IsValid", 0);
	write_double  ("TheMoney", "TheMoney", 67892.00241);
	write_int     ("Test"    , "ToDelete", 1234);
	WriteIniFile ("Test.Ini");
	printf ("Key ToDelete created. Check ini file. Any key to continue");
	while (!kbhit());
	OpenIniFile  ("Test.ini");
	delete_key    ("Test"	  , "ToDelete");
	WriteIniFile ("Test.ini");
#endif
	printf ("[Test] Name = %s\n", read_string ("Test", "Name", "NotFound"));
	printf ("[Test] Port = %s\n", read_string ("Test", "Port", "NotFound"));
	printf ("[Test] User = %s\n", read_string ("Test", "User", "NotFound"));
	printf ("[Configuration] eDriver = %s\n", read_string ("Configuration", "eDriver", "NotFound"));
	printf ("[Configuration] Wrap = %s\n", read_string ("Configuration", "Wrap", "NotFound"));
	printf ("[IO-Port] Com = %d\n", read_int ("IO-Port", "Com", 0));
	printf ("[IO-Port] IsValid = %d\n", read_bool ("IO-Port", "IsValid", 0));
	printf ("[TheMoney] TheMoney = %1.10lf\n", read_double ("TheMoney", "TheMoney", 111));
	CloseIniFile ();
	return 0;
}
Example #4
0
void UmlCom::send_cmd(CmdFamily f, unsigned int cmd, const char * s, bool b)
{
#ifdef TRACE
    cout << "UmlCom::send_cmd((CmdFamily) " << f << ", " << cmd << ", " << ((s) ? s : "") << b << ")\n";
#endif

    write_char(f);
    write_char(cmd);
    write_string(s);
    write_bool(b);
    flush();
}
Example #5
0
void UmlCom::send_cmd(CmdFamily f, unsigned int cmd, bool b, const char * s, const char * v)
{
#ifdef TRACE
  qDebug() << "UmlCom::send_cmd((CmdFamily) " << f << ", " << cmd << ", " << b << ", " << s << ", " << v << ")\n";
#endif
  
  write_char(f);
  write_char(cmd);
  write_bool(b);
  write_string(s);
  write_string(v);
  flush();
}
Example #6
0
static int write_field(cJSON *json, struct argp_option *opt,
		struct nl_buffer *buffer)
{
	if (strcmp(opt->arg, BOOL_FORMAT) == 0) {
		return write_bool(buffer, opt->key, json);
	} else if (strcmp(opt->arg, NUM_FORMAT) == 0) {
		return write_number(buffer, opt->key, json);
	} else if (strcmp(opt->arg, NUM_ARRAY_FORMAT) == 0) {
		return write_plateaus(buffer, json);
	} else if (strcmp(opt->arg, OPTIONAL_PREFIX6_FORMAT) == 0) {
		return write_optional_prefix6(buffer, opt->key, json);
	}

	log_err("Unimplemented data type: %s", opt->arg);
	return -EINVAL;
}
Example #7
0
void KfmIpc::selectRootIcons(int _x, int _y, int _w, int _h, bool _add)
{
	int len = 0;
	len += len_int( _x );
	len += len_int( _y );
	len += len_int( _w );
	len += len_int( _h );
	len += len_bool( _add );
	len += len_string("selectRootIcons");
	write_int( sock->socket(), len );
	write_string( sock->socket(), "selectRootIcons" );
	write_int( sock->socket(), _x );
	write_int( sock->socket(), _y );
	write_int( sock->socket(), _w );
	write_int( sock->socket(), _h );
	write_bool( sock->socket(), _add );
}
Example #8
0
void Storage::Binary::write_data_set(DataSet::DataSet *data_set) {
  bool sparse = (typeid(*data_set) == typeid(DataSet::SparseDataSet));
  int num_categories = data_set->categories_size();
  int num_features = data_set->features_size();
  int num_examples = data_set->examples_size();

  // data set header
  write_bool(sparse);
  write_string(data_set->name);
  write_int(data_set->category_index);
  write_bool(data_set->counted);
  write_bool(data_set->indexed);
  write_int(num_features);
  write_int(num_categories);
  
  // features
  DataSet::NominalFeature *nominal_feature;
  DataSet::NumericFeature *numeric_feature;
  DataSet::Feature *feature;
  uint32_t count = 0;
  bool nominal;
  
  for(int i = 0; i < num_features; i++) {
    feature = data_set->features[i];
    nominal = (typeid(*feature) == typeid(DataSet::NominalFeature));
    write_bool(nominal);
    write_int(feature->index);
    write_string(feature->name);
    
    if(nominal) {
      nominal_feature = (DataSet::NominalFeature *)feature;
      
      // category names
      count = nominal_feature->names.size();
      write_int(count - 1);
      for(int i = 1; i < count; i++)
        write_string(nominal_feature->names.at(i));
      
      // cached counts
      if(data_set->counted) {
        write_vector<int>(&(nominal_feature->frequencies));
        write_vector<double>(&(nominal_feature->probabilities));
        
        for(int i = 1; i <= num_categories; i++)
          write_vector<int>(&(nominal_feature->category_frequencies.at(i)));
        
        for(int i = 1; i <= num_categories; i++)
          write_vector<double>(&(nominal_feature->category_probabilities.at(i)));
      }
      
      // TODO: cached indexes
      if(data_set->indexed) {
      }
      
    } else {
      numeric_feature = (DataSet::NumericFeature *)feature;
      
      // cached counts
      if(data_set->counted) {
        file.write((const char *)&(numeric_feature->counts), sizeof(DataSet::NumericFeature::Counts));
        for(int i = 1; i <= num_categories; i++)
          file.write((const char *)&(numeric_feature->category_counts[i]), sizeof(DataSet::NumericFeature::Counts));
      }
      
      // TODO: cached indexes
      if(data_set->indexed) {
      }
    }
  }
  
  // examples
  write_bool(should_write_examples);
  if(should_write_examples) {
    write_int(num_examples);
    
    if(sparse) {
      DataSet::SparseExample *example;
      for(int i = 0; i < num_examples; i++) {
        example = (DataSet::SparseExample *) data_set->examples[i];
        count = example->size;
        write_int(count);
        file.write((char *)(example->values), count * sizeof(DataSet::SparseExample::Value));
      }
      
    } else {
      // each dense example stores the same number of values
      count = data_set->examples[0]->size;
      write_int(count);
      
      // write each example
      for(int i = 0; i < num_examples; i++)
        file.write((char *)((DataSet::DenseExample *)data_set->examples[i])->values, count * sizeof(double));
    }
  }
}