char* game_clear_board(Game *game) { game->handicap = 0; slist_clear(game->moves); slist_clear(game->placed_black_stones); slist_clear(game->placed_white_stones); return empty_position(game->pos); }
/* This function inits the counters */ void destroy_counters(void) { sd.changes = 0UL; sd.crypto = 0UL; sd.acct_changes = 0UL; sd.good_logins = 0UL; sd.bad_logins = 0UL; sd.good_auth = 0UL; sd.bad_auth = 0UL; sd.events = 0UL; sd.avcs = 0UL; sd.mac = 0UL; sd.failed_syscalls = 0UL; sd.anomalies = 0UL; sd.responses = 0UL; slist_clear(&sd.users); slist_clear(&sd.terms); slist_clear(&sd.files); slist_clear(&sd.hosts); slist_clear(&sd.exes); slist_clear(&sd.avc_objs); slist_clear(&sd.keys); ilist_clear(&sd.pids); ilist_clear(&sd.sys_list); ilist_clear(&sd.anom_list); ilist_create(&sd.mac_list); ilist_clear(&sd.resp_list); ilist_create(&sd.crypto_list); }
void slist_free(struct simple_list* slist) { #ifndef NVALGRIND VALGRIND_DESTROY_MEMPOOL(slist->value); #endif slist_clear(slist); free(slist->key); free(slist->value); slist->capacity = 0; }
int main(int argc, const char *argv[]) { char **areena = NULL; char *file = NULL; int cflag, ch; struct point p; struct slist *siirrot = NULL; size_t i = 0; cflag = 0; if (argc < 2) usage(); areena = luo_areena(); memset(&p, 0, sizeof(struct point)); while ((ch = getopt(argc, (char *const *)argv, "cf:")) != -1) { switch ((char)ch) { case 'c': cflag = 1; break; case 'f': file = optarg; break; default: usage(); } } argc -= optind; argv += optind; for (i = 0; i < 20; i++) { if (i % 2 == 0) { p = satunnainen_paikka(areena, M1); slist_insertbeginning(siirrot, &p); } else { p = satunnainen_paikka(areena, M2); slist_insertbeginning(siirrot, &p); } } tulosta_areena(areena); slist_print(siirrot); slist_clear(siirrot); free_areena(areena); return 0; }
int main(int argc, char *argv[]) { struct slist *list; list = slist_new(); assert(list); assert(0 == slist_size(list)); assert(list == slist_idx(list, 0)); assert(NULL == slist_idx(list, -1)); assert(NULL == slist_idx(list, 1)); /* Build an array and set canary values */ struct slist *nodes1[NODECNT]; for (int i = 0; i < NODECNT; i++) { nodes1[i] = malloc(sizeof(struct slist)); nodes1[i]->s = malloc(sizeof(struct sample)); nodes1[i]->s->rx_bytes = i; } /* Then add array elements to a list */ for (int i = 0; i < NODECNT; i++) { slist_push(list, nodes1[i]); assert(1 + i == slist_size(list)); } /* check slist_size */ assert(NODECNT == slist_size(list)); /* check the list_idx function */ for (int i = 0; i < NODECNT; i++) { struct slist *n = slist_idx(list, i); assert(n); assert(n->s->rx_bytes == i); } /* check slist_clear */ slist_clear(list); assert(0 == slist_size(list)); }
// --------------------- Evaluation of the final Position --------------------- void final_status_list(Position *pos, Status block_status[MAX_BLOCKS], Status point_status[BOARDSIZE], char *str_st, Point points[BOARDSIZE]) // Compute the status of all points (evaluation from owner_map[]) { Block b; Status st; for (char *p=str_st ; *p != 0 ; p++) *p = tolower(*p); if (strcmp(str_st, "dead") == 0) st = DEAD; else if (strcmp(str_st, "alive") == 0) st = ALIVE; else st = UNKNOWN; slist_clear(points); FORALL_POINTS(pos, pt) { b = point_block(pos, pt); if (b != 0 && block_status[b] == st) slist_push(points, pt); }
void list_clear(llist* l) { lnode* nextnode; register lnode* current; current = l->head; while (current) { nextnode=current->next; free(current->message); free(current); current=nextnode; } l->head = NULL; l->cur = NULL; l->cnt = 0; l->e.milli = 0L; l->e.sec = 0L; l->e.serial = 0L; free((char *)l->e.node); l->e.node = NULL; l->e.type = 0; l->s.gid = -1; l->s.egid = -1; l->s.ppid = -1; l->s.pid = -1; l->s.success = S_UNSET; l->s.uid = -1; l->s.euid = -1; l->s.loginuid = -2; free(l->s.hostname); l->s.hostname = NULL; if (l->s.filename) { slist_clear(l->s.filename); free(l->s.filename); l->s.filename = NULL; } free(l->s.terminal); l->s.terminal = NULL; free(l->s.cwd); l->s.cwd = NULL; free(l->s.exe); l->s.exe = NULL; if (l->s.key) { slist_clear(l->s.key); free(l->s.key); l->s.key = NULL; } free(l->s.comm); l->s.comm = NULL; if (l->s.avc) { alist_clear(l->s.avc); free(l->s.avc); l->s.avc = NULL; } free(l->s.acct); l->s.acct = NULL; l->s.arch = 0; l->s.syscall = 0; l->s.session_id = -2; free(l->s.uuid); l->s.uuid = NULL; free(l->s.vmname); l->s.vmname = NULL; l->s.exit = 0; l->s.exit_is_set = 0; }
int main(void) { snode n, *node; int rc, i = 0; slist_create(&s); // This first test checks to see if list is // created in a numeric order slist_add_if_uniq(&s, "test1"); slist_add_if_uniq(&s, "test2"); slist_first(&s); slist_add_if_uniq(&s, "test3"); puts("should be 3"); rc = print_list(); if (s.cnt != 3 || rc !=3) { puts("test count is wrong"); return 1; } n.str = strdup("test4"); n.key = NULL; n.hits = 1; slist_append(&s, &n); puts("should add a #4"); rc = print_list(); if (s.cnt != 4 || rc != 4) { puts("test count is wrong"); return 1; } slist_add_if_uniq(&s, "test2"); puts("should be same"); rc = print_list(); if (s.cnt != 4 || rc != 4) { puts("test count is wrong"); return 1; } slist_clear(&s); puts("should be empty"); rc = print_list(); if (s.cnt != 0 || rc != 0) { puts("test count is wrong"); return 1; } puts("starting sort test"); // Now test to see if the sort function works // Fill the list exactly backwards slist_add_if_uniq(&s, "test3"); slist_add_if_uniq(&s, "test3"); slist_add_if_uniq(&s, "test4"); slist_add_if_uniq(&s, "test3"); slist_add_if_uniq(&s, "test4"); slist_add_if_uniq(&s, "test2"); slist_add_if_uniq(&s, "test4"); slist_add_if_uniq(&s, "test2"); slist_add_if_uniq(&s, "test4"); slist_add_if_uniq(&s, "test1"); slist_sort_by_hits(&s); slist_first(&s); do { node = slist_get_cur(&s); if (node->hits != (4-i)) { printf("Sort test failed - i:%d != hits:%u\n", i, node->hits); return 1; } i++; } while ((node = slist_next(&s))); puts("sort test passes"); slist_clear(&s); return 0; }
static int do_akill(User * u) { char *cmd = strtok(NULL, " "); char breason[BUFSIZE]; if (!cmd) cmd = ""; if (!stricmp(cmd, "ADD")) { int deleted = 0; char *expiry, *mask, *reason; time_t expires, now = time(NULL); mask = strtok(NULL, " "); if (mask && *mask == '+') { expiry = mask; mask = strtok(NULL, " "); } else { expiry = NULL; } expires = expiry ? dotime(expiry) : AutokillExpiry; /* If the expiry given does not contain a final letter, it's in days, * said the doc. Ah well. */ if (expiry && isdigit(expiry[strlen(expiry) - 1])) expires *= 86400; /* Do not allow less than a minute expiry time */ if (expires != 0 && expires < 60) { notice_lang(s_OperServ, u, BAD_EXPIRY_TIME); return MOD_CONT; } else if (expires > 0) { expires += time(NULL); } if (mask && (reason = strtok(NULL, ""))) { /* We first do some sanity check on the proposed mask. */ if (strchr(mask, '!')) { notice_lang(s_OperServ, u, OPER_AKILL_NO_NICK); return MOD_CONT; } if (!strchr(mask, '@')) { notice_lang(s_OperServ, u, BAD_USERHOST_MASK); return MOD_CONT; } if (mask && strspn(mask, "~@.*?") == strlen(mask)) { notice_lang(s_OperServ, u, USERHOST_MASK_TOO_WIDE, mask); return MOD_CONT; } /** * Changed sprintf() to snprintf()and increased the size of * breason to match bufsize * -Rob **/ if (AddAkiller) { snprintf(breason, sizeof(breason), "[%s] %s", u->nick, reason); reason = sstrdup(breason); } deleted = add_akill(u, mask, u->nick, expires, reason); if (deleted < 0) { if (AddAkiller) { free(reason); } return MOD_CONT; } else if (deleted) { notice_lang(s_OperServ, u, OPER_AKILL_DELETED_SEVERAL, deleted); } notice_lang(s_OperServ, u, OPER_AKILL_ADDED, mask); if (WallOSAkill) { char buf[128]; if (!expires) { strcpy(buf, "does not expire"); } else { int wall_expiry = expires - now; char *s = NULL; if (wall_expiry >= 86400) { wall_expiry /= 86400; s = "day"; } else if (wall_expiry >= 3600) { wall_expiry /= 3600; s = "hour"; } else if (wall_expiry >= 60) { wall_expiry /= 60; s = "minute"; } snprintf(buf, sizeof(buf), "expires in %d %s%s", wall_expiry, s, (wall_expiry == 1) ? "" : "s"); } anope_cmd_global(s_OperServ, "%s added an AKILL for %s (%s) (%s)", u->nick, mask, reason, buf); } if (readonly) { notice_lang(s_OperServ, u, READ_ONLY_MODE); } if (AddAkiller) { free(reason); } } else { syntax_error(s_OperServ, u, "AKILL", OPER_AKILL_SYNTAX); } } else if (!stricmp(cmd, "DEL")) { char *mask; int res = 0; mask = strtok(NULL, " "); if (!mask) { syntax_error(s_OperServ, u, "AKILL", OPER_AKILL_SYNTAX); return MOD_CONT; } if (akills.count == 0) { notice_lang(s_OperServ, u, OPER_AKILL_LIST_EMPTY); return MOD_CONT; } if (isdigit(*mask) && strspn(mask, "1234567890,-") == strlen(mask)) { /* Deleting a range */ res = slist_delete_range(&akills, mask, NULL); if (res == 0) { notice_lang(s_OperServ, u, OPER_AKILL_NO_MATCH); return MOD_CONT; } else if (res == 1) { notice_lang(s_OperServ, u, OPER_AKILL_DELETED_ONE); } else { notice_lang(s_OperServ, u, OPER_AKILL_DELETED_SEVERAL, res); } } else { if ((res = slist_indexof(&akills, mask)) == -1) { notice_lang(s_OperServ, u, OPER_AKILL_NOT_FOUND, mask); return MOD_CONT; } slist_delete(&akills, res); notice_lang(s_OperServ, u, OPER_AKILL_DELETED, mask); } if (readonly) notice_lang(s_OperServ, u, READ_ONLY_MODE); } else if (!stricmp(cmd, "LIST")) { char *mask; int res, sent_header = 0; if (akills.count == 0) { notice_lang(s_OperServ, u, OPER_AKILL_LIST_EMPTY); return MOD_CONT; } mask = strtok(NULL, " "); if (!mask || (isdigit(*mask) && strspn(mask, "1234567890,-") == strlen(mask))) { res = slist_enum(&akills, mask, &akill_list_callback, u, &sent_header); if (res == 0) { notice_lang(s_OperServ, u, OPER_AKILL_NO_MATCH); return MOD_CONT; } else { notice_lang(s_OperServ, u, END_OF_ANY_LIST, "Akill"); } } else { int i; char amask[BUFSIZE]; for (i = 0; i < akills.count; i++) { snprintf(amask, sizeof(amask), "%s@%s", ((Akill *) akills.list[i])->user, ((Akill *) akills.list[i])->host); if (!stricmp(mask, amask) || match_wild_nocase(mask, amask)) akill_list(i + 1, akills.list[i], u, &sent_header); } if (!sent_header) notice_lang(s_OperServ, u, OPER_AKILL_NO_MATCH); else { notice_lang(s_OperServ, u, END_OF_ANY_LIST, "Akill"); } } } else if (!stricmp(cmd, "VIEW")) { char *mask; int res, sent_header = 0; if (akills.count == 0) { notice_lang(s_OperServ, u, OPER_AKILL_LIST_EMPTY); return MOD_CONT; } mask = strtok(NULL, " "); if (!mask || (isdigit(*mask) && strspn(mask, "1234567890,-") == strlen(mask))) { res = slist_enum(&akills, mask, &akill_view_callback, u, &sent_header); if (res == 0) { notice_lang(s_OperServ, u, OPER_AKILL_NO_MATCH); return MOD_CONT; } } else { int i; char amask[BUFSIZE]; for (i = 0; i < akills.count; i++) { snprintf(amask, sizeof(amask), "%s@%s", ((Akill *) akills.list[i])->user, ((Akill *) akills.list[i])->host); if (!stricmp(mask, amask) || match_wild_nocase(mask, amask)) akill_view(i + 1, akills.list[i], u, &sent_header); } if (!sent_header) notice_lang(s_OperServ, u, OPER_AKILL_NO_MATCH); } } else if (!stricmp(cmd, "CLEAR")) { slist_clear(&akills, 1); notice_lang(s_OperServ, u, OPER_AKILL_CLEAR); } else { syntax_error(s_OperServ, u, "AKILL", OPER_AKILL_SYNTAX); } return MOD_CONT; }
void slist_release(void** L) { slist_clear(*L, NULL); FREE(*L); }
/** * The /os admin command. * @param u The user who issued the command * @param MOD_CONT to continue processing other modules, MOD_STOP to stop processing. **/ int do_admin(User * u) { char *cmd = strtok(NULL, " "); char *nick = strtok(NULL, " "); NickAlias *na; int res = 0; if (skeleton) { notice_lang(s_OperServ, u, OPER_ADMIN_SKELETON); return MOD_CONT; } if (!cmd || (!nick && stricmp(cmd, "LIST") && stricmp(cmd, "CLEAR"))) { syntax_error(s_OperServ, u, "ADMIN", OPER_ADMIN_SYNTAX); } else if (!stricmp(cmd, "ADD")) { if (!is_services_root(u)) { notice_lang(s_OperServ, u, PERMISSION_DENIED); return MOD_CONT; } if (!(na = findnick(nick))) { notice_lang(s_OperServ, u, NICK_X_NOT_REGISTERED, nick); return MOD_CONT; } if (na->status & NS_VERBOTEN) { notice_lang(s_OperServ, u, NICK_X_FORBIDDEN, nick); return MOD_CONT; } if (na->nc->flags & NI_SERVICES_ADMIN || slist_indexof(&servadmins, na->nc) != -1) { notice_lang(s_OperServ, u, OPER_ADMIN_EXISTS, nick); return MOD_CONT; } res = slist_add(&servadmins, na->nc); if (res == -2) { notice_lang(s_OperServ, u, OPER_ADMIN_REACHED_LIMIT, nick); return MOD_CONT; } else { if (na->nc->flags & NI_SERVICES_OPER && (res = slist_indexof(&servopers, na->nc)) != -1) { slist_delete(&servopers, res); na->nc->flags |= NI_SERVICES_ADMIN; notice_lang(s_OperServ, u, OPER_ADMIN_MOVED, nick); } else if (na->nc->flags & NI_SERVICES_HELPOP && (res = slist_indexof(&servhelpops, na->nc)) != -1) { slist_delete(&servhelpops, res); na->nc->flags |= NI_SERVICES_ADMIN; notice_lang(s_OperServ, u, OPER_ADMIN_MOVED, nick); } else { na->nc->flags |= NI_SERVICES_ADMIN; notice_lang(s_OperServ, u, OPER_ADMIN_ADDED, nick); } LogStaffAction(STAFFLOG_CHANNEL | STAFFLOG_OPERGLOBAL, "OperServ", "%s!%s@%s added %s to the services admin list", u->nick, u->username, u->host, nick); } if (readonly) notice_lang(s_OperServ, u, READ_ONLY_MODE); } else if (!stricmp(cmd, "DEL")) { if (!is_services_root(u)) { notice_lang(s_OperServ, u, PERMISSION_DENIED); return MOD_CONT; } if (servadmins.count == 0) { notice_lang(s_OperServ, u, OPER_ADMIN_LIST_EMPTY); return MOD_CONT; } if (isdigit(*nick) && strspn(nick, "1234567890,-") == strlen(nick)) { /* Deleting a range */ res = slist_delete_range(&servadmins, nick, NULL); if (res == 0) { notice_lang(s_OperServ, u, OPER_ADMIN_NO_MATCH); return MOD_CONT; } else if (res == 1) { notice_lang(s_OperServ, u, OPER_ADMIN_DELETED_ONE); } else { notice_lang(s_OperServ, u, OPER_ADMIN_DELETED_SEVERAL, res); } } else { if (!(na = findnick(nick))) { notice_lang(s_OperServ, u, NICK_X_NOT_REGISTERED, nick); return MOD_CONT; } if (na->status & NS_VERBOTEN) { notice_lang(s_OperServ, u, NICK_X_FORBIDDEN, nick); return MOD_CONT; } if (!(na->nc->flags & NI_SERVICES_ADMIN) || (res = slist_indexof(&servadmins, na->nc)) == -1) { notice_lang(s_OperServ, u, OPER_ADMIN_NOT_FOUND, nick); return MOD_CONT; } slist_delete(&servadmins, res); notice_lang(s_OperServ, u, OPER_ADMIN_DELETED, nick); } if (readonly) notice_lang(s_OperServ, u, READ_ONLY_MODE); } else if (!stricmp(cmd, "LIST")) { int sent_header = 0; if (servadmins.count == 0) { notice_lang(s_OperServ, u, OPER_ADMIN_LIST_EMPTY); return MOD_CONT; } if (!nick || (isdigit(*nick) && strspn(nick, "1234567890,-") == strlen(nick))) { res = slist_enum(&servadmins, nick, &admin_list_callback, u, &sent_header); if (res == 0) { notice_lang(s_OperServ, u, OPER_ADMIN_NO_MATCH); return MOD_CONT; } else { notice_lang(s_OperServ, u, END_OF_ANY_LIST, "Admin"); } } else { int i; for (i = 0; i < servadmins.count; i++) if (!stricmp (nick, ((NickCore *) servadmins.list[i])->display) || match_wild_nocase(nick, ((NickCore *) servadmins. list[i])->display)) admin_list(i + 1, servadmins.list[i], u, &sent_header); if (!sent_header) notice_lang(s_OperServ, u, OPER_ADMIN_NO_MATCH); else { notice_lang(s_OperServ, u, END_OF_ANY_LIST, "Admin"); } } } else if (!stricmp(cmd, "CLEAR")) { if (!is_services_root(u)) { notice_lang(s_OperServ, u, PERMISSION_DENIED); return MOD_CONT; } if (servadmins.count == 0) { notice_lang(s_OperServ, u, OPER_ADMIN_LIST_EMPTY); return MOD_CONT; } slist_clear(&servadmins, 1); notice_lang(s_OperServ, u, OPER_ADMIN_CLEAR); } else { syntax_error(s_OperServ, u, "ADMIN", OPER_ADMIN_SYNTAX); } return MOD_CONT; }
/** * The /os sgline command. * @param u The user who issued the command * @param MOD_CONT to continue processing other modules, MOD_STOP to stop processing. **/ int do_sgline(User * u) { char *cmd = strtok(NULL, " "); if (!cmd) cmd = ""; if (!stricmp(cmd, "ADD")) { int deleted = 0; char *expiry, *mask, *reason; time_t expires; mask = strtok(NULL, ":"); if (mask && *mask == '+') { expiry = mask; mask = strchr(expiry, ' '); if (mask) { *mask = 0; mask++; } } else { expiry = NULL; } expires = expiry ? dotime(expiry) : SGLineExpiry; /* If the expiry given does not contain a final letter, it's in days, * said the doc. Ah well. */ if (expiry && isdigit(expiry[strlen(expiry) - 1])) expires *= 86400; /* Do not allow less than a minute expiry time */ if (expires != 0 && expires < 60) { notice_lang(s_OperServ, u, BAD_EXPIRY_TIME); return MOD_CONT; } else if (expires > 0) { expires += time(NULL); } if (mask && (reason = strtok(NULL, ""))) { /* Clean up the last character of the mask if it is a space * See bug #761 */ size_t masklen = strlen(mask); if (mask[masklen - 1] == ' ') mask[masklen - 1] = '\0'; /* We first do some sanity check on the proposed mask. */ if (mask && strspn(mask, "*?") == strlen(mask)) { notice_lang(s_OperServ, u, USERHOST_MASK_TOO_WIDE, mask); return MOD_CONT; } deleted = add_sgline(u, mask, u->nick, expires, reason); if (deleted < 0) return MOD_CONT; else if (deleted) notice_lang(s_OperServ, u, OPER_SGLINE_DELETED_SEVERAL, deleted); notice_lang(s_OperServ, u, OPER_SGLINE_ADDED, mask); if (WallOSSGLine) { char buf[128]; if (!expires) { strcpy(buf, "does not expire"); } else { int wall_expiry = expires - time(NULL); char *s = NULL; if (wall_expiry >= 86400) { wall_expiry /= 86400; s = "day"; } else if (wall_expiry >= 3600) { wall_expiry /= 3600; s = "hour"; } else if (wall_expiry >= 60) { wall_expiry /= 60; s = "minute"; } snprintf(buf, sizeof(buf), "expires in %d %s%s", wall_expiry, s, (wall_expiry == 1) ? "" : "s"); } xanadu_cmd_global(s_OperServ, "%s added an SGLINE for %s (%s)", u->nick, mask, buf); } if (readonly) notice_lang(s_OperServ, u, READ_ONLY_MODE); } else { syntax_error(s_OperServ, u, "SGLINE", OPER_SGLINE_SYNTAX); } } else if (!stricmp(cmd, "DEL")) { char *mask; int res = 0; mask = strtok(NULL, ""); if (!mask) { syntax_error(s_OperServ, u, "SGLINE", OPER_SGLINE_SYNTAX); return MOD_CONT; } if (sglines.count == 0) { notice_lang(s_OperServ, u, OPER_SGLINE_LIST_EMPTY); return MOD_CONT; } if (isdigit(*mask) && strspn(mask, "1234567890,-") == strlen(mask)) { /* Deleting a range */ res = slist_delete_range(&sglines, mask, NULL); if (res == 0) { notice_lang(s_OperServ, u, OPER_SGLINE_NO_MATCH); return MOD_CONT; } else if (res == 1) { notice_lang(s_OperServ, u, OPER_SGLINE_DELETED_ONE); } else { notice_lang(s_OperServ, u, OPER_SGLINE_DELETED_SEVERAL, res); } } else { if ((res = slist_indexof(&sglines, mask)) == -1) { notice_lang(s_OperServ, u, OPER_SGLINE_NOT_FOUND, mask); return MOD_CONT; } slist_delete(&sglines, res); notice_lang(s_OperServ, u, OPER_SGLINE_DELETED, mask); } if (readonly) notice_lang(s_OperServ, u, READ_ONLY_MODE); } else if (!stricmp(cmd, "LIST")) { char *mask; int res, sent_header = 0; if (sglines.count == 0) { notice_lang(s_OperServ, u, OPER_SGLINE_LIST_EMPTY); return MOD_CONT; } mask = strtok(NULL, ""); if (!mask || (isdigit(*mask) && strspn(mask, "1234567890,-") == strlen(mask))) { res = slist_enum(&sglines, mask, &sgline_list_callback, u, &sent_header); if (res == 0) { notice_lang(s_OperServ, u, OPER_SGLINE_NO_MATCH); return MOD_CONT; } } else { int i; char *amask; for (i = 0; i < sglines.count; i++) { amask = ((SXLine *) sglines.list[i])->mask; if (!stricmp(mask, amask) || match_wild_nocase(mask, amask)) sgline_list(i + 1, sglines.list[i], u, &sent_header); } if (!sent_header) notice_lang(s_OperServ, u, OPER_SGLINE_NO_MATCH); else { notice_lang(s_OperServ, u, END_OF_ANY_LIST, "SGLine"); } } } else if (!stricmp(cmd, "VIEW")) { char *mask; int res, sent_header = 0; if (sglines.count == 0) { notice_lang(s_OperServ, u, OPER_SGLINE_LIST_EMPTY); return MOD_CONT; } mask = strtok(NULL, ""); if (!mask || (isdigit(*mask) && strspn(mask, "1234567890,-") == strlen(mask))) { res = slist_enum(&sglines, mask, &sgline_view_callback, u, &sent_header); if (res == 0) { notice_lang(s_OperServ, u, OPER_SGLINE_NO_MATCH); return MOD_CONT; } } else { int i; char *amask; for (i = 0; i < sglines.count; i++) { amask = ((SXLine *) sglines.list[i])->mask; if (!stricmp(mask, amask) || match_wild_nocase(mask, amask)) sgline_view(i + 1, sglines.list[i], u, &sent_header); } if (!sent_header) notice_lang(s_OperServ, u, OPER_SGLINE_NO_MATCH); } } else if (!stricmp(cmd, "CLEAR")) { slist_clear(&sglines, 1); notice_lang(s_OperServ, u, OPER_SGLINE_CLEAR); } else { syntax_error(s_OperServ, u, "SGLINE", OPER_SGLINE_SYNTAX); } return MOD_CONT; }
void clients_clear(clients_t* list) { slist_clear(&(list->list_)); }
void PropValue(void) // PropValue = "[" ValueType "]" { yyaccept('['); ValueType(); // Property Value was read : use it to modify the game int size = board_size(game->pos); if (board_nmoves(game->pos) < nmoves-1 && strcmp(prop_name[prop], "B") == 0) { if (yytext[0] != 'B') do_play(game, BLACK, parse_sgf_coord(yytext, size)); else do_play(game, BLACK, PASS_MOVE); } else if (board_nmoves(game->pos) < nmoves-1 && strcmp(prop_name[prop], "W") == 0) { if (yytext[0] != 'W') do_play(game, WHITE, parse_sgf_coord(yytext, size)); else do_play(game, WHITE, PASS_MOVE); } else if (strcmp(prop_name[prop], "AB") == 0) { Point pt = parse_sgf_coord(yytext, size); slist_push(game->placed_black_stones, pt); board_place_stone(game->pos, pt, BLACK); } else if (strcmp(prop_name[prop], "AW") == 0) { Point pt = parse_sgf_coord(yytext, size); slist_push(game->placed_white_stones, pt); board_place_stone(game->pos, pt, WHITE); } else if (strcmp(prop_name[prop], "KM") == 0) board_set_komi(game->pos, atof(yytext)); else if (strcmp(prop_name[prop], "SZ") == 0) { if (is_game_board_empty(game)) { board_set_size(game->pos, atoi(yytext)); game_clear_board(game); } else { // Can happen if SZ occurs after AB or AW Point bstones[BOARDSIZE], wstones[BOARDSIZE]; Position *pos=game->pos; slist_clear(bstones); slist_clear(wstones); slist_append(bstones, game->placed_black_stones); slist_append(wstones, game->placed_white_stones); board_set_size(game->pos, atoi(yytext)); game_clear_board(game); FORALL_IN_SLIST(bstones, pt) { board_set_color_to_play(pos, BLACK); play_move(pos, pt); slist_push(game->placed_black_stones, pt); } FORALL_IN_SLIST(wstones, pt) { board_set_color_to_play(pos, WHITE); play_move(pos, pt); slist_push(game->placed_white_stones, pt); } }