comparison src/util.c @ 9426:dfee44a581a4

[gaim-migrate @ 10244] " This patch causes gaim to write out a file containing an ascii representation of the big-endian version of the port number which gaim listens in on for incoming zephyrs, of the form "gaimwgXXXXXX". It will be useful for debugging occasional problems with zephyr loss of subscriptions (chats). I've made some changes in util.c to allow the creation of temporary files with arbitrary templates: I've renamed gaim_mkstemp to gaim_mkstemp_template, modifying it to take a second argument, template, and use that instead of gaim_mkstemp_templ. A new gaim_mkstemp which is a wrapper around gaim_mkstemp_template has been put in place for compatibility with all the existing code using this function." --Arun A Tharuvai "The patch I submitted causes the wgfile to always be written out, because it would be useful for endusers too, and also to try to keep it consistent with the standard zephyr distribution." --Arun A Tharuvai committer: Tailor Script <tailor@pidgin.im>
author Luke Schierer <lschiere@pidgin.im>
date Tue, 29 Jun 2004 17:23:08 +0000
parents 79c4acbac4cd
children 66b3f54527e6
comparison
equal deleted inserted replaced
9425:42afbd004e6a 9426:dfee44a581a4
1949 * Returns NULL on failure and cleans up after itself if so. 1949 * Returns NULL on failure and cleans up after itself if so.
1950 */ 1950 */
1951 static const char *gaim_mkstemp_templ = {"gaimXXXXXX"}; 1951 static const char *gaim_mkstemp_templ = {"gaimXXXXXX"};
1952 1952
1953 FILE * 1953 FILE *
1954 gaim_mkstemp(char **fpath) 1954 gaim_mkstemp(char **fpath) {
1955 return gaim_mkstemp_template(fpath, gaim_mkstemp_templ);
1956 }
1957
1958
1959 FILE *
1960 gaim_mkstemp_template(char **fpath, const char *template)
1955 { 1961 {
1956 const gchar *tmpdir; 1962 const gchar *tmpdir;
1957 #ifndef _WIN32 1963 #ifndef _WIN32
1958 int fd; 1964 int fd;
1959 #endif 1965 #endif
1960 FILE *fp = NULL; 1966 FILE *fp = NULL;
1961 1967
1962 g_return_val_if_fail(fpath != NULL, NULL); 1968 g_return_val_if_fail(fpath != NULL, NULL);
1963 1969
1964 if((tmpdir = (gchar*)g_get_tmp_dir()) != NULL) { 1970 if((tmpdir = (gchar*)g_get_tmp_dir()) != NULL) {
1965 if((*fpath = g_strdup_printf("%s" G_DIR_SEPARATOR_S "%s", tmpdir, gaim_mkstemp_templ)) != NULL) { 1971 if((*fpath = g_strdup_printf("%s" G_DIR_SEPARATOR_S "%s", tmpdir, template)) != NULL) {
1966 #ifdef _WIN32 1972 #ifdef _WIN32
1967 char* result = _mktemp( *fpath ); 1973 char* result = _mktemp( *fpath );
1968 if( result == NULL ) 1974 if( result == NULL )
1969 gaim_debug(GAIM_DEBUG_ERROR, "gaim_mkstemp", 1975 gaim_debug(GAIM_DEBUG_ERROR, "gaim_mkstemp",
1970 "Problem creating the template\n"); 1976 "Problem creating the template\n");