Changeset 2045:372a02360fff in roaraudio


Ignore:
Timestamp:
06/22/09 19:55:41 (15 years ago)
Author:
phi
Branch:
default
Phase:
public
Message:

added dstr support to roarmon

File:
1 edited

Legend:

Unmodified
Added
Removed
  • roarclients/roarmon.c

    r1897 r2045  
    22 
    33/* 
    4  *      Copyright (C) Philipp 'ph3-der-loewe' Schafft - 2008 
     4 *      Copyright (C) Philipp 'ph3-der-loewe' Schafft - 2008, 2009 
    55 * 
    66 *  This file is part of roarclients a part of RoarAudio, 
     
    5656 char * server   = NULL; 
    5757 char * k; 
    58  int    fh; 
    5958 int    i; 
    60  int    out = -1; 
    61  char buf[BUFSIZE]; 
    62  struct roar_connection con; 
    63  struct roar_stream     s; 
     59 struct roar_connection    con; 
     60 struct roar_stream        s; 
     61 struct roar_vio_calls     file, stream; 
     62 struct roar_vio_defaults  def; 
     63 int file_opened = 0; 
     64 
     65 if ( roar_vio_open_fh(&file, ROAR_STDOUT) == -1 ) 
     66  return 1; 
     67 
     68 if ( roar_vio_dstr_init_defaults(&def, ROAR_VIO_DEF_TYPE_NONE, O_CREAT|O_TRUNC|O_WRONLY, 0644) == -1 ) 
     69  return 1; 
    6470 
    6571 for (i = 1; i < argc; i++) { 
     
    104110   usage(); 
    105111   return 0; 
    106   } else if ( out == -1 ) { 
    107    if ( (out = open(k, O_CREAT|O_TRUNC|O_WRONLY, 0644)) == -1 ) { 
     112  } else if ( !file_opened ) { 
     113   file_opened = 1; 
     114   if ( roar_vio_open_dstr(&file, k, &def, 1) == -1 ) { 
    108115    fprintf(stderr, "Error: can not open file: %s: %s\n", k, strerror(errno)); 
    109116    return 1; 
     
    115122  } 
    116123 } 
    117  
    118  if ( out == -1 ) 
    119   out = ROAR_STDOUT; 
    120124 
    121125 if ( roar_simple_connect(&con, server, "roarmon") == -1 ) { 
     
    150154 } 
    151155 
    152  if ( (fh = roar_get_connection_fh(&con)) == -1 ) { 
    153   fprintf(stderr, "Error: can not get stream fh\n"); 
     156 if ( roar_get_connection_vio(&con, &stream) == -1 ) { 
     157  fprintf(stderr, "Error: can not get stream vio\n"); 
    154158  roar_disconnect(&con); 
    155159  return 13; 
    156160 } 
    157161 
    158  ROAR_SHUTDOWN(fh, SHUT_WR); 
     162// TODO: FIXME: 
     163// ROAR_SHUTDOWN(fh, SHUT_WR); // we need to have something do do shutdowns here... 
    159164 
    160  while((i = read(fh, buf, BUFSIZE))) 
    161   if (write(out, buf, i) != i) 
    162    break; 
     165 roar_vio_copy_data(&file, &stream); 
    163166 
    164  roar_simple_close(fh); 
     167 roar_vio_close(&stream); 
     168 roar_vio_close(&file); 
    165169 
    166170 return 0; 
Note: See TracChangeset for help on using the changeset viewer.