static void fix_diff_singleton(struct saucy *s, int cf) { int r = s->right.lab[cf]; int l = s->left.lab[cf]; int rcfl; if (!s->right.clen[cf] && r != l) { /* Make sure diff is marked */ add_diff(s, r); /* It is now undiffed since it is singleton */ ++s->nundiffs; remove_diffnon(s, r); /* Mark the other if not singleton already */ rcfl = s->right.cfront[l]; if (s->right.clen[rcfl]) { add_diff(s, l); /* Check for pairs */ if (in_cell_range(&s->right, s->left.unlab[r], rcfl)) { add_pair(s, l); } } /* Otherwise we might be eating a pair */ else if (is_a_pair(s, r)) { eat_pair(s, r); } } }
bool_t add(divisor& x, const divisor& a, const divisor& b) // This subroutine wraps other functions that does the actual // divisor arithmetic. It checks the validity of input divisors // so that other subroutines it calls do not need to do so. { bool_t OK = TRUE; /* Reduce overhead of checking with NDEBUG flag */ assert(OK = OK && a.is_valid_divisor() && b.is_valid_divisor()); if (deg(a.get_upoly()) == genus && deg(b.get_upoly()) == genus) { if (a == - b) { x.set_unit(); OK = TRUE; return OK; } if (a != b && IsOne(GCD(a.get_upoly(), b.get_upoly()))) { // Addition OK = OK && add_diff(x, a, b); return OK; } else if (a == b && IsOne(GCD(a.get_curve().get_h() + 2*a.get_vpoly(), a.get_upoly())) ) { // Doubling // Exclude the case when one point of the divisor is equal to // its opposite OK = OK && doubling(x, a); return OK; } } // Call add_cantor() to handle other cases OK = OK && add_cantor(x, a, b); return OK; }
int genere_diff(int sock,int nb){ long lus; int i; char buff[57]; buff[56]='\0'; for(i=0;i<nb;i++){ char type[5]; char id[9]; char ip1[16]; char port1[5]; char ip2[16]; char port2[5]; lus=recv(sock, buff, 57, 0);//4+1+8+1+15+1+4+1+15+1+4+2 // printf("LUS : %lu -%s-\n",lus,buff); if(lus!=57){ print("Erreur de format -5-, fin de la connexion au gestionnaire."); return 0; } snprintf(type,5,"%s",buff); if(strcmp("ITEM",type)){ print("Erreur de format -6-, fin de la connexion au gestionnaire."); return 0; } snprintf(id,9,"%s",(buff+5)); snprintf(ip1,16,"%s",(buff+14)); snprintf(port1, 5, "%s",(buff+30)); snprintf(ip2,16,"%s",(buff+35)); snprintf(port2, 5, "%s",(buff+51)); if(strlen(id)!=8 || !verif_ip(ip1) || !verif_ip(ip2) || !verif_port(port1) || !verif_port(port2)){ print("Erreur de format -7-, fin de la connexion au gestionnaire."); return 0; } printf("GENERE LIST : \n"); printf("id : -%s-\n p1 : -%s-\n ip1 : -%s-\n p2 : -%s-\n ip2 : -%s-\n",id,port1,ip1,port2,ip2); add_diff(&liste_tmp, make_diff(id, port1, ip1, port2, ip2)); } return 1; }
static void fix_diff_subtract(struct saucy *s, int cf, const int *a, const int *b) { int i, k; int cb = cf + s->right.clen[cf]; /* Mark the contents of the first set */ for (i = cf; i <= cb; ++i) { s->stuff[a[i]] = 1; } /* Add elements from second set not present in the first */ for (i = cf; i <= cb; ++i) { k = b[i]; if (!s->stuff[k]) add_diff(s, k); } /* Clear the marks of the first set */ for (i = cf; i <= cb; ++i) { s->stuff[a[i]] = 0; } }
void transfert_liste(liste_dif * src, liste_dif ** cible){ while(src!=NULL){ add_diff(cible, src->diff); src = src->suivant; } }