• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /******************************************************************************/
2 /*                                                                            */
3 /* Copyright (c) International Business Machines  Corp., 2007                 */
4 /*                                                                            */
5 /* This program is free software;  you can redistribute it and/or modify      */
6 /* it under the terms of the GNU General Public License as published by       */
7 /* the Free Software Foundation; either version 2 of the License, or          */
8 /* (at your option) any later version.                                        */
9 /*                                                                            */
10 /* This program is distributed in the hope that it will be useful,            */
11 /* but WITHOUT ANY WARRANTY;  without even the implied warranty of            */
12 /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See                  */
13 /* the GNU General Public License for more details.                           */
14 /*                                                                            */
15 /* You should have received a copy of the GNU General Public License          */
16 /* along with this program;  if not, write to the Free Software               */
17 /* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA    */
18 /*                                                                            */
19 /******************************************************************************/
20 
21 /******************************************************************************/
22 /*                                                                            */
23 /* File:        libcontrollers.h                                              */
24 /*                                                                            */
25 /* Description: This file contains the declarations for the functions and     */
26 /*              variables used by the library and the test files.             */
27 /*                                                                            */
28 /* Author:      Sudhir Kumar skumar@linux.vnet.ibm.com                        */
29 /*                                                                            */
30 /* History:                                                                   */
31 /* Created-     15/02/2008 -Sudhir Kumar <skumar@linux.vnet.ibm.com>          */
32 /*                                                                            */
33 /******************************************************************************/
34 
35 /* Standard Include Files */
36 #include <dirent.h>
37 #include <limits.h>
38 #include <stdio.h>
39 #include <stdlib.h>
40 #include <string.h>
41 #include <sys/stat.h>
42 #include <sys/types.h>
43 #include <unistd.h>
44 
45 extern char fullpath[PATH_MAX];
46 extern int FLAG;
47 extern volatile int timer_expired;
48 extern int retval;
49 extern unsigned int num_line;
50 extern unsigned int current_shares;
51 extern unsigned int total_shares;
52 extern unsigned int *shares_pointer;
53 extern char target[LINE_MAX];
54 extern struct dirent *dir_pointer;
55 
56 enum{
57 	GET_SHARES	=1,
58 	GET_TASKS
59 };
60 
61 static inline void error_function(char *msg1, char *msg2);
62 
63 int read_shares_file(char *filepath);
64 
65 int read_file(char *filepath, int action, unsigned int *value);
66 
67 int scan_shares_files(unsigned int *shares_pointer);
68 
69 int write_to_file (char * file, const char* mode, unsigned int value);
70 
71 void signal_handler_alarm (int signal );
72 
73 void signal_handler_sigusr2 (int signal);
74