1 /* 2 * Copyright (c) International Business Machines Corp., 2001 3 * 4 * This program is free software; you can redistribute it and/or modify 5 * it under the terms of the GNU General Public License as published by 6 * the Free Software Foundation; either version 2 of the License, or 7 * (at your option) any later version. 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 12 * the GNU General Public License for more details. 13 * 14 * You should have received a copy of the GNU General Public License 15 * along with this program; if not, write to the Free Software 16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 17 */ 18 /* 19 * FUNCTIONS: Scheduler Test Suite 20 */ 21 22 /*---------------------------------------------------------------------+ 23 | sched.c | 24 | ==================================================================== | 25 | | 26 | Description: Simplistic test to verify the signal system function | 27 | calls: | 28 | | 29 | Last update: Ver. 1.2, 4/10/94 23:06:22 | 30 | | 31 | Change Activity | 32 | | 33 | Version Date Name Reason | 34 | 0.1 040294 DJK Initial version for AIX 4.1 | 35 | 0.2 010402 Manoj Iyer Ported to Linux | 36 | | 37 +---------------------------------------------------------------------*/ 38 39 #include <stdarg.h> 40 #include <stdio.h> 41 #include <string.h> 42 #include "sched.h" 43 44 #if 0 45 extern FILE *logfile; 46 47 /*---------------------------------------------------------------------+ 48 | openlog () | 49 | ==================================================================== | 50 | | 51 | Function: ... | 52 | | 53 +---------------------------------------------------------------------*/ 54 int openlog(char *filename) 55 { 56 57 if (filename == NULL) 58 error("passed bad file name to openlog()", __FILE__, __LINE__); 59 60 /* 61 * Open the log file... 62 */ 63 if ((logfile = fopen(filename, "a")) == (FILE *) NULL) 64 sys_error("fopen failed", __FILE__, __LINE__); 65 66 return (0); 67 } 68 69 /*---------------------------------------------------------------------+ 70 | logmsg () | 71 | ==================================================================== | 72 | | 73 | Function: ... | 74 | | 75 +---------------------------------------------------------------------*/ 76 void logmsg(const char *args, ...) 77 { 78 fprintf(logfile, args); 79 fflush(logfile); 80 } 81 #endif 82 83 /*---------------------------------------------------------------------+ 84 | sys_error () | 85 | ==================================================================== | 86 | | 87 | Function: Creates system error message and calls error () | 88 | | 89 +---------------------------------------------------------------------*/ 90 void sys_error(const char *msg, const char *file, int line) 91 { 92 char syserr_msg[256]; 93 94 sprintf(syserr_msg, "%s: %s\n", msg, strerror(errno)); 95 error(syserr_msg, file, line); 96 } 97 98 /*---------------------------------------------------------------------+ 99 | error () | 100 | ==================================================================== | 101 | | 102 | Function: Prints out message and exits... | 103 | | 104 +---------------------------------------------------------------------*/ 105 void error(const char *msg, const char *file, int line) 106 { 107 fprintf(stderr, "ERROR [file: %s, line: %d] %s\n", file, line, msg); 108 exit(-1); 109 } 110