void issuejob(char **args,int numbofargs,char *jobname,int jobID,int *status) {
    int i,check;
    char *argum[numbofargs+1];
    pid_t pid;
    info *data;

    check = enter();
    if (check == 1) {
        for(i=0;i<numbofargs;i++)
            argum[i]=args[i];
        argum[numbofargs] = NULL;
        if ( (pid =fork ()) == -1) {
            perror("fork "); 
            exit (2) ; 
        }
        if (pid == 0) {
            execvp(argum[0],argum);
        }
        else {
            *status = 1;            
            set_values(jobname,jobID,1,&data);
            set_pid(pid,data);          
            running_insert(data);
        }
    }
    else {
        *status = 0;
        set_values(jobname,jobID,0,&data);
        queued_insert(data);
    }        
}
Beispiel #2
0
uint8_t *read_sms_raw_bytes(int type, int *size)
{
    int kernFunc;
    char *servMatch;
    int dataType;
    uint8_t *data;
    int t;

    data = malloc(sizeof(union motion_data));
    if ( data == 0 )
        return 0;

    t = type;
    if ( t == 0 ) {
        int i;

        for ( i = 1; ; i++ ) {
            if ( !set_values(i, &kernFunc, &servMatch, &dataType) )
                break;
            if ( probe_sms(kernFunc, servMatch, dataType, data) ) {
                t = i;
                break;
            }
        }
    } else {
        if ( !set_values(type, &kernFunc, &servMatch, &dataType) )
            return 0;
        if ( !probe_sms(kernFunc, servMatch, dataType, data) )
            return 0;
    }

    if ( t ) {
        switch ( dataType ) {
            case PB_IB:
                if ( size )
                    *size = sizeof(struct pb_ib_data);
                break;
            case MBP:
                if ( size )
                    *size = sizeof(struct mbp_data);
                break;
            default:
                t = 0;
                break;
        }
        if ( t )
            return data;
    }
    free(data);
    if ( size )
        *size = 0;
    return 0;
}
Beispiel #3
0
  void
  int_range_steps_holder::
set_value( value_type new_value)
{
    // set_value_base( this, value_, new_value);
    set_values( new_value, get_min_value( ), get_max_value( ));
}
int harmony_best(hdesc_t *hdesc)
{
    int retval = 0;

    if (hdesc->state >= HARMONY_STATE_CONNECTED) {
        /* Prepare a Harmony message. */
        hmesg_scrub(&hdesc->mesg);

        if (send_request(hdesc, HMESG_BEST) != 0)
            return -1;

        if (hdesc->mesg.status != HMESG_STATUS_OK) {
            hdesc->errstr = "Invalid message received from server.";
            errno = EINVAL;
            return -1;
        }

        if (hdesc->best.id < hdesc->mesg.data.point.id) {
            if (update_best(hdesc, &hdesc->mesg.data.point) != 0)
                return -1;
            retval = 1;
        }
    }

    /* Make sure our best known point is valid. */
    if (hdesc->best.id < 0) {
        errno = EINVAL;
        return -1;
    }

    if (set_values(hdesc, &hdesc->best) != 0)
        return -1;

    return retval;
}
Beispiel #5
0
MatxRow& MatxRow::operator=(const MatxRow& r)
{
    if (&r == this)
       return *this;
    set_values(r.get_values());
    return *this;
}
Beispiel #6
0
scalar* transpose(int m,int n, scalar* A,scalar* AT){
	int i;
	AT=AT?AT:alloc_data(n*m);
	i=m;
	while(i--){		set_values(n,A+i*n,1,AT+i,m);	 } /* AT[*i]=A[i*] */
	return AT;
}
Beispiel #7
0
  void
  int_range_steps_holder::
set_page_step( value_type new_page_step)
{
    // set_value_base( this, page_step_, new_page_step, & int_range_steps_holder::has_changed__page_step);
    set_values( get_value( ), get_min_value( ), get_max_value( ), get_single_step( ), new_page_step);
}
int main(void)
{
  int res, creating = 0;
  struct memory_content *mem;

  res = shmget(KEY, sizeof(struct memory_content), 0);

  if ((res < 0) && (errno == ENOENT)) {
    printf("Memory area does not exist. Creating...\n");
    res = shmget(KEY, sizeof(struct memory_content), IPC_CREAT | IPC_EXCL | 0644);
    if (res < 0) {
      perror("shmget");
      exit(1);
    }
    creating = 1;
  }

  mem = shmat(res, NULL, 0);
  if (!mem) {
    perror("shmat");
    exit(1);
  }

  if (creating) {
    printf("Setting values...\n");
    set_values(mem);
  }

  print_values(mem);
  mem->last_access = getpid();
  shmdt(mem);
  return 0;
}
Beispiel #9
0
  /* slot */
  void
  double_slide_holder::
set_value( value_type new_value)
{
    // set_value_base( this, value_, new_value);
    set_values( new_value, get_min_value( ), get_max_value( ));
}
Beispiel #10
0
int read_sms_raw(int type, int *x, int *y, int *z)
{
    int kernFunc;
    char *servMatch;
    int dataType;
    union motion_data data;

    if ( !set_values(type, &kernFunc, &servMatch, &dataType) )
        return 0;
    if ( probe_sms(kernFunc, servMatch, dataType, &data) ) {
        switch ( dataType ) {
            case PB_IB:
                if ( x ) *x = data.pb_ib.x;
                if ( y ) *y = data.pb_ib.y;
                if ( z ) *z = data.pb_ib.z;
                break;
            case MBP:
                if ( x ) *x = data.mbp.x;
                if ( y ) *y = data.mbp.y;
                if ( z ) *z = data.mbp.z;
                break;
            default:
                return 0;
        }
        return 1;
    }
    return 0;
}
Beispiel #11
0
  void
  int_range_steps_holder::
set_max_value( value_type new_max_value)
{
    // set_value_base( this, max_value_, new_max_value, & int_range_steps_holder::has_changed__max_value);
    set_values( get_value( ), get_min_value( ), new_max_value);
}
Beispiel #12
0
/**
 * Method for estimating aoa of incident infrared light. Returns value between
 * 0 and 360. If measurement is not reliable i.e. received light intensity was
 * not high enough, this method returns negative value.
 */
float AoAPlug::get_aoa_deg() {
  set_values();
  // if double_peak() is implemented change force version
  if (max_value()<MAX_VAL_THRESHOLD) {
    return AOA_DEG_FAIL;
  }
  return calculate_aoa();
}
Beispiel #13
0
int harmony_fetch(hdesc_t *hdesc)
{
    int i;

    if (hdesc->state < HARMONY_STATE_CONNECTED) {
        hdesc->errstr = "Descriptor not currently joined to any session.";
        errno = EINVAL;
        return -1;
    }

    /* Prepare a Harmony message. */
    hmesg_scrub(&hdesc->mesg);

    if (send_request(hdesc, HMESG_FETCH) != 0)
        return -1;

    if (hdesc->mesg.status == HMESG_STATUS_BUSY) {
        if (update_best(hdesc, &hdesc->mesg.data.point) != 0)
            return -1;

        if (hdesc->best.id == -1) {
            /* No best point is available. Inform the user by returning 0. */
            return 0;
        }

        /* Set current point to best point. */
        if (hpoint_copy(&hdesc->curr, &hdesc->best) != 0) {
            hdesc->errstr = "Internal error copying point data.";
            errno = EINVAL;
            return -1;
        }
    }
    else if (hdesc->mesg.status == HMESG_STATUS_OK) {
        if (hpoint_copy(&hdesc->curr, &hdesc->mesg.data.point) != 0) {
            hdesc->errstr = "Internal error copying point data.";
            errno = EINVAL;
            return -1;
        }
    }
    else {
        hdesc->errstr = "Invalid message received from server.";
        errno = EINVAL;
        return -1;
    }

    /* Update the variables from the content of the message. */
    if (set_values(hdesc, &hdesc->curr) != 0)
        return -1;

    /* Initialize our internal performance array. */
    for (i = 0; i < hdesc->perf->n; ++i)
        hdesc->perf->p[i] = NAN;

    /* Client variables were changed.  Inform the user by returning 1. */
    hdesc->state = HARMONY_STATE_TESTING;
    return 1;
}
Beispiel #14
0
void show_edit_number(int setting_key, int value, SettingParams params) {
  initialise_ui();
  init_action_bar();
  
  set_values(setting_key, value, params);
  
  window_set_window_handlers(s_window, (WindowHandlers) {
    .unload = handle_window_unload,
  });
static void
add_account (GoaPanelAccountsModel  *model,
             GoaObject              *object)
{
  GtkTreeIter iter;
  gtk_list_store_insert (GTK_LIST_STORE (model),
                         &iter,
                         G_MAXINT); /* position */
  set_values (model, object, &iter);
}
Beispiel #16
0
/*
 * Build the settings window
 */
static void create_settings_window(void) {
  setting_window = window_create();
  Layer *window_layer = window_get_root_layer(setting_window);
  GRect bounds = layer_get_bounds(window_layer);
  int16_t centre = bounds.size.w / 2;
  int16_t width = bounds.size.w;

  window_set_background_color(setting_window, SETTING_BACKGROUND_COLOR);
  
  is24hr = clock_is_24h_style();

  // Get the resources we need
  large_font = fonts_get_system_font(FONT_KEY_GOTHIC_28_BOLD);
  small_font = fonts_get_system_font(FONT_KEY_GOTHIC_24_BOLD);
 
  // Set click provider
  window_set_click_config_provider(setting_window, (ClickConfigProvider) setting_click_config_provider);

  // from_layer
  from_layer = macro_text_layer_create(GRect(SA_ROW_1_X, SA_ROW_1_Y, SA_ROW_1_WIDTH, SA_HEIGHT), window_layer, NON_HIGHLIGHT_FG_COLOR, SETTING_BACKGROUND_COLOR, small_font, GTextAlignmentCenter);
  text_layer_set_text(from_layer, EARLIEST);

  // fields[FROM_HOUR]
  fields[F_FROM_HOUR] = macro_text_layer_create(GRect(is24hr ? SA_HOUR_LEFT_24 : SA_HOUR_LEFT_12, SA_ROW_2_Y, SA_WIDTH, SA_HEIGHT), window_layer, NON_HIGHLIGHT_FG_COLOR, NON_HIGHLIGHT_BG_COLOR, large_font, GTextAlignmentCenter);

  // fields[FROM_MINUTE]
  fields[F_FROM_MINUTE] = macro_text_layer_create(GRect(is24hr ? SA_MIN_LEFT_24 : SA_MIN_LEFT_12, SA_ROW_2_Y, SA_WIDTH, SA_HEIGHT), window_layer, NON_HIGHLIGHT_FG_COLOR, NON_HIGHLIGHT_BG_COLOR, large_font, GTextAlignmentCenter);

  // fields[FROM_AMPM]
  if (!is24hr) {
    fields[F_FROM_AMPM] = macro_text_layer_create(GRect(SA_AMPM_LEFT, SA_ROW_2_Y, SA_WIDTH, SA_HEIGHT), window_layer, NON_HIGHLIGHT_FG_COLOR, NON_HIGHLIGHT_BG_COLOR, large_font, GTextAlignmentCenter);
  }
  
  // to_layer
  to_layer = macro_text_layer_create(GRect(SA_ROW_3_X, SA_ROW_3_Y, SA_ROW_3_WIDTH, SA_HEIGHT), window_layer, NON_HIGHLIGHT_FG_COLOR, SETTING_BACKGROUND_COLOR, small_font, GTextAlignmentCenter);
  text_layer_set_text(to_layer, LATEST);

  // fields[TO_HOUR]
  fields[F_TO_HOUR] = macro_text_layer_create(GRect(is24hr ? SA_HOUR_LEFT_24 : SA_HOUR_LEFT_12, SA_ROW_4_Y, SA_WIDTH, SA_HEIGHT), window_layer, NON_HIGHLIGHT_FG_COLOR, NON_HIGHLIGHT_BG_COLOR, large_font, GTextAlignmentCenter);

  // fields[TO_MINUTE]
  fields[F_TO_MINUTE] = macro_text_layer_create(GRect(is24hr ? SA_MIN_LEFT_24 : SA_MIN_LEFT_12, SA_ROW_4_Y, SA_WIDTH, SA_HEIGHT), window_layer, NON_HIGHLIGHT_FG_COLOR, NON_HIGHLIGHT_BG_COLOR, large_font, GTextAlignmentCenter);

  // fields[TO_AMPM]
  if (!is24hr) {
    fields[F_TO_AMPM] = macro_text_layer_create(GRect(SA_AMPM_LEFT, SA_ROW_4_Y, SA_WIDTH, SA_HEIGHT), window_layer, NON_HIGHLIGHT_FG_COLOR, NON_HIGHLIGHT_BG_COLOR, large_font, GTextAlignmentCenter);
  }
    
  current_field = F_FROM_HOUR;

  set_values();
  write_values_to_fields();
  highlight_field(current_field, true);
}
Beispiel #17
0
  void
  int_range_steps_holder::
set_values_from( QAbstractSlider * p_slider)
{
    d_assert( p_slider);
    set_values
     (  p_slider->value( )
      , p_slider->minimum( )
      , p_slider->maximum( )
      , p_slider->singleStep( )
      , p_slider->pageStep( )
     );
}
Beispiel #18
0
  void
  int_range_steps_holder::
set_values( int_range_steps_holder const * p_copy)
{
    d_assert( p_copy);
    set_values
     (  p_copy->get_value(       )
      , p_copy->get_min_value(   )
      , p_copy->get_max_value(   )
      , p_copy->get_single_step( )
      , p_copy->get_page_step(   )
     );
}
Beispiel #19
0
  void
  int_range_steps_holder::
set_values_from( QSpinBox * p_spinb)
{
    d_assert( p_spinb);
    set_values
     (  p_spinb->value( )
      , p_spinb->minimum( )
      , p_spinb->maximum( )
      , p_spinb->singleStep( )
      //p_spinb->pageStep( )
     );
}
Beispiel #20
0
// Used to sum up partial results. 
void update_values(int sum, int max, int maxi, int maxj, int min, int mini, int minj) {
  pthread_mutex_lock(&updatelock);
  int id = rand()%99;
  final_sum  += sum;
  final_num_workers++;
  
  set_values(max, maxi, maxj, min, mini, minj);

  if (final_num_workers == size)
    pthread_cond_broadcast(&finished);

  pthread_mutex_unlock(&updatelock);
}
static void
update_account (GoaPanelAccountsModel  *model,
                GoaObject              *object)
{
  GtkTreeIter iter;
  if (!find_iter_for_object (model, object, &iter))
    {
      goa_warning ("Error updating object %s - not in tree", g_dbus_object_get_object_path (G_DBUS_OBJECT (object)));
    }
  else
    {
      set_values (model, object, &iter);
    }
}
Beispiel #22
0
int detect_sms()
{
    int kernFunc;
    char *servMatch;
    int dataType;
    union motion_data data;
    int i;

    for ( i = 1; ; i++ ) {
        if ( !set_values(i, &kernFunc, &servMatch, &dataType) )
            break;
        if ( probe_sms(kernFunc, servMatch, dataType, &data) )
            return i;
    }

    return unknown;
}
Beispiel #23
0
static void set_tsdb_values(set_args *args) {
    tsdb_handler db;
    tsdb_value *values;
    u_int32_t epoch = (args->timestamp ? args->timestamp : time(NULL));

    open_db(args->file, &db);
    values = alloc_values(args, db.values_per_entry);
    if (!values) {
        printf("tsdb-set: Could not allocate memory for set_tsdb_values!");
	exit(1);
    }
    //normalize_epoch(&db, &epoch);
    goto_epoch(&db, epoch);
    set_values(&db, args->key, values);
    free(values);
    tsdb_close(&db);
}
Beispiel #24
0
void start_group (FILE **StartFile, int ***auts, struct pga_vars *pga, struct pcp_vars *pcp)
{
   register int *y = y_address;

   int retain;
   int ***central;

   *StartFile = TemporaryFile ();
   save_pcp (*StartFile, pcp);
   retain = pcp->lastg;
   pcp->lastg = y[pcp->clend + pcp->cc - 1];
   pga->nmr_stabilisers = pga->m;
   pga->nmr_centrals = 0;
   pga->final_stage = TRUE;
   set_values (pga, pcp);
   save_pga (*StartFile, central, auts, pga, pcp);
   RESET(*StartFile);
   pcp->lastg = retain;
}
Beispiel #25
0
static int
load_preset (const gchar *fn)
{
  char  line[1024] = "";
  FILE *f;

  f = g_fopen (fn, "rt");
  if (!f)
    {
      g_printerr ("Error opening file \"%s\" for reading!\n",
                  gimp_filename_to_utf8 (fn));
      return -1;
    }
  fgets (line, 10, f);
  if (strncmp (line, PRESETMAGIC, 4))
    {
      fclose (f);
      return load_old_preset (fn);
    }

  restore_default_values ();

  while (!feof (f))
    {
      char *tmps;

      if (!fgets (line, 1024, f))
        break;
      g_strchomp (line);
      tmps = strchr (line, '=');
      if (!tmps)
        continue;
      *tmps = '\0';
      tmps++;
      set_values (line, tmps);
    }
  fclose (f);
  return 0;
}
 /// Copy the value of \a val in the element at position
 /// \a pos in the partition_vector container.
 ///
 /// \param pos   Position of the element in the partition_vector
 /// \param val   The value to be copied
 ///
 void set_values_sync(std::vector<std::size_t> const& pos,
     std::vector<T> const& val)
 {
     set_values(pos, val).get();
 }
Beispiel #27
0
/*
 * Build the settings window
 */
static void create_settings_window(void) {
  setting_window = window_create();
  Layer *window_layer = window_get_root_layer(setting_window);

  window_set_background_color(setting_window, SETTING_BACKGROUND_COLOR);

  // Get the resources we need
  up_button_res = gbitmap_create_with_resource(RESOURCE_ID_PICK_UP);
  next_button_res = gbitmap_create_with_resource(RESOURCE_ID_PICK_NEXT);
  down_button_res = gbitmap_create_with_resource(RESOURCE_ID_PICK_DOWN);
  tick_button_res = gbitmap_create_with_resource(RESOURCE_ID_PICK_TICK);
  small_font = fonts_get_system_font(FONT_KEY_GOTHIC_18_BOLD);
  large_font = fonts_get_system_font(FONT_KEY_GOTHIC_24_BOLD);

  // button_layer
  button_layer = action_bar_layer_create();
  action_bar_layer_add_to_window(button_layer, setting_window);
  action_bar_layer_set_background_color(button_layer, ACTION_BAR_BACKGROUND_COLOR);
  action_bar_layer_set_icon(button_layer, BUTTON_ID_UP, up_button_res);
  action_bar_layer_set_icon(button_layer, BUTTON_ID_SELECT, next_button_res);
  action_bar_layer_set_icon(button_layer, BUTTON_ID_DOWN, down_button_res);
#ifdef PBL_PLATFORM_BASALT 
  action_bar_layer_set_icon_press_animation(button_layer, BUTTON_ID_UP, ActionBarLayerIconPressAnimationMoveUp);
  action_bar_layer_set_icon_press_animation(button_layer, BUTTON_ID_SELECT, ActionBarLayerIconPressAnimationMoveRight);
  action_bar_layer_set_icon_press_animation(button_layer, BUTTON_ID_DOWN, ActionBarLayerIconPressAnimationMoveDown);
#endif
  layer_add_child(window_layer, (Layer *) button_layer);
  action_bar_layer_set_click_config_provider(button_layer, setting_click_config_provider);

  // title_layer
  title_layer = macro_text_layer_create(GRect(SETTING_TITLE_LEFT, 6, 90, SETTING_SMALL_FONT_HEIGHT), window_layer, NON_HIGHLIGHT_FG_COLOR, NON_HIGHLIGHT_BG_COLOR, small_font, GTextAlignmentLeft);
  text_layer_set_text(title_layer, SMART_ALARM);

  // from_layer
  from_layer = macro_text_layer_create(GRect(SETTING_TITLE_LEFT, 30, 55, SETTING_SMALL_FONT_HEIGHT), window_layer, NON_HIGHLIGHT_FG_COLOR, NON_HIGHLIGHT_BG_COLOR, small_font, GTextAlignmentLeft);
  text_layer_set_text(from_layer, EARLIEST);

  // fields[FROM_HOUR]
  fields[F_FROM_HOUR] = macro_text_layer_create(GRect(20, SETTING_FROM_TOP, SETTING_TIME_WIDTH, SETTING_BIG_FONT_HEIGHT), window_layer, NON_HIGHLIGHT_FG_COLOR, NON_HIGHLIGHT_BG_COLOR, large_font, GTextAlignmentCenter);

  // from_colon_layer
  from_colon_layer = macro_text_layer_create(GRect(43, SETTING_FROM_TOP, 13, SETTING_BIG_FONT_HEIGHT), window_layer, NON_HIGHLIGHT_FG_COLOR, NON_HIGHLIGHT_BG_COLOR, large_font, GTextAlignmentCenter);
  text_layer_set_text(from_colon_layer, COLON);

  // fields[FROM_MINUTE]
  fields[F_FROM_MINUTE] = macro_text_layer_create(GRect(52, SETTING_FROM_TOP, SETTING_TIME_WIDTH, SETTING_BIG_FONT_HEIGHT), window_layer, NON_HIGHLIGHT_FG_COLOR, NON_HIGHLIGHT_BG_COLOR, large_font, GTextAlignmentCenter);

  // to_layer
  to_layer = macro_text_layer_create(GRect(SETTING_TITLE_LEFT, 81, 48, SETTING_SMALL_FONT_HEIGHT), window_layer, NON_HIGHLIGHT_FG_COLOR, NON_HIGHLIGHT_BG_COLOR, small_font, GTextAlignmentLeft);
  text_layer_set_text(to_layer, LATEST);

  // fields[TO_HOUR]
  fields[F_TO_HOUR] = macro_text_layer_create(GRect(20, SETTING_TO_TOP, SETTING_TIME_WIDTH, SETTING_BIG_FONT_HEIGHT), window_layer, NON_HIGHLIGHT_FG_COLOR, NON_HIGHLIGHT_BG_COLOR, large_font, GTextAlignmentCenter);

  // to_color_layer
  to_color_layer = macro_text_layer_create(GRect(43, SETTING_TO_TOP, 13, SETTING_BIG_FONT_HEIGHT), window_layer, NON_HIGHLIGHT_FG_COLOR, NON_HIGHLIGHT_BG_COLOR, large_font, GTextAlignmentCenter);
  text_layer_set_text(to_color_layer, COLON);

  // fields[TO_MINUTE]
  fields[F_TO_MINUTE] = macro_text_layer_create(GRect(52, SETTING_TO_TOP, SETTING_TIME_WIDTH, SETTING_BIG_FONT_HEIGHT), window_layer, NON_HIGHLIGHT_FG_COLOR, NON_HIGHLIGHT_BG_COLOR, large_font, GTextAlignmentCenter);

  // fields[SMART_ALARM]
  fields[F_SMART_ALARM] = macro_text_layer_create(GRect(SA_LEFT, SA_TOP, 25, SETTING_BIG_FONT_HEIGHT), window_layer, NON_HIGHLIGHT_FG_COLOR, NON_HIGHLIGHT_BG_COLOR, large_font, GTextAlignmentCenter);

  // fields[DONE]
  fields[F_DONE] = macro_text_layer_create(GRect(DONE_LEFT, DONE_TOP, 45, SETTING_BIG_FONT_HEIGHT), window_layer, NON_HIGHLIGHT_FG_COLOR, NON_HIGHLIGHT_BG_COLOR, large_font, GTextAlignmentCenter);

  current_field = F_SMART_ALARM;

  set_values();
  write_values_to_fields();
  highlight_field(current_field, true);
}
Beispiel #28
0
MatxRow::MatxRow(const std::vector<std::string>& values)
{
    set_values(values);
}
Beispiel #29
0
  void
  int_range_steps_holder::
set_range( value_type min, value_type max)
{
    set_values( get_value( ), min, max);
}
Beispiel #30
0
  void
  int_range_steps_holder::
set_steps( value_type single_step, value_type page_step)
{
    set_values( get_value( ), get_min_value( ), get_max_value( ), single_step, page_step);
}