1 /* Hey EMACS -*- linux-c -*- */
2 /* $Id: grouped.c 1266 2005-06-29 13:37:03Z roms $ */
3 
4 /*  libtifiles - file format library, a part of the TiLP project
5  *  Copyright (C) 1999-2005  Romain Lievin
6  *
7  *  This program is free software; you can redistribufe it and/or modify
8  *  it under the terms of the GNU General Public License as published by
9  *  the Free Software Foundation; either version 2 of the License, or
10  *  (at your option) any later version.
11  *
12  *  This program is distribufed in the hope that it will be useful,
13  *  buf WITHOUT ANY WARRANTY; without even the implied warranty of
14  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15  *  GNU General Public License for more details.
16  *
17  *  You should have received a copy of the GNU General Public License
18  *  along with this program; if not, write to the Free Software Foundation,
19  *  Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20  */
21 
22 /*
23 	Convenient functions which puts a comment into a TI file.
24 */
25 
26 #include <stdio.h>
27 #include <string.h>
28 #include <time.h>
29 #include <glib.h>
30 
31 #include "tifiles.h"
32 
33 static char comment[64];	// 40 bytes max
34 
35 /**
36  * tifiles_comment_set_single:
37  *
38  * Returns a string which contains a comment such as "Group file dated 12/31/99, 15:15".
39  *
40  * Return value: a static string.
41  **/
tifiles_comment_set_single(void)42 TIEXPORT2 const char* TICALL tifiles_comment_set_single(void)
43 {
44 	time_t t = time(NULL);
45 	char *str = asctime(localtime(&t));
46 
47 	sprintf(comment, "Single file dated %s", str);
48 	comment[40] = '\0';
49 
50 	return comment;
51 }
52 
53 /**
54  * tifiles_comment_set_group:
55  *
56  * Returns a string which contains a comment such as "Group file dated 12/31/99, 15:15".
57  *
58  * Return value: a static string.
59  **/
tifiles_comment_set_group(void)60 TIEXPORT2 const char* TICALL tifiles_comment_set_group(void)
61 {
62 	time_t t = time(NULL);
63 	char *str = asctime(localtime(&t));
64 
65 	sprintf(comment, "Group file dated %s", str);
66 	comment[40] = '\0';
67 
68 	return comment;
69 }
70 
71 /**
72  * tifiles_comment_set_backup:
73  *
74  * Returns a string which contains a comment such as "Group file dated 12/31/99, 15:15".
75  *
76  * Return value: a static string.
77  **/
tifiles_comment_set_backup(void)78 TIEXPORT2 const char* TICALL tifiles_comment_set_backup(void)
79 {
80 	time_t t = time(NULL);
81 	char *str = asctime(localtime(&t));
82 
83 	sprintf(comment, "Backup file dated %s", str);
84 	comment[40] = '\0';
85 
86 	return comment;
87 }
88 
89 /**
90  * tifiles_comment_set_tigroup:
91  *
92  * Returns a string which contains a comment such as "TiGroup file dated 12/31/99, 15:15".
93  *
94  * Return value: a _dynamically allocated_ .
95  **/
tifiles_comment_set_tigroup(void)96 TIEXPORT2 const char* TICALL tifiles_comment_set_tigroup(void)
97 {
98 	time_t t = time(NULL);
99 	char *str = asctime(localtime(&t));
100 
101 	sprintf(comment, "TiGroup file dated %s", str);
102 	comment[40] = 0;
103 
104 	return comment;
105 }
106