void mace4_exit(int exit_code) { if (Opt && flag(Opt->verbose)) p_mem(); if (Opt && parm(Opt->report_stderr) > 0) fprintf(stderr, "Domain_size=%d. Models=%d. User_CPU=%.2f.\n", Domain_size, Total_models, user_seconds()); printf("\nUser_CPU=%.2f, System_CPU=%.2f, Wall_clock=%d.\n", user_seconds(), system_seconds(), wallclock()); if (Total_models == 0) printf("\nExiting with failure.\n"); else printf("\nExiting with %d model%s.\n", Total_models, Total_models == 1 ? "" : "s"); fprintf(stderr, "\n------ process %d exit (%s) ------\n", my_process_id(), exit_string(exit_code)); printf("\nProcess %d exit (%s) %s", my_process_id(), exit_string(exit_code), get_date()); printf("The process finished %s", get_date()); exit(exit_code); } /* mace4_exit */
/* * The Date header must indicate a time within 3600 seconds of the receipt of a * message. RFC 4474 [6] Step 4 */ static int check_date(struct sip_msg* msg, char* srt1, char* str2) { time_t tnow, tmsg; int ires; ires=datehdr_proc(NULL, NULL, msg); if (ires) return -1; #ifdef HAVE_TIMEGM tmsg=timegm(&get_date(msg)->date); #else tmsg=_timegm(&get_date(msg)->date); #endif if (tmsg < 0) { LOG(L_ERR, "AUTH_IDENTITY:check_date: timegm error\n"); return -2; } if ((tnow=time(0)) < 0) { LOG(L_ERR, "AUTH_IDENTITY:check_date: time error %s\n", strerror(errno)); return -3; } if (tnow > tmsg + glb_iauthval) { LOG(L_INFO, "AUTH_IDENTITY VERIFIER: Outdated date header value (%ld sec)\n", tnow - tmsg + glb_iauthval); return -4; } else LOG(AUTH_DBG_LEVEL, "AUTH_IDENTITY VERIFIER: Date header value OK\n"); return 1; }
closure* telaEscolhePeriodo(closure* cl) { point top, bottom; int y,x; int clear_key_pressed = FALSE; date_t* begin = NULL, *end = NULL; closure* next_cl = NULL; getScreenDims(&top, &bottom); y=bottom.y/2-2; x=bottom.x/2-8; while(!clear_key_pressed && NULL==next_cl) { clrscr (); show_bmp(LOGO_FILENAME); WRITE_AT("Início: ddmmaaaa", x, y); WRITE_AT("Fim: ddmmaaaa", x, y+1); begin = get_date(x+8,y,8,&top,&bottom,&clear_key_pressed); if (NULL!=begin && !clear_key_pressed) { end = get_date(x+8,y+1,8,&top,&bottom,&clear_key_pressed); } if (!clear_key_pressed) { if (NULL==begin || NULL==end || !date_check2(begin,end)) { show_data_incorreta(&bottom); } else if (NULL!=begin && NULL!=end) { next_cl = telaRelatorio(cl,date_makeCopy(begin),date_makeCopy(end)); } } date_delete(begin); date_delete(end); } return next_cl? next_cl : popClosure(cl); }
void Task::validate_before (const std::string& left, const std::string& right) { if (has (left) && has (right)) { Date date_left (get_date (left)); Date date_right (get_date (right)); if (date_left > date_right) context.footnote (format (STRING_TASK_VALID_BEFORE, left, right)); } }
char * build_cookie_string(cookie * cookies){ char * buffer = malloc(strlen(cookies->key) + strlen(cookies->value) + strlen(get_date(24)) + 1); if(cookies->action == 2){ sprintf(buffer, "%s=%s;Expires=%s", cookies->key, cookies->value, get_date(24)); }else { sprintf(buffer, "%s=%s;Expires=%s", cookies->key, cookies->value, get_date(0)); } //while(cookies){ // strcat(buffer, cookies->key); // strcat(buffer, "="); // strcat(buffer, cookies->value); // cookies++; //} return buffer; }
void log_entry(enum log_level level, const struct irc_network *n, const struct irc_client *c, const char *data) { if (flog == NULL) return; if (level > current_log_level) return; if (level < LOG_DATA) admin_log(level, n, c, data); if (!no_log_timestamp) fprintf(flog, "[%s] ", get_date()); g_assert(strchr(data, '\n') == NULL); fprintf(flog, "%s", data); if (n) { fprintf(flog, " (%s", n->name); if (c) fprintf(flog, "/%s", c->description); fprintf(flog, ")"); } fprintf(flog, "\n"); fflush(flog); }
FILE *file_init(FILE *primefile) { primefile=fopen("./semiprimes.txt","w"); fprintf(primefile,"***** File Generated by Prime Numbers " VERSION", ©2008 samus250. All Rights Reserved *****\n"); get_date(primefile); return primefile; }
int get_appointments(const char *file_name, Appointment_t appointments[], int max_size) { int year,month,day,hour,min,tc1,tc2; TCId_no_t tc; Time_t time; Date_t date; char dead; int i=0; int status; int flag=1; FILE* inp; inp=fopen(file_name,"r"); do{ status=fscanf(inp,"%6d%5d %d %d %d %2d%c%2d ",&tc1,&tc2,&year,&month,&day,&hour,&dead,&min); if(status == EOF || i == max_size) flag=0; else { time=get_time(hour,min); date=get_date(year,month,day,time); tc=get_tc(tc1,tc2); appointments[i].date=date; appointments[i].people.id_no=tc; ++i; } }while(flag); fclose(inp); return i; }
void ft_add_file(t_mem *s, struct dirent *f, char *name, t_fil **list) { t_fil *file; struct stat buf; file = NULL; file = (t_fil*)malloc(sizeof(t_fil)); file->path = ft_strjoin(name, "/"); file->path = ft_strjoin(file->path, f->d_name); if ((lstat(file->path, &buf)) < 0) { if (lstat(name, &buf) < 0) { ft_error(file->path); return ; } } file->size = buf.st_size; file->name = ft_strdup(f->d_name); get_date(file, buf, s); get_rights(file, buf); get_type(file, buf); file->inode = buf.st_ino; ft_add_file2(s, file, buf, list); }
static t_litem *print_list_item(t_dir_item *item, int *total, char *params) { t_litem *line; int i; i = 0; line = NULL; t_litem_push(&line, get_rights(item->prop.st_mode)); t_litem_push(&line, t_litem_new(ft_itoa(item->prop.st_nlink))); if (getpwuid(item->prop.st_uid) != NULL) t_litem_push(&line, t_litem_new(ft_strdup(getpwuid(item->prop.st_uid)->pw_name))); else t_litem_push(&line, t_litem_new(ft_itoa((long)(item->prop.st_uid)))); if (getgrgid(item->prop.st_gid) != NULL) t_litem_push(&line, t_litem_new(ft_strdup(getgrgid(item->prop.st_gid)->gr_name))); else t_litem_push(&line, t_litem_new(ft_itoa((long)(item->prop.st_gid)))); if (S_ISCHR(item->prop.st_mode) || S_ISBLK(item->prop.st_mode)) t_litem_push(&line, t_litem_new(get_maj_min(item->prop.st_rdev))); else t_litem_push(&line, t_litem_new(ft_itoa((long)item->prop.st_size))); t_litem_push(&line, get_date(item)); t_litem_push(&line, t_litem_new(get_item_name(item, params))); *(total) += (int)(item->prop.st_blocks); return (line); }
static krb5_deltat _decode_timedelta_input(PyObject *timedelta) { PyDateTime_IMPORT; time_t now = 0; krb5_deltat delta = TIME_NONE; if (timedelta) { char *date_string = NULL; if (PyDelta_CheckExact(timedelta)) { delta = pykadmin_seconds_from_pydatetime(timedelta); } else if (PyUnicodeBytes_Check(timedelta)) { date_string = PyUnicode_or_PyBytes_asCString(timedelta); } else if (timedelta == Py_None) { date_string = kNEVER; } if (date_string) { delta = get_date(date_string); } } if (delta == TIME_NONE) { PyErr_SetString(PyExc_ValueError, "Invalid input"); } else if (delta != 0) { time(&now); delta -= now; } return delta; }
/** * Send the response to the client. If the response has already been * commited, this function does nothing. */ static void send_response(HttpResponse res) { Socket_T S= res->S; if(!res->is_committed) { char date[STRLEN]; char server[STRLEN]; char *headers= get_headers(res); int length = StringBuffer_length(res->outputbuffer); res->is_committed= TRUE; get_date(date, STRLEN); get_server(server, STRLEN); socket_print(S, "%s %d %s\r\n", res->protocol, res->status, res->status_msg); socket_print(S, "Date: %s\r\n", date); socket_print(S, "Server: %s\r\n", server); socket_print(S, "Content-Length: %d\r\n", length); socket_print(S, "Connection: close\r\n"); if(headers) socket_print(S, "%s", headers); socket_print(S, "\r\n"); if(length) socket_write(S, (unsigned char *)StringBuffer_toString(res->outputbuffer), length); FREE(headers); } }
int vsd_append_entry(VideoSwitchDatabase* db, int sourceIndex, const char* sourceId, const Timecode* tc) { int year, month, day; get_date(&year, &month, &day); return vsd_append_entry_with_date(db, sourceIndex, sourceId, year, month, day, tc); }
static int set_timefilter_date_w(struct archive_match *a, int timetype, const wchar_t *datestr) { struct archive_string as; time_t t; if (datestr == NULL || *datestr == L'\0') { archive_set_error(&(a->archive), EINVAL, "date is empty"); return (ARCHIVE_FAILED); } archive_string_init(&as); if (archive_string_append_from_wcs(&as, datestr, wcslen(datestr)) < 0) { archive_string_free(&as); if (errno == ENOMEM) return (error_nomem(a)); archive_set_error(&(a->archive), -1, "Failed to convert WCS to MBS"); return (ARCHIVE_FAILED); } t = get_date(a->now, as.s); archive_string_free(&as); if (t == (time_t)-1) { archive_set_error(&(a->archive), EINVAL, "invalid date string"); return (ARCHIVE_FAILED); } return set_timefilter(a, timetype, t, 0, t, 0); }
struct timeval get_tv() { struct timeval ret; ret.tv_sec = get_date(); ret.tv_usec = get_clock()*USEC_PER_SEC/CLOCKS_PER_SEC; return ret; }
long xFile(FILE *fp, char *msg, int mode) { long log_offset = 0; char line[1024]; if (msg != NULL) { char *log_info; char *date; long info_len; if ( mode == 1) { info_len = strlen(msg) + strlen("\r\n") + 1; } else { date = get_date(); info_len = strlen(date) + strlen(" ") + strlen(msg) + strlen("\r\n") + 1; } log_info = (char *) malloc(info_len); if (log_info != NULL) { if ( mode == 1) { fseek(fp, 0, SEEK_SET); sprintf(log_info, "%s\r\n", msg); } else { fseek(fp, 0, SEEK_END); sprintf(log_info, "%s,%s\r\n", date, msg); } fwrite(log_info, info_len, 1, fp); free(log_info); } } else { fseek(fp, 0, SEEK_SET); fgets(line, 1024, fp); log_offset = atol(line); return log_offset; } return 0; }
//Process GET&HEAD header for response void http_header(char* writebuf, int writebuf_size, FILE *resource, HTTPResponse* response) { char* buf = writebuf; char mime[20]; char date[500]; char LastModified[500]; long int size; get_mime_type(mime, response->path); get_date(date, sizeof(date)); fseek(resource, 0L, SEEK_END); size = ftell(resource); fseek(resource, 0L, SEEK_SET); get_last_modified(LastModified, sizeof(LastModified), response); strcpy(buf, "HTTP/1.1 200 OK\r\n"); sprintf(buf+strlen(buf), "Date: %s\r\n", date); strcat(buf, SERVER_STRING); sprintf(buf+strlen(buf), "Last-Modified: %s\r\n", LastModified); strcat(buf, "Connection: close\r\n"); sprintf(buf+strlen(buf), "Content-Type: %s\r\n", mime); sprintf(buf+strlen(buf), "Content-Length: %ld\r\n", size); strcat(buf, "\r\n"); if(!strcasecmp(response->method, "GET")) response->file_size = size; response->file = resource; response->header_size = strlen(buf); response->write_byte += strlen(buf); }
float Task::urgency_due () const { if (has ("due")) { Date now; Date due (get_date ("due")); int days_overdue = (now - due) / 86400; if (days_overdue >= 7) return 1.0; // 7 days ago else if (days_overdue >= 6) return 0.96; else if (days_overdue >= 5) return 0.92; else if (days_overdue >= 4) return 0.88; else if (days_overdue >= 3) return 0.84; else if (days_overdue >= 2) return 0.80; else if (days_overdue >= 1) return 0.76; else if (days_overdue >= 0) return 0.72; else if (days_overdue >= -1) return 0.68; else if (days_overdue >= -2) return 0.64; else if (days_overdue >= -3) return 0.60; else if (days_overdue >= -4) return 0.56; else if (days_overdue >= -5) return 0.52; else if (days_overdue >= -6) return 0.48; else if (days_overdue >= -7) return 0.44; else if (days_overdue >= -8) return 0.40; else if (days_overdue >= -9) return 0.36; else if (days_overdue >= -10) return 0.32; else if (days_overdue >= -11) return 0.28; else if (days_overdue >= -12) return 0.24; else if (days_overdue >= -13) return 0.20; else return 0.16; // two weeks from now } return 0.0; }
/* funzione utilizzate per la creazione di semafori, memorie e code di messaggi. * ritorna 1 se tutte le risorse sono allocate correttamente, 0 altrimenti. */ int server_start() { log_date(LOG_PATH, "(start) Avvio server"); get_date(start_date); // Creazione di semafori, memorie e code di messaggi if ((semid = semget(SEMKEY, SEM_TOT, 0600 | IPC_CREAT)) == -1) errorlog(LOG_PATH, "Semafori non allocati"); if ((shmid = shmget(SHMKEY, sizeof(repo), 0600 | IPC_CREAT)) == -1) errorlog( LOG_PATH, "Area di memoria Repository non allocata"); if ((shmlog = shmget(BUFFER_SHMKEY, sizeof(buffer), 0600 | IPC_CREAT)) == -1) errorlog( LOG_PATH, "Area di memoria LOG non allocata"); if ((shmls = shmget(LS_SHMKEY, sizeof(numlettori), 0600 | IPC_CREAT)) == -1) errorlog( LOG_PATH, "Area di memoria LETTORI/SCRITTORI non allocata"); if ((shmauth = shmget(AUTH_SHMKEY, sizeof(auth), 0600 | IPC_CREAT)) == -1) errorlog( LOG_PATH, "Area di memoria AUTORIZZAZIONI non allocata"); if ((shmpush = shmget(PUSH_SHMKEY, sizeof(push), 0600 | IPC_CREAT)) == -1) errorlog( LOG_PATH, "Area di memoria PUSH non allocata"); if ((msgid = msgget(MSGKEY, IPC_CREAT | 0600)) == -1) errorlog(LOG_PATH, "Coda messaggi non allocata"); // Controllo errori all'avvio */ if (semid == -1 || shmid == -1 || shmlog == -1 || shmls == -1 || shmauth == -1 || shmpush == -1 || msgid == -1) server_stop(); if (!setup()) { errorlog(LOG_PATH, "(start) File del repository iniziale non trovato"); return 0; } return 1; }
int my_redel(const char *org_name, const char *tmp_name, myf MyFlags) { int error=1; DBUG_ENTER("my_redel"); DBUG_PRINT("my",("org_name: '%s' tmp_name: '%s' MyFlags: %d", org_name,tmp_name,MyFlags)); if (my_copystat(org_name,tmp_name,MyFlags) < 0) goto end; if (MyFlags & MY_REDEL_MAKE_BACKUP) { char name_buff[FN_REFLEN+20]; char ext[20]; ext[0]='-'; get_date(ext+1,2+4,(time_t) 0); strmov(strend(ext),REDEL_EXT); if (my_rename(org_name, fn_format(name_buff, org_name, "", ext, 2), MyFlags)) goto end; } else if (my_delete(org_name,MyFlags)) goto end; if (my_rename(tmp_name,org_name,MyFlags)) goto end; error=0; end: DBUG_RETURN(error); } /* my_redel */
static krb5_timestamp _decode_timestamp_input(PyObject *date) { PyDateTime_IMPORT; krb5_timestamp timestamp = TIME_NONE; if (date) { char *date_string = NULL; if (PyDate_CheckExact(date) || PyDateTime_CheckExact(date)) { timestamp = pykadmin_timestamp_from_pydatetime(date); } else if (PyUnicodeBytes_Check(date)) { date_string = PyUnicode_or_PyBytes_asCString(date); } else if (date == Py_None) { date_string = kNEVER; } if (date_string) { timestamp = get_date(date_string); } } if (timestamp == TIME_NONE) PyErr_SetString(PyExc_ValueError, "Invalid input"); return timestamp; }
int Csysarg_guess_price::insert(userid_t userid, char* nick, uint32_t itemid, uint32_t price) { uint32_t table_price = 0; this->get_exist(userid, itemid, price); if(table_price < price){ if(table_price == 0){ char nick_mysql[mysql_str_len(NICK_LEN)]; memset(nick_mysql, 0, sizeof(nick_mysql)); set_mysql_string(nick_mysql,nick, NICK_LEN); sprintf(this->sqlstr, "insert into %s values(%u, %u, '%s', %u, %u)", this->get_table_name(), userid, itemid, nick_mysql, price, (uint32_t)get_date(time(0)) ); STD_SET_RETURN_EX(this->sqlstr, USER_ID_EXISTED_ERR); } else{ int ret = this->update(userid, itemid, price); return ret; } } return 0; }
void server_log(char level, char nexit, char *format, ...) { va_list ap; char *str; char date[128]; int fd; va_start(ap, format); vasprintf(&str, format, ap); if (!str) { perror("Error on malloc"); exit(1); } va_end(ap); get_date(date); fd = open("server.log", O_WRONLY | O_APPEND); if (fd != -1) { xwrite(fd, date, strlen(date)); write_level(fd, level); xwrite(fd, str, strlen(str)); close(fd); } write_log(str, level); if (nexit) exit(1); }
void save_log(char *slug, char *hostaddrp, char *h_name) { if (LOG != NULL) { char contents[256]; if (slug != NULL) snprintf(contents, sizeof contents, "%s -- %s -- %s (%s)\n", slug, get_date(), hostaddrp, h_name); else snprintf(contents, sizeof contents, "%s -- %s -- %s (%s)\n", "rej", get_date(), hostaddrp, h_name); FILE *fp; fp = fopen(LOG, "a"); fprintf(fp, "%s", contents); fclose(fp); } }
int Log::init() { std::ostringstream message; message << "----------------------------------------" "----------------------------------------" "\n" << get_date() << "\n"; s_state.write(message.str()); return 0; }
void my_create_backup_name(char *to, const char *from, time_t backup_start) { char ext[MY_BACKUP_NAME_EXTRA_LENGTH+1]; ext[0]='-'; get_date(ext+1, GETDATE_SHORT_DATE | GETDATE_HHMMSSTIME, backup_start); strmov(strend(ext),REDEL_EXT); strmov(strmov(to, from), ext); }
/* * Return a file name containing * the project name and the current date. */ gchar * get_default_filename () { gchar *date = get_date (); gchar *filename = g_strdup_printf ("%s_%s", project_name, date); g_free (date); return filename; }
float Task::urgency_scheduled () const { if (has ("scheduled") && get_date ("scheduled") < time (NULL)) return 1.0; return 0.0; }
int initial_archive() { std::set< uint32_t > date_set; uint32_t now = get_now_tv()->tv_sec; uint32_t day_ts = get_day_timestamp(now); struct dirent * p_de = NULL; DIR * p_dir = opendir(g_log_path); if (NULL == p_dir) { ERROR_LOG("opendir %s failed (%s)", g_log_path, strerror(errno)); return -1; } while (NULL != (p_de = readdir(p_dir))) { if (DT_REG != p_de->d_type) { continue; } char file[PATH_MAX]; snprintf(file, sizeof(file), "%s/%s", g_log_path, p_de->d_name); struct stat file_stat; if (0 != stat(file, &file_stat)) { ERROR_LOG("stat %s failed (%s)", file, strerror(errno)); continue; } uint32_t modify_time = file_stat.st_mtime; if (modify_time >= day_ts) { continue; } uint32_t date = 0; if (0 != get_date(modify_time, &date)) { continue; } date_set.insert(date); } closedir(p_dir); set_for_each(date_set, it) { uint32_t date = *it; const char * archive_file = get_archive_name(date); if (-1 == access(archive_file, F_OK)) { archive_log(date); } }
void stop_billing() { get_time(&end_time); get_date(&end_date); #if (0) printf("end_time=%s\n",&end_time); printf("end_date=%s\n",&end_date); #endif } /* stop_billing */