File: SIGUSR2_handler.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 (43 lines) | stat: -rw-r--r-- 791 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
#include <signal.h>
#include <stdlib.h>
#include <stdio.h>

#include "npfile.h"
#include "nptext.h"

extern void *text_p;

void SIGUSR2_handler( int signo )
{
   static int running = 0;

   if ( running )
      return;
   else
      running = 1;

   NP_Text *text = ( NP_Text *)text_p;

   char buffer[ 1024 ];
   NP_File file;
   snprintf( buffer, sizeof buffer,
             "%s/.peruser_spool/.current_article_origin", text->home );
   if ( file.openw( buffer ))
   {
      file.print_error();
      return;
   }

   snprintf( buffer, sizeof buffer, "%s\n%s\n%d\n%d\n", text->server,
             text->group, text->offset, text->size );
   if ( file.put_string( buffer ))
      file.print_error();

   file.close();

   running = 0;

   signal( SIGUSR2, SIGUSR2_handler );

   return;
}