void *network_init(const char *ifname) { Interface *p = malloc(sizeof(Interface)); if(!p) err(errno, "iface malloc"); p->name = ifname; p->rx = smprintf("/sys/class/net/%s/statistics/rx_bytes", ifname); p->tx = smprintf("/sys/class/net/%s/statistics/tx_bytes", ifname); FILE *f; if(!(f = fopen(p->rx, "r"))) { network_deinit(p); err(errno, "%s", ifname); } fscanf(f,"%ld", &p->rx_bytes); fclose(f); p->rx_old = p->rx_bytes; if(!(f = fopen(p->tx, "r"))) { network_deinit(p); err(errno, "%s", ifname); } fscanf(f,"%ld", &p->tx_bytes); fclose(f); p->tx_old = p->tx_bytes; return p; }
GSM_Error DUMMY_SendSMS(GSM_StateMachine *s, GSM_SMSMessage *sms) { unsigned char buffer[1000] = {'\0'}; int length = 0; GSM_Error error; if (sms->PDU == SMS_Deliver) { smprintf(s, "SMS Deliver\n"); error = PHONE_EncodeSMSFrame(s, sms, buffer, PHONE_SMSDeliver, &length, TRUE); if (error != ERR_NONE) { return error; } } else { smprintf(s, "SMS Submit\n"); error = PHONE_EncodeSMSFrame(s, sms, buffer, PHONE_SMSSubmit, &length, TRUE); if (error != ERR_NONE) { return error; } } s->User.SendSMSStatus(s, 0, 0xff, s->User.SendSMSStatusUserData); return ERR_NONE; }
static GSM_Error DCT4_ReplyTuneRadio(GSM_Protocol_Message *msg, GSM_StateMachine *sm) { int length; unsigned char name[100]; switch (msg->Buffer[3]) { case 0x09: N6510_DecodeFMFrequency(&RadioFreq, msg->Buffer+16); length = msg->Buffer[8]; memcpy(name,msg->Buffer+18,length*2); name[length*2] = 0x00; name[length*2+1] = 0x00; CopyUnicodeString(RadioName,name); smprintf(sm,"Station name: \"%s\"\n",DecodeUnicodeString(RadioName)); return ERR_NONE; case 0x15: case 0x16: smprintf(sm,"Response for enabling radio/headset status received\n"); if (msg->Buffer[5] == 0) { smprintf(sm,"Connected\n"); return ERR_NONE; } smprintf(sm,"Probably not connected\n"); return ERR_PERMISSION; } return ERR_UNKNOWNRESPONSE; }
char *get_nmail(char *directory, char *label) { /* directory : Maildir path * return label : number_of_new_mails */ int n = 0; DIR* dir = NULL; struct dirent* rf = NULL; dir = opendir(directory); /* try to open directory */ if (dir == NULL) perror(""); while ((rf = readdir(dir)) != NULL) /*count number of file*/ { if (strcmp(rf->d_name, ".") != 0 && strcmp(rf->d_name, "..") != 0) n++; } closedir(dir); if (n == 0) return smprintf(""); else return smprintf("%s%d",label, n); }
ssize_t GSM_USB_Write(GSM_StateMachine *s, const void *buf, size_t nbytes) { GSM_Device_USBData *d = &s->Device.Data.USB; int rc = LIBUSB_ERROR_TIMEOUT, ret = 0, repeat = 0; while (repeat < 10 && (rc == LIBUSB_ERROR_TIMEOUT || rc == LIBUSB_ERROR_INTERRUPTED || rc == LIBUSB_ERROR_OTHER || rc == LIBUSB_ERROR_NO_MEM)) { rc = libusb_bulk_transfer(d->handle, d->ep_write, (void *)buf, nbytes, &ret, 1000); /* This seems to be some strange failure on partial data transfer */ if (rc == LIBUSB_ERROR_OTHER && ret != 0) { smprintf(s, "Other error while writing, but got some data\n"); rc = 0; break; } if (rc == LIBUSB_ERROR_TIMEOUT && ret != 0) { smprintf(s, "Timeout while write, but some data were written\n"); rc = 0; break; } if (rc != 0) { smprintf(s, "Failed to write to usb (%d)!\n", rc); GSM_USB_Error(s, rc); } repeat++; usleep(1000); } if (rc != 0) { return -1; } return ret; }
char * getbattery(void){ long lnum1, lnum2 = 0; char *status = malloc(sizeof(char)*12); char s = '?'; FILE *fp = NULL; if ((fp = fopen(BATT_NOW, "r"))) { fscanf(fp, "%ld\n", &lnum1); fclose(fp); fp = fopen(BATT_FULL, "r"); fscanf(fp, "%ld\n", &lnum2); fclose(fp); fp = fopen(BATT_STATUS, "r"); fscanf(fp, "%s\n", status); fclose(fp); if (strcmp(status,"Charging") == 0) s = '+'; if (strcmp(status,"Discharging") == 0) s = '-'; if (strcmp(status,"Full") == 0) s = '='; return smprintf("%c%ld%%", s,(lnum1/(lnum2/100))); } else return smprintf(""); }
GSM_Error GSM_USB_Terminate(GSM_StateMachine *s) { GSM_Device_USBData *d = &s->Device.Data.USB; int rc; if (d->handle != NULL) { rc = libusb_set_interface_alt_setting(d->handle, d->data_iface, d->data_idlesetting); if (rc != 0) { smprintf(s, "Failed to set idle settings\n"); return GSM_USB_Error(s, rc); } rc = libusb_release_interface(d->handle, d->control_iface); if (rc != 0) { smprintf(s, "Failed to release control interface\n"); return GSM_USB_Error(s, rc); } rc = libusb_release_interface(d->handle, d->data_iface); if (rc != 0) { smprintf(s, "Failed to release data interface\n"); return GSM_USB_Error(s, rc); } libusb_close(d->handle); } libusb_exit(d->context); d->handle = NULL; d->context = NULL; return ERR_NONE; }
char* getvolume() { int sound_on; double normalized_volume; int err; snd_mixer_t *handle; snd_mixer_selem_id_t *sid; snd_mixer_open(&handle, 0); snd_mixer_attach(handle, soundcard); snd_mixer_selem_register(handle, NULL, NULL); snd_mixer_load(handle); snd_mixer_selem_id_alloca(&sid); snd_mixer_selem_id_set_index(sid, 0); snd_mixer_selem_id_set_name(sid, soundelement); snd_mixer_elem_t* elem = snd_mixer_find_selem(handle, sid); err = snd_mixer_selem_get_playback_switch(elem, channel, &sound_on); if (err < 0 || !sound_on) { snd_mixer_close(handle); /* return smprintf("\x9D "); */ return smprintf("Muted \x19 "); } normalized_volume = getnormvolume(elem); snd_mixer_close(handle); /* return smprintf("%.0f\x90 ", normalized_volume * 100); */ return smprintf("Vol %.0f%% \x19 ", normalized_volume * 100); }
char * cpu_usage(void) { FILE *f; int i = 0, stats[10], delta[10]; f = fopen("/proc/stat", "r"); if(f == NULL) return smprintf("ERROR"); /* Get current stats*/ fscanf(f, "%*s"); for(i = 0; i < 10; ++i) { char str[10]; fscanf(f, "%s", str); stats[i] = atoi(str); /* Compare it with old_stats to create delta */ delta[i] = stats[i] - old_stats[i]; /* Create new old_stats */ old_stats[i] = stats[i]; } int total_used = delta[0] + delta[1] + delta[2] + delta[4] + delta[5] + delta[6] + delta[7] + delta[8] + delta[9]; int total = total_used + delta[3]; fclose(f); return smprintf("%2.0f%%", (float)total_used*100/total); }
int stm_reg_rp_alarm_handler(const tstring *rp_name) { int err = 0; char * alarm_name = NULL; /* * We cant avoid the memory leak for alarm_name here * the memory allocated here is used up in the registeration as it is. * This leak will becaused everytime the resource pool is added/deleted. */ lc_log_basic(LOG_DEBUG, "rp-name - %s", ts_str(rp_name)); alarm_name = smprintf("rp_%s_client_sessions", ts_str(rp_name)); bail_null(alarm_name); err = st_register_alarm_handler(alarm_name, stm_nkn_alarms_rp_callback, NULL); bail_error(err); alarm_name = smprintf("rp_%s_max_bandwidth", ts_str(rp_name)); bail_null(alarm_name); err = st_register_alarm_handler(alarm_name, stm_nkn_alarms_rp_callback,NULL); bail_error(err); bail: return err; }
/* Find the directory in which FontForge places all of its configurations and * save files. On Unix-likes, the argument `dir` (see the below case switch, * enum in inc/gfile.h) determines which directory is returned according to the * XDG Base Directory Specification. On Windows, the argument is ignored--the * home directory as obtained by getUserHomeDir() appended with "/FontForge" is * returned. On error, NULL is returned. * * http://standards.freedesktop.org/basedir-spec/basedir-spec-latest.html */ char *getFontForgeUserDir(int dir) { const char *def; const char *home, *xdg; char *buf = NULL; /* find home directory first, it is needed if any of the xdg env vars are * not set */ if (!(home = getUserHomeDir())) { /* if getUserHomeDir returns NULL, pass NULL to calling function */ fprintf(stderr, "%s\n", "cannot find home directory"); return NULL; } #if defined(__MINGW32__) /* Allow for preferences to be saved locally in a 'portable' configuration. */ if (getenv("FF_PORTABLE") != NULL) { buf = smprintf("%s/preferences/", getShareDir()); } else { buf = smprintf("%s/FontForge/", home); } return buf; #else /* Home directory exists, so check for environment variables. For each of * XDG_{CACHE,CONFIG,DATA}_HOME, assign `def` as the corresponding fallback * for if the environment variable does not exist. */ switch(dir) { case Cache: xdg = getenv("XDG_CACHE_HOME"); def = ".cache"; break; case Config: xdg = getenv("XDG_CONFIG_HOME"); def = ".config"; break; case Data: xdg = getenv("XDG_DATA_HOME"); def = ".local/share"; break; default: /* for an invalid argument, return NULL */ fprintf(stderr, "%s\n", "invalid input"); return NULL; } if(xdg != NULL) /* if, for example, XDG_CACHE_HOME exists, assign the value * "$XDG_CACHE_HOME/fontforge" */ buf = smprintf("%s/fontforge", xdg); else /* if, for example, XDG_CACHE_HOME does not exist, instead assign * the value "$HOME/.cache/fontforge" */ buf = smprintf("%s/%s/fontforge", home, def); if(buf != NULL) { /* try to create buf. If creating the directory fails, return NULL * because nothing will get saved into an inaccessible directory. */ if(mkdir_p(buf, 0755) != EXIT_SUCCESS) return NULL; return buf; } return NULL; #endif }
int main(void) { char tmnyc[128]; char avgs[128]; char *status; int warn = 0; if (!(dpy = XOpenDisplay(NULL))) { fprintf(stderr, "dwmstatus: cannot open display.\n"); return 1; } for (;;sleep(2)) { loadavg(avgs, 128); warn = mktimes(tmnyc, 128, "%a, %B %d, %R", tznyc); if (warn) { status = smprintf("[L: %s | \x04%s\x01]", avgs, tmnyc); } else { status = smprintf("[L: %s | %s]", avgs, tmnyc); } setstatus(status); free(status); } XCloseDisplay(dpy); return 0; }
/** * \author Peter Ondraska, based on code by Marcin Wiacek and Michal Cihar * * License: Whatever the current maintainer of gammulib chooses, as long as there * is an easy way to obtain the source under GPL, otherwise the author's parts * of this function are GPL 2.0. */ GSM_Error ATOBEX_SetLocale(GSM_StateMachine *s, GSM_Locale *locale) { /* this is not yet supported by gammu.c */ int format=0; char req[12]; GSM_Error error; if ((error = ATOBEX_SetATMode(s))!= ERR_NONE) return error; if (locale->DateFormat==GSM_Date_OFF) { format=0; } else if ((locale->DateFormat==GSM_Date_DDMMMYY)&&(locale->DateSeparator=='-')) { format=1; } else if ((locale->DateFormat==GSM_Date_DDMMYY)&&(locale->DateSeparator=='-')) { format=2; } else if ((locale->DateFormat==GSM_Date_MMDDYY)&&(locale->DateSeparator=='/')) { format=3; } else if ((locale->DateFormat==GSM_Date_DDMMYY)&&(locale->DateSeparator=='/')) { format=4; } else if ((locale->DateFormat==GSM_Date_DDMMYY)&&(locale->DateSeparator=='.')) { format=5; } else if ((locale->DateFormat==GSM_Date_YYMMDD)&&(locale->DateSeparator==0)) { format=6; } else if ((locale->DateFormat==GSM_Date_YYMMDD)&&(locale->DateSeparator=='-')) { format=7; } else { return ERR_NOTSUPPORTED; } /* ERR_WRONGINPUT */ sprintf(req,"AT*ESDF=%i\r",format); smprintf(s, "Setting date format\n"); error = GSM_WaitFor (s, req, strlen(req), 0x00, 3, ID_SetLocale); if (error!=ERR_NONE) return error; if (locale->AMPMTime) { format=2; } else { format=1; } sprintf(req,"AT*ESTF=%i\r",format); smprintf(s, "Setting time format\n"); return GSM_WaitFor (s, req, strlen(req), 0x00, 3, ID_SetLocale); }
char * getpavolume(void) { uint8_t ctr; char * result; pa_devicelist_t pa_output_devicelist[16]; result = smprintf("vol: "); if (pa_get_devicelist(pa_output_devicelist) < 0) { return smprintf("ERR"); } for (ctr = 0; ctr < 16; ctr++) { if (! pa_output_devicelist[ctr].initialized) { continue; } if ( pa_output_devicelist[ctr].mute ) { char * tmp_res = result ; result = smprintf("%s mute", tmp_res) ; free(tmp_res); } else { char * tmp_res = result; result = smprintf("%s %d%%", tmp_res, (pa_cvolume_avg(&pa_output_devicelist[ctr].volume)*100)/PA_VOLUME_NORM); free(tmp_res); } } return result; }
static GSM_Error DCT4_ReplyVibra(GSM_Protocol_Message *msg, GSM_StateMachine *sm) { #ifdef DEBUG switch (msg->Buffer[3]) { case 0x0D : smprintf(sm, "Vibra state set OK\n"); break; case 0x0F : smprintf(sm, "Vibra power set OK\n"); break; } #endif return ERR_NONE; }
static GSM_Error N3320_ReplyGetDateTime(GSM_Protocol_Message *msg, GSM_StateMachine *s) { smprintf(s, "Date & time received\n"); if (msg->Buffer[4]==0x01) { NOKIA_DecodeDateTime(s, msg->Buffer+10, s->Phone.Data.DateTime, TRUE, FALSE); return ERR_NONE; } smprintf(s, "Not set in phone\n"); return ERR_EMPTY; }
char * gettemperature(char *sensor) { char *co; co = readfile(sensor); if (co == NULL) return smprintf(""); return smprintf("%02.0f°C", atof(co) / 1000); }
char * cal_bytes(double b) { if (b > GIGA) return smprintf("%.1fG", b / GIGA); else if (b > MEGA) return smprintf("%.1fM", b / MEGA); else if (b > KILO) return smprintf("%.1fk", b / KILO); else return smprintf("%.0f", b); }
void GSM_OSErrorInfo(GSM_StateMachine *s, const char *description) { #ifdef WIN32 int i=0; unsigned char *lpMsgBuf = NULL; #endif GSM_Debug_Info *curdi; curdi = GSM_GetDI(s); #ifdef WIN32 /* We don't use errno in win32 - GetLastError gives better info */ if (GetLastError() != 0) { if (curdi->dl == DL_TEXTERROR || curdi->dl == DL_TEXT || curdi->dl == DL_TEXTALL || curdi->dl == DL_TEXTERRORDATE || curdi->dl == DL_TEXTDATE || curdi->dl == DL_TEXTALLDATE) { FormatMessage( FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, NULL, GetLastError(), MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), /* Default language */ (LPTSTR) &lpMsgBuf, 0, NULL ); for (i=0;i<(int)strlen(lpMsgBuf);i++) { if (lpMsgBuf[i] == 13 || lpMsgBuf[i] == 10) { lpMsgBuf[i] = ' '; } } smprintf(s,"[System error - %s, %i, \"%s\"]\n", description, (int)GetLastError(), (LPCTSTR)lpMsgBuf); LocalFree(lpMsgBuf); } } #else if (errno!=-1) { if (curdi->dl == DL_TEXTERROR || curdi->dl == DL_TEXT || curdi->dl == DL_TEXTALL || curdi->dl == DL_TEXTERRORDATE || curdi->dl == DL_TEXTDATE || curdi->dl == DL_TEXTALLDATE) { smprintf(s,"[System error - %s, %i, \"%s\"]\n",description,errno,strerror(errno)); } } #endif }
char * get_mpd(void) { struct mpd_connection *con; struct mpd_status *status; struct mpd_song *song; int status_type; char *res; const char *artist = NULL, *title = NULL; con = mpd_connection_new(NULL, 0, 30000); if(mpd_connection_get_error(con)) { mpd_connection_free(con); return NO_MPD; } mpd_command_list_begin(con, true); mpd_send_status(con); mpd_send_current_song(con); mpd_command_list_end(con); status = mpd_recv_status(con); if(!status) { mpd_connection_free(con); return NO_MPD; } mpd_response_next(con); song = mpd_recv_song(con); title = mpd_song_get_tag(song, MPD_TAG_TITLE, 0); if(!title) title = mpd_song_get_uri(song); artist = mpd_song_get_tag(song, MPD_TAG_ARTIST, 0); status_type = mpd_status_get_state(status); switch(status_type) { case(MPD_STATE_PLAY): res = smprintf(MPD, "Playing", artist, title); break; case(MPD_STATE_PAUSE): res = smprintf(MPD, "Paused", artist, title); break; case(MPD_STATE_STOP): res = smprintf(MPD, "Stopped", artist, title); break; default: res = NO_MPD; break; } mpd_song_free(song); mpd_response_finish(con); mpd_status_free(status); mpd_connection_free(con); return res; }
int md_uf_update_param(const char *uf_name, uf_param_type type, const char *value) { int err = 0; uf_context_data_t *context = NULL; bail_null(uf_name); bail_null(value); err = md_uf_find_context(uf_name, &context); bail_error(err); bail_null(context); switch(type) { case eFileURL: if (value && strcmp(value, "")) { safe_free(context->url); context->url = smprintf("%s", value); context->valid = 1; } else { context->url = NULL; context->valid = 0; } break; case eCryptoKey: /* if value is non-empty */ if (value && strcmp(value, "")) { safe_free(context->crypto_key); context->crypto_key = smprintf("%s", value); } else { context->crypto_key = NULL; } break; case eRefreshInterval: context->refresh_interval = strtoul(value, NULL, 10); /* milli seconds in 1 hr: 60*60*1000 */ context->poll_frequency = context->refresh_interval * 60 *60 * 1000; break; case eFormatType: safe_free(context->type); context->type = smprintf("%s", value); break; default: err = 1; goto bail; break; } context->cfg_updated++; bail: return err; }
static void GSM_RegisterModule(GSM_StateMachine *s,GSM_Phone_Functions *phone) { /* Auto model */ if (s->CurrentConfig->Model[0] == 0) { if (strstr(phone->models,GetModelData(s, NULL, s->Phone.Data.Model, NULL)->model) != NULL) { smprintf(s,"[Module - \"%s\"]\n",phone->models); s->Phone.Functions = phone; } } else { if (strstr(phone->models,s->CurrentConfig->Model) != NULL) { smprintf(s,"[Module - \"%s\"]\n",phone->models); s->Phone.Functions = phone; } } }
int cli_nvsd_rtstream_media_show_one(const bn_binding_array *bindings, uint32 idx, const bn_binding *binding, const tstring *name, const tstr_array *name_components, const tstring *name_last_part, const tstring *value, void *callback_data) { int err = 0; char *c_ext = NULL; char *c_lib = NULL; tstring *t_ext = NULL; tstring *t_lib = NULL; UNUSED_ARGUMENT(binding); UNUSED_ARGUMENT(name_components); UNUSED_ARGUMENT(name_last_part); UNUSED_ARGUMENT(value); UNUSED_ARGUMENT(callback_data); c_ext = smprintf("%s/extension", ts_str(name)); bail_null(c_ext); c_lib = smprintf("%s/module", ts_str(name)); bail_null(c_lib); err = bn_binding_array_get_value_tstr_by_name(bindings, c_ext, NULL, &t_ext); bail_error(err); err = bn_binding_array_get_value_tstr_by_name(bindings, c_lib, NULL, &t_lib); bail_error(err); if (idx == 0) { cli_printf(_( " S.No. Extension Module\n")); cli_printf(_( "---------------------------------\n")); } cli_printf(_( " %3d. %5s %-10s\n"), idx+1, ts_str(t_ext), ts_str(t_lib)); bail: safe_free(c_ext); safe_free(c_lib); ts_free(&t_ext); ts_free(&t_lib); return err; }
int main(void) { char *status; char *batt; char *tmmtl; char *tmgva; if (!(dpy = XOpenDisplay(NULL))) { fprintf(stderr, "dwmstatus: cannot open display.\n"); return 1; } for (;;sleep(1)) { batt = battery(); tmmtl = mktimes(tmfmt, tzmtl); tmgva = mktimes(tmfmt, tzgva); status = smprintf("%s | mtl: %s gva: %s", batt,tmmtl,tmgva); setstatus(status); free(batt); free(tmmtl); free(status); } XCloseDisplay(dpy); return 0; }
static GSM_Error DCT4_ReplyTestsStatus(GSM_Protocol_Message *msg, GSM_StateMachine *sm) { int i,pos,j; pos = 6; smprintf(sm,"%i status entries for phone tests received\n",msg->Buffer[5]); for (i=0;i<msg->Buffer[5];i++) { for (j=0;j<DCT4Tests.Num;j++) { if (DCT4Tests.Tests[j].ID == msg->Buffer[pos+2]) { printf("\"%40s\" : ",DCT4Tests.Tests[j].Name); switch(msg->Buffer[pos+3]) { case 0x00: printf("%s", _("Passed")); break; case 0x01: printf("%s", _("Fail")); break; case 0x03: printf("%s", _("Not executed")); break; case 0x06: printf("%s", _("No signal")); break; case 0x0D: printf("%s", _("Timeout")); break; default : printf(_("Unknown (%x)"),msg->Buffer[pos+3]); } if (DCT4Tests.Tests[j].Startup) printf("%s", _(" (startup)")); printf("\n"); break; } } pos+=msg->Buffer[pos+1]; } return ERR_NONE; }
static char * get_fan() { char *fan_speed; fan_speed = get_str(FAN_F); return smprintf("%sRpm", fan_speed); }
/** * \author Peter Ondraska, based on code by Marcin Wiacek and Michal Cihar * * License: Whatever the current maintainer of gammulib chooses, as long as there * is an easy way to obtain the source under GPL, otherwise the author's parts * of this function are GPL 2.0. */ GSM_Error ATOBEX_GetLocale(GSM_StateMachine *s, GSM_Locale *locale) { GSM_Error error; if ((error = ATOBEX_SetATMode(s))!= ERR_NONE) return error; s->Phone.Data.Locale = locale; smprintf(s, "Getting date format\n"); error=GSM_WaitFor (s, "AT*ESDF?\r", 9, 0x00, 3, ID_GetLocale); if (error!=ERR_NONE) return error; smprintf(s, "Getting time format\n"); return GSM_WaitFor (s, "AT*ESTF?\r", 9, 0x00, 3, ID_GetLocale); }
int main(void) { char *status; char *newmails; if (!(dpy = XOpenDisplay(NULL))) { fprintf(stderr, "dwmstatus: cannot open display.\n"); return 1; } for (;;sleep(60)) { newmails = get_nmail("/home/xavier/Maildir/laposte/new", "Mails:"); status = smprintf("%s",newmails); setstatus(status); free(newmails); free(status); } XCloseDisplay(dpy); return 0; }
int main(void) { struct items { char *up; char *load; char *fan; char *temp; char *mem; char *swap; char *diskio; char *fs_root; char *fs_home; char *fs_storage; char *net_speed; char *batt; char *vol; char *time; char *status; }; if (!(dpy = XOpenDisplay(NULL))) { fprintf(stderr, "dwmstatus: cannot open display.\n"); return 1; } struct items *i = malloc(sizeof(struct items)); while(1) { i->up = get_up(); i->load = get_load(); i->fan = get_fan(); i->temp = get_temp(); i->mem = get_mem(); i->swap = get_swap(); i->diskio = get_diskio("sda"); i->fs_root = get_space("/"); i->fs_home = get_space("/home"); i->net_speed = get_net_speed(); i->batt = get_batt(); i->vol = get_vol(); i->time = mktimes("%m/%d/%Y %a %H:%M", tzkiev); i->status = smprintf( "up:%s la:%s fan:%s temp:%s m:%s s:%s io:%s /:%s " "~/:%s net:%s bat:%s vol:%s %s", i->up, i->load, i->fan, i->temp, i->mem, i->swap, i->diskio, i->fs_root, i->fs_home, i->net_speed, i->batt, i->vol, i->time); setstatus(i->status); sleep(INTERVAL); } free(i); XCloseDisplay(dpy); return EXIT_SUCCESS; }
void GSM_LogError(GSM_StateMachine * s, const char * message, const GSM_Error err) { if (err != ERR_NONE) { smprintf(s, "%s failed with error %s[%d]: %s\n", message, GSM_ErrorName(err), err, GSM_ErrorString(err)); } }