root/alternc-sympa/tags/BASE/src/lst_putfile.c

Revision 1432, 2.1 kB (checked in by benjamin, 6 years ago)

Initial revision

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
Line 
1 /*
2  $Id$
3  ----------------------------------------------------------------------
4  AlternC - Web Hosting System
5  Copyright (C) 2002 by the AlternC Development Team.
6  http://alternc.org/
7  ----------------------------------------------------------------------
8  Based on:
9  Valentin Lacambre's web hosting softwares: http://altern.org/
10  ----------------------------------------------------------------------
11  LICENSE
12
13  This program is free software; you can redistribute it and/or
14  modify it under the terms of the GNU General Public License (GPL)
15  as published by the Free Software Foundation; either version 2
16  of the License, or (at your option) any later version.
17
18  This program is distributed in the hope that it will be useful,
19  but WITHOUT ANY WARRANTY; without even the implied warranty of
20  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
21  GNU General Public License for more details.
22
23  To read the license please visit http://www.gnu.org/copyleft/gpl.html
24  ----------------------------------------------------------------------
25  Original Author of file: Benjamin Sonntag - 2002/09/05
26  Purpose of file: Set a file content to sympa expl archive.
27  ----------------------------------------------------------------------
28 */
29 #include <stdio.h>
30 #include <stdlib.h>
31 #include <sys/types.h>
32 #include <sys/stat.h>
33
34
35 /* Usage : "lst_putfile PATH FILE SOURCE" Put SOURCE into FILE in the path PATH (in /var/lib/sympa/expl) */
36 int main(int argc,char *argv[]) {
37   char res[512];
38   FILE* f;
39   FILE* g;
40
41   if (argc!=4) {
42     printf("Utilisation : lst_putfile path file source\nPut SOURCE into FILE in the path PATH  '/var/lib/sympa/expl/'path'\n\n");
43     exit(-1);
44   }
45
46   setuid(geteuid());
47   setgid(getegid());
48
49   // WARNING : SYMPA ZONE //
50
51   sprintf(res,"/var/lib/sympa/expl/%.255s/%.255s",argv[1],argv[2]);
52   f=fopen(res,"wb");
53   if (!f) {
54     printf("Impossible d'ouvrir le fichier en ECRITURE\n");
55     exit(-1);
56   }
57   g=fopen(argv[3],"rb");
58   if (!g) {
59     printf("Impossible d'ouvrir le fichier en LECTURE\n");
60     exit(-1);
61   }
62   printf("OK\n");
63   while (!feof(g)) {
64     fgets(res,500,g);
65     if (!feof(g)) {
66       fputs(res,f);
67     }
68   }
69   fclose(f);
70   fclose(g);
71   exit(0);
72 }
Note: See TracBrowser for help on using the browser.