]>
Commit | Line | Data |
---|---|---|
1 | # include <stdio.h> | |
2 | # include <string.h> | |
3 | # include "employee.h" | |
4 | ||
5 | bool employee_setName (employee *e, char na []) | |
6 | { | |
7 | size_t i; | |
8 | ||
9 | for (i = 0; na[i] != '\0'; i++) | |
10 | { | |
11 | if (i == maxEmployeeName) | |
12 | { | |
13 | e->name[0] = '\0'; | |
14 | return FALSE; | |
15 | } | |
16 | } | |
17 | ||
18 | strcpy (e->name, na); | |
19 | return TRUE; | |
20 | } | |
21 | ||
22 | bool employee_equal (employee * e1, employee * e2) | |
23 | { | |
24 | return ((e1->ssNum == e2->ssNum) | |
25 | && (e1->salary == e2->salary) | |
26 | && (e1->gen == e2->gen) | |
27 | && (e1->j == e2->j) | |
28 | && (strncmp (e1->name, e2->name, maxEmployeeName) == 0)); | |
29 | } | |
30 | ||
31 | typedef /*@observer@*/ char *obscharp; | |
32 | ||
33 | void employee_sprint (char s[], employee e) | |
34 | { | |
35 | static obscharp gender[] ={ "male", "female", "?" }; | |
36 | static obscharp jobs[] = { "manager", "non-manager", "?" }; | |
37 | ||
38 | (void) sprintf (s, FORMATEMPLOYEE, e.ssNum, e.name, | |
39 | gender[(int) e.gen], jobs[(int) e.j], e.salary); | |
40 | } | |
41 |