#include <stdio.h>
#include "extra.h"
Go to the source code of this file.
Defines | |
#define | EXTRA_RLIMIT_DATA_DEFAULT 67108864 |
Functions | |
long | Extra_CpuTime () |
int | Extra_GetSoftDataLimit () |
void | Extra_UtilGetoptReset () |
int | Extra_UtilGetopt (int argc, char *argv[], char *optstring) |
char * | Extra_UtilPrintTime (long t) |
char * | Extra_UtilStrsav (char *s) |
char * | Extra_UtilTildeExpand (char *fname) |
int | Extra_UtilCheckFile (char *filename, char *mode) |
char * | Extra_UtilFileSearch (char *file, char *path, char *mode) |
void | Extra_UtilMMout_Of_Memory (long size) |
Variables | |
char * | globalUtilOptarg |
int | globalUtilOptind = 0 |
static char * | pScanStr |
void(* | Extra_UtilMMoutOfMemory )() = Extra_UtilMMout_Of_Memory |
#define EXTRA_RLIMIT_DATA_DEFAULT 67108864 |
CFile****************************************************************
FileName [extraUtilUtil.c]
SystemName [ABC: Logic synthesis and verification system.]
PackageName [extra]
Synopsis [Old SIS utilities.]
Author [Alan Mishchenko]
Affiliation [UC Berkeley]
Date [Ver. 1.0. Started - June 20, 2005.]
Revision [
] DECLARATIONS ///
Definition at line 28 of file extraUtilUtil.c.
long Extra_CpuTime | ( | ) |
FUNCTION DEFINITIONS ///Function*************************************************************
Synopsis [util_cpu_time()]
Description []
SideEffects []
SeeAlso []
Definition at line 61 of file extraUtilUtil.c.
int Extra_GetSoftDataLimit | ( | ) |
Function*************************************************************
Synopsis [getSoftDataLimit()]
Description []
SideEffects []
SeeAlso []
Definition at line 77 of file extraUtilUtil.c.
00078 { 00079 return EXTRA_RLIMIT_DATA_DEFAULT; 00080 }
int Extra_UtilCheckFile | ( | char * | filename, | |
char * | mode | |||
) |
Function*************************************************************
Synopsis [check_file()]
Description []
SideEffects []
SeeAlso []
Definition at line 219 of file extraUtilUtil.c.
char* Extra_UtilFileSearch | ( | char * | file, | |
char * | path, | |||
char * | mode | |||
) |
Function*************************************************************
Synopsis [util_file_search()]
Description []
SideEffects []
SeeAlso []
Definition at line 246 of file extraUtilUtil.c.
00250 { 00251 int quit; 00252 char *buffer, *filename, *save_path, *cp; 00253 00254 if (path == 0 || strcmp(path, "") == 0) { 00255 path = "."; /* just look in the current directory */ 00256 } 00257 00258 save_path = path = Extra_UtilStrsav(path); 00259 quit = 0; 00260 do { 00261 cp = strchr(path, ':'); 00262 if (cp != 0) { 00263 *cp = '\0'; 00264 } else { 00265 quit = 1; 00266 } 00267 00268 /* cons up the filename out of the path and file name */ 00269 if (strcmp(path, ".") == 0) { 00270 buffer = Extra_UtilStrsav(file); 00271 } else { 00272 buffer = ALLOC(char, strlen(path) + strlen(file) + 4); 00273 (void) sprintf(buffer, "%s/%s", path, file); 00274 } 00275 filename = Extra_UtilTildeExpand(buffer); 00276 FREE(buffer); 00277 00278 /* see if we can access it */ 00279 if (Extra_UtilCheckFile(filename, mode)) { 00280 FREE(save_path); 00281 return filename; 00282 } 00283 FREE(filename); 00284 path = ++cp; 00285 } while (! quit); 00286 00287 FREE(save_path); 00288 return 0; 00289 }
int Extra_UtilGetopt | ( | int | argc, | |
char * | argv[], | |||
char * | optstring | |||
) |
Function*************************************************************
Synopsis [util_getopt()]
Description []
SideEffects []
SeeAlso []
Definition at line 111 of file extraUtilUtil.c.
00112 { 00113 register int c; 00114 register char *place; 00115 00116 globalUtilOptarg = NULL; 00117 00118 if (pScanStr == NULL || *pScanStr == '\0') { 00119 if (globalUtilOptind == 0) globalUtilOptind++; 00120 if (globalUtilOptind >= argc) return EOF; 00121 place = argv[globalUtilOptind]; 00122 if (place[0] != '-' || place[1] == '\0') return EOF; 00123 globalUtilOptind++; 00124 if (place[1] == '-' && place[2] == '\0') return EOF; 00125 pScanStr = place+1; 00126 } 00127 00128 c = *pScanStr++; 00129 place = strchr(optstring, c); 00130 if (place == NULL || c == ':') { 00131 (void) fprintf(stderr, "%s: unknown option %c\n", argv[0], c); 00132 return '?'; 00133 } 00134 if (*++place == ':') { 00135 if (*pScanStr != '\0') { 00136 globalUtilOptarg = pScanStr; 00137 pScanStr = NULL; 00138 } else { 00139 if (globalUtilOptind >= argc) { 00140 (void) fprintf(stderr, "%s: %c requires an argument\n", 00141 argv[0], c); 00142 return '?'; 00143 } 00144 globalUtilOptarg = argv[globalUtilOptind]; 00145 globalUtilOptind++; 00146 } 00147 } 00148 return c; 00149 }
void Extra_UtilGetoptReset | ( | ) |
Function*************************************************************
Synopsis [util_getopt_reset()]
Description []
SideEffects []
SeeAlso []
Definition at line 93 of file extraUtilUtil.c.
00094 { 00095 globalUtilOptarg = 0; 00096 globalUtilOptind = 0; 00097 pScanStr = 0; 00098 }
void Extra_UtilMMout_Of_Memory | ( | long | size | ) |
Function*************************************************************
Synopsis [MMout_of_memory()]
Description []
SideEffects []
SeeAlso []
Definition at line 303 of file extraUtilUtil.c.
char* Extra_UtilPrintTime | ( | long | t | ) |
Function*************************************************************
Synopsis [util_print_time()]
Description []
SideEffects []
SeeAlso []
Definition at line 162 of file extraUtilUtil.c.
00163 { 00164 static char s[40]; 00165 00166 (void) sprintf(s, "%ld.%02ld sec", t/1000, (t%1000)/10); 00167 return s; 00168 }
char* Extra_UtilStrsav | ( | char * | s | ) |
Function*************************************************************
Synopsis [Extra_UtilStrsav()]
Description []
SideEffects []
SeeAlso []
Definition at line 182 of file extraUtilUtil.c.
char* Extra_UtilTildeExpand | ( | char * | fname | ) |
Function*************************************************************
Synopsis [util_tilde_expand()]
Description []
SideEffects []
SeeAlso []
Definition at line 203 of file extraUtilUtil.c.
00204 { 00205 return Extra_UtilStrsav( fname ); 00206 }
void(* Extra_UtilMMoutOfMemory)() = Extra_UtilMMout_Of_Memory |
Function*************************************************************
Synopsis [MMoutOfMemory()]
Description []
SideEffects []
SeeAlso []
char* globalUtilOptarg |
Definition at line 41 of file extraUtilUtil.c.
int globalUtilOptind = 0 |
Definition at line 42 of file extraUtilUtil.c.
char* pScanStr [static] |
Definition at line 44 of file extraUtilUtil.c.