static void gui_demo_update_status(int i) { const struct demo *d; if (!total) return; d = DEMO_GET(items, i < total ? i : 0); if (!d) return; gui_set_label(name_id, d->name); gui_set_label(date_id, date_to_str(d->date)); gui_set_label(player_id, d->player); if (d->status == GAME_GOAL) gui_set_color(status_id, gui_grn, gui_grn); else gui_set_color(status_id, gui_red, gui_red); gui_set_label(status_id, status_to_str(d->status)); gui_set_count(coin_id, d->coins); gui_set_clock(time_id, d->timer); }
/* * print_status - print current password status */ static void print_status (const struct passwd *pw) { struct spwd *sp; sp = getspnam (pw->pw_name); /* local, no need for xgetspnam */ if (NULL != sp) { printf ("%s %s %s %ld %ld %ld %ld\n", pw->pw_name, pw_status (sp->sp_pwdp), date_to_str (sp->sp_lstchg * SCALE), (sp->sp_min * SCALE) / DAY, (sp->sp_max * SCALE) / DAY, (sp->sp_warn * SCALE) / DAY, (sp->sp_inact * SCALE) / DAY); } else { printf ("%s %s\n", pw->pw_name, pw_status (pw->pw_passwd)); } }
/* * new_fields - change the user's password aging information interactively. * * prompt the user for all of the password age values. set the fields * from the user's response, or leave alone if nothing was entered. The * value (-1) is used to indicate the field should be removed if possible. * any other negative value is an error. very large positive values will * be handled elsewhere. */ static int new_fields (void) { char buf[200]; (void) puts (_("Enter the new value, or press ENTER for the default")); (void) puts (""); (void) snprintf (buf, sizeof buf, "%ld", mindays); change_field (buf, sizeof buf, _("Minimum Password Age")); if ( (getlong (buf, &mindays) == 0) || (mindays < -1)) { return 0; } (void) snprintf (buf, sizeof buf, "%ld", maxdays); change_field (buf, sizeof buf, _("Maximum Password Age")); if ( (getlong (buf, &maxdays) == 0) || (maxdays < -1)) { return 0; } if (-1 == lstchgdate) { strcpy (buf, "-1"); } else { date_to_str (buf, sizeof buf, (time_t) lstchgdate * SCALE); } change_field (buf, sizeof buf, _("Last Password Change (YYYY-MM-DD)")); if (strcmp (buf, "-1") == 0) { lstchgdate = -1; } else { lstchgdate = strtoday (buf); if (lstchgdate <= -1) { return 0; } } (void) snprintf (buf, sizeof buf, "%ld", warndays); change_field (buf, sizeof buf, _("Password Expiration Warning")); if ( (getlong (buf, &warndays) == 0) || (warndays < -1)) { return 0; } (void) snprintf (buf, sizeof buf, "%ld", inactdays); change_field (buf, sizeof buf, _("Password Inactive")); if ( (getlong (buf, &inactdays) == 0) || (inactdays < -1)) { return 0; } if (-1 == expdate) { strcpy (buf, "-1"); } else { date_to_str (buf, sizeof buf, (time_t) expdate * SCALE); } change_field (buf, sizeof buf, _("Account Expiration Date (YYYY-MM-DD)")); if (strcmp (buf, "-1") == 0) { expdate = -1; } else { expdate = strtoday (buf); if (expdate <= -1) { return 0; } } return 1; }
static int gui_demo_status(int id) { const char *status; int jd, kd, ld; int s; /* Find the longest status string. */ for (status = "", s = GAME_NONE; s < GAME_MAX; s++) if (strlen(status_to_str(s)) > strlen(status)) status = status_to_str(s); /* Build info bar with dummy values. */ if ((jd = gui_hstack(id))) { gui_filler(jd); if ((kd = gui_hstack(jd))) { if ((ld = gui_vstack(kd))) { gui_filler(ld); time_id = gui_clock(ld, 35000, GUI_SML); coin_id = gui_count(ld, 100, GUI_SML); status_id = gui_label(ld, status, GUI_SML, gui_red, gui_red); gui_filler(ld); } if ((ld = gui_vstack(kd))) { gui_filler(ld); gui_label(ld, _("Time"), GUI_SML, gui_wht, gui_wht); gui_label(ld, _("Coins"), GUI_SML, gui_wht, gui_wht); gui_label(ld, _("Status"), GUI_SML, gui_wht, gui_wht); gui_filler(ld); } gui_set_rect(kd, GUI_ALL); } gui_space(jd); if ((kd = gui_hstack(jd))) { if ((ld = gui_vstack(kd))) { gui_filler(ld); name_id = gui_label(ld, " ", GUI_SML, 0, 0); player_id = gui_label(ld, " ", GUI_SML, 0, 0); date_id = gui_label(ld, date_to_str(time(NULL)), GUI_SML, 0, 0); gui_filler(ld); gui_set_trunc(name_id, TRUNC_TAIL); gui_set_trunc(player_id, TRUNC_TAIL); } if ((ld = gui_vstack(kd))) { gui_filler(ld); gui_label(ld, _("Replay"), GUI_SML, gui_wht, gui_wht); gui_label(ld, _("Player"), GUI_SML, gui_wht, gui_wht); gui_label(ld, _("Date"), GUI_SML, gui_wht, gui_wht); gui_filler(ld); } gui_set_rect(kd, GUI_ALL); } gui_filler(jd); } return jd; }
void file_write (File *file, const char* directory) { char *path = NULL; assert (file); if (!file) return; if (file->name == NULL) { file->name = strdup( TNEF_DEFAULT_FILENAME ); debug_print ("No file name specified, using default %s.\n", TNEF_DEFAULT_FILENAME); } if ( file->path == NULL ) { file->path = munge_fname( file->name ); if (file->path == NULL) { file->path = strdup( TNEF_DEFAULT_FILENAME ); debug_print ("No path name available, using default %s.\n", TNEF_DEFAULT_FILENAME); } } path = concat_fname( directory, file->path ); if (path == NULL) { path = strdup( TNEF_DEFAULT_FILENAME ); debug_print ("No path generated, using default %s.\n", TNEF_DEFAULT_FILENAME); } debug_print ("%sWRITING\t|\t%s\t|\t%s\n", ((LIST_ONLY==0)?"":"NOT "), file->name, path); if (!LIST_ONLY) { FILE *fp = NULL; if (!confirm_action ("extract %s?", file->name)) return; if (!OVERWRITE_FILES) { if (file_exists (path)) { if (!NUMBER_FILES) { fprintf (stderr, "tnef: %s: Could not create file: File exists\n", path); return; } else { char *tmp = find_free_number (path); debug_print ("Renaming %s to %s\n", path, tmp); XFREE (path); path = tmp; } } } fp = fopen (path, "wb"); if (fp == NULL) { perror (path); exit (1); } if (fwrite (file->data, 1, file->len, fp) != file->len) { perror (path); exit (1); } fclose (fp); } if (LIST_ONLY || VERBOSE_ON) { if (LIST_ONLY && VERBOSE_ON) { /* FIXME: print out date and stuff */ const char *date_str = date_to_str(&file->dt); fprintf (stdout, "%11lu\t|\t%s\t|\t%s\t|\t%s", (unsigned long)file->len, date_str+4, /* skip the day of week */ file->name, path); } else { fprintf (stdout, "%s\t|\t%s", file->name, path); } if ( SHOW_MIME ) { fprintf (stdout, "\t|\t%s", file->mime_type ? file->mime_type : "unknown"); fprintf (stdout, "\t|\t%s", file->content_id ? file->content_id : ""); } fprintf (stdout, "\n"); } XFREE(path); }
void get_all(char *mitnr_in) { dbfcmd(dbproc,"SELECT m.Name, m.Vorname, m.Ort, m.Gebdat, m.Beruf, m.Telnr, mp.Istvzae, mp.Planvzae, p.Proname FROM Mitarbeiter m, MiPro mp, Projekt p WHERE m.Mitnr = mp.Mitnr AND mp.Pronr = p.Pronr AND m.Mitnr = '%s'", mitnr_in); dbsqlexec(dbproc); while (dbresults(dbproc)!=NO_MORE_RESULTS) { i=0; dbbind(dbproc,1,NTBSTRINGBIND,0,name); dbbind(dbproc,2,NTBSTRINGBIND,0,vorname); dbbind(dbproc,3,NTBSTRINGBIND,0,ort); dbbind(dbproc,4,DATETIMEBIND,0,(BYTE *)&gebdat); dbbind(dbproc,5,NTBSTRINGBIND,0,beruf); dbbind(dbproc,6,NTBSTRINGBIND,0,telnr); dbbind(dbproc,7,FLT8BIND,0,(BYTE *)&istvzae); dbbind(dbproc,8,FLT8BIND,0,(BYTE *)&planvzae); dbbind(dbproc,9,NTBSTRINGBIND,0,proname); while (dbnextrow(dbproc)!=NO_MORE_ROWS) { printf("%d:\t%s,\t%s,\t%s,\t%s,\t%s,\t%s,\t%f,\t%f,\t%s,\n",i, name, vorname, ort, date_to_str(gebdat), beruf, telnr, istvzae, planvzae, proname); i++; } } }