Mercurial > hg > nnchat
comparison util.c @ 419:d015ecbd231d
Use C99 style comments, too.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Thu, 24 May 2012 07:37:36 +0300 |
parents | 14b685cdbd2c |
children | a9b20b31cae1 |
comparison
equal
deleted
inserted
replaced
418:8ca09a6cca09 | 419:d015ecbd231d |
---|---|
87 PUSHCHAR(' '); | 87 PUSHCHAR(' '); |
88 s++; | 88 s++; |
89 break; | 89 break; |
90 | 90 |
91 case '½': | 91 case '½': |
92 /* Escape these .. */ | 92 // Escape these .. |
93 PUSHCHAR('½'); | 93 PUSHCHAR('½'); |
94 PUSHCHAR('½'); | 94 PUSHCHAR('½'); |
95 s++; | 95 s++; |
96 break; | 96 break; |
97 | 97 |
555 int nn_userhash_insert(nn_userhash_t *list, const char *name) | 555 int nn_userhash_insert(nn_userhash_t *list, const char *name) |
556 { | 556 { |
557 uint8_t hash; | 557 uint8_t hash; |
558 nn_user_t *user; | 558 nn_user_t *user; |
559 | 559 |
560 /* Check arguments */ | 560 // Check arguments |
561 if (list == NULL || name == NULL) | 561 if (list == NULL || name == NULL) |
562 return -1; | 562 return -1; |
563 | 563 |
564 /* Check if username is already there */ | 564 // Check if username is already there |
565 if (nn_user_find(list, name) != NULL) | 565 if (nn_user_find(list, name) != NULL) |
566 return 1; | 566 return 1; |
567 | 567 |
568 /* No, we'll add it */ | 568 // No, we'll add it |
569 if ((user = th_calloc(1, sizeof(nn_user_t))) == NULL) | 569 if ((user = th_calloc(1, sizeof(nn_user_t))) == NULL) |
570 return -3; | 570 return -3; |
571 | 571 |
572 user->name = th_strdup(name); | 572 user->name = th_strdup(name); |
573 if (user->name == NULL) | 573 if (user->name == NULL) |
582 | 582 |
583 int nn_userhash_delete(nn_userhash_t *list, const char *name) | 583 int nn_userhash_delete(nn_userhash_t *list, const char *name) |
584 { | 584 { |
585 uint8_t hash; | 585 uint8_t hash; |
586 | 586 |
587 /* Check arguments */ | 587 // Check arguments |
588 if (list == NULL || name == NULL) | 588 if (list == NULL || name == NULL) |
589 return -1; | 589 return -1; |
590 | 590 |
591 /* Check if username is already there */ | 591 // Check if username is already there |
592 hash = nn_hash_user(name); | 592 hash = nn_hash_user(name); |
593 if (list->buckets[hash] != NULL) | 593 if (list->buckets[hash] != NULL) |
594 { | 594 { |
595 nn_user_t *curr, *prev; | 595 nn_user_t *curr, *prev; |
596 curr = list->buckets[hash]; | 596 curr = list->buckets[hash]; |
627 if (src == NULL) return NULL; | 627 if (src == NULL) return NULL; |
628 | 628 |
629 if ((user = th_calloc(1, sizeof(nn_user_t))) == NULL) | 629 if ((user = th_calloc(1, sizeof(nn_user_t))) == NULL) |
630 return NULL; | 630 return NULL; |
631 | 631 |
632 /* Copy relevant data */ | 632 // Copy relevant data |
633 user->name = th_strdup(src->name); | 633 user->name = th_strdup(src->name); |
634 user->lastspoke = src->lastspoke; | 634 user->lastspoke = src->lastspoke; |
635 user->joined = src->joined; | 635 user->joined = src->joined; |
636 | 636 |
637 return user; | 637 return user; |