Freeciv-3.3: /fast/freeciv/nightly/main/common/sex.c Source File

Freeciv-3.3

Loading...
Searching...
No Matches
sex.c
Go to the documentation of this file.
1/****************************************************************************
2 Freeciv - Copyright (C) 2004 - The Freeciv Team
3 This program is free software; you can redistribute it and/or modify
4 it under the terms of the GNU General Public License as published by
5 the Free Software Foundation; either version 2, or (at your option)
6 any later version.
7
8 This program is distributed in the hope that it will be useful,
9 but WITHOUT ANY WARRANTY; without even the implied warranty of
10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 GNU General Public License for more details.
12****************************************************************************/
13
14#ifdef HAVE_CONFIG_H
15#include <fc_config.h>
16#endif
17
18/* utility */
19#include "fcintl.h"
20#include "support.h"
21
22#include "sex.h"
23
24/************************************************************************/
27 sex_t sex_by_name(const char *name)
28{
29 if (!fc_strcasecmp("Male", name)) {
30 return SEX_MALE;
31 }
32
33 if (!fc_strcasecmp("Female", name)) {
34 return SEX_FEMALE;
35 }
36
37 return SEX_UNKNOWN;
38}
39
40/************************************************************************/
43 const char *sex_rule_name(sex_t kind)
44{
45 switch (kind) {
46 case SEX_MALE:
47 return N_("Male");
48 case SEX_FEMALE:
49 return N_("Female");
50 case SEX_UNKNOWN:
51 return NULL;
52 }
53
54 return NULL;
55}
56
57/************************************************************************/
60 const char *sex_name_translation(sex_t kind)
61{
62 const char *rule_name = sex_rule_name(kind);
63
64 if (rule_name == NULL) {
65 return NULL;
66 }
67
68 return _(rule_name);
69}
70
71/************************************************************************/
74 const char *sex_name_mnemonic(sex_t kind, const char *mnemonic)
75{
76 static char buf[128];
77
78 switch (kind) {
79 case SEX_MALE:
80 fc_snprintf(buf, sizeof(buf), _("%sMale"), mnemonic);
81 return buf;
82 case SEX_FEMALE:
83 fc_snprintf(buf, sizeof(buf), _("%sFemale"), mnemonic);
84 return buf;
85 case SEX_UNKNOWN:
86 break;
87 }
88
89 return NULL;
90}
incite_cost
char * incite_cost
Definition comments.c:74
fcintl.h
_
#define _(String)
Definition fcintl.h:67
N_
#define N_(String)
Definition fcintl.h:69
name
const char * name
Definition inputfile.c:127
sex_name_mnemonic
const char * sex_name_mnemonic(sex_t kind, const char *mnemonic)
Definition sex.c:74
sex_name_translation
const char * sex_name_translation(sex_t kind)
Definition sex.c:60
sex_by_name
sex_t sex_by_name(const char *name)
Definition sex.c:27
sex_rule_name
const char * sex_rule_name(sex_t kind)
Definition sex.c:43
sex.h
sex_t
sex_t
Definition sex.h:20
SEX_UNKNOWN
@ SEX_UNKNOWN
Definition sex.h:21
SEX_FEMALE
@ SEX_FEMALE
Definition sex.h:22
SEX_MALE
@ SEX_MALE
Definition sex.h:23
fc_snprintf
int fc_snprintf(char *str, size_t n, const char *format,...)
Definition support.c:960
fc_strcasecmp
int fc_strcasecmp(const char *str0, const char *str1)
Definition support.c:186
support.h