#include #include #include #include #include #include #include "projet.h" #include "projetx.m" #if 0 FILE *fopen_err (const char *f, const char *mode, bool quit) { FILE *ret = fopen (f,mode); if (ret == NULL){ xconf_error (MSG_U(E_CANTOPEN,"Can't open file %s (%s)\n") ,f,strerror(errno)); if (quit) exit (-1); } return ret; } FILE *fopen_binerr (const char *f, const char *mode, bool quit) { return fopen_err (f,mode,quit); } void *calloc_err (int nb, int size, bool quit) { void *ret = calloc (nb,size); if (ret == NULL && nb != 0 && size != 0){ fprintf (stderr,"out of memory\n"); if (quit) exit(-1); } return ret; } void *calloc_err (int nb, int size) { return calloc_err (nb,size,true); } #endif void strlwr (char *pt) { while (*pt != '\0'){ if (isupper(*pt)) *pt = tolower(*pt); pt++; } } #if 0 static int cmp (const void *p1, const void *p2) { char *pt1 = *(char**)p1; char *pt2 = *(char**)p2; return (strcmp(pt1,pt2)); } /* tri des chaines de caracteres */ export void tbstr_sort ( char *tb[], /* tableau de chaine a trier */ int nbstr) /* nombre de chaine a trier */ { hsort (tb,nbstr,sizeof(char*),cmp); } #endif void bugapp_printf (const char *key, const char *ctl, ...) { fprintf (stderr,"%s:",key); va_list list; va_start (list,ctl); vfprintf (stderr,ctl,list); va_end (list); } PUBLIC PREFER_PATH::PREFER_PATH(const char *k, const char *p) { key.setfrom (k); path.setfrom (p); } PUBLIC const char *PREFER_PATH::getval (char *s, int len) { strncpy (s,path.get(),len); return s; } PUBLIC PREFER_INT::PREFER_INT(const char *k, int v) { key.setfrom (k); defval = v; } PUBLIC int PREFER_INT::getval () { return defval; } PREFER_PATH configPath ("config","/etc/projetx"); PREFER_PATH applicationPath ("apppath","/usr/lib/projetx");