int sos_smaller (int i, int j, int k, int l) /* SoS predicate smaller. Assumes indices in proper range and (i,j) != (k,l) */ { int result; #ifdef __DEBUG__ if (sos_proto_flag) print ("sos_smaller (%d,%d,%d,%d, %f (fp), %f (fp)) ", i, j, k, l, lia_real (sos_lia (i,j)), lia_real (sos_lia (k,l))); if (sos_test_flag) if (not (((i != k) or (j != l)) and (0 < i) and (i <= sos_common.n) and (0 < k) and (k <= sos_common.n) and (0 < j) and (j <= sos_common.d) and (0 < l) and (l <= sos_common.d))) basic_error ("sos_smaller: wrong arguments"); #endif if (not lia_eq (sos_lia (i,j), sos_lia (k,l))) result = (lia_le (sos_lia (i,j), sos_lia (k,l))); else if (i != k) result = (i > k); else result = (j < l); #ifdef __DEBUG__ if (sos_proto_flag) print ("sos_smaller result: %d\n", result); #endif return (result); }
static void lia_cput (char c) /* Adds c to lia_buffer[] and checks for overflow. Internal use only! */ { lia_buffer[lia_buffer_pointer] = c; lia_buffer_pointer ++; if (lia_buffer_pointer > CBUFLEN) basic_error ("lia: buffer overflow; use lia_clear()"); }
int main (int ac, char **av) { int station_pid ; int delai_moyen; int delai_min; int delai_max; int station_index; time_t tick; time_t tock; if (ac != 5) basic_error ("invalid parameters numbers trafic\n"); station_index = atoi (av[1]); if (station_index < 0) basic_error ("invalid polling number\n"); station_pid = atoi (av[2]); if (station_pid < 0) basic_error ("invalid polling delai\n"); delai_min = atoi (av[3]); if (delai_min < 0) basic_error ("invalid secondary station number\n"); delai_max = atoi (av[4]); if (delai_max < 0) basic_error ("invalid secondary station number\n"); if (delai_max < delai_min) basic_error ("delai max < delai min\n"); srand (time(NULL)); delai_moyen = rand() % (delai_max - delai_min + 1) + delai_min; while (TRUE) { time (&tick); do { time (&tock); } while (difftime(tock, tick) < delai_moyen); kill (station_pid, DATA_REQ_TX); } return 0; }
Dt* dt_load (const char path_name[]) { Dt *dt = MALLOC (Dt, 1); Trist *s = MALLOC (Trist, 1); ; { /* using binary format */ FILE *f = basic_fopen (path_name, "r"); print ("Reading Delaunay triangulation from binary file \"%s\" ...\n", If (basic_fopen_zpath, basic_fopen_zpath, path_name)); ; Read1f (dt->type); Read1f (dt->bpt); Read1f (dt->n); Read1f (dt->redundant); Read1f (dt->hull_ef); Read1f (dt->last_hull); Read1f (dt->num); Read1f (dummy_word); ; Read1f (s->magic); Read1f (dummy_word); Read1f (s->last_triangle); Read1f (s->max_triangle); Read1f (s->max_org); Read1f (dummy_word); Read1f (s->used_triangles); Read1f (s->next_reusable_triangle); s->data_size = 0; s->data = NULL; ; dt->trist = s; ; /* just checking... */ if (s->magic != MAGIC) basic_error ("dt_load: wrong magic number (%d != %d)\n", s->magic, MAGIC); if (dt->bpt != (short) sizeof (Trist_record)) basic_error ("dt_load: wrong Trist record size (%d != %d)\n", dt->bpt, (short) sizeof (Trist_record)); if (NOT ( (dt->n == dt->trist->max_org) AND (dt->n == dt->num.v + dt->redundant))) basic_error ("dt_load: corrupted header\n"); if (dt->redundant) { print ("%15d redundant vertices dumped.\n", dt->redundant); print ("%15d actual vertices remain.\n", dt->num.v); } ; s->triangle = MALLOC (Trist_record, s->max_triangle + 1); binfread (s->triangle, s->max_triangle + 1, f); ; if (offset > 0) { dt->sos_offset = offset; s->max_org += offset; trist_set(s); trist_modify_vertices (offset); offset = 0; } else dt->sos_offset = 0; #ifdef __DEBUG__ trist_io_check (s, dt->num); #endif basic_fclose (f); } return (dt); }