You should have received a copy of the GNU General Public License
along with GNUnet; see the file COPYING. If not, write to the
- Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- Boston, MA 02111-1307, USA.
+ Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
*/
/**
"Unable to write to file! (Size: %u, size2: %u)\n",
size,
size2);
+
+ if (GNUNET_YES != GNUNET_DISK_file_close (f))
+ LOG (GNUNET_ERROR_TYPE_WARNING,
+ "Unable to close file\n");
+
return;
}
*end = '\0';
}
- size = GNUNET_snprintf (name_buf, name_buf_size, "sampler_el-%s-", buf);
+ size = GNUNET_snprintf (name_buf, name_buf_size, "sampler_el-%s", buf);
if (0 > size)
LOG (GNUNET_ERROR_TYPE_WARNING, "Failed to create name_buf\n");
return name_buf;
}
+
+struct GNUNET_CRYPTO_AuthKey
+string_to_auth_key (const char *str)
+{
+ struct GNUNET_CRYPTO_AuthKey auth_key;
+
+ if (GNUNET_OK !=
+ GNUNET_STRINGS_string_to_data (str,
+ strlen (str),
+ &auth_key.key,
+ sizeof (struct GNUNET_CRYPTO_AuthKey)))
+ {
+ LOG (GNUNET_ERROR_TYPE_WARNING, "Failed to convert string to data\n");
+ }
+
+ return auth_key;
+}
+
+
char *
create_file (const char *name)
{
name_buf_size = (strlen (prefix) + strlen (name) + 2) * sizeof (char);
name_buf = GNUNET_malloc (name_buf_size);
- size = GNUNET_snprintf (name_buf, name_buf_size, "%s%s-", prefix, name);
+ size = GNUNET_snprintf (name_buf, name_buf_size, "%s%s", prefix, name);
if (0 > size)
LOG (GNUNET_ERROR_TYPE_WARNING, "Failed to create name_buf\n");
- GNUNET_DISK_directory_create (prefix);
-
- file_name = GNUNET_malloc (strlen (name_buf) + 6);
+ if (GNUNET_YES != GNUNET_DISK_directory_create (prefix))
+ {
+ LOG (GNUNET_ERROR_TYPE_WARNING,
+ "Could not create directory %s.\n",
+ prefix);
+ }
- if (NULL == (file_name = GNUNET_DISK_mktemp (name_buf)))
- LOG (GNUNET_ERROR_TYPE_WARNING, "Could not create file\n");
+ if (NULL == strstr (name, "sampler_el"))
+ {/* only append random string to sampler */
+ if (NULL == (file_name = GNUNET_DISK_mktemp (name_buf)))
+ LOG (GNUNET_ERROR_TYPE_WARNING, "Could not create file\n");
GNUNET_free (name_buf);
-
return file_name;
+ }
+
+ return name_buf;
}
#endif /* TO_FILE */