Example #1
0
static void log_add_full_v(logtype_t typ, char *pname, char *format, va_list argp)
{
    char *leader = NULL;
    char *xlated_fmt = gettext(format);
    char linebuf[STR_SIZE];
    size_t n;
    static gboolean in_log_add = 0;

    /* avoid recursion */
    if (in_log_add)
	return;

    /* format error message */

    if((int)typ <= (int)L_BOGUS || (int)typ > (int)L_MARKER) typ = L_BOGUS;

    if(multiline > 0) {
	leader = g_strdup("  ");		/* continuation line */
    } else {
	leader = g_strjoin(NULL, logtype_str[(int)typ], " ", pname, " ", NULL);
    }

    /* use sizeof(linebuf)-2 to save space for a trailing newline */
    g_vsnprintf(linebuf, sizeof(linebuf)-2, xlated_fmt, argp);
						/* -1 to allow for '\n' */

    /* avoid recursive call from error() */

    in_log_add = 1;

    /* append message to the log file */

    if(multiline == -1) open_log();

    if (full_write(logfd, leader, strlen(leader)) < strlen(leader)) {
	error(_("log file write error: %s"), strerror(errno));
	/*NOTREACHED*/
    }

    amfree(leader);

    /* add a newline if necessary */
    n = strlen(linebuf);
    if(n == 0 || linebuf[n-1] != '\n') linebuf[n++] = '\n';
    linebuf[n] = '\0';

    if (full_write(logfd, linebuf, n) < n) {
	error(_("log file write error: %s"), strerror(errno));
	/*NOTREACHED*/
    }

    if(multiline != -1) multiline++;
    else close_log();

    in_log_add = 0;
}
Example #2
0
int main(void)
{ 
	enable_syslog();
        read_config();
	open_log();
        daemonize();
        sockify();
        closelog();
        return 0;
}
Example #3
0
int log::write_log(const char * msg, int len){

	if(!m_file){
		error_log("file is not open\n");
		return -1;
	}
	
	time_t cur = time(NULL);
	struct tm tm_cur ;
	localtime_r(&cur, &tm_cur);	
	int cur_size = (int)ftell(m_file);
	
	if(cur_size > m_max_size || m_logbegin.tm_mday != tm_cur.tm_mday){
		
		fprintf(m_file, "file log %d-%d day end write %d/%d bytes\n", 
		m_logbegin.tm_mday , tm_cur.tm_mday, cur_size, m_max_size);

		fclose(m_file);
		
		if(m_logbegin.tm_mday != tm_cur.tm_mday){
			tm_cur.tm_hour = 24;
			tm_cur.tm_min = 0; 
			tm_cur.tm_sec = 0;
		}
	
		char newfilename[max_path_len] = {0};
		snprintf(newfilename ,sizeof(newfilename),
			"%s-%d%02d%02d-%02d%02d%02d.log", 
			m_pathname,
			m_logbegin.tm_year+1900, 
			m_logbegin.tm_mon+1,
			m_logbegin.tm_mday,
			tm_cur.tm_hour,
			tm_cur.tm_min, 
			tm_cur.tm_sec);
	
		rename(m_filename, newfilename);
		
		if(open_log() < 0){
			return -1;
		}
	}
	
	int ret = fwrite(msg, 1, len, m_file);
	
	if(ret < len){
		warn_log("write %d/%d bytes error(%d)\n", ret, len, errno);
	}
	
	if(m_immediate_flush){	
		fflush(m_file);
	}	
	
	return 0;
}
Example #4
0
void
init_log(const char *filename)
{
  open_log(filename);
#ifdef USE_SYSLOG
  openlog(PACKAGE, LOG_PID | LOG_NDELAY, LOG_FACILITY);
#endif
#ifndef SYSLOG_USERS
  eventAddIsh("user_log_resync", user_log_resync, NULL, 60);
#endif
}
Example #5
0
 // faster method to make log entries
 int log_bin_shorthand(string log_folder, Priority logPriority, uint8_t process_id, short int data) {
     FILE *test_log;
     const char * process = cs1_systems[process_id];
     test_log = open_log(log_folder,process); 
     int log_result=-1;
     if(test_log!=NULL) {
         log_result = Shakespeare::log_bin(test_log, logPriority, process_id, data);
     }
     fclose(test_log);
     return log_result; 
 }
Example #6
0
static int32_t backup_log(log_t *log)
{
    int32_t ret = 0;
    char bakName[LOG_NAME_LEN];
    char name[LOG_NAME_LEN];
    time_t t = 0;    
    struct tm *ts = NULL;

    if (0 == (log->mode & LOG_TO_FILE))
    {
        return 0;
    }
    
    MkDir(log->dir);
    
    OS_RWLOCK_WRLOCK(&log->rwlock);
    
    t = time(NULL);
    ts = localtime(&t);
    if (NULL == ts)
    {
        OS_SNPRINTF(bakName, LOG_NAME_LEN, "%s/%s.log.bak",
            log->dir, log->name);
    }
    else
    {
        OS_SNPRINTF(bakName, LOG_NAME_LEN, "%s/%s_%04d%02d%02d_%02d%02d%02d.log", 
            log->dir, log->name, ts->tm_year+1900, ts->tm_mon+1, ts->tm_mday, 
            ts->tm_hour, ts->tm_min, ts->tm_sec);
    }
    
    OS_SNPRINTF(name, LOG_NAME_LEN, "%s/%s.log",
        log->dir, log->name);

    if (NULL != log->disk_hnd)
    {
        os_file_close(log->disk_hnd);
        log->disk_hnd = NULL;
    }
    
    unlink(bakName);
    rename(name, bakName);

    if (NULL == open_log(log))
    {
        ret = -1;
    }

    log->total_lines = 0;

    OS_RWLOCK_WRUNLOCK(&log->rwlock);
    
    return ret;
}
Example #7
0
static ErlDrvData gen_q_drv_start(ErlDrvPort port, char* buff) {
    open_log();
    GenQData* d = (GenQData*)genq_alloc(sizeof(GenQData));
    d->port = port;
    d->opts.unix_timestamp_is_q_datetime = 0;
    d->opts.day_seconds_is_q_time = 0;

    khp("",-1);
    LOG("port started %d\n", 0);
    return (ErlDrvData)d;
}
Example #8
0
File: cash.c Project: tangfu/Cash
int write_to_log(const char *priority, const char *message){
  if(!logging)
    return 1;
  else
    if(!log_open)
      open_log();
  if(verbose)
    fprintf(stderr,"%s  %s\n", priority, message);
  fprintf(log_file, "%s  %s\n", priority, message);
  return 0;
}
Example #9
0
void main(int argc, char* argv[]){
	int i = 2;
	FILE *log;

	log = open_log("logger.txt");
	Log(log, "Test 1 \n");
	Log(log, "Test %d \n", i);
	close_log(log);

    exit(0);
}
Example #10
0
EventLogger::EventLogger(RoleConfig roleconfig) : Role(roleconfig),
    m_log("eventlogger", "Event Logger"), m_file(nullptr)
{
    bind(bind_addr.get_rval(roleconfig));

    m_file_format = output_format.get_rval(roleconfig);
    open_log();

    LoggedEvent event("log-opened", "EventLogger");
    event.add("msg", "Log opened upon Event Logger startup.");
    process_packet(event.make_datagram(), m_local);
}
Example #11
0
static int
check_start_ok(const char *vmxfile)
{
	pid_t pid, w;
	int status;
	FILE *logfp;
	
	logfp = open_log();
	
	LOG(logfp, "check_start_ok: %s\n", vmxfile);
	pid = fork();
	if (pid < 0)	{
		LOG(logfp, "check_start_ok: fork failed: %d\n", errno);
		return 0;
	}
	if (pid == 0)	{
		char cmdbuf[256];
		sprintf(cmdbuf, csokformat, (char *)vmxfile);
		csokargv[2] = cmdbuf;
		if (miq_loglevel)	{
			char **avp;
			LOG(logfp, "check_start_ok: exec'ing %s\n", csokpath);
			for (avp = csokargv; *avp; avp++)	{
				LOG(logfp, "\t%s\n", *avp);
			}
		}
		if (real_execve(csokpath, csokargv, __environ) < 0)	{
			LOG(logfp, "check_start_ok: exec of %s failed: %d\n", csokpath, errno);
			return 0;
		}
	}
	else	{
		do	{
			w = waitpid(pid, &status, 0);
			if (w < 0)	{
				LOG(logfp, "check_start_ok: waitpid failed: %d\n", errno);
				return 0;
			}
			if (WIFEXITED(status))	{
				int rv = WEXITSTATUS(status);
				LOG(logfp, "check_start_ok: %s returned: %d\n", csokpath, rv);
				LOG(logfp, "check_start_ok: returning: %d\n", !rv);
				return !rv;
			}
			if (WIFSIGNALED(status))	{
				LOG(logfp, "check_start_ok: killed by signal: %d\n", WTERMSIG(status));
				return 0;
			}
		} while(1);
	}
	return 1;
}
Example #12
0
void clear_log()
{
	bool was_logging = (gLog != NULL);
	end_log();
	FILE* f = open_log("w");
	if(f)
	{
		fclose(f);
	}
	if(was_logging) {
		begin_log();
	}
}
Example #13
0
 // faster method to make log entries
 int log_shorthand(string log_folder, Priority logPriority, string process, string msg) 
 {
     FILE *test_log;
     test_log = open_log(log_folder,process); 
     int log_result=-1;
 
     if(test_log!=NULL) 
     {
         log_result = Shakespeare::log(test_log, logPriority, process, msg);
         fclose(test_log);
     }
     return log_result; 
 }
Example #14
0
static void initialize(void)
{
   if (!al_init()) {
      abort_example("Could not init Allegro.\n");
   }

   open_log();

   al_init_primitives_addon();
   al_init_image_addon();
   al_init_font_addon();
   if (!al_install_keyboard()) {
      abort_example("Could not init keyboard!\n");
   }
   if (!al_install_mouse()) {
      abort_example("Could not init mouse!\n");
   }
   
   al_init_acodec_addon();

   if (!al_install_audio()) {
      abort_example("Could not init sound!\n");
   }
   if (!al_reserve_samples(16)) {
      abort_example("Could not set up voice and mixer.\n");
   }

   init_platform_specific();

   display = al_create_display(640, 228);
   if (!display) {
      abort_example("Could not create display!\n");
   }
   
   basic_font = al_load_font("data/font.tga", 0, 0);
   if (!basic_font) {
      abort_example("Could not load font!\n");
   }
   timer = al_create_timer(1.000 / 30);
   if (!timer) {
      abort_example("Could not init timer!\n");
   }
   queue = al_create_event_queue();
   if (!queue) {
      abort_example("Could not create event queue!\n");
   }
   al_register_event_source(queue, al_get_keyboard_event_source());
   al_register_event_source(queue, al_get_mouse_event_source());
   al_register_event_source(queue, al_get_display_event_source(display));
   al_register_event_source(queue, al_get_timer_event_source(timer));
}
Example #15
0
Logger::Logger(MessageLevel console_level, MessageLevel log_level)
:
console_message_level(console_level),
log_message_level(log_level),
old_print_handler(NULL),
old_log_handler(NULL),
h_log_file(NULL),
flush_log_timer(0)
{
	old_log_handler = g_log_set_default_handler(log_handler, NULL);
	old_print_handler = g_set_print_handler(print_handler);
	if(log_message_level > MessageLevel_NONE)
		open_log();
}
Example #16
0
void begin_log()
{
	static bool registered_exit = false;
	
	gLog = open_log("a");

	if(gLog == NULL) {
		error("ERROR: Failed to open log file %s.");
	}

	if(!registered_exit) {
		registered_exit = (atexit(end_log) == 0);
	}
}
Example #17
0
static void checkday(void)
{
    time_t t;
    struct tm tm;

    time(&t);
    tm = *localtime(&t);

    if (curday != tm.tm_yday) {
        close_log();
        remove_log();
        open_log();
    }
}
Example #18
0
int main(int argc, const char *argv[])
{
   enum Mode mode = ALL;
   int i;

   if (argc > 1) {
      i = strtol(argv[1], NULL, 10);
      switch (i) {
         case 0:
            mode = PLAIN_BLIT;
            break;
         case 1:
            mode = SCALED_BLIT;
            break;
         case 2:
            mode = ROTATE_BLIT;
            break;
      }
   }

   if (!al_init()) {
      abort_example("Could not init Allegro\n");
   }

   open_log();

   al_init_image_addon();
   al_init_primitives_addon();

   display = al_create_display(640, 480);
   if (!display) {
      abort_example("Error creating display\n");
   }
   
   if (mode == ALL) {
      for (mode = PLAIN_BLIT; mode <= ROTATE_BLIT; mode++) {
         do_test(mode);
      }
   }
   else {
      do_test(mode);
   }

   al_destroy_display(display);

   close_log(true);

   return 0;
}
Example #19
0
int read_config_file(char *config_filename)
{
	FILE *fd;
	char *p;
	char textline[LINEBUFFER];
	int ret;

	if ((fd = fopen(config_filename, "r")) == NULL)
		return 1;

	while (fgets(textline, LINEBUFFER - 1, fd) != NULL) {
		/* We ignore blank lines and comments */
		if (textline[0] == '\n' || textline[0] == '#')
			continue;	

		p = strtok(textline, " \t\n");

		if (strncasecmp("server", p, 4) == 0) {
			int ret;
			p = strtok(NULL, " \t\n");
			ret = set_server(p);
			if (ret) {
				/* error */
				fflush(stderr);
				fflush(stdout);
				fprintf(stderr, "Server IP unknown.\n");
				exit(1);
			}
		} else if (strncasecmp("logfile", p, 7) == 0) {
			p = strtok(NULL, " \t\n");
			open_log(p);
		} else if (strncasecmp("background", p, 10) == 0) {
			p = strtok(NULL, " \t\n");
			set_background(p);
		} else if (strncasecmp("logo", p, 4) == 0) {
			p = strtok(NULL, " \t\n");
			set_logo(p);
		} else if (strncasecmp("foreground", p, 10) == 0) {
			p = strtok(NULL, " \t\n");
			set_foreground(p);
		} else if (strncasecmp("port", p, 4) == 0) {
			p = strtok(NULL, " \t\n");
			set_listen_port(p);
		}
	}
	ret = fclose(fd);
	return ret;

}
Example #20
0
void gmrt2fb(FILE *input, FILE *output) /* includefile*/
{
  double mean,sum,num;
  short junk,result[256];
  unsigned short ur[256];
  int c,r,opened;
  char string[80];
  unsigned char uc[256];
  r=opened=0;
  c=256;
  sum=num=0.0;
  while (!ferror(input)) {
    if ( (fread(&junk,2,1,input)) != 1) return;
    result[c--]= -1*((~junk) & 32767);
    if (c==0) {
      r++;
      if (r>10) {
	for (c=1;c<=256;c++) {
	  ur[c-1]=result[c];
	  uc[c-1]=128+((double)result[c]-mean);
	}
	ur[0]=ur[1]=ur[254]=ur[255]=uc[0]=uc[1]=uc[254]=uc[255]=0;
	if (obits==16) 
	  fwrite(ur,sizeof(short),256,output);
	if (obits==8)
	  fwrite(uc,sizeof(char),256,output);
      } else {
	/* for some reason, the first 10 samples were not
           used in the f77 code, so repeat that here but
           use these samples to calculate a mean */
	for (c=1;c<=256;c++) {
	  sum+=result[c];
	  num+=1.0;
	}
	mean=sum/num;
      }
      if (r%1024 == 0) {
	if (!opened) {
	  open_log("filterbank.monitor");
	  opened=1;
	}
	sprintf(string,"time:%.1fs",r*tsamp);
	update_log(string);
      }
      c=256;
    }
  }
}
Example #21
0
int main(int argc, char **argv)
{
   ALLEGRO_BITMAP *bitmap;
   double t0;
   double t1;

   if (!al_init()) {
      abort_example("Could not init Allegro.\n");
   }

   open_log();

   if (argc < 3) {
      log_printf("This example needs to be run from the command line.\n");
      log_printf("Usage: %s <infile> <outfile>\n", argv[0]);
      log_printf("\tPossible file types: BMP PCX PNG TGA\n");
      goto done;
   }

   al_init_image_addon();

   al_set_new_bitmap_format(ALLEGRO_PIXEL_FORMAT_ARGB_8888);
   al_set_new_bitmap_flags(ALLEGRO_MEMORY_BITMAP
      | ALLEGRO_NO_PREMULTIPLIED_ALPHA);

   bitmap = al_load_bitmap(argv[1]);
   if (!bitmap) {
      log_printf("Error loading input file\n");
      goto done;
   }

   t0 = al_get_time();
   if (!al_save_bitmap(argv[2], bitmap)) {
      log_printf("Error saving bitmap\n");
      goto done;
   }
   t1 = al_get_time();
   log_printf("Saving took %.4f seconds\n", t1 - t0);

   al_destroy_bitmap(bitmap);

done:
   close_log(true);

   return 0;
}
Example #22
0
/**
 * Initialize the log system and 'log' function
 * @return TRUE if the log system was successfully initialized
 */
int log_init() {

  if (!Run.dolog) {
    return TRUE;
  }

  if (!open_log()) {
    return FALSE;
  }

  /* Register log_close to be
  called at program termination */
    atexit(log_close);

  return TRUE;

}
Example #23
0
int
execl(const char *path, const char *arg, ...)
{
	size_t argv_max = INITIAL_ARGV_MAX;
	const char *initial_argv[INITIAL_ARGV_MAX];
	const char **argv = initial_argv;
	va_list args;
	FILE *logfp;
	
	logfp = open_log();
	LOG(logfp, "\n*** miq_execl ***\n");
	
	argv[0] = arg;
	
	va_start(args, arg);
	unsigned int i = 0;
	while (argv[i++] != NULL)	{
	    if (i == argv_max)	{
	        argv_max *= 2;
	        const char **nptr = realloc(argv == initial_argv ? NULL : argv,
	                                     argv_max * sizeof (const char *));
	        if (nptr == NULL)	{
	            if (argv != initial_argv)	{
	            	free (argv);
				}
	            return -1;
	        }
	        if (argv == initial_argv)	{
	        	memcpy(nptr, argv, i * sizeof (const char *));
			}
	
	        argv = nptr;
	    }
	
	    argv[i] = va_arg(args, const char *);
	}
	va_end (args);
	
	int ret = execve(path, (char *const *) argv, __environ);
	if (argv != initial_argv)	{
		free (argv);
	}
	
	return ret;
}
Example #24
0
void log_error(int code, char *string, char *url, struct proxy_t *proxy) {

  time_t rawtime;
  time ( &rawtime );

  // Cannot be freed.
  char *timestr = ctime (&rawtime);
  timestr[24] = 0;

  open_log();

  if (proxy == NULL) 
    fprintf(cfg.logfd, "%s [%d %s] via DIRECT CONNECTION\n%s\n", timestr, code, string, url);
  else
    fprintf(cfg.logfd, "%s [%d %s] via %s(%s:%d)\n%s\n", timestr, code, string, proxy->name, proxy->host, proxy->port, url);

  close_log();
}
Example #25
0
int main(void)
{
    svr_cfg dbcfg;
    strcpy(dbcfg.host,"127.0.0.1");
    strcpy(dbcfg.user,"root");
    strcpy(dbcfg.password,"123456");
    strcpy(dbcfg.db,"user");
    dbcfg.port = DB_DEFAULT_PORT;
    dbcfg.nmin = DB_DEFAULT_NMIN;
    dbcfg.nkeep = DB_DEFAULT_NKEEP;
    dbcfg.nmax = DB_DEFAULT_NMAX;
    dbcfg.exptime = DB_DEFAULT_EXPTIME;
    dbcfg.timeout = DB_DEFAULT_TIMEOUT;
    strcpy(dbcfg.charset,DB_DEFAULT_CHARSET);

    open_log("|/usr/bin/cronolog logs/%Y-%m-%d.%H.log");
    int rv = mysql_pool_init(&dbcfg);

    char *sql = "select uid,uname from game_user where uid = 1";
    MYSQL_RES *rs = NULL;                                                                 
    int ret = mysql_pool_query(&dbcfg,sql,strlen(sql),&rs); 
    if(ret < 0)                                                                           
    {                                                                                     
	return -1;
    }                                                                                     
    int rows = mysql_num_rows(rs); 
    if(rows > 0)                                                                          
    {                                                                                     
	MYSQL_ROW row = mysql_fetch_row(rs);
        log_error(LOG_MARK,"uname:%s\n",row[1]);
	mysql_free_result(rs);
	return 0;
    }
    else
    {
	mysql_free_result(rs);
	return 0;
    }

    mysql_pool_fini(&dbcfg);
    log_close();
    return 0;
}
Example #26
0
int main(int argc, char **argv)
{
   int pass;

   (void)argc;
   (void)argv;

   /* defaults to blank */
   al_set_org_name("liballeg.org");

   /* defaults to the exename, set it here to remove the .exe on windows */
   al_set_app_name("ex_get_path");
   
   if (!al_init()) {
      abort_example("Could not init Allegro.\n");
   }
   open_log();

   for (pass = 1; pass <= 3; pass++) {
      if (pass == 1) {
         log_printf("With default exe name:\n");
      }
      else if (pass == 2) {
         log_printf("\nOverriding exe name to blahblah\n");
         al_set_exe_name("blahblah");
      }
      else if (pass == 3) {
         log_printf("\nOverriding exe name to /tmp/blahblah.exe:\n");
         al_set_exe_name("/tmp/blahblah.exe");
      }

      show_path(ALLEGRO_RESOURCES_PATH, "RESOURCES_PATH");
      show_path(ALLEGRO_TEMP_PATH, "TEMP_PATH");
      show_path(ALLEGRO_USER_DATA_PATH, "USER_DATA_PATH");
      show_path(ALLEGRO_USER_SETTINGS_PATH, "USER_SETTINGS_PATH");
      show_path(ALLEGRO_USER_HOME_PATH, "USER_HOME_PATH");
      show_path(ALLEGRO_USER_DOCUMENTS_PATH, "USER_DOCUMENTS_PATH");
      show_path(ALLEGRO_EXENAME_PATH, "EXENAME_PATH");
   }

   close_log(true);
   return 0;
}
Example #27
0
int
log_time(FILE *log)
{
	if (!log) {
		int rc = open_log();
		if (rc < 0)
			return rc;
	}

	time_t t = time(NULL);
	char timestr[27];

	ctime_r(&t, timestr);
	timestr[26] = '\0';
	for (int i = 26; i >= 0; i--)
		if (timestr[i] == '\n')
			timestr[i] = '\0';

	return log_message(log, "DBG: %d: %s: ", getpid(), timestr);
}
Example #28
0
File: hlog.c Project: hessu/aprsc
int close_log(int reopen)
{
    hlog(LOG_DEBUG, "close_log");

    char *s = NULL;
    if (log_name)
        s = hstrdup(log_name);

    rwl_wrlock(&log_file_lock);

    if (log_name) {
        hfree(log_name);
        log_name = NULL;
    }

    if (log_dest == L_SYSLOG) {
        closelog();
    } else if (log_dest == L_FILE) {
        if (log_file >= 0) {
            if (close(log_file))
                fprintf(stderr, "aprsc logger: Could not close log file %s: %s\n", log_fname, strerror(errno));
            log_file = -1;
        }
        if (log_fname) {
            hfree(log_fname);
            log_fname = NULL;
        }
    }

    if (reopen && s)
        open_log(s, 1);

    if (!reopen)
        rwl_wrunlock(&log_file_lock);

    if (s)
        hfree(s);

    return 0;
}
Example #29
0
static int hotplug(void) {

	int ret;
	char *action;


	ret = open_log();
	if( ret < 0 ) {
		logwarn("could not open logfile");
	}
	logmsg(" ------------ hotplug() called ---------------" );


	ret = check_environment_sane();
	if( ret ) {
		logerr("environment is not sane");
		return -1;
	}

	action = getenv("ACTION");
	if( action == NULL ) { /* after check_environment that cannot happen */
		logerr("ACTION is not set.");
		return -1;
	}

	if( ! strncmp(action, "add", 3 )) {
		hotplug_add_device();
	}
	else if( ! strncmp(action, "remove", 6)) {
		hotplug_remove_device();
	}
	else {
		logerr("illegal ACTION value: %s", action);
		return -1;
	}
	
	close_log();

	return 0;
}
Example #30
0
int main(int argc, const char *argv[])
{
   const char *url;
   ALLEGRO_DISPLAY *display;
   ALLEGRO_BITMAP *bmp;

   if (argc > 1)
      url = argv[1];
   else
      url = "http://liballeg.org/images/logo.png";

   if (!al_init()) {
      abort_example("Could not init Allegro.\n");
   }

   open_log();

   al_init_image_addon();
   al_install_keyboard();

   display = al_create_display(640, 480);
   if (!display) {
      abort_example("Unable to create display.\n");
   }

   curl_global_init(CURL_GLOBAL_ALL);
   al_set_new_file_interface(&curl_file_vtable);

   bmp = al_load_bitmap(url);
   if (bmp) {
      show_image(bmp);
      al_destroy_bitmap(bmp);
   }

   curl_global_cleanup();

   close_log(true);

   return 0;
}