*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
/* General functions for accessing address book files */
#include <glib.h>
#include <stdio.h>
#include <stdlib.h>
-#include <dirent.h>
#include <sys/stat.h>
#include <math.h>
#include <setjmp.h>
element = xml_get_element(file);
addritem_attrib_set_value(uAttr, element);
+ g_free(element);
if (uAttr) {
if (person) {
book->retVal = MGU_OPEN_FILE;
#ifdef DEV_STANDALONE
- fp = fopen(fileSpec, "wb");
+ fp = g_fopen(fileSpec, "wb");
g_free(fileSpec);
if (fp) {
fputs("<?xml version=\"1.0\" ?>\n", fp);
g_free(fileSpec);
if (pfile) {
fp = pfile->fp;
- fprintf(fp, "<?xml version=\"1.0\" encoding=\"%s\" ?>\n",
- conv_get_current_charset_str());
+ fprintf( fp, "<?xml version=\"1.0\" encoding=\"%s\" ?>\n", CS_INTERNAL );
#endif
addrbook_write_elem_s(fp, 0, AB_ELTAG_ADDRESS_BOOK);
addrbook_write_attr(fp, AB_ATTAG_NAME,
*/
GList *addrbook_get_bookfile_list(AddressBookFile *book) {
gchar *adbookdir;
- DIR *dp;
- struct dirent *entry;
+ GDir *dir;
+ const gchar *dir_name;
struct stat statbuf;
gchar buf[WORK_BUFLEN];
gchar numbuf[WORK_BUFLEN];
adbookdir = g_strdup(buf);
strcat(buf, ADDRBOOK_PREFIX);
- if ((dp = opendir(adbookdir)) == NULL) {
+ if( ( dir = g_dir_open( adbookdir, 0, NULL ) ) == NULL ) {
book->retVal = MGU_OPEN_DIRECTORY;
g_free(adbookdir);
return NULL;
lennum = FILE_NUMDIGITS + lenpre;
maxval = -1;
- while ((entry = readdir(dp)) != NULL) {
+ while( ( dir_name = g_dir_read_name( dir ) ) != NULL ) {
gchar *endptr = NULL;
gint i;
gboolean flg;
strcpy(buf, adbookdir);
- strcat(buf, entry->d_name);
+ strcat( buf, dir_name );
stat(buf, &statbuf);
- if (S_IFREG & statbuf.st_mode) {
+ if (S_ISREG(statbuf.st_mode)) {
if (strncmp(
- entry->d_name,
+ dir_name,
ADDRBOOK_PREFIX, lenpre) == 0)
{
if (strncmp(
- (entry->d_name) + lennum,
+ (dir_name) + lennum,
ADDRBOOK_SUFFIX, lensuf) == 0)
{
strncpy(numbuf,
- (entry->d_name) + lenpre,
+ (dir_name) + lenpre,
FILE_NUMDIGITS);
numbuf[FILE_NUMDIGITS] = '\0';
flg = TRUE;
if (val > maxval) maxval = val;
fileList = g_list_append(
fileList,
- g_strdup(entry->d_name));
+ g_strdup(dir_name));
}
}
}
}
}
}
- closedir(dp);
+ g_dir_close( dir );
g_free(adbookdir);
book->maxValue = maxval;