Proxy para ReceitaNET.
[cascardo/rnetproxy.git] / ppmanager.c
diff --git a/ppmanager.c b/ppmanager.c
deleted file mode 100644 (file)
index f67714b..0000000
+++ /dev/null
@@ -1,117 +0,0 @@
-/*
-** Copyright (C) 2006 Thadeu Lima de Souza Cascardo <cascardo@minaslivre.org>
-** Copyright (C) 2009 Thadeu Lima de Souza Cascardo <cascardo@holoscopio.com>
-**  
-** This program is free software; you can redistribute it and/or modify
-** it under the terms of the GNU General Public License as published by
-** the Free Software Foundation; either version 2 of the License, or
-** (at your option) any later version.
-**  
-** This program is distributed in the hope that it will be useful,
-** but WITHOUT ANY WARRANTY; without even the implied warranty of
-** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-** GNU General Public License for more details.
-**  
-** 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-1307, USA.
-**  
-*/
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <gdbm.h>
-#include <errno.h>
-
-enum
-{
-  ACTION_ADD,
-  ACTION_DEL,
-  ACTION_LIST
-};
-
-void
-pp_dblistkeys (GDBM_FILE db)
-{
-  datum key;
-  datum oldkey;
-  key = gdbm_firstkey (db);
-  while (key.dptr != NULL)
-    {
-      printf ("%s\n", key.dptr);
-      oldkey = key;
-      key = gdbm_nextkey (db, oldkey);
-      free (oldkey.dptr);
-    }
-}
-
-void
-usage (char *programname)
-{
-  fprintf (stderr, "%s {allow | deny} {add | del | list} [user]\n",
-           programname);
-  exit (1);
-}
-
-int
-main (int argc, char **argv)
-{
-  GDBM_FILE db;
-  int action;
-  char *db_fn;
-  char *username;
-  datum key;
-  datum data;
-  int r = 0;
-  if (argc < 3)
-    usage (argv[0]);
-  if (!strcmp (argv[1], "deny"))
-    db_fn = "/var/lib/popproxy/deny.db";
-  else if (!strcmp (argv[1], "allow"))
-    db_fn = "/var/lib/popproxy/allow.db";
-  else
-    usage (argv[0]);
-  if (!strcmp (argv[2], "add"))
-    action = ACTION_ADD;
-  else if (!strcmp (argv[2], "del"))
-    action = ACTION_DEL;
-  else if (!strcmp (argv[2], "list"))
-    action = ACTION_LIST;
-  else
-    usage (argv[0]);
-  if ((action == ACTION_ADD || action == ACTION_DEL) && argc < 4)
-    usage (argv[0]);
-  if (action != ACTION_LIST)
-    {
-      username = argv[3];
-      key.dptr = username;
-      key.dsize = strlen (username);
-      data.dptr =  "";
-      data.dsize = 1;
-    }
-  db = gdbm_open (db_fn, 0, GDBM_WRCREAT, 0600, NULL);
-  if (db == NULL)
-    {
-      fprintf (stderr, "Could not create database.\n");
-      exit (1);
-    }
-  switch (action)
-    {
-    case ACTION_ADD:
-      r = gdbm_store (db, key, data, GDBM_REPLACE);
-      break;
-    case ACTION_DEL:
-      r = gdbm_delete (db, key);
-      break;
-    case ACTION_LIST:
-      pp_dblistkeys (db);
-      r = 0;
-      break;
-    default:
-      fprintf (stderr, "Action unrecognized.\n");
-      r = 1;
-    }
-  gdbm_close (db);
-  return r;
-}