]> git.sesse.net Git - vlc/blobdiff - modules/visualization/galaktos/preset.c
Test pointers against NULL instead of 0.
[vlc] / modules / visualization / galaktos / preset.c
index a33e1eb8769fc140f899b04e96f2be8d75eb8159..e7aea345ddb48ca71c10b8c33d2c4578712eb47d 100644 (file)
@@ -1,7 +1,7 @@
 /*****************************************************************************
  * preset.c:
  *****************************************************************************
- * Copyright (C) 2004 VideoLAN (Centrale Réseaux) and its contributors
+ * Copyright (C) 2004 the VideoLAN team
  * $Id$
  *
  * Authors: Cyril Deguet <asmax@videolan.org>
  *
  * 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, USA.
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
  *****************************************************************************/
 
+#ifdef HAVE_CONFIG_H
+# include "config.h"
+#endif
 
+#include <vlc_common.h>
+#include <vlc_charset.h>
 
-#include <stdio.h>
-#include <string.h>
 #include <stdlib.h>
+#include <stdio.h>
 #include <dirent.h>
 #include <time.h>
 #include "common.h"
@@ -381,7 +385,6 @@ int loadPresetByFile(char * filename) {
 int init_idle_preset() {
 
   preset_t * preset;
-  int i;
 
     /* Initialize idle preset struct */
   if ((preset = (preset_t*)malloc(sizeof(preset_t))) == NULL)
@@ -519,7 +522,7 @@ int load_preset_file(char * pathname, preset_t * preset) {
          return FAILURE;
   
   /* Open the file corresponding to pathname */
-  if ((fs = fopen(pathname, "r")) == 0) {
+  if ((fs = utf8_fopen(pathname, "r")) == NULL) {
     if (PRESET_DEBUG) printf("load_preset_file: loading of file %s failed!\n", pathname);
     return ERROR;      
   }
@@ -737,7 +740,6 @@ void reloadPerFrame(char * s, preset_t * preset) {
 preset_t * load_preset(char * pathname) {
 
   preset_t * preset;
-  int i;
 
   /* Initialize preset struct */
   if ((preset = (preset_t*)malloc(sizeof(preset_t))) == NULL)
@@ -791,7 +793,7 @@ void savePreset(char * filename) {
     return;
   
   /* Open the file corresponding to pathname */
-  if ((fs = fopen(filename, "w+")) == 0) {
+  if ((fs = utf8_fopen(filename, "w+")) == NULL) {
     if (PRESET_DEBUG) printf("savePreset: failed to create filename \"%s\"!\n", filename);
     return;    
   }
@@ -886,15 +888,19 @@ void write_init(init_cond_t * init_cond) {
     sprintf(s, "%s=%d\n", init_cond->param->name, init_cond->init_val.int_val);
 
   else if (init_cond->param->type == P_TYPE_DOUBLE)
-    sprintf(s, "%s=%f\n", init_cond->param->name, init_cond->init_val.double_val);
+  {
+    lldiv_t div = lldiv( init_cond->init_val.double_val * 1000000,1000000 );
+    sprintf(s, "%s=%"PRId64".%06u\n", init_cond->param->name, div.quot,
+                    (unsigned int) div.rem );
+  }
 
   else { printf("write_init: unknown parameter type!\n"); return; }
-  
+
   len = strlen(s);
 
   if ((fwrite(s, 1, len, write_stream)) != len)
     printf("write_init: failed writing to file stream! Out of disk space?\n");
-  
+
 }