void coff_obj_read_begin_hook (void) { /* These had better be the same. Usually 18 bytes. */ know (sizeof (SYMENT) == sizeof (AUXENT)); know (SYMESZ == AUXESZ); tag_init (); }
int _gui_sns_tag_dialog(void *self) { Tag **tag = (Tag **) self; int rws = 1; char title[100]; char argi[rws * 2 + 1][100]; if (tag == NULL) { strcpy(title, "新建爱好"); strcpy(argi[rws + 1], ""); } else { strcpy(title, "编辑爱好"); strcpy(argi[rws + 1], (*tag)->name); } strcpy(argi[0], title); strcpy(argi[1], "爱好名"); GtkWidget **dialog_result = (GtkWidget **) malloc(sizeof(GtkWidget *) * (rws * 2 + 2)); dialog_result = gui_create_edit_dialog(window, rws, argi, dialog_result); gtk_widget_show_all(dialog_result[0]); char validate_message[100]; validate_message[0] = '\0'; int result; GtkEntryBuffer *buffer; char name[100]; while (gtk_dialog_run(GTK_DIALOG(dialog_result[0])) == GTK_RESPONSE_ACCEPT) { validate_message[0] = '\0'; buffer = gtk_entry_get_buffer(GTK_ENTRY(dialog_result[2 * 1 + 1])); if (gtk_entry_buffer_get_length(buffer) >= 100) { strcpy(validate_message, "爱好名过长"); } else { strcpy(name, gtk_entry_buffer_get_text(buffer)); } if (validate_message[0] != '\0') { gui_show_message(validate_message, GTK_MESSAGE_WARNING); continue; } if (tag == NULL) { Tag *_tag_tmp = NULL; tag = &_tag_tmp; result = tag_init(SNS, tag, name, 0, 0); } else { strcpy((*tag)->name, name); result = PEOPLE_OP_SUCCESS; } break; } gtk_widget_destroy(GTK_WIDGET(dialog_result[0])); free(dialog_result); return result; }
int main(int ac, char **av) { char *file; char *tag; int ret; if (ac < 2) syntax(av[0]); else { // get correct filename if (!strcmp(av[1], "-F")) { if (ac < 4) { syntax(av[0]); return (0); } else { file = av[2]; tag = av[3]; } } else { file = DEFAULT_FILENAME; tag = av[1]; } // call libtag functions if ((ret = tag_init(file)) != tagSuccess) { if (ret == tagNonExisting) { tag_exit(); printf("File don't exist\n"); return (-1); } } else if ((ret = tag_delete(tag)) == tagSuccess) { tag_exit(); printf("Tag %s deleted.\n", tag); return (0); } tag_exit(); printf("Lib error %d\n", ret); } return (-1); }
int reader_parse_poll_packet(struct reader *reader, struct list *tagList, char *packetPayload, int packetPayload_len) { const char *p = packetPayload; char idbuf[RFID_ID_LEN+1]; int pos; for(;;){ while(*p != '['){ if(*p == '\0') return list_size(tagList); p++; } p++; pos = 0; // While we have a valid ID character, construct the ID. while((*p >= '0' && *p <= '9') || (*p >= 'A' && *p <= 'F') || (*p >= 'a' && *p <= 'f')){ if(pos >= RFID_ID_LEN) break; idbuf[pos++] = *p++; } // Check it's a valid ID (must be followed by a ',' delimiter if(*p == ',' && pos > 0){ struct tag *tag; idbuf[pos] = '\0'; tag = tag_create(); tag_init(tag, strdup(idbuf), reader); if(tag != NULL){ list_push(tagList, tag); } } else if(*p == '\0') { return list_size(tagList); } } }
/** * @short Compiles the infilename to outfilename. */ int work(const char *infilename, const char *outfilename, onion_assets_file *assets){ tag_init(); parser_status status; memset(&status, 0, sizeof(status)); status.mode=TEXT; status.functions=list_new((void*)function_free); status.function_stack=list_new(NULL); status.status=0; status.line=1; status.rawblock=onion_block_new(); status.infilename=infilename; char tmp2[256]; strncpy(tmp2, infilename, sizeof(tmp2)-1); const char *tname=basename(tmp2); ONION_DEBUG("Create init function on top, tname %s",tname); status.blocks_init=function_new(&status, "%s_blocks_init", tname); status.blocks_init->signature="onion_dict *context"; if (strcmp(infilename, "-")==0) status.in=stdin; else status.in=fopen(infilename,"rt"); if (!status.in){ ONION_ERROR("Could not open in file %s", infilename); goto work_end; } ONION_DEBUG("Create main function on top, tname %s",tname); function_new(&status, tname); function_add_code(&status, " int has_context=(context!=NULL);\n" " if (!has_context)\n" " context=onion_dict_new();\n" " \n" " %s(context);\n", status.blocks_init->id); parse_template(&status); ((function_data*)status.function_stack->tail->data)->flags=0; function_add_code(&status, " if (!has_context)\n" " onion_dict_free(context);\n" ); if (status.status){ ONION_ERROR("Parsing error"); goto work_end; } if (strcmp(outfilename, "-")==0) status.out=stdout; else status.out=fopen(outfilename,"wt"); if (!status.out){ ONION_ERROR("Could not open out file %s", infilename); goto work_end; } fprintf(status.out, "/** Autogenerated by otemplate v. 0.2.0 */\n" "\n" "#include <libintl.h>\n" "#include <string.h>\n\n" "#include <onion/onion.h>\n" "#include <onion/dict.h>\n" "\n" "typedef struct dict_res_t{\n" " onion_dict *dict;\n" " onion_response *res;\n" "}dict_res;\n" "\n" "\n"); functions_write_declarations_assets(&status, assets); functions_write_declarations(&status); functions_write_main_code(&status); if (use_orig_line_numbers) fprintf(status.out, "#line 1 \"%s\"\n", infilename); functions_write_code(&status); work_end: if (status.in) fclose(status.in); if (status.out) fclose(status.out); list_free(status.functions); list_free(status.function_stack); //list_free(status.blocks); onion_block_free(status.rawblock); tag_free(); return status.status; }