File: editor_button_callback.C

package info (click to toggle)
peruser 4b33-10
  • links: PTS
  • area: main
  • in suites: woody
  • size: 2,944 kB
  • ctags: 1,064
  • sloc: cpp: 22,397; perl: 2,733; makefile: 345; sh: 335
file content (53 lines) | stat: -rw-r--r-- 1,146 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#include <string.h>

#include "npcompose.h"

void editor_button_callback( GtkWidget *widget, gpointer data )
{
   NP_Compose *compose = ( NP_Compose *)data;

   NP_File file;
   char buffer[ 1024 ];
   snprintf( buffer, sizeof buffer, "%s/.peruser4-config", compose->home );
   if ( file.openr( buffer ))
   {
      compose->show_message( file.get_error() );
      return;
   }

   char *line = NULL;
   for( int i = 0; i < 2; ++i )
   {
      if (( line = file.get_string()) == NULL )
      {
         compose->show_message( "You have not configured News Peruser.\n(Press"
                                " the configure button on the main window.)" );
         return;
      }
   }

   strcpy( buffer, line );
   strtok( buffer, "\r\n" );

   file.close();

   char filename[ 1024 ];
   snprintf( filename, sizeof filename, "%s/.peruser4-edit", compose->home );
   if ( file.openw( filename ))
   {
      compose->show_message( file.get_error() );
      return;
   }

   compose->write_message( file, 0 );
   file.close();

   strcat( buffer, " " );
   strcat( buffer, filename );

   system( buffer );

   compose->load( 1 );
   
   return;
}