FOSSology  3.2.0rc1
Open Source License Compliance by Open Source Software
delagent.h
1 /********************************************************
2  Copyright (C) 2007-2012 Hewlett-Packard Development Company, L.P.
3  Copyright (C) 2015-2019 Siemens AG
4 
5  This program is free software; you can redistribute it and/or
6  modify it under the terms of the GNU General Public License
7  version 2 as published by the Free Software Foundation.
8 
9  This program is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  GNU General Public License for more details.
13 
14  You should have received a copy of the GNU General Public License along
15  with this program; if not, write to the Free Software Foundation, Inc.,
16  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17 
18  ********************************************************/
23 #ifndef _DELAGENT_H
24 #define _DELAGENT_H 1
25 
26 #include <stdlib.h>
27 #include <stdio.h>
28 #include <unistd.h>
29 #include <stdint.h>
30 #include <ctype.h>
31 #include <string.h>
32 #include <dirent.h>
33 #include <time.h>
34 #include <signal.h>
35 #include <libgen.h>
36 #include <getopt.h>
37 #include <gcrypt.h>
38 
39 #include "libfossology.h"
40 
41 extern int Verbose;
46 extern int Test;
47 
48 /* for DB */
49 extern PGconn* pgConn;
50 
55 #define MAXSQL 1024
56 
60 #define MAXSQLFolder 1024
61 
65 #define MAXLINE 1024
66 
70 #define myBUFSIZ 2048
71 
72 /* authentication and permission checking */
73 int authentication(char *user, char * password, int *userId, int *userPerm);
74 
75 int check_permission_upload(int wantedPermissions, long uploadId, int userId, int userPerm);
76 int check_read_permission_upload(long upload_id, int userId, int userPerm);
77 int check_write_permission_upload(long upload_id, int userId, int userPerm);
78 int check_permission_folder(long folder_id, int userId, int userPerm);
79 int check_permission_license(long license_id, int userPerm);
80 
81 /* functions that list things */
82 int listFolders(int userId, int userPerm);
83 int listUploads(int userId, int userPerm);
84 int listFoldersRecurse(long Parent, int Depth, long Row, int DelFlag, int userId, int userPerm);
85 
86 /* function that delete actual things */
87 int deleteUpload(long uploadId, int userId, int userPerm);
88 int deleteFolder(long cFolder, long pFolder, int userId, int userPerm);
89 int unlinkContent(long child, long parent, int mode, int userId, int userPerm);
90 
91 /* for usage from scheduler */
92 void doSchedulerTasks();
93 
94 /* misc */
95 void usage(char *Name);
96 void exitNow(int exitVal);
97 #endif /* _DELAGENT_H */
int Test
Definition: util.c:29
int deleteFolder(long cFolder, long pFolder, int userId, int userPerm)
recursively delete a folder
Definition: util.c:940
PGconn * pgConn
Database connection.
Definition: adj2nest.c:98
int check_permission_upload(int wanted_permissions, long uploadId, int userId, int userPerm)
check if the upload can be deleted, that is the user have the permission to delete this upload ...
Definition: util.c:169
void doSchedulerTasks()
process the jobs from scheduler
Definition: util.c:1060
int Verbose
Verbose level.
Definition: util.c:28
int check_read_permission_upload(long uploadId, int userId, int userPerm)
check if the user has read permission on the given upload
Definition: util.c:200
int check_write_permission_upload(long uploadId, int userId, int userPerm)
check if the user has read permission on the given upload
Definition: util.c:215
int deleteUpload(long uploadId, int userId, int userPerm)
Given an upload ID, delete it.
Definition: util.c:289
The main FOSSology C library.
FUNCTION void usage(char *name)
Definition: usage.c:30
int unlinkContent(long child, long parent, int mode, int userId, int userPerm)
remove link between parent and (child,mode) if there are other parents
Definition: util.c:458
int listFoldersRecurse(long Parent, int Depth, long Row, int DelFlag, int userId, int userPerm)
Draw folder tree.
Definition: util.c:520
int listFolders(int userId, int userPerm)
List every folder.
Definition: util.c:843
void exitNow(int exitVal)
Exit function. This does all cleanup and should be used instead of calling exit() or main() return...
Definition: util.c:1099
int authentication(char *user, char *password, int *userId, int *userPerm)
if this account is valid
Definition: util.c:105
int listUploads(int userId, int userPerm)
List every upload ID.
Definition: util.c:886