void myHISsetup(char *histpath) { if (HISwritefp == NULL) { /* * Open the history file for appending formatted I/O. */ if ((HISwritefp = fopen(histpath, "a")) == NULL) { syslog(LOG_CRIT, "%s cant fopen %s %m", LogName, histpath); exit(1); } CloseOnExec((int) fileno(HISwritefp), TRUE); /* * Open the history file for reading. */ if ((HISreadfd = open(histpath, O_RDONLY)) < 0) { syslog(LOG_CRIT, "%s cant open %s %m", LogName, histpath); exit(1); } CloseOnExec(HISreadfd, TRUE); /* * Open the DBZ file. */ /* * (void)dbzincore(HISincore); */ (void) dbzincore(HISincore); (void) dbzwritethrough(1); if (dbminit(histpath) < 0) { syslog(LOG_CRIT, "%s cant dbminit %s %m", histpath, LogName); exit(1); } } }
int main (int argc,char * argv []) { datum cle; datum donnee; int i; int numero; if (argc < 2) { fprintf (stderr, "Syntaxe : %s nom_base clés...\n", argv [0]); exit (1); } if (dbminit (argv [1]) != 0) { perror ("dbminit"); exit (1); } for (i = 2; i < argc; i ++) { if (sscanf (argv [i], "%d", & numero) == 1) { cle . dptr = (char *) (& numero); cle . dsize = sizeof (int); donnee = fetch (cle); if (donnee . dptr != NULL) affiche_contributeur (cle, donnee); else fprintf (stderr, "%s : inconnu\n", argv [i]); } } dbmclose (); return (0); }
int OsInitColors() { if (!rgb_dbm) { #ifdef NDBM rgb_dbm = dbm_open(rgbPath, 0, 0); #else if (dbminit(rgbPath) == 0) rgb_dbm = 1; #endif if (!rgb_dbm) { ErrorF( "Couldn't open RGB_DB '%s'\n", rgbPath ); return FALSE; } } return TRUE; }
return d; } /* * Method: dbminit * Signature: (Ljava/lang/String;)I */ JNIEXPORT jint JNICALL Java_DBM_dbminit (JNIEnv *env, jobject this, jstring filename) { jboolean iscopy; jint ret = 0; int err; const char *cname = (*env)->GetStringUTFChars(env, filename, &iscopy); // printf("Filename is %s\n", cname); ret = dbminit(cname); err = errno; /* if GetString made this copy for us, free it up. */ if (iscopy) (*env)->ReleaseStringUTFChars(env, filename, cname); // If dbminit() failed, throw exception containing strerror(errno) if (ret < 0) { jclass myClass = (*env)->FindClass(env, "java/lang/IllegalArgumentException"); (*env)->ThrowNew(env, myClass, strerror(err)); } return 0; }
OsInit() { static Bool been_here = FALSE; char fname[MAXPATHLEN]; #ifdef macII set42sig(); #endif /* hack test to decide where to log errors */ if (!been_here) { if (write (2, fname, 0)) { long t; char *ctime(); FILE *err; fclose(stdin); fclose(stdout); sprintf (fname, ADMPATH, display); /* * uses stdio to avoid os dependencies here, * a real os would use * open (fname, O_WRONLY|O_APPEND|O_CREAT, 0666) */ if (!(err = fopen (fname, "a"))) err = fopen ("/dev/null", "w"); if (err && (fileno(err) != 2)) { dup2 (fileno (err), 2); fclose (err); } #ifdef SYSV /* yes, even though it is 4.2bsd.... */ { static char buf[BUFSIZ]; setvbuf (stderr, buf, _IOLBF, BUFSIZ); } #else setlinebuf(stderr); #endif time (&t); fprintf (stderr, "start %s", ctime(&t)); } if (getpgrp (0) == 0) setpgrp (0, getpid ()); #ifndef SYSV #if !defined(AIXrt) && !defined(AIX386) if (limitDataSpace >= 0) { struct rlimit rlim; if (!getrlimit(RLIMIT_DATA, &rlim)) { if ((limitDataSpace > 0) && (limitDataSpace < rlim.rlim_max)) rlim.rlim_cur = limitDataSpace; else rlim.rlim_cur = rlim.rlim_max; (void)setrlimit(RLIMIT_DATA, &rlim); } } if (limitStackSpace >= 0) { struct rlimit rlim; if (!getrlimit(RLIMIT_STACK, &rlim)) { if ((limitStackSpace > 0) && (limitStackSpace < rlim.rlim_max)) rlim.rlim_cur = limitStackSpace; else rlim.rlim_cur = rlim.rlim_max; (void)setrlimit(RLIMIT_STACK, &rlim); } } #endif #endif been_here = TRUE; } if (!rgb_dbm) { #ifdef NDBM rgb_dbm = dbm_open(rgbPath, 0, 0); #else if (dbminit(rgbPath) == 0) rgb_dbm = 1; #endif if (!rgb_dbm) ErrorF( "Couldn't open RGB_DB '%s'\n", rgbPath ); } }